:root {
  color-scheme: dark;
  --bg: #08111f;
  --panel: rgba(10, 18, 34, 0.82);
  --panel-2: rgba(16, 29, 54, 0.9);
  --text: #edf2ff;
  --muted: #a9b5d6;
  --green: #2ab673;
  --yellow: #f0b53a;
  --red: #d85f5f;
  --border: rgba(120, 146, 204, 0.18);
  --accent: #7dd3fc;
  --accent-2: #c084fc;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(125,211,252,.18), transparent 30%),
    radial-gradient(circle at top right, rgba(192,132,252,.16), transparent 26%),
    linear-gradient(180deg, #07101d, #0d1526 48%, #0a1120);
  color: var(--text);
}
a { color: #8dd8ff; text-decoration: none; }
a:hover { color: white; }

/* ── Layout shell ── */
.shell { max-width: 1240px; margin: 0 auto; }
.page-main {
  padding: clamp(12px, 4vw, 28px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-shell { max-width: 1240px; margin: 0 auto; padding: clamp(12px, 4vw, 28px); }

.muted { color: var(--muted); }

/* ── Topbar ── */
.topbar {
  display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
  padding: 20px 22px; border: 1px solid var(--border); border-radius: 20px;
  background: rgba(9,16,30,.65); backdrop-filter: blur(18px);
}
.topbar h1 { margin: 0; font-family: "Iowan Old Style", "Palatino Linotype", serif; font-size: clamp(1.3rem, 4vw, 2rem); letter-spacing: .02em; }
.topbar p { color: var(--muted); margin-top: 6px; max-width: 70ch; }
.build-chip { display:inline-block; margin-top: 10px; padding: 6px 10px; border-radius: 999px; border: 1px solid rgba(125,211,252,.35); background: rgba(125,211,252,.10); color: #cfefff; font-size: .82rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.topbar nav { display: flex; gap: 16px; margin-top: 8px; flex-wrap: wrap; }

/* ── Banner ── */
.banner { padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); backdrop-filter: blur(16px); }
.banner.green { background: rgba(42,182,115,.14); }
.banner.yellow { background: rgba(240,181,58,.14); }
.banner.red { background: rgba(216,95,95,.14); }
.zone-chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: .85rem; vertical-align: middle; }
.zone-chip.green { background: rgba(42,182,115,.85); color: #0a2e1a; }
.zone-chip.yellow { background: rgba(240,181,58,.85); color: #2e2000; }
.zone-chip.red { background: rgba(216,95,95,.85); color: #fff; }

/* ── Card grid ── */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid.single { grid-template-columns: 1fr; }
.card {
  background: linear-gradient(180deg, rgba(14,24,45,.92), rgba(10,18,34,.92));
  border: 1px solid var(--border); border-radius: 20px; padding: 22px;
  box-shadow: 0 18px 40px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.04);
  min-width: 0;
}
.card h2 { margin-top: 0; font-family: "Iowan Old Style", "Palatino Linotype", serif; letter-spacing: .02em; font-size: clamp(1rem, 3vw, 1.4rem); }
.hero { grid-column: span 2; }
.full-width { grid-column: span 2; }

/* ── Hero row (title + live badge) ── */
.hero-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.hero-row > div:first-child { flex: 1 1 0; min-width: 0; }
.live-stack { display: grid; gap: 8px; justify-items: end; flex-shrink: 0; }
.live-meta { color: var(--muted); font-size: .92rem; margin: 8px 0 0; }
.live-badge { padding: 8px 12px; border-radius: 999px; background: rgba(42,182,115,.14); border: 1px solid rgba(42,182,115,.35); color: #baf7d6; font-size: .9rem; font-weight: 700; white-space: nowrap; }
.live-badge.is-stale { background: rgba(240,181,58,.14); border-color: rgba(240,181,58,.35); color: #ffe8ab; }
.pulse-note { color: var(--muted); font-size: .85rem; letter-spacing: .02em; }
.pulse-clock { color: #baf7d6; font-size: .82rem; font-variant-numeric: tabular-nums; }

/* ── Stats ── */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.stats div, .checklist li {
  background: linear-gradient(180deg, rgba(18,31,58,.95), rgba(15,24,43,.95));
  border: 1px solid var(--border); border-radius: 14px; padding: 16px;
}
.stats span { display: block; font-size: clamp(20px, 4vw, 32px); font-weight: 800; color: white; }
.stats label { color: var(--muted); font-size: 13px; }
.role-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.role-metrics div { background: linear-gradient(180deg, rgba(18,31,58,.95), rgba(15,24,43,.95)); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.role-metrics span { display: block; font-size: clamp(18px, 3.5vw, 28px); font-weight: 800; color: white; }
.role-metrics label { color: var(--muted); font-size: 13px; }

/* ── Checklist ── */
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.hero .checklist { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ── Pre / code blocks ── */
pre {
  white-space: pre-wrap; word-break: break-word; color: #dbeafe;
  background: #08111f; border-radius: 14px; border: 1px solid var(--border);
  padding: 16px; overflow: auto; font-size: clamp(.75rem, 2vw, .9rem);
  max-width: 100%;
}

/* ── Lists ── */
ul { padding-left: 20px; }
.reason-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.reason-list li { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; background: linear-gradient(180deg, rgba(18,31,58,.95), rgba(15,24,43,.95)); }
.reason-yellow { border-color: rgba(240,181,58,.35); }
.reason-red { border-color: rgba(216,95,95,.35); }
.reason-green { border-color: rgba(42,182,115,.35); }

/* ── Markdown body ── */
.md-body { line-height: 1.7; font-size: .95rem; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  margin: 1.2em 0 .4em; color: var(--text); letter-spacing: .02em;
}
.md-body h1 { font-size: 1.4rem; border-bottom: 1px solid var(--border); padding-bottom: .4em; }
.md-body h2 { font-size: 1.15rem; }
.md-body h3 { font-size: 1rem; color: var(--accent); }
.md-body h4 { font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.md-body p { margin: .6em 0; color: var(--text); }
.md-body strong { color: white; font-weight: 700; }
.md-body em { color: #c4d4f5; }
.md-body a { color: var(--accent); }
.md-body a:hover { color: white; }
.md-body ul, .md-body ol { padding-left: 20px; margin: .5em 0; }
.md-body li { margin: .3em 0; color: var(--text); }
.md-body li > p { margin: 0; }
.md-body code {
  background: rgba(125,211,252,.1); border: 1px solid rgba(125,211,252,.2);
  border-radius: 6px; padding: 2px 6px; font-size: .85em; color: #bae6fd;
  font-family: "IBM Plex Mono", "Fira Code", monospace;
}
.md-body pre {
  background: #060e1c; border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; overflow-x: auto; margin: .8em 0;
}
.md-body pre code {
  background: none; border: none; padding: 0; font-size: .85rem;
  color: #93c5fd; white-space: pre;
}
.md-body blockquote {
  border-left: 3px solid var(--accent); margin: .8em 0; padding: .4em 0 .4em 16px;
  background: rgba(125,211,252,.05); border-radius: 0 8px 8px 0; color: var(--muted);
}
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
.md-body table { width: 100%; border-collapse: collapse; margin: .8em 0; font-size: .9rem; }
.md-body th {
  background: rgba(18,31,58,.95); border: 1px solid var(--border);
  padding: 10px 14px; text-align: left; color: var(--accent); font-weight: 600;
}
.md-body td { border: 1px solid var(--border); padding: 9px 14px; color: var(--text); }
.md-body tr:nth-child(even) td { background: rgba(14,24,45,.6); }

/* ── Login ── */
.login-card {
  max-width: 440px; margin: 10vh auto 0; display: grid; gap: 12px;
  background: linear-gradient(180deg, rgba(12,22,42,.94), rgba(8,14,28,.96));
}
.login-card h1 { margin-bottom: 0; font-family: "Iowan Old Style", "Palatino Linotype", serif; }
.login-card p { color: var(--muted); margin-top: 0; }
label { font-size: .95rem; color: #d7e3ff; }
input, button { border-radius: 14px; border: 1px solid var(--border); padding: 13px 14px; font: inherit; }
input { background: #0a1325; color: var(--text); width: 100%; }
button {
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  color: white; cursor: pointer; font-weight: 700; border: none;
  box-shadow: 0 10px 24px rgba(67, 56, 202, .28);
}
button:hover { filter: brightness(1.06); }

/* ── Responsive ── */
@media (max-width: 700px) {
  .topbar { flex-direction: column; gap: 12px; padding: 16px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .hero { grid-column: span 1; }
  .full-width { grid-column: span 1; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
  .hero .checklist { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .role-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats div, .checklist li, .role-metrics div { padding: 12px; }
  .card { padding: 16px; border-radius: 16px; }
  .banner { border-radius: 12px; }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero .checklist { grid-template-columns: 1fr; }
  .role-metrics { grid-template-columns: 1fr; }
  .hero-row { gap: 10px; }
  .live-badge { font-size: .8rem; padding: 6px 10px; }
}

/* ── Service health grid ── */
.svc-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.svc-item { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 88px; }
.svc-item label { font-size: .78rem; color: var(--muted); letter-spacing: .03em; }

/* ── Log viewer ── */
.logs-card { display: flex; flex-direction: column; gap: 12px; }
.logs-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logs-header h2 { margin: 0; }
.log-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.log-tab { background: rgba(255,255,255,.06); border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 4px 14px; font-size: .8rem; font-weight: 600; cursor: pointer; letter-spacing: .03em; transition: background .15s, color .15s; }
.log-tab:hover { background: rgba(255,255,255,.12); color: #e2e8f0; }
.log-tab.active { background: rgba(125,211,252,.15); border-color: rgba(125,211,252,.4); color: #cfefff; }
.log-output { background: rgba(0,0,0,.45); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; font-size: .78rem; line-height: 1.6; font-family: 'Fira Mono', 'Cascadia Code', 'SF Mono', monospace; white-space: pre-wrap; word-break: break-all; max-height: 520px; overflow-y: auto; margin: 0; color: #cbd5e1; min-height: 200px; }
.log-placeholder { color: var(--muted); font-style: italic; }

/* ── Codex usage tile ── */
.usage-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 600; font-size: .9rem; }
.usage-label { font-size: .78rem; color: var(--muted); margin: 8px 0 4px; }
.usage-bar-wrap { background: rgba(255,255,255,.08); border-radius: 999px; height: 8px; overflow: hidden; margin-bottom: 2px; }
.usage-bar { height: 100%; border-radius: 999px; transition: width .4s ease; }
.usage-bar.bar-ok   { background: var(--green); }
.usage-bar.bar-warn { background: var(--yellow); }
.usage-bar.bar-crit { background: var(--red); }
.usage-status { font-size: .85rem; font-weight: 700; border-radius: 6px; padding: 2px 8px; }
.usage-status.ok   { color: var(--green); }
.usage-status.warn { color: var(--yellow); }
.usage-status.crit { color: var(--red); animation: blink 1s step-end infinite; }
.usage-ts { font-size: .72rem; margin-top: 6px; }
.card-alert { border: 1px solid var(--red) !important; box-shadow: 0 0 12px rgba(216,95,95,.35); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.4} }
