/* ESET Syslog Monitor — tokens follow a light/dark pair; status colours are fixed. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ef;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --hover: rgba(11, 11, 11, 0.04);
  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --info: #a8a69f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: rgba(57, 135, 229, 0.16);
    --hover: rgba(255, 255, 255, 0.05); --good-ink: #0ca30c; --info: #6f6e69;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: rgba(57, 135, 229, 0.16);
  --hover: rgba(255, 255, 255, 0.05); --good-ink: #0ca30c; --info: #6f6e69;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink); }
body { font-size: 14px; line-height: 1.45; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
button, input, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- top bar ---------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; padding: 10px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; white-space: nowrap; }
.controls { display: flex; gap: 12px; align-items: center; flex: 1; }
.right { display: flex; gap: 10px; align-items: center; }
.user { color: var(--ink-2); font-size: 13px; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.segmented button {
  border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; cursor: pointer;
  color: var(--ink-2); font-weight: 500;
}
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--border); }

select, input[type="search"], .login-card input {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; min-height: 32px;
}
select:focus-visible, input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="search"] { min-width: 260px; }

.btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; font-weight: 500; min-height: 32px; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.small { padding: 3px 10px; min-height: 26px; font-size: 12px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn[disabled] { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 6px 8px; border-radius: 6px; color: var(--ink-2); }
.icon-btn:hover { background: var(--hover); }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border);
  background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 12px; cursor: pointer; color: var(--ink-2);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--info); }
.status-pill.ok .dot { background: var(--good); }
.status-pill.bad .dot { background: var(--critical); }
.status-pill.warn .dot { background: var(--warning); }

/* ---- layout ----------------------------------------------------------- */
main { padding: 20px 24px 48px; display: flex; flex-direction: column; gap: 16px; max-width: 1680px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head.wrap { flex-wrap: wrap; }
.card-head h2 { margin-right: auto; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---- tiles ------------------------------------------------------------ */
.tiles { display: grid; grid-template-columns: 1.4fr repeat(5, 1fr); gap: 12px; }
@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; text-align: left; min-width: 0;
}
button.tile { cursor: pointer; }
button.tile:hover { background: var(--hover); }
.tile-label { color: var(--ink-2); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.tile-value { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
.tile.hero .tile-value { font-size: 48px; line-height: 1.05; }
.tile.hero.alert { border-color: var(--critical); box-shadow: inset 4px 0 0 var(--critical), var(--shadow); }
.tile-sub { color: var(--muted); font-size: 12px; }
.tile-sub.warn { color: var(--ink-2); }

/* ---- severity --------------------------------------------------------- */
.sev-dot { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex: none; }
.sev-dot.critical { background: var(--critical); }
.sev-dot.error { background: var(--serious); }
.sev-dot.warning { background: var(--warning); }
.sev-dot.info { background: var(--info); }
.sev { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 500; }
.sev svg { flex: none; }
.sev.l0, .sev.l1 { color: var(--ink-2); font-weight: 400; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 8px;
  border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge.critical .dot { background: var(--critical); }
.badge.attention .dot { background: var(--serious); }
.badge.silent .dot { background: var(--muted); }
.badge.ok .dot { background: var(--good); }
.badge.critical { color: var(--ink); font-weight: 600; }

/* ---- timeline chart --------------------------------------------------- */
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.timeline { height: 220px; position: relative; }
.timeline svg { display: block; width: 100%; height: 100%; overflow: visible; }
.timeline .gridline { stroke: var(--grid); stroke-width: 1; }
.timeline .baseline { stroke: var(--axis); stroke-width: 1; }
.timeline text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.timeline .hit { fill: transparent; cursor: default; }
.timeline .col-hover { fill: var(--hover); }
.timeline-table { max-height: 260px; overflow: auto; }

/* ---- tables ----------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 10px;
  border-bottom: 1px solid var(--grid); white-space: nowrap;
}
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.data tbody tr:hover { background: var(--hover); }
table.data tr.clickable { cursor: pointer; }
table.data tr.selected { background: var(--accent-wash); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .zero { color: var(--muted); }
table.data .tenant-name { font-weight: 500; }
table.data .sub { color: var(--muted); font-size: 12px; }
table.events td.time { white-space: nowrap; color: var(--ink-2); font-variant-numeric: tabular-nums; }
table.events td.summary { max-width: 560px; word-break: break-word; }
table.events tr.acked td { color: var(--muted); }
table.events tr.acked .sev { opacity: .6; }
th.check, td.check { width: 28px; }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 10px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---- lists ------------------------------------------------------------ */
.barlist { display: flex; flex-direction: column; gap: 10px; }
.barrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.barrow:hover { background: var(--hover); }
.barrow .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.barrow .val { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.barrow .meta { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.barrow svg { grid-column: 1 / -1; width: 100%; height: 8px; display: block; }
.barrow .track { fill: var(--surface-2); }
.barrow .fill { fill: var(--accent); }
.hostlist { display: flex; flex-direction: column; }
.hostrow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--grid); cursor: pointer; }
.hostrow:last-child { border-bottom: 0; }
.hostrow:hover { background: var(--hover); }
.hostrow .h { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hostrow .h b { font-weight: 500; }
.hostrow .h span { color: var(--muted); font-size: 12px; margin-left: 6px; }
.hostrow .n { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; }

/* ---- tabs & filters --------------------------------------------------- */
.tabs { display: flex; gap: 4px; margin-right: auto; }
.tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--ink-2); font-weight: 500; }
.tabs button.active { background: var(--surface-2); color: var(--ink); }
.tabs .count { font-variant-numeric: tabular-nums; color: var(--muted); margin-left: 2px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 6px 4px 10px; background: var(--accent-wash); border-radius: 999px; font-size: 12px; }
.chip button { border: 0; background: transparent; cursor: pointer; padding: 0 4px; }

/* ---- drawer ----------------------------------------------------------- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--surface); border-left: 1px solid var(--border); transform: translateX(100%); transition: transform .18s ease; z-index: 40; overflow-y: auto; }
.drawer.open { transform: none; }
.drawer-inner { padding: 18px 22px 40px; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .25); opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 30; }
.scrim.open { opacity: 1; pointer-events: auto; }
dl.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 14px; margin: 0 0 16px; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
pre.raw { background: var(--surface-2); border-radius: 8px; padding: 12px; font-size: 12px; overflow: auto; max-height: 420px; white-space: pre-wrap; word-break: break-word; }
.drawer-actions { display: flex; gap: 8px; margin: 12px 0 18px; flex-wrap: wrap; }
.drawer-actions input { flex: 1; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.summary-line { font-size: 15px; font-weight: 500; margin: 4px 0 14px; }

/* ---- tooltip / toast -------------------------------------------------- */
.tooltip { position: fixed; z-index: 60; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.12); opacity: 0; transition: opacity .08s; min-width: 150px; }
.tooltip.show { opacity: 1; }
.tooltip .tt-title { font-weight: 600; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tooltip .tt-row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tooltip .tt-row b { font-weight: 500; font-variant-numeric: tabular-nums; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--surface); padding: 8px 14px; border-radius: 8px; opacity: 0; transition: all .2s; z-index: 70; font-size: 13px; }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ---- login ------------------------------------------------------------ */
.login-body { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 6px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
.login-card input { color: var(--ink); }
.form-error { margin: 0; color: var(--critical); font-size: 13px; }
.form-notice { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--accent-wash); font-size: 13px; }
.form-foot { margin: 4px 0 0; text-align: center; }
a { color: var(--accent-ink); }

/* ---- registration ----------------------------------------------------- */
.login-card.wide { width: min(560px, calc(100vw - 32px)); margin: 24px 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }
.login-card label.check { flex-direction: row; align-items: flex-start; gap: 8px; }
.login-card label.check input { min-height: 0; margin-top: 2px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---- navigation ------------------------------------------------------- */
.nav { display: flex; gap: 2px; }
.nav a { color: var(--ink-2); text-decoration: none; padding: 5px 10px; border-radius: 6px; font-weight: 500; white-space: nowrap; }
.nav a:hover { background: var(--hover); }
.nav a.active { background: var(--surface-2); color: var(--ink); }
.nav-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--critical); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---- subscriptions / administration ----------------------------------- */
main.narrow { max-width: 1280px; }
.steps { margin: 0 0 16px; padding-left: 20px; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
.form-grid input, .form-grid select { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; min-height: 32px; color: var(--ink); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid .hint { font-size: 12px; color: var(--muted); }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.form-actions .form-error { margin-right: auto; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
table.data td.actions { white-space: nowrap; text-align: right; }
table.data td.actions .btn + .btn { margin-left: 4px; }
table.data select.pick-tenant { max-width: 280px; }
.sample { padding: 10px 0; border-bottom: 1px solid var(--grid); font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.sample .sub { color: var(--muted); font-size: 12px; }
@media (max-width: 900px) { .topbar { flex-wrap: wrap; } }

@media (forced-colors: active) {
  .sev-dot, .badge .dot, .status-pill .dot { forced-color-adjust: none; border: 1px solid CanvasText; }
}

/* SVG fills by role (classes rather than presentation attributes) */
.f-critical { fill: var(--critical); }
.f-error { fill: var(--serious); }
.f-warning { fill: var(--warning); }
.s-info { stroke: var(--info); }
