:root {
  color-scheme: light only;
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f1f3f6; --border: #e3e6eb;
  --text: #0f172a; --text-2: #475467; --muted: #8a94a6;
  --accent: #2a78d6; --accent-dark: #1d5fae; --accent-soft: #e8f1fc;
  --side: #0f172a; --side-text: #cbd5e1; --side-active: #1e293b;
  --good: #12805c; --warn: #b54708; --bad: #c4320a;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.layout { display: flex; min-height: 100vh; }

/* sidebar */
.sidebar { width: 236px; flex: 0 0 236px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px 14px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 16px; }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; } .brand-sub { font-size: 11.5px; color: #94a3b8; }
.nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; overflow-y: auto; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 14px 10px 4px; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--side-text); font-weight: 500; }
.nav a:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.ico { width: 18px; text-align: center; opacity: .9; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; font-size: 11.5px; color: #94a3b8; border-top: 1px solid #1e293b; }

/* main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* content at 80% of the screen, centered (full width on small screens, see media query) */
.main > .topbar, .main > .page { width: 80%; margin-left: auto; margin-right: auto; }
.main > .filters { width: 80%; margin-left: auto !important; margin-right: auto !important; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 18px 28px 10px; }
.titles h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; } .titles p { margin: 2px 0 0; font-size: 13px; }
.refresh { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 12.5px; text-align: right; }
.menu-btn { display: none; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 6px 10px; font-size: 16px; }
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 7px 13px;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn-primary:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-dark); }

/* filters */
.filters { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  margin: 0 28px; padding: 12px 16px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.filters select, .filters input { font: inherit; font-size: 13px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); min-width: 130px; }
.filters label.state select { min-width: 190px; border-color: var(--accent); font-weight: 600; }
.filters label[hidden], .filters[hidden] { display: none; }
.scope { margin-left: auto; font-size: 12px; color: var(--text-2); max-width: 420px; text-align: right; }

/* page */
.page { padding: 18px 28px 60px; display: flex; flex-direction: column; gap: 18px; }
.loading { padding: 60px; text-align: center; color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k { font-size: 12px; color: var(--text-2); font-weight: 600; } .kpi .v { font-size: 25px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.kpi .s { font-size: 11.5px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card h2 { margin: 0; font-size: 15px; } .card .summary { margin: 3px 0 12px; color: var(--text-2); font-size: 12.5px; }
.card-head { display: flex; align-items: flex-start; gap: 10px; } .card-head .tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 11px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--text-2); }
.seg button.on { background: var(--accent); color: #fff; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--text-2); margin: 1px 3px 1px 0; }
.tag.ppe { background: var(--accent-soft); color: var(--accent-dark); } .tag.open { background: #fef0c7; color: var(--warn); }
.tag.closed { background: #e7f6ee; color: var(--good); }
.note { font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border-radius: 8px; padding: 9px 12px; }

/* charts */
svg text { font-size: 11.5px; font-family: inherit; } .label { fill: var(--text-2); } .tick { fill: var(--muted); font-size: 10.5px; }
.grid { stroke: var(--border); stroke-width: 1; } .baseline { stroke: #b8c0cc; stroke-width: 1; }
.bar { fill: var(--accent); } .hit { fill: transparent; } .row:hover .bar { fill: var(--accent-dark); } .row:hover .label { fill: var(--text); }
.line { fill: none; stroke: var(--accent); stroke-width: 2; } .area { fill: var(--accent-soft); }
.dot { fill: var(--accent); }
.mini-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.mini h3 { margin: 0 0 2px; font-size: 13px; } .mini .big { font-size: 20px; font-weight: 700; } .delta-up { color: var(--good); } .delta-down { color: var(--bad); }
#tip { position: fixed; pointer-events: none; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 12px; max-width: 420px; box-shadow: 0 8px 24px rgba(16,24,40,.14); z-index: 50; }

/* tables */
.table-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.table-search { font: inherit; font-size: 13px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; width: 280px; }
.table-count { font-size: 12px; color: var(--muted); }
.table-wrap { max-height: 560px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; padding: 8px 10px; white-space: nowrap;
  font-weight: 600; color: var(--text-2); border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; }
td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:nth-child(even) td { background: #fafbfc; } tbody tr:hover td { background: var(--accent-soft); }
th.num, td.num { text-align: right; white-space: nowrap; } td.wide { min-width: 300px; } td.nowrap { white-space: nowrap; }

/* how-to page */
.howto { max-width: 1100px; } .howto h2 { font-size: 19px; margin-bottom: 6px; } .howto h3 { margin: 22px 0 6px; font-size: 15px; }
.howto p, .howto li { color: var(--text-2); font-size: 13.5px; } .howto li { margin: 4px 0; } .howto ul.dos { list-style: none; padding-left: 4px; }
.howto .table-wrap { max-height: none; } .howto td { font-size: 13px; }

/* key page */
.key dl { display: grid; grid-template-columns: 230px 1fr; gap: 8px 18px; margin: 0; }
.key dt { font-weight: 600; } .key dd { margin: 0; color: var(--text-2); }

@media (max-width: 980px) {
  .grid-2 { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; z-index: 30; transition: left .2s; } .sidebar.open { left: 0; }
  .menu-btn { display: inline-block; }
  .topbar, .page { padding-left: 14px; padding-right: 14px; } .filters { margin: 0 14px; }
  .main > .topbar, .main > .page, .main > .filters { width: auto; } .main > .filters { margin: 0 14px !important; }
  .refresh #refresh-status { display: none; } .key dl { grid-template-columns: 1fr; }
}
