:root {
  color-scheme: dark;
  --bg: #07111e;
  --panel: rgba(13, 24, 40, .84);
  --panel-strong: rgba(19, 32, 52, .94);
  --line: rgba(177, 194, 220, .16);
  --line-strong: rgba(177, 194, 220, .26);
  --text: #eef5ff;
  --muted: #9dadc5;
  --soft: #d7e3f5;
  --accent: #6ee7ff;
  --accent-2: #9b8cff;
  --danger: #ff9c8d;
  --ok: #91f2bf;
  --warning: #ffd37a;
  --shadow: 0 24px 80px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(110, 231, 255, .17), transparent 34rem),
    radial-gradient(circle at top right, rgba(155, 140, 255, .14), transparent 30rem),
    var(--bg);
  color: var(--text);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  padding: 24px;
}
.auth-copy, .auth-actions {
  padding: 16px;
}
.auth-copy h1 {
  margin: 12px 0;
  font-size: clamp(34px, 6vw, 68px);
  line-height: .94;
  letter-spacing: -.07em;
}
.auth-copy p, .auth-message, .form-note, .muted, .row-meta, .empty-state span, .system-card small, .brand small, .user-card span {
  color: var(--muted);
}
.auth-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}
.auth-actions details {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(4, 11, 23, .4);
  padding: 16px;
}
.auth-actions summary {
  color: var(--soft);
  font-weight: 800;
}
.stack-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(5, 13, 26, .78);
  backdrop-filter: blur(18px);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06101f;
  font-weight: 950;
}
.brand strong { display: block; font-size: 18px; }
.nav-list { display: grid; gap: 8px; }
.nav-item, .ghost-button {
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 12px 14px;
  background: transparent;
  color: var(--soft);
  text-align: left;
  transition: background .18s, border-color .18s, transform .18s;
}
.nav-item:hover, .ghost-button:hover { background: rgba(177, 194, 220, .08); }
.nav-item.active {
  background: rgba(110, 231, 255, .1);
  border-color: rgba(110, 231, 255, .28);
  color: var(--accent);
}
.system-card, .user-card {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(4, 11, 23, .54);
  padding: 14px;
}
.system-card {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pulse {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--warning);
  box-shadow: 0 0 0 6px rgba(255, 211, 122, .12);
}
.pulse.online { background: var(--ok); box-shadow: 0 0 0 6px rgba(145, 242, 191, .12); }
.pulse.offline { background: var(--danger); box-shadow: 0 0 0 6px rgba(255, 156, 141, .12); }
.user-card {
  margin-top: 0;
  display: grid;
  gap: 10px;
}
.user-card span { overflow-wrap: anywhere; font-size: 13px; }

.workspace { min-width: 0; padding: 28px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.topbar h1, .panel h2, .hero-panel h2 { margin: 0; letter-spacing: -.04em; }
.topbar h1 { font-size: clamp(30px, 4vw, 54px); }
.topbar-actions, .button-row, .hero-actions, .row-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.view { display: none; }
.view.active { display: block; }
.hero-panel, .panel, .metric-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.hero-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 26px;
  margin-bottom: 18px;
}
.hero-panel p { color: var(--muted); max-width: 720px; line-height: 1.55; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.metric-card { padding: 18px; }
.metric-card span { color: var(--muted); font-size: 13px; }
.metric-card strong { display: block; margin-top: 6px; font-size: 34px; letter-spacing: -.04em; }
.panel { padding: 22px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-head.compact { margin-bottom: 14px; }
.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .85fr);
  gap: 18px;
}
.wide-left { grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); }
.axis-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.axis-form .full { grid-column: 1 / -1; }
label { display: grid; gap: 8px; color: var(--soft); font-size: 13px; font-weight: 800; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 13px 14px;
  color: var(--text);
  background: rgba(4, 11, 23, .68);
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
textarea { resize: vertical; min-height: 180px; }
input:focus, textarea:focus {
  border-color: rgba(110, 231, 255, .72);
  box-shadow: 0 0 0 4px rgba(110, 231, 255, .12);
  background: rgba(4, 11, 23, .9);
}
.primary-button, .secondary-button {
  border: 0;
  border-radius: 17px;
  padding: 13px 16px;
  font-weight: 900;
  transition: transform .18s, opacity .18s;
}
.primary-button {
  color: #06101f;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.secondary-button {
  color: var(--text);
  border: 1px solid var(--line-strong);
  background: rgba(177, 194, 220, .08);
}
.primary-button:hover, .secondary-button:hover { transform: translateY(-1px); }
.ghost-button { text-align: center; }
.form-note { grid-column: 1 / -1; margin: 0; font-size: 13px; line-height: 1.5; }
.upload-zone {
  position: relative;
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 150px;
  border: 1px dashed rgba(110, 231, 255, .36);
  border-radius: 22px;
  background: rgba(110, 231, 255, .06);
  margin-bottom: 14px;
  text-align: center;
}
.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-zone span { color: var(--muted); }
.textarea-label { margin-bottom: 14px; }
.empty-state {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  background: rgba(4, 11, 23, .48);
}
.run-list, .preview-list { display: grid; gap: 12px; }
.run-row, .preview-row, .progress-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(4, 11, 23, .48);
  padding: 15px;
}
.run-row, .preview-row, .progress-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}
.row-meta { margin-top: 4px; font-size: 13px; line-height: 1.45; }
.status-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(145, 242, 191, .26);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--ok);
  background: rgba(145, 242, 191, .08);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.status-pill.running { color: var(--warning); border-color: rgba(255, 211, 122, .26); background: rgba(255, 211, 122, .08); }
.status-pill.failed { color: var(--danger); border-color: rgba(255, 156, 141, .28); background: rgba(255, 156, 141, .08); }
.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(177, 194, 220, .14);
  margin: 14px 0 8px;
}
.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .28s;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { border-bottom: 1px solid var(--line); padding: 14px 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.report-panel { min-height: calc(100vh - 120px); display: grid; grid-template-rows: auto 1fr; }
iframe {
  width: 100%;
  min-height: 720px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
}
.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 10px;
  z-index: 40;
}
.toast {
  max-width: min(420px, calc(100vw - 40px));
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 13px 15px;
  color: var(--text);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-two, .wide-left, .hero-panel, .auth-card { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .workspace, .sidebar, .auth-shell { padding: 14px; }
  .topbar, .panel-head, .run-row, .preview-row { align-items: stretch; flex-direction: column; }
  .axis-form, .metric-grid, .nav-list { grid-template-columns: 1fr; }
  .hero-actions, .topbar-actions, .button-row, .row-actions { align-items: stretch; flex-direction: column; }
  .primary-button, .secondary-button, .ghost-button { width: 100%; text-align: center; }
}
