:root {
  --bg: #f5f6f8; --panel: #fff; --ink: #1b2330; --muted: #6b7686; --line: #e3e7ed; --soft: #f0f3f7;
  --brand: #1f5fbf; --brand-soft: #e8f0fc; --good: #1b8a5a; --bad: #c43d3d; --warn: #b7791f;
  --c1: #1f5fbf; --c2: #e07b39; --c3: #2a9d8f; --c4: #8e5cc4; --c5: #c9a227; --c6: #d1495b; --c7: #6c757d; --c8: #3d8bd4;
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 13.5px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif; }
a { color: var(--brand); text-decoration: none; cursor: pointer; }
.app { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
nav.side { background: #142033; color: #c9d3e1; padding: 18px 0; position: sticky; top: 0; height: 100vh; }
nav.side .logo { font-weight: 700; color: #fff; font-size: 16px; padding: 0 20px 4px; }
nav.side .sub { font-size: 11px; color: #8394ad; padding: 0 20px 18px; }
nav.side a { display: block; color: #c9d3e1; padding: 9px 20px; border-left: 3px solid transparent; }
nav.side a:hover { background: #1b2a42; }
nav.side a.on { background: #1d3150; color: #fff; border-left-color: #5b9cff; }
nav.side .foot { position: absolute; bottom: 14px; left: 20px; right: 20px; font-size: 11px; color: #7f8ea6; }
main { padding: 18px 26px 60px; min-width: 0; }
header.top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
header.top h1 { font-size: 20px; margin: 0; flex: 1; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 4px 11px; font-size: 12px; color: var(--muted); }
.chip b { color: var(--ink); }
select, input, button, textarea { font: inherit; }
select, input[type=text], input[type=number], input[type=date], input[type=search] { border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; background: #fff; color: var(--ink); }
button { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 6px 12px; cursor: pointer; color: var(--ink); }
button:hover { border-color: #c5ccd6; }
button.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
button.small { padding: 3px 8px; font-size: 12px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.toolbar label { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3, .g2 { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card h3 { margin: 0 0 10px; font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card h3 .grow { flex: 1; }
.card .hint { font-size: 12px; color: var(--muted); margin: -4px 0 10px; }
.kpi .lbl { font-size: 12px; color: var(--muted); }
.kpi .val { font-size: 22px; font-weight: 650; margin: 2px 0; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.up { color: var(--good); } .down { color: var(--bad); } .warn { color: var(--warn); }
.tbl-wrap { overflow: auto; max-height: 68vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.tbl-wrap.short { max-height: 40vh; }
table.t { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; font-variant-numeric: tabular-nums; }
table.t th, table.t td { padding: 6px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; }
table.t th { position: sticky; top: 0; background: var(--soft); font-weight: 600; color: #3a4556; cursor: pointer; z-index: 1; user-select: none; }
table.t th.num, table.t td.num { text-align: right; }
table.t tr:hover td { background: #f8fafc; }
table.t tr.click td { cursor: pointer; }
table.t tfoot td { position: sticky; bottom: 0; background: #eef2f7; font-weight: 650; border-top: 1px solid #cfd6df; }
table.t td.wrap { white-space: normal; min-width: 220px; }
table.t td.neg { color: var(--bad); }
table.t td.hl { background: #fff8e6; }
table.t tr.sub td { background: #fafbfd; color: var(--muted); font-size: 12px; }
table.t tr.total td { font-weight: 650; background: #f3f6fa; }
table.t tr.danger td { background: #fdf0f0; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; background: var(--soft); color: #445; }
.tag.bad { background: #fde8e8; color: var(--bad); } .tag.warn { background: #fdf3e1; color: var(--warn); } .tag.good { background: #e3f4ec; color: var(--good); } .tag.info { background: var(--brand-soft); color: var(--brand); }
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.note { background: #fffbea; border: 1px solid #f0e2a8; border-radius: 8px; padding: 9px 12px; font-size: 12.5px; margin-bottom: 12px; }
.note.info { background: var(--brand-soft); border-color: #c9dbf6; }
.drop { border: 2px dashed #c5cfdc; border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); background: #fafcff; cursor: pointer; }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop b { color: var(--ink); display: block; margin-bottom: 4px; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 36, .45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 20px; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: min(1200px, 100%); max-height: 88vh; overflow: auto; padding: 18px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal header { display: flex; align-items: center; margin-bottom: 12px; }
.modal header h2 { font-size: 16px; margin: 0; flex: 1; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.form-row .f { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 18px; }
.settings-grid .f { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.settings-grid .f small { color: #98a2b0; }
.toast { position: fixed; bottom: 18px; right: 18px; background: #142033; color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 60; max-width: 420px; }
.toast.err { background: var(--bad); }
.loading { color: var(--muted); padding: 30px; text-align: center; }
input.ovr { width: 110px; text-align: right; }

/* sign-in + roles */
body.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #142033; }
.login-card { background: #fff; border-radius: 12px; padding: 28px 30px; width: min(360px, calc(100% - 32px)); display: flex; flex-direction: column; gap: 12px; }
.login-card .logo { font-weight: 700; font-size: 20px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.login-card input { border: 1px solid var(--line); border-radius: 7px; padding: 9px 10px; font: inherit; }
.login-card button { padding: 9px; }
nav.side .foot a { display: inline; padding: 0; border: 0; color: #9fb3d1; }
body.viewer .drop, body.viewer #ss, body.viewer #sv, body.viewer #ladd, body.viewer #badd, body.viewer #frz, body.viewer #sg,
body.viewer [data-del], body.viewer .edit-only { display: none !important; }
body.viewer input.ovr, body.viewer #sg input, body.viewer .settings-grid input, body.viewer #glt select, body.viewer #chs input { pointer-events: none; background: var(--soft); }
