/* LILO KPI dashboard — LILO greens for brand chrome; blue for data; reserved status colours. */
:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #f1f3ef;
  --line: #e3e7e1;
  --line-strong: #cfd5cc;
  --text: #121512;
  --text-2: #4f574f;
  --muted: #7d857c;
  --brand: #0f6325;
  --brand-accent: #28af4b;
  --brand-tint: #e7f5eb;
  --on-brand: #ffffff;
  --series-1: #2a78d6;
  --expected: #8a918a;
  --good: #0ca30c; --good-ink: #006300; --good-bg: #e3f4e3;
  --warn: #fab219; --warn-ink: #7a5200; --warn-bg: #fff3d6;
  --bad: #d03b3b;  --bad-ink: #a32121;  --bad-bg: #fbe4e4;
  --na: #b3b9b2;   --na-bg: #eef0ed;
  --shadow: 0 1px 2px rgba(16, 24, 16, .05), 0 1px 3px rgba(16, 24, 16, .04);
  --shadow-hover: 0 4px 14px rgba(16, 24, 16, .09);
  --radius: 12px;
  --side-w: 248px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f110f; --surface: #181b18; --surface-2: #20241f; --line: #2b302a; --line-strong: #3a4139;
    --text: #eef1ed; --text-2: #c0c7bf; --muted: #8f978e;
    --brand: #5cc97a; --brand-accent: #28af4b; --brand-tint: #17301e; --on-brand: #08210f;
    --series-1: #3987e5; --expected: #8f978e;
    --good-ink: #5fd35f; --good-bg: #183218; --warn-ink: #ffcf66; --warn-bg: #3a2e10;
    --bad-ink: #ff8a8a; --bad-bg: #3d1c1c; --na: #4a5149; --na-bg: #252a24;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-hover: 0 4px 16px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f110f; --surface: #181b18; --surface-2: #20241f; --line: #2b302a; --line-strong: #3a4139;
  --text: #eef1ed; --text-2: #c0c7bf; --muted: #8f978e;
  --brand: #5cc97a; --brand-accent: #28af4b; --brand-tint: #17301e; --on-brand: #08210f;
  --series-1: #3987e5; --expected: #8f978e;
  --good-ink: #5fd35f; --good-bg: #183218; --warn-ink: #ffcf66; --warn-bg: #3a2e10;
  --bad-ink: #ff8a8a; --bad-bg: #3d1c1c; --na: #4a5149; --na-bg: #252a24;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-hover: 0 4px 16px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; }
.muted { color: var(--muted); }
.neg { color: var(--bad-ink); font-weight: 600; }
.pos { color: var(--good-ink); font-weight: 600; }

/* ------------------------------------------------------------------ app shell */
.app { display: flex; min-height: 100vh; }
.side {
  width: var(--side-w); flex: none; background: var(--surface); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; z-index: 20;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; border-bottom: 1px solid var(--line); }
.side-brand .logo { height: 30px; width: auto; display: block; }
.side-sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding-top: 6px; }
.nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 6px 10px 8px; }
.nav button, .nav a {
  all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 7px 10px; border-radius: 8px; color: var(--text-2); font-size: 13px;
}
.nav button:hover, .nav a:hover { background: var(--surface-2); color: var(--text); }
.nav button:focus-visible, .nav a:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: -2px; }
.nav .group { font-weight: 650; color: var(--text); font-size: 13.5px; }
.nav .badge-sc { width: 26px; height: 26px; border-radius: 7px; background: var(--brand); color: var(--on-brand); flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 800; letter-spacing: .02em; }
.nav .chev { margin-left: auto; color: var(--muted); font-size: 10px; transition: transform .15s; }
.nav [aria-expanded="true"] > .chev { transform: rotate(90deg); }
.nav ul { list-style: none; margin: 0; padding: 0; }
.nav .lvl1 { padding-left: 10px; margin: 2px 0 6px 13px; border-left: 1px solid var(--line); }
.nav .lvl2 { padding-left: 8px; margin: 0 0 4px 12px; border-left: 1px solid var(--line); }
.nav .lvl2 a { font-size: 12.5px; padding: 5px 8px; }
.nav a.active { background: var(--brand-tint); color: var(--brand); font-weight: 650; }
.nav .count { margin-left: auto; font-size: 11px; color: var(--muted); font-weight: 500; flex: none; }
.nav .row { display: flex; align-items: center; }
.nav .row > a { flex: 1; min-width: 0; }
.nav .row > .exp { width: 26px; flex: none; justify-content: center; padding: 7px 0; }
.nav .row > .exp .chev { margin: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--na); }
.dot.good { background: var(--good); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.nav .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot { border-top: 1px solid var(--line); padding: 12px 20px 16px; font-size: 12px; color: var(--muted); line-height: 1.5; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 14px 28px;
}
.crumbs { flex: 1; min-width: 180px; }
.eyebrow { font-size: 12px; color: var(--muted); }
h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.015em; color: var(--text); margin-top: 1px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.datebox { display: flex; gap: 4px; align-items: center; }
button, .primary, input[type=date], select {
  font: inherit; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); padding: 6px 12px; cursor: pointer; text-decoration: none; line-height: 1.35;
}
select { padding: 6px 10px; max-width: 170px; }
input[type=date] { cursor: text; }
button:hover, input[type=date]:hover, select:hover { background: var(--surface-2); }
button.icon { padding: 6px 10px; font-size: 15px; line-height: 1.2; }
.primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); font-weight: 600; }
.primary:hover { filter: brightness(1.08); }
button.link { border: 0; background: none; color: var(--brand); padding: 2px 4px; margin-left: auto; font-weight: 600; }
button:focus-visible, .primary:focus-visible, input:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
.menu { display: none; }

.status-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 14px 28px 0; font-size: 13px; color: var(--text-2); }
.live { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; color: var(--good-ink); }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.live.past { color: var(--text-2); }
.live.past::before { background: var(--muted); box-shadow: none; }
.daybar { width: 110px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; margin: 0 4px; }
.daybar i { display: block; height: 100%; background: var(--muted); }
.pills { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 12px; color: var(--text-2); }
.pill b { color: var(--text); }

.banner { margin: 12px 28px 0; padding: 10px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; }
.banner.error { background: var(--bad-bg); color: var(--bad-ink); }
.banner a { color: inherit; font-weight: 700; }

.content { padding: 20px 28px 48px; display: flex; flex-direction: column; gap: 30px; max-width: 1480px; width: 100%; }
.sec[hidden] { display: none; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-bottom: 12px; }
.sec-head h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.sec-meta { font-size: 13px; color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.panel .sec-head { align-items: center; }

/* ------------------------------------------------------------------ cards */
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.card {
  all: unset; box-sizing: border-box; display: flex; flex-direction: column; gap: 8px; cursor: pointer; position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 14px 20px;
  box-shadow: var(--shadow); transition: box-shadow .15s, border-color .15s, transform .15s; overflow: hidden; color: var(--text);
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--na); }
.card.st-good::before { background: var(--good); }
.card.st-warn::before { background: var(--warn); }
.card.st-bad::before { background: var(--bad); }
.card:hover { box-shadow: var(--shadow-hover); border-color: var(--line-strong); transform: translateY(-1px); }
.card:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
.card .top { display: flex; align-items: flex-start; gap: 8px; }
.card .name { flex: 1; font-weight: 650; font-size: 13.5px; line-height: 1.3; }
.num-badge { flex: none; width: 22px; height: 22px; border-radius: 6px; background: var(--brand-tint); color: var(--brand);
  font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.card .big { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card .big b { font-size: 28px; font-weight: 750; letter-spacing: -0.025em; line-height: 1.1; }
.card .big span { font-size: 12.5px; color: var(--text-2); }
.card.st-na .big b { color: var(--muted); }
.card .gap { font-size: 12.5px; color: var(--text-2); }
.card .sub { font-size: 12px; color: var(--muted); padding-right: 64px; }
.card .open { position: absolute; right: 14px; bottom: 12px; font-size: 12px; color: var(--brand); font-weight: 600; opacity: 0; transition: opacity .15s; }
.card:hover .open, .card:focus-visible .open { opacity: 1; }
.card .minis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 2px; }
.card .mini { background: var(--surface-2); border-radius: 8px; padding: 6px 8px; min-width: 0; }
.card .mini span { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.card .mini b { font-size: 13.5px; }
.card .check { font-size: 12px; color: var(--text-2); border-top: 1px dashed var(--line); padding-top: 8px; padding-right: 64px; }
.card.lg .big b { font-size: 32px; }

.bar { position: relative; height: 8px; background: var(--surface-2); border-radius: 4px; margin: 2px 0; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--series-1); }
.bar > b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--muted); border-radius: 1px; }
.bar > b.tgt { background: var(--text); }
.bar.empty { background: transparent; border-top: 1px dashed var(--line); height: 0; margin: 6px 0; }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 999px; white-space: nowrap; flex: none; }
.chip.good { background: var(--good-bg); color: var(--good-ink); }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip.bad { background: var(--bad-bg); color: var(--bad-ink); }
.chip.na { background: var(--na-bg); color: var(--text-2); }
.tag-cat { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 6px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); flex: none; }
.op-badge { font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 6px; text-transform: uppercase; flex: none; }
.op-badge.open { background: var(--good-bg); color: var(--good-ink); }
.op-badge.closed { background: var(--bad-bg); color: var(--bad-ink); }

/* ------------------------------------------------------------------ chart */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 4px 12px; background: transparent; color: var(--text-2); }
.seg button[aria-selected="true"] { background: var(--brand-tint); color: var(--brand); font-weight: 650; }
.chart { width: 100%; height: 280px; position: relative; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .actual { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; }
.chart .area { fill: var(--series-1); opacity: 0.08; }
.chart .expected { fill: none; stroke: var(--expected); stroke-width: 2; stroke-dasharray: 5 4; }
.chart .now line { stroke: var(--muted); stroke-dasharray: 2 3; }
.chart .now text { fill: var(--muted); font-size: 11px; }
.chart .cross { stroke: var(--text-2); stroke-width: 1; }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .dlabel { fill: var(--text); font-size: 12px; font-weight: 650; }
.legend { display: flex; flex-wrap: wrap; gap: 18px; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 0; border-top: 2px solid var(--series-1); }
.legend i.exp { border-top: 2px dashed var(--expected); }

.tip { position: fixed; pointer-events: none; z-index: 40; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.14); min-width: 150px; }
.tip .t { font-weight: 650; margin-bottom: 4px; }
.tip .r { display: flex; justify-content: space-between; gap: 14px; color: var(--text-2); }
.tip .r b { color: var(--text); font-weight: 650; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
table.kv td:first-child { color: var(--text-2); }

/* ------------------------------------------------------------------ developer mode */
.dev-badge { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; padding: 1px 4px 1px 8px; border-radius: 999px;
  background: #1f2937; color: #f9fafb; font-size: 11px; font-weight: 650; }
.dev-badge[hidden] { display: none; }
.dev-badge .link { color: #93c5fd; font-size: 11px; padding: 0 4px; margin: 0; }
details.sql { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; background: var(--surface); }
details.sql summary { cursor: pointer; display: flex; gap: 10px; align-items: center; padding: 9px 12px; font-size: 13px; list-style: none; }
details.sql summary::-webkit-details-marker { display: none; }
details.sql summary::before { content: "\25B6"; font-size: 9px; color: var(--muted); transition: transform .15s; }
details.sql[open] summary::before { transform: rotate(90deg); }
.sql-tag { font-weight: 600; flex: 1; }
.sql-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.sql-meta code { font: 11.5px ui-monospace, Consolas, monospace; color: var(--text-2); background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
.sql-body { position: relative; border-top: 1px solid var(--line); }
.sql-body pre { margin: 0; padding: 12px 14px; overflow-x: auto; font: 12px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace;
  background: var(--surface-2); border-radius: 0 0 10px 10px; white-space: pre; color: var(--text); }
.sql-body .copy { position: absolute; top: 8px; right: 10px; font-size: 12px; padding: 3px 10px; }

.foot { color: var(--muted); font-size: 12px; line-height: 1.6; border-top: 1px solid var(--line); padding-top: 14px; }
.empty { color: var(--muted); padding: 12px 0; }

/* ------------------------------------------------------------------ drill-down */
.drill { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px 26px; background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(0,0,0,.28); }
.drill::backdrop { background: rgba(10, 20, 12, .45); }
.drill .close { position: absolute; top: 14px; right: 14px; border: 0; background: transparent; }
.drill h3 { font-size: 19px; letter-spacing: -0.01em; }
.drill h4 { margin: 22px 0 8px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.drill p { margin: 4px 0 0; }
.dhead { display: flex; gap: 12px; align-items: flex-start; padding-right: 36px; }
.dhead > div { flex: 1; }
.dhead .num-badge { width: 32px; height: 32px; border-radius: 8px; font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-top: 18px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stat span { font-size: 11px; color: var(--muted); }
.stat b { font-size: 19px; letter-spacing: -0.01em; }
.dnote { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-top: 14px !important; }
.small { font-size: 12px; margin-top: 6px !important; }
.hist { width: 100%; height: auto; display: block; margin: 6px 0 10px; }
.hist .g { stroke: var(--line); }
.hist .ax { fill: var(--muted); font-size: 10px; }
.hist .hb { fill: var(--series-1); }
.hist .hb.st-na { fill: var(--line-strong); }
.hist .tl { stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 5 4; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1240px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 960px) {
  .side { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; visibility: hidden; }
  .side.open { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 15; }
  .menu { display: inline-block; }
  .topbar, .status-row { padding-left: 16px; padding-right: 16px; }
  .content { padding: 16px 16px 40px; }
  .banner { margin: 10px 16px 0; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr; }
  .topbar { position: static; }
  .chart { height: 220px; }
  .card .big b { font-size: 26px; }
  .pills { margin-left: 0; }
}
@media print {
  .side, .controls, .menu, button.link, #banner, .scrim { display: none !important; }
  .topbar { position: static; backdrop-filter: none; }
  body { background: #fff; }
  .card, .panel { break-inside: avoid; box-shadow: none; }
  .sec[hidden] { display: block !important; }
}
