:root, :root[data-theme="dark"] {
  --bg: #0f1216; --panel: #171b21; --fg: #e7e9ec; --muted: #9aa3ae; --line: #2b323c; --chip: #1f252d;
  --accent: #4f8cff; --ok: #3fbf7f; --bad: #f2685f; --warn: #f0b443; --on-accent: #ffffff;
}
:root[data-theme="light"] {
  --bg: #f5f6f8; --panel: #ffffff; --fg: #1b1f24; --muted: #5b6573; --line: #d7dce2; --chip: #eef1f4;
  --accent: #2459d6; --ok: #127a4a; --bad: #b42318; --warn: #9a5b00; --on-accent: #ffffff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }      /* wins over every display rule below: nothing hidden ever shows */
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 14px/1.5 "Segoe UI", Tahoma, system-ui, sans-serif; padding: 0 16px 32px; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: .04em; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.btn, .seg button { font: inherit; min-height: 36px; padding: 6px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--chip); color: var(--fg); cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.sm { min-height: 30px; padding: 3px 10px; }
.seg { display: inline-flex; gap: 0; }
.seg button { border-radius: 0; }
.seg button:first-child { border-start-start-radius: 8px; border-end-start-radius: 8px; }
.seg button:last-child { border-start-end-radius: 8px; border-end-end-radius: 8px; }
.seg button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.alert-bar { margin: 10px 0 0; padding: 8px 12px; border-radius: 8px; background: var(--bad); color: #fff; font-weight: 700; cursor: pointer; }
#msg { min-height: 1.5em; margin: 8px 0; }
#msg.ok { color: var(--ok); } #msg.bad { color: var(--bad); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.login { max-width: 380px; margin: 48px auto; }
.login h1 { font-size: 22px; margin: 0 0 12px; }
label { display: block; margin: 10px 0; }
label > span { display: block; color: var(--muted); margin-bottom: 4px; }
form.inline label { display: inline-block; margin-inline-end: 12px; }
input, select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.login input { width: 100%; }
.app { display: grid; grid-template-columns: 200px 1fr; gap: 20px; margin-top: 12px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button { text-align: start; font: inherit; min-height: 40px; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--fg); cursor: pointer; }
.nav button.on { background: var(--chip); font-weight: 700; }
main { min-width: 0; }
main h2 { margin: 4px 0 12px; font-size: 20px; }
.page[hidden] { display: none; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.cards .card .v { font-size: 20px; font-weight: 700; margin-top: 4px; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin: 8px 0 16px; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: start; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { direction: ltr; }
.ok { color: var(--ok); font-weight: 600; } .bad { color: var(--bad); font-weight: 600; } .warn { color: var(--warn); font-weight: 600; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; }
.warn-box { border-color: var(--warn); margin-top: 12px; }
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--fg); max-width: 360px; }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.row { display: flex; gap: 8px; }
td input { width: 6em; }
td input.name { width: 9em; }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .nav { flex-direction: row; flex-wrap: wrap; }
}
