:root {
  --bg: #f5f6f4; --panel: #ffffff; --ink: #1b1f1d; --muted: #66706b; --line: #e2e5e1;
  --accent: #1f6f5c; --accent-ink: #ffffff; --warn: #b35c00; --bad: #b3261e; --ok: #1f6f5c;
  --chip: #eef1ee; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121614; --panel: #1a1f1d; --ink: #e6ebe8; --muted: #95a09a; --line: #2b322f;
    --accent: #4fb397; --accent-ink: #0d1411; --warn: #e3a04f; --bad: #ef7d74; --ok: #4fb397; --chip: #232a27; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
.btn { border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; border-radius: 8px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: default; }
input[type=text], input[type=password], input[type=date], select {
  border: 1px solid var(--line); background: var(--panel); padding: 8px 10px; border-radius: 8px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: 100%; max-width: 440px; }
.card h1 { margin: 0 0 4px; font-size: 20px; }
.card .sub { margin: 0 0 22px; color: var(--muted); }
.opt { border-top: 1px solid var(--line); padding: 18px 0; }
.opt:first-of-type { border-top: 0; padding-top: 0; }
.opt h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }
.opt p { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
.full { width: 100%; }
.err { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); padding: 10px 12px; border-radius: 8px; margin-bottom: 16px; display: none; }

/* app */
header.top { display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
header.top .brand { font-weight: 650; }
header.top .spacer { flex: 1; }
main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid var(--line); background: var(--panel); }
.banner.bad { border-color: var(--bad); color: var(--bad); }
.banner.warn { border-color: var(--warn); }
.banner.ok { border-color: var(--ok); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kpi .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; }
.bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--chip); margin: 6px 0 18px; }
.bar span { display: block; height: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: 70vh; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--panel); font-weight: 600; font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; z-index: 1; }
td.n, th.n { text-align: right; }
tr:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
tr.click { cursor: pointer; }
.chip { display: inline-block; background: var(--chip); border-radius: 999px; padding: 1px 8px; font-size: 11.5px; margin-right: 4px; }
.chip.bad { color: var(--bad); }
.chip.warn { color: var(--warn); }
.chip.ok { color: var(--ok); }
.steps { font-size: 12px; color: var(--muted); }
.empty { padding: 40px; text-align: center; color: var(--muted); }
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); padding: 0; width: min(1100px, 95vw); }
dialog .hd { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
dialog .bd { padding: 14px 18px; max-height: 70vh; overflow: auto; }
dialog::backdrop { background: rgba(0,0,0,.35); }
@media (max-width: 640px) { main { padding: 14px 16px; } header.top { padding: 10px 16px; } }

/* filter bar */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters:empty { display: none; }
.fdrop { position: relative; }
.fdrop > summary { list-style: none; cursor: pointer; border: 1px solid var(--line); background: var(--panel); padding: 8px 12px; border-radius: 8px; user-select: none; white-space: nowrap; }
.fdrop > summary::-webkit-details-marker { display: none; }
.fdrop[open] > summary, .fdrop > summary:hover { border-color: var(--accent); }
.fdrop > summary::after { content: " ▾"; color: var(--muted); }
.fopts { position: absolute; z-index: 5; top: calc(100% + 4px); left: 0; min-width: 260px; max-height: 320px; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); }
.fopts label { display: flex; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.fopts label:hover { background: var(--chip); }
.fopts .c { margin-left: auto; padding-left: 16px; color: var(--muted); font-size: 12px; }
.fdate { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.fdate input { padding: 6px 8px; }
