:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-strong: #f0f4f8;
  --ink: #111827;
  --muted: #64748b;
  --line: #d9e2ec;
  --teal: #0f766e;
  --green: #15803d;
  --blue: #2563eb;
  --amber: #b45309;
  --violet: #6d28d9;
  --red: #b91c1c;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.auth-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: #0f172a;
  color: #e5edf6;
  padding: 24px;
}

.brand {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #14b8a6;
  color: #042f2e;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 16px;
}

.brand small,
.nav-muted,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
}

.sidebar .brand small,
.sidebar .nav-muted {
  color: #9fb0c3;
}

.nav-list {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.nav-link,
.nav-label,
.nav-muted {
  border-radius: 8px;
  padding: 9px 12px;
}

.nav-link {
  background: transparent;
  color: #cbd5e1;
  font-weight: 700;
  font-size: 14px;
}

.nav-link.is-active {
  background: #e5f9f6;
  color: #0f172a;
}

.nav-label {
  margin-top: 18px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.main-panel {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar h1,
.hero-band h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 30px;
}

.eyebrow {
  margin: 0 0 6px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-pill,
.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-safe {
  border-color: #a7f3d0;
  color: var(--green);
}

.status-live {
  border-color: #a7f3d0;
  color: var(--green);
}

.status-live-warn {
  border-color: #fde68a;
  color: var(--amber);
}

.status-live-error {
  border-color: #fecaca;
  color: var(--red);
}

.hero-band,
.panel,
.metric-card {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  border-radius: 8px;
  padding: 28px;
}

.hero-band h2 {
  max-width: 820px;
  font-size: 28px;
  line-height: 1.18;
}

.hero-copy {
  max-width: 820px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
  font-weight: 800;
}

.button-primary {
  border-color: #0f766e;
  background: #0f766e;
  color: #ffffff;
}

.button-small {
  min-height: 36px;
  padding: 0 12px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.metric-card {
  min-height: 112px;
  border-radius: 8px;
  padding: 16px;
}

.metric-card span {
  display: block;
  min-height: 38px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin-top: 14px;
  font-size: 34px;
}

.metric-amber strong { color: var(--amber); }
.metric-teal strong { color: var(--teal); }
.metric-green strong { color: var(--green); }
.metric-blue strong { color: var(--blue); }
.metric-violet strong { color: var(--violet); }
.metric-red strong { color: var(--red); }

.content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.pipeline-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.step-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
}

.step-card span,
.step-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.step-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 28px;
}

.step-done strong { color: var(--green); }
.step-waiting strong { color: var(--amber); }
.step-stopped strong { color: var(--red); }

.mini-list {
  display: grid;
  gap: 9px;
}

.mini-row {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 11px 12px;
  color: var(--ink);
  font: inherit;
  text-align: left;
}

.mini-row span,
.mini-row small {
  display: block;
}

.mini-row span {
  font-weight: 850;
}

.mini-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.panel {
  border-radius: 8px;
  padding: 22px;
}

.pipeline-run-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-top: 18px;
  padding: 22px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.compact-hero {
  margin-bottom: 18px;
}

.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: var(--surface-strong);
  color: #475569;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  color: #1f2937;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 220px;
}

td code,
.hero-copy code,
.auth-hint code {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 2px 5px;
  color: #334155;
  white-space: nowrap;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.alert {
  border-radius: 8px;
  padding: 12px 14px;
  margin: 16px 0;
  font-weight: 700;
}

.alert-error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: var(--red);
}

.demo-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-top: 16px;
  padding: 12px 14px;
  color: #475569;
  font-weight: 800;
}

.demo-status-success {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: var(--green);
}

.demo-status-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--red);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 0;
}

.summary-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.summary-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.summary-grid dd {
  margin: 8px 0 0;
  font-size: 24px;
  font-weight: 900;
}

.auth-panel {
  width: min(100%, 430px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 28px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.48);
}

.record-modal {
  width: min(1120px, 100%);
  max-height: min(900px, 92vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h2 {
  margin: 0;
}

.modal-status {
  border-radius: 8px;
  margin: 14px 0;
  padding: 11px 12px;
  font-weight: 800;
}

.modal-status-success {
  border: 1px solid #a7f3d0;
  background: #ecfdf5;
  color: var(--green);
}

.modal-status-error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: var(--red);
}

.record-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.record-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  min-width: 0;
}

.record-field strong {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.record-field pre {
  margin: 8px 0 0;
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}

.auth-brand {
  margin-bottom: 28px;
}

.auth-panel h1 {
  margin: 0;
  font-size: 30px;
}

.auth-copy,
.auth-hint {
  color: var(--muted);
  line-height: 1.55;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: #475569;
  font-size: 13px;
  font-weight: 800;
}

.auth-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  font: inherit;
}

@media (max-width: 1180px) {
  .metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 840px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 18px;
  }

  .nav-list {
    display: none;
  }

  .main-panel {
    padding: 18px;
  }

  .topbar,
  .hero-band {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .topbar,
  .hero-actions {
    justify-content: flex-start;
  }

  .metrics-grid,
  .content-grid,
  .pipeline-steps,
  .record-fields,
  .summary-grid {
    grid-template-columns: 1fr;
  }
}
