:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface-1: #fcfcfb;
  --border: #e3e2de;
  --grid: #ecebe7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77766f;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --track: #cde2fb;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-ink: #006300;
  --warning-ink: #7a5200;
  --critical-ink: #a32222;
  --focus: #2a78d6;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface-1: #1a1a19;
    --border: #2e2e2c;
    --grid: #262624;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #94938b;
    --series-1: #3987e5;
    --series-2: #d95926;
    --track: #184f95;
    --good-ink: #5fd35f;
    --warning-ink: #fab219;
    --critical-ink: #f07a7a;
    --focus: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface-1: #1a1a19;
  --border: #2e2e2c;
  --grid: #262624;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #94938b;
  --series-1: #3987e5;
  --series-2: #d95926;
  --track: #184f95;
  --good-ink: #5fd35f;
  --warning-ink: #fab219;
  --critical-ink: #f07a7a;
  --focus: #3987e5;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login {
  width: 100%; max-width: 360px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px 24px;
}
.login h1 { font-size: 18px; margin: 0 0 4px; }
.login p { margin: 0 0 20px; color: var(--text-secondary); }
.login label { display: block; font-size: 13px; color: var(--text-secondary); margin: 14px 0 6px; }
.login input {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg);
}
.login button {
  width: 100%; margin-top: 20px; padding: 10px; border: 0; border-radius: 8px;
  background: var(--series-1); color: #fff; font-weight: 600; cursor: pointer;
}
.alert { margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 13px; border: 1px solid var(--critical); color: var(--critical-ink); }
.alert[hidden] { display: none; }

/* ---------- dashboard ---------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 20px 16px 48px; }
header.top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
header.top h1 { font-size: 18px; margin: 0; }
.sub { color: var(--text-muted); font-size: 12px; }
.actions { display: flex; gap: 8px; align-items: center; }
.btn {
  border: 1px solid var(--border); background: var(--surface-1); border-radius: 8px;
  padding: 6px 12px; cursor: pointer;
}

.status {
  margin-top: 16px; display: flex; gap: 14px; align-items: center; padding: 14px 16px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  border-left-width: 6px;
}
.status[data-level="normal"] { border-left-color: var(--good); }
.status[data-level="sibuk"] { border-left-color: var(--warning); }
.status[data-level="penuh"] { border-left-color: var(--critical); }
.status .ikon { width: 28px; height: 28px; flex: none; }
.status .label { font-size: 16px; font-weight: 700; }
.status[data-level="normal"] .label { color: var(--good-ink); }
.status[data-level="sibuk"] .label { color: var(--warning-ink); }
.status[data-level="penuh"] .label { color: var(--critical-ink); }
.status .alasan { color: var(--text-secondary); font-size: 13px; }

.filter { display: flex; gap: 4px; margin: 20px 0 12px; flex-wrap: wrap; align-items: center; }
.filter span { color: var(--text-muted); font-size: 12px; margin-right: 6px; }
.filter button {
  border: 1px solid var(--border); background: var(--surface-1); border-radius: 999px;
  padding: 4px 12px; cursor: pointer; font-size: 13px;
}
.filter button[aria-pressed="true"] { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tile {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; min-width: 0;
}
.tile h2 { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin: 0 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.tile .val { font-size: 26px; font-weight: 700; line-height: 1.1; }
.tile .val small { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-left: 4px; }
.tile .detail { color: var(--text-muted); font-size: 12px; margin-top: 4px; min-height: 17px; }
.meter { height: 8px; border-radius: 4px; background: var(--track); margin-top: 10px; overflow: hidden; }
.meter > div { height: 100%; border-radius: 4px; background: var(--series-1); width: 0; transition: width .4s; }
.meter[data-sev="sibuk"] > div { background: var(--warning); }
.meter[data-sev="penuh"] > div { background: var(--critical); }
.spark { display: block; width: 100%; height: 32px; margin-top: 8px; }
.spark path { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; margin-top: 12px; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card.lebar { grid-column: 1 / -1; }
.card h2 { font-size: 14px; margin: 0; }
.card .ket { color: var(--text-muted); font-size: 12px; margin: 2px 0 8px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis text { fill: var(--text-muted); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ref { stroke: var(--text-muted); stroke-dasharray: 3 4; stroke-width: 1; }
.chart .ref-label { fill: var(--text-muted); font-size: 11px; }
.chart .endlabel { font-size: 11px; fill: var(--text-secondary); font-weight: 600; }
.chart .cross { stroke: var(--text-muted); stroke-width: 1; }
.chart .dot { stroke: var(--surface-1); stroke-width: 2; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgb(0 0 0 / .12);
  white-space: nowrap; z-index: 2;
}
.tooltip[hidden] { display: none; }
.tooltip b { display: block; margin-bottom: 2px; color: var(--text-secondary); font-weight: 600; }
.tooltip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.kosong { color: var(--text-muted); font-size: 13px; padding: 40px 0; text-align: center; }

details { margin-top: 8px; font-size: 12px; color: var(--text-secondary); }
details summary { cursor: pointer; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; }
td.r, th.r { text-align: right; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; }
.pill svg { width: 14px; height: 14px; }
.pill.ok { color: var(--good-ink); }
.pill.bad { color: var(--critical-ink); }
footer.note { margin-top: 18px; color: var(--text-muted); font-size: 12px; }

@media (max-width: 520px) {
  .tile .val { font-size: 22px; }
  .chart svg { height: 180px; }
}
