/* Darwin 2.0 — neutral analytics interface.
   Colours are tokens: edit them here. Chart series colours follow a validated colour-blind-safe order. */
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("/static/vendor/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("/static/vendor/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("/static/vendor/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("/static/vendor/fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --bg: #f3f5f8; --surface: #ffffff; --surface-2: #f7f8fa;
  --ink: #18212f; --ink-2: #455064; --ink-3: #657083;
  --line: #d9dee6; --line-2: #e9ecf1;
  --accent: #1c5cab; --accent-hover: #184f95; --accent-ink: #ffffff; --accent-soft: #e6effa;
  --danger: #b3261e; --danger-soft: #fbeae8; --ok: #17704a;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0e131a; --surface: #161c25; --surface-2: #1b222d;
    --ink: #e7ebf1; --ink-2: #b2bccb; --ink-3: #8f9bad;
    --line: #2a3441; --line-2: #222b37;
    --accent: #6da7ec; --accent-hover: #86b6ef; --accent-ink: #0b1520; --accent-soft: #17283a;
    --danger: #ff8a80; --danger-soft: #3a1e1d; --ok: #5fd39b;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e131a; --surface: #161c25; --surface-2: #1b222d;
  --ink: #e7ebf1; --ink-2: #b2bccb; --ink-3: #8f9bad;
  --line: #2a3441; --line-2: #222b37;
  --accent: #6da7ec; --accent-hover: #86b6ef; --accent-ink: #0b1520; --accent-soft: #17283a;
  --danger: #ff8a80; --danger-soft: #3a1e1d; --ok: #5fd39b;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.5 var(--font); font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.005em; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 16px; line-height: 1.3; }
h3 { font-size: 13px; color: var(--ink-2); }
p { margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }

/* ---- top bar */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 28px; height: 56px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.brand-ver { font-size: 12px; font-weight: 600; color: var(--ink-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; line-height: 18px; }
.tabs { display: flex; align-self: stretch; gap: 2px; }
.tabs button { appearance: none; border: 0; background: none; color: var(--ink-2); font: 500 14px var(--font); padding: 0 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.count { color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.count strong { color: var(--ink); font-size: 15px; font-weight: 600; }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 8px; border: 1px solid transparent; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover, .menu[open] summary { background: var(--surface-2); border-color: var(--line); }
.avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13px; text-transform: uppercase; }
.role-tag { font-size: 12px; color: var(--ink-3); }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); width: 248px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(10, 20, 35, .16); padding: 6px; z-index: 40; }
.menu-panel .who-line { padding: 8px 10px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 6px; }
.menu-panel .who-line strong { display: block; }
.menu-item { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--ink); font: 400 14px var(--font); padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }
.menu-item small { display: block; color: var(--ink-3); font-size: 12px; }
.theme-row { display: flex; gap: 4px; padding: 6px 10px 8px; align-items: center; justify-content: space-between; }
.theme-row span { color: var(--ink-3); font-size: 12.5px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--ink-2); font: 500 12.5px var(--font); padding: 4px 9px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* ---- layout */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.layout.wide { grid-template-columns: minmax(0, 1fr); }
.rail { background: var(--surface); border-right: 1px solid var(--line); padding: 20px; position: sticky; top: 56px; align-self: start;
  height: calc(100vh - 56px); overflow: auto; display: grid; gap: 16px; align-content: start; }
.rail-title { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.main { padding: 24px 28px 56px; min-width: 0; width: 100%; }
.page-head { margin-bottom: 18px; display: grid; gap: 4px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 8px 16px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .tabs button { height: 40px; }
  .main { padding: 16px; }
}

/* ---- forms */
.field { display: grid; gap: 5px; min-width: 0; }
.field > label, .field > span { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
select, input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], textarea {
  font: 400 14px var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  height: 34px; padding: 0 10px; width: 100%; min-width: 0; }
textarea { height: auto; padding: 8px 10px; resize: vertical; }
select { padding-right: 6px; }
select[multiple] { height: 140px; padding: 4px; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
.filter-form, .f-value { display: grid; gap: 10px; }
.btn { font: 500 14px var(--font); height: 34px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--ink-3); background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.quiet { border-color: transparent; background: none; color: var(--accent); padding: 0 8px; }
.btn.quiet:hover:not(:disabled) { background: var(--accent-soft); border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.check input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 16px; }
.checks.scroll { max-height: 260px; overflow: auto; padding: 2px; }

/* ---- applied filters */
.applied { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.applied li { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 6px 6px 10px; font-size: 13px; }
.applied li span { overflow-wrap: anywhere; }
.applied button { flex: none; border: 0; background: none; color: var(--ink-3); width: 22px; height: 22px; border-radius: 4px; cursor: pointer; font-size: 16px; line-height: 1; }
.applied button:hover { background: var(--line); color: var(--ink); }

/* ---- summary */
.builder { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 14px; }
.split-box { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; margin-bottom: 14px; }
.split-box summary { cursor: pointer; font-weight: 500; }
.split-box summary span { color: var(--ink-2); font-weight: 400; }
.split-actions { display: flex; gap: 6px; margin: 10px 0 8px; align-items: center; flex-wrap: wrap; }
.figure { margin: 0 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px 12px; }
.figure-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 10px; flex-wrap: wrap; }
.figure-head p { margin-top: 2px; }
.figure-actions { display: flex; gap: 8px; }
.chart-box { position: relative; height: clamp(380px, calc(100vh - 380px), 980px); }
.hint { color: var(--ink-3); font-size: 12.5px; margin-top: 8px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; margin-bottom: 14px; display: grid; gap: 12px; align-content: start; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.two > .panel { margin-bottom: 0; }
@media (max-width: 1100px) { .two { grid-template-columns: 1fr; } }

/* ---- tables */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.table-wrap.short { max-height: 380px; } .table-wrap.tall { max-height: calc(100vh - 250px); min-height: 260px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 14px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--ink-2); font-weight: 600; font-size: 12.5px; border-bottom: 1px solid var(--line); user-select: none; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--ink); }
td.num, th.num { text-align: right; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.editable { cursor: cell; } td.editable:hover { box-shadow: inset 0 0 0 1px var(--accent); }
td.saved { animation: saved 1s ease-out; }
@keyframes saved { from { background: var(--accent-soft); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { td.saved { animation: none; } }
td input, td select { height: 28px; min-width: 120px; }
td.pk { color: var(--ink-3); }
tr.off td { color: var(--ink-3); }
.table-bar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.pager { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink-2); }

/* ---- export */
.export-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .export-grid { grid-template-columns: 1fr; } }
.export-side .panel { position: sticky; top: 76px; margin-bottom: 0; }
.big-number { display: flex; align-items: baseline; gap: 8px; }
.big-number strong { font-size: 34px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.big-number span { color: var(--ink-2); }
.mini-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; max-height: 240px; overflow: auto; }
.mini-list li { display: flex; justify-content: space-between; padding: 6px 12px; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list li.total { font-weight: 600; background: var(--surface-2); position: sticky; bottom: 0; }
.mini-actions { display: flex; gap: 4px; flex-wrap: wrap; margin: -4px 0 0 -8px; }

/* ---- feedback */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 12px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 60; max-width: min(560px, 92vw); font-size: 14px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: 6px; padding: 8px 12px; font-size: 13.5px; }
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: min(440px, 92vw); background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px rgba(10, 20, 35, .35); }
dialog::backdrop { background: rgba(8, 14, 24, .55); }
dialog form, dialog .dlg { display: grid; gap: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.qr { display: grid; justify-items: center; gap: 8px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.qr img { width: 176px; height: 176px; image-rendering: pixelated; }
.secret { font: 500 14px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .06em; word-break: break-all; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; user-select: all; }
.steps { margin: 0; padding-left: 18px; display: grid; gap: 4px; color: var(--ink-2); }

/* ---- users / activity */
.add-user { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.add-user .role-help { grid-column: 1 / -1; }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.pill.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.row-actions { display: flex; gap: 6px; }

/* ---- sign-in page */
.login-page .topbar { justify-content: flex-start; }
.login-wrap { display: grid; place-items: start center; padding: 72px 16px; }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: grid; gap: 16px; box-shadow: 0 1px 2px rgba(16, 24, 40, .05); }
.login-card h1 { font-size: 20px; }

.presets{display:flex;flex-wrap:wrap;gap:6px}
.presets .btn{padding:3px 8px}

.st-2fa{grid-column:1/-1}
#idle-dialog .dialog-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:16px}

.login-logo{display:block;width:min(100%,260px);height:auto;margin:0 auto 20px}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]) .login-logo{background:#fff;padding:12px 18px;border-radius:10px;box-sizing:border-box;width:min(100%,300px)}}
:root[data-theme="dark"] .login-logo{background:#fff;padding:12px 18px;border-radius:10px;box-sizing:border-box;width:min(100%,300px)}

/* ---- Use the space on big monitors ------------------------------------------------ */
.summary-grid { display: grid; gap: 0; }
.summary-grid > .figure, .summary-grid > .data-panel { min-width: 0; }
@media (min-width: 1500px) {
  .layout { grid-template-columns: 320px minmax(0, 1fr); }
  .main { padding: 28px 36px 64px; }
  .checks { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}
@media (min-width: 1750px) {
  body { font-size: 15px; }
  h1 { font-size: 26px; } h2 { font-size: 17px; } .small { font-size: 13px; }
  .layout { grid-template-columns: 350px minmax(0, 1fr); }
  .summary-grid { grid-template-columns: minmax(0, 1.8fr) minmax(400px, 1fr); gap: 20px; align-items: start; }
  .summary-grid > .data-panel { position: sticky; top: 76px; margin-bottom: 0; }
  .summary-grid .table-wrap.short { max-height: calc(100vh - 230px); }
  .export-grid { grid-template-columns: minmax(0, 1fr) 420px; }
  .checks.scroll { max-height: 340px; }
  .table-wrap.tall { max-height: calc(100vh - 270px); }
  #view-users { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; align-items: start; }
  #view-users > .page-head, #view-users > .panel:last-of-type { grid-column: 1 / -1; }
}
@media (min-width: 2300px) {
  body { font-size: 16.5px; }
  h1 { font-size: 30px; } h2 { font-size: 19px; } .small { font-size: 14px; }
  .layout { grid-template-columns: 400px minmax(0, 1fr); }
  .main { padding: 36px 56px 80px; }
  .summary-grid { grid-template-columns: minmax(0, 2fr) minmax(480px, 1fr); }
  .export-grid { grid-template-columns: minmax(0, 1fr) 480px; }
  .checks { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
