:root {
  color-scheme: light;
  --ink: #0a0a0a;
  --muted: #6b7280;
  --line: #e7e7e7;
  --panel: #ffffff;
  --soft: #f6f6f6;
  --brand: #000000;
  --bg: #f8f8f8;
  --sidebar: #0b0f0d;
  --accent: #2f8f5b;
  --focus-ring: #2a78d6;
  --shadow: 0 1px 1px rgba(0, 0, 0, 0.02), 0 8px 24px rgba(0, 0, 0, 0.035);
  --mono: "Geist Mono", "SFMono-Regular", Consolas, monospace;
  --display: "Geist", "Inter", "Segoe UI", sans-serif;
  --body: "Geist", "Inter", "Segoe UI", sans-serif;

  --status-good: #0ca30c;
  --status-info: #2a78d6;
  --status-warning: #b45309;
  --status-critical: #d03b3b;
  --sidebar-soft: #111714;
  --sidebar-line: #202821;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --ink: #f3f3f1;
    --muted: #a4a89f;
    --line: rgba(255, 255, 255, 0.12);
    --panel: #17191a;
    --soft: #1e2121;
    --brand: #f3f3f1;
    --bg: #0d0e0d;
    --focus-ring: #5fa8f5;
    --status-good: #17c317;
    --status-info: #5fa8f5;
    --status-warning: #fab219;
    --status-critical: #e66767;
    --sidebar-soft: #111714;
    --sidebar-line: #202821;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f3f3f1;
  --muted: #a4a89f;
  --line: rgba(255, 255, 255, 0.12);
  --panel: #17191a;
  --soft: #1e2121;
  --brand: #f3f3f1;
  --bg: #0d0e0d;
  --focus-ring: #5fa8f5;
  --status-good: #17c317;
  --status-info: #5fa8f5;
  --status-warning: #fab219;
  --status-critical: #e66767;
  --sidebar-soft: #111714;
  --sidebar-line: #202821;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--body);
  background: var(--bg);
  transition: background-color 160ms ease, color 160ms ease;
}

/* Phase 1's single centered landing card — scoped so it doesn't affect
   the dashboard's own full-width sidebar layout below. */
body.landing-body {
  display: flex;
  align-items: center;
  justify-content: center;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 2.5rem 3rem;
  max-width: 440px;
  text-align: center;
}

.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  color: var(--brand);
}

.tagline {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.4rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.5rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--status-good);
}

.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-good);
}

.meta {
  margin-top: 1.25rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

/* ═══════════════ Dashboard shell (sidebar + main) ═══════════════ */

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

.shell > aside {
  background: var(--sidebar);
  color: #f3f3f1;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.25rem;
}

.brand-row .wordmark {
  color: #f3f3f1;
  font-size: 1.15rem;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-title {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7d8a80;
  padding: 0.4rem 0.6rem 0.3rem;
}

.nav-group a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.6rem;
  border-radius: 8px;
  font-size: 0.88rem;
  color: #cfd6cf;
  transition: background-color 120ms ease, color 120ms ease;
}

.nav-group a:hover {
  background: var(--sidebar-soft);
  color: #fff;
}

.nav-group a[aria-current="page"] {
  background: var(--sidebar-soft);
  color: #fff;
  font-weight: 600;
  border: 1px solid var(--sidebar-line);
}

.shell > main {
  padding: 2rem 2.5rem 3rem;
  max-width: 1100px;
}

/* ═══════════════ Section / page structure ═══════════════ */

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.section-head h1 {
  font-family: var(--display);
  font-size: 1.4rem;
  margin: 0 0 0.25rem;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.button-row {
  display: flex;
  gap: 0.6rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.btn:hover { background: var(--soft); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-danger {
  background: transparent;
  border-color: var(--status-critical);
  color: var(--status-critical);
}

.btn-danger:hover { background: var(--status-critical); color: #fff; }

/* ═══════════════ Cards / forms ═══════════════ */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.control-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow);
}

/* ═══════════════ Stat cards (Overview page) ═══════════════ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem 1.3rem;
  box-shadow: var(--shadow);
}

.stat-value {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.stat-value .stat-value-sub {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--muted);
}

.stat-label {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.job-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.control-card h2 {
  font-family: var(--display);
  font-size: 1.02rem;
  margin: 0 0 0.3rem;
}

.control-card .subtle {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0 0 1rem;
}

.form-grid {
  display: grid;
  gap: 0.85rem;
}

.field { display: flex; flex-direction: column; gap: 0.3rem; }

.field .label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}

.field textarea.token-output {
  font-family: var(--mono);
  font-size: 0.8rem;
  resize: vertical;
}

.field-hint { font-size: 0.75rem; color: var(--muted); }

.form-actions { margin-top: 0.3rem; }

/* ═══════════════ Tables / lists ═══════════════ */

.results-stack { display: flex; flex-direction: column; gap: 0.75rem; }

table.compact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

table.compact-table th,
table.compact-table td {
  padding: 0.65rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

table.compact-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--soft);
}

table.compact-table tr:last-child td { border-bottom: none; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--soft);
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-badge.good { color: var(--status-good); }
.status-badge.good::before { background: var(--status-good); }
.status-badge.critical { color: var(--status-critical); }
.status-badge.critical::before { background: var(--status-critical); }
.status-badge.warning { color: var(--status-warning); }
.status-badge.warning::before { background: var(--status-warning); }

/* ═══════════════ Danger zone ═══════════════ */

.danger-zone {
  border: 1px solid var(--status-critical);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  margin-top: 0.5rem;
}

.danger-zone h3 {
  font-size: 0.85rem;
  margin: 0 0 0.3rem;
  color: var(--status-critical);
}

/* ═══════════════ Docs page ═══════════════ */

.docs-section {
  margin-bottom: 2.25rem;
}

.docs-section h2 {
  font-family: var(--display);
  font-size: 1.08rem;
  margin: 0 0 0.4rem;
}

.docs-section p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 0 0 0.9rem;
}

.docs-section p code,
.docs-section li code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
}

.docs-section ul {
  margin: 0 0 0.9rem;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

pre.code-block {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  margin: 0 0 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--ink);
}

/* ═══════════════ Mobile: hamburger nav + off-canvas drawer ═══════════════ */

.topbar {
  display: none;
}

.burger {
  display: none;
}

.sidebar-overlay {
  display: none;
}

@media (max-width: 880px) {
  .shell {
    display: block;
  }

  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--sidebar);
    padding: 0.85rem 1rem;
  }

  .topbar .wordmark {
    color: #f3f3f1;
    font-size: 1.1rem;
  }

  .burger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 34px;
    height: 34px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--sidebar-line);
    border-radius: 8px;
    cursor: pointer;
  }

  .burger span {
    display: block;
    height: 2px;
    margin: 0 7px;
    background: #f3f3f1;
    border-radius: 2px;
    transition: transform 160ms ease, opacity 160ms ease;
  }

  body.nav-open .burger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  body.nav-open .burger span:nth-child(2) { opacity: 0; }
  body.nav-open .burger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  .shell > aside {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    max-width: 82vw;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: var(--shadow);
  }

  body.nav-open .shell > aside {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
  }

  body.nav-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  body.nav-open {
    overflow: hidden;
  }

  .shell > main {
    padding: 1.25rem 1rem 2.5rem;
    max-width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  table.compact-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
