/* Lengo dashboard. Colour tokens first; dark mode redefines them. No external assets. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #17202b;
  --muted: #5b6676;
  --accent: #3b5bdb;
  --accent-soft: #e7ecfd;
  --good: #1f8a4c;
  --good-soft: #e3f4ea;
  --bad: #c8322e;
  --bad-soft: #fbe7e6;
  --warn: #a86400;
  --warn-soft: #fdf1dc;
  --info: #475569;
  --info-soft: #eef1f5;
  --band: rgba(59, 91, 219, 0.18);
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --surface: #161c23;
    --surface-2: #1d252e;
    --border: #2b3540;
    --text: #e6eaef;
    --muted: #97a3b2;
    --accent: #7c96f5;
    --accent-soft: #1f2a4a;
    --good: #4cc27f;
    --good-soft: #15301f;
    --bad: #f0716b;
    --bad-soft: #3a1a19;
    --warn: #e6a640;
    --warn-soft: #362a12;
    --info: #a7b3c2;
    --info-soft: #1f2730;
    --band: rgba(124, 150, 245, 0.22);
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 0.88em; }
h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: 0.95rem; margin: 0 0 8px; }
p { margin: 0 0 10px; }

/* Layout */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner, main, .footer {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 16px;
}
.topbar-inner { display: flex; align-items: center; gap: 20px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--accent);
  display: inline-block; position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; left: 5px; right: 5px; bottom: 5px; height: 4px;
  border-radius: 2px; background: var(--surface);
}
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: 0.92rem;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
main { padding-top: 24px; padding-bottom: 40px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.subtitle { color: var(--muted); margin: 0; }
.footer { color: var(--muted); font-size: 0.85rem; padding-bottom: 32px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); }
.grid-tiles { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.stack > * + * { margin-top: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.tile .value { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.tile .label { color: var(--muted); font-size: 0.85rem; }
.tile .hint { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }

/* Badges and lights */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; white-space: nowrap;
  background: var(--info-soft); color: var(--info);
}
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; display: inline-block; }
.lights { display: grid; gap: 8px; }
.light { display: flex; gap: 10px; align-items: flex-start; }
.light .reasons { color: var(--muted); font-size: 0.85rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.wrap { overflow-wrap: anywhere; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 14px 28px; }
.timeline li::before {
  content: ""; position: absolute; left: 2px; top: 6px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--info);
}
.timeline li.good::before { border-color: var(--good); background: var(--good-soft); }
.timeline li.bad::before { border-color: var(--bad); background: var(--bad-soft); }
.timeline li.warn::before { border-color: var(--warn); background: var(--warn-soft); }
.timeline .when { color: var(--muted); font-size: 0.8rem; }
.timeline .title { font-weight: 600; }
.timeline .text { color: var(--muted); font-size: 0.88rem; overflow-wrap: anywhere; }
.kind { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-right: 6px; }

/* Charts (SVG drawn by charts.py) */
.chart, .rollout { width: 100%; height: auto; display: block; }
.chart text, .rollout text { font: 11px var(--sans); fill: var(--muted); }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-zero { stroke: var(--text); stroke-width: 1; opacity: 0.55; }
.chart-band { fill: var(--band); stroke: none; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart-target { stroke: var(--good); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-limit { stroke: var(--bad); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-step { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.6; }
.chart .chart-label { fill: var(--good); font-weight: 600; }
.chart .chart-label-bad { fill: var(--bad); }
.chart-dot { stroke: var(--surface); stroke-width: 1.5; fill: var(--accent); }
.chart-dot-kill { fill: var(--bad); }
.chart-dot-proven { fill: var(--good); }
.chart-muted { fill: var(--muted); }
.rollout-track { fill: var(--surface-2); stroke: var(--border); }
.rollout-fill { fill: var(--accent); }
.rollout-tick { stroke: var(--surface); stroke-width: 2; }
.spark { width: 120px; height: 28px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 0.8rem; margin-top: 6px; }
.swatch { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-right: 5px; background: var(--accent); }
.swatch.band { height: 10px; background: var(--band); }
.swatch.goal { background: var(--good); }
.swatch.limit { background: var(--bad); }

/* Banners, forms */
.banner { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; border: 1px solid var(--border); background: var(--surface); }
.banner.info { background: var(--accent-soft); border-color: transparent; }
.banner.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.banner.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.banner.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
form.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input[type="text"], input[type="search"], input[type="password"], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; max-width: 100%;
}
textarea { width: 100%; font-family: var(--mono); font-size: 0.85rem; line-height: 1.45; min-height: 420px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .button {
  font: inherit; font-weight: 600; border-radius: 8px; padding: 7px 14px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:hover { filter: brightness(0.97); }
button[disabled] { opacity: 0.5; cursor: not-allowed; }
.dial { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 8px; }
.dial button { text-align: left; font-weight: 500; padding: 10px 12px; }
.dial button strong { display: block; }
.dial button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
pre.diff { background: var(--surface-2); border-radius: 8px; padding: 10px; overflow-x: auto; margin: 0; }
.diff .add { color: var(--good); }
.diff .del { color: var(--bad); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs a { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; }
.tabs a.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.result { border-top: 1px solid var(--border); padding: 12px 0; }
.result:first-child { border-top: 0; padding-top: 0; }
details summary { cursor: pointer; color: var(--muted); }

@media (max-width: 640px) {
  .topbar-inner { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  h1 { font-size: 1.25rem; }
  .tile .value { font-size: 1.3rem; }
}
