:root {
  --brand: #0f2c4c;
  --brand-2: #173c63;
  --accent: #0b7a75;
  --accent-soft: #e3f2f1;
  --surface: #ffffff;
  --canvas: #f3f5f8;
  --line: #e1e5eb;
  --line-strong: #cdd3dc;
  --text: #191919;
  --text-2: #5b6573;
  --text-3: #8a93a0;
  --series-1: #257de0;
  --series-1-wash: rgba(37, 125, 224, 0.10);
  --good: #0a7a32;
  --good-bg: #e6f4ea;
  --warn: #9a5b00;
  --warn-bg: #fff4dc;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --radius: 6px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--canvas); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.boot { padding: 80px; text-align: center; color: var(--text-2); }
[hidden] { display: none !important; }

/* ---------- top bar */
.topbar { background: var(--brand); color: #fff; display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 54px; position: sticky; top: 0; z-index: 20; }
.brandmark { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .2px; white-space: nowrap; }
.brandmark .logo { width: 26px; height: 26px; border-radius: 5px; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.brandmark small { display: block; font-weight: 400; font-size: 11px; opacity: .7; letter-spacing: .3px; text-transform: uppercase; }
.nav { display: flex; gap: 2px; height: 100%; }
.nav a { color: rgba(255,255,255,.78); display: flex; align-items: center; padding: 0 12px; height: 100%; border-bottom: 3px solid transparent; font-weight: 500; }
.nav a:hover { color: #fff; text-decoration: none; background: rgba(255,255,255,.06); }
.nav a.on { color: #fff; border-bottom-color: #5fc4bd; }
.topbar .spacer { flex: 1; }
.updated { font-size: 12px; opacity: .75; white-space: nowrap; }
.usermenu { position: relative; }
.usermenu > button { background: rgba(255,255,255,.1); border: 0; color: #fff; border-radius: 16px; padding: 5px 12px; cursor: pointer; white-space: nowrap; }
.usermenu .menu { position: absolute; right: 0; top: 38px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(15,44,76,.15); min-width: 200px; padding: 6px 0; }
.usermenu .menu a, .usermenu .menu button { display: block; width: 100%; text-align: left; padding: 8px 14px; background: none; border: 0; cursor: pointer; color: var(--text); }
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--canvas); text-decoration: none; }
.usermenu .menu .who { padding: 6px 14px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 12.5px; color: var(--text-2); }

/* ---------- layout */
main { max-width: 1320px; margin: 0 auto; padding: 22px 20px 60px; }
.pagehead { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.pagehead h1 { font-size: 20px; margin: 0; font-weight: 600; }
.pagehead .sub { color: var(--text-2); margin-top: 2px; }
.pagehead .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card h2 { font-size: 15px; margin: 0 0 2px; font-weight: 600; }
.card .cardsub { color: var(--text-2); font-size: 12.5px; margin-bottom: 12px; }
.cardhead { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.cardhead .actions { margin-left: auto; display: flex; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.split { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 980px) { .grid2, .split { grid-template-columns: 1fr; } .nav a { padding: 0 8px; } .updated { display: none; } }
@media (max-width: 980px) { .sidelist { position: static; max-height: 240px; } }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .brandmark small { display: none; }
  .nav { order: 3; width: 100%; overflow-x: auto; height: 40px; scrollbar-width: none; }
  .nav a { flex: none; }
  main { padding: 14px 10px 40px; padding-bottom: max(40px, env(safe-area-inset-bottom)); }
  .pagehead h1, .itemhead h1 { font-size: 18px; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { padding: 10px 11px; }
  .tile .value { font-size: 17px; }
  .card { padding: 12px; }
  .filters > * { flex: 1 1 140px; }
  .filters .btn { flex: 0 0 auto; }
  input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], select { font-size: 16px; }
  table.t { font-size: 12.5px; }
  table.t td, table.t th { padding: 6px 8px; }
  .modalback { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; }
  .usermenu .menu { position: fixed; right: 10px; top: 52px; }
}

/* ---------- controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius); padding: 6px 12px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--brand-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.linkbtn { background: none; border: 0; color: var(--brand-2); cursor: pointer; padding: 0; }
.linkbtn:hover { text-decoration: underline; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], select, textarea {
  border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 6px 9px; background: var(--surface); min-height: 32px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid #8fc6f5; outline-offset: 0; border-color: var(--series-1); }
label.fld { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-2); }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.filters .grow { flex: 1; min-width: 220px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--canvas); border: 1px solid var(--line); font-size: 12px; color: var(--text-2); white-space: nowrap; }
.chip.good { background: var(--good-bg); border-color: transparent; color: var(--good); }
.chip.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.chip.bad { background: var(--bad-bg); border-color: transparent; color: var(--bad); }
.chip.info { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

/* ---------- search box */
.searchwrap { position: relative; }
.bigsearch { width: 100%; font-size: 16px; padding: 10px 14px !important; min-height: 44px !important; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 28px rgba(15,44,76,.14); z-index: 15; max-height: 420px; overflow: auto; }
.suggest .opt { display: flex; gap: 12px; padding: 8px 12px; cursor: pointer; align-items: baseline; }
.suggest .opt.on, .suggest .opt:hover { background: var(--accent-soft); }
.suggest .opt .code { font-family: var(--mono); font-size: 12.5px; min-width: 120px; color: var(--brand-2); }
.suggest .opt .d { flex: 1; }
.suggest .opt .c { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.suggest .grouplabel { padding: 6px 12px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); }

/* ---------- stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .label { font-size: 12.5px; color: var(--text-2); }
.tile .value { font-size: 21px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: 13px; font-weight: 400; color: var(--text-2); }
.tile .meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.delta.up { color: var(--bad); }
.delta.down { color: var(--good); }

/* ---------- tables */
.tablewrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tablewrap.tall { max-height: 620px; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { position: sticky; top: 0; background: #f7f8fa; text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: default; user-select: none; z-index: 1; }
table.t th.sortable { cursor: pointer; }
table.t th.sortable:hover { color: var(--text); }
table.t th .arrow { font-size: 10px; margin-left: 3px; }
table.t td { padding: 6px 10px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f6f9fc; }
table.t tr.dim td { color: var(--text-3); }
table.t td.desc { min-width: 220px; max-width: 460px; }
table.t tfoot td { font-weight: 600; background: #f7f8fa; border-top: 1px solid var(--line); }
.more { padding: 10px; text-align: center; }
.empty { padding: 28px; text-align: center; color: var(--text-2); }

/* ---------- item header */
.itemhead { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.itemhead .code { font-family: var(--mono); color: var(--brand-2); font-size: 13px; }
.itemhead h1 { margin: 2px 0 6px; font-size: 20px; font-weight: 600; }
.itemhead .chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- side list */
.sidelist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); max-height: calc(100vh - 120px); overflow: auto; position: sticky; top: 70px; }
.sidelist .cat { padding: 10px 12px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); display: flex; justify-content: space-between; }
.sidelist a { display: flex; gap: 8px; padding: 6px 12px; color: var(--text); border-left: 3px solid transparent; }
.sidelist a:hover { background: var(--canvas); text-decoration: none; }
.sidelist a.on { background: var(--accent-soft); border-left-color: var(--accent); }
.sidelist a .nm { flex: 1; }
.sidelist a .ct { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- charts */
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--text-2); font-size: 11px; }
.chart .grid line { stroke: #e9ecf0; stroke-width: 1; }
.chart .baseline { stroke: var(--line-strong); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .cross { stroke: var(--text-3); stroke-width: 1; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 18px rgba(15,44,76,.16); padding: 8px 10px; font-size: 12.5px; max-width: 320px; }
.tooltip .tt-h { font-weight: 600; margin-bottom: 3px; }
.tooltip .tt-r { display: flex; justify-content: space-between; gap: 16px; }
.tooltip .tt-r span:last-child { font-variant-numeric: tabular-nums; font-weight: 500; }

/* ---------- forms, modal, toast */
.form { display: grid; gap: 12px; max-width: 420px; }
.form .row { display: flex; gap: 10px; }
.form .row > * { flex: 1; }
.err { color: var(--bad); font-size: 13px; }
.note { background: var(--warn-bg); border-radius: var(--radius); padding: 10px 12px; color: #5c3b00; font-size: 13px; margin-bottom: 14px; }
.note.info { background: var(--accent-soft); color: #0b4f4b; }
.authwrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #0f2c4c 0%, #173c63 60%, #0b7a75 140%); }
.authcard { background: var(--surface); border-radius: 10px; padding: 28px 30px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.authcard h1 { font-size: 19px; margin: 0 0 4px; }
.authcard p { color: var(--text-2); margin: 0 0 18px; }
.authcard .btn.primary { width: 100%; justify-content: center; padding: 9px; }
.modalback { position: fixed; inset: 0; background: rgba(15,30,50,.45); z-index: 40; display: flex; align-items: flex-start; justify-content: center; padding: 50px 16px; overflow: auto; }
.modal { background: var(--surface); border-radius: 8px; width: 100%; max-width: 1000px; box-shadow: 0 24px 60px rgba(0,0,0,.3); }
.modal .mh { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal .mh h2 { margin: 0; font-size: 16px; }
.modal .mh .x { margin-left: auto; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--text-2); line-height: 1; }
.modal .mb { padding: 16px 18px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1d2733; color: #fff; padding: 10px 16px; border-radius: var(--radius); z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }
.dropzone { border: 2px dashed var(--line-strong); border-radius: 8px; padding: 26px; text-align: center; background: #fafbfc; }
.dropzone.over { border-color: var(--series-1); background: #f0f7ff; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 13px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a.on { color: var(--text); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.bar-inline { height: 6px; background: var(--canvas); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar-inline > i { display: block; height: 100%; background: var(--series-1); border-radius: 3px; }
@media print { .topbar, .actions, .filters, .btn { display: none !important; } body { background: #fff; } .card, .tile { border-color: #ccc; } }
