:root {
  --bg: #0a0e15; --surface: #111721; --surface-2: #161d29; --surface-3: #1d2633;
  --line: #243041; --line-soft: #1a2230;
  --text: #e8eef6; --text-2: #b0bccc; --muted: #7d8a9c;
  --accent: #7b8af0; --accent-2: #5264d9; --accent-soft: rgba(82, 100, 217, .2); --brand: #5264d9;
  --ok: #3ccf7a; --ok-soft: rgba(60, 207, 122, .13);
  --warm: #f0b43c; --warm-soft: rgba(240, 180, 60, .14);
  --hot: #ff5d5d; --hot-soft: rgba(255, 93, 93, .13);
  --violet: #b892ff; --violet-soft: rgba(184, 146, 255, .14);
  --radius: 14px;
  --mono: "Cascadia Mono", ui-monospace, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
svg.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .mono { font-family: var(--mono); font-size: 12.5px; }
a { color: var(--accent); }
a.btn, a.ib { text-decoration: none; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); padding: 7px 13px; font-weight: 600; font-size: 13px; color: var(--text); white-space: nowrap; transition: border-color .15s, background .15s, filter .15s; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent-2); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn.danger { background: var(--hot-soft); color: var(--hot); border-color: rgba(255, 93, 93, .35); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn svg.ic { width: 16px; height: 16px; }
input[type=text], input[type=password], input[type=search], input[type=number], select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; outline: none; width: 100%; min-width: 0; transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover, textarea:hover { border-color: #2e3c52; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: #566376; opacity: 1; }
textarea { resize: vertical; min-height: 80px; line-height: 1.45; }
/* Chrome/Edge autofill paints fields light yellow — keep them dark */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text); caret-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset; box-shadow: 0 0 0 1000px var(--bg) inset;
  border-color: var(--line); transition: background-color 9999s ease-in-out 0s;
}
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; cursor: pointer; background: linear-gradient(45deg, transparent 44%, var(--muted) 44%, var(--muted) 56%, transparent 56%), linear-gradient(-45deg, transparent 44%, var(--muted) 44%, var(--muted) 56%, transparent 56%); }
input[type=number]::-webkit-inner-spin-button { opacity: .4; }
/* Selects: own arrow, dark option list */
select { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer; text-overflow: ellipsis; white-space: nowrap;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
select:focus { background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%); }
select option, select optgroup { background: var(--surface-2); color: var(--text); }
select option:checked { background: var(--surface-3); }
select option:disabled { color: var(--muted); }
/* Chromium 135+: the option list is part of the page and fully styled */
@supports (appearance: base-select) {
  select, ::picker(select) { appearance: base-select; }
  select { display: flex; align-items: center; gap: 8px; background-image: none; padding-right: 11px; }
  select:focus { background-image: none; }
  select::picker-icon { content: ""; width: 6px; height: 6px; margin: 0 3px -1px auto; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); rotate: 45deg; translate: 0 -2px; transition: rotate .15s, translate .15s; flex: none; }
  select:focus::picker-icon, select:open::picker-icon { border-color: var(--accent); }
  select:open::picker-icon { rotate: 225deg; translate: 0 1px; }
  ::picker(select) { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin-block: 4px;
    box-shadow: 0 14px 36px rgba(0, 0, 0, .5); max-height: min(320px, 60vh); overflow: auto; min-width: anchor-size(width); }
  select option { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 7px; background: transparent; color: var(--text); font-size: 13px; cursor: pointer; white-space: nowrap; }
  select option:hover, select option:focus-visible { background: var(--surface-3); outline: none; }
  select option:checked { background: var(--accent-soft); font-weight: 600; }
  select option::checkmark { color: var(--accent); }
  select option:disabled { background: transparent; cursor: not-allowed; }
}
select.sm, input.sm { padding-top: 5px; padding-bottom: 5px; font-size: 12.5px; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; margin: 0; vertical-align: middle; }
input[type=file] { font-size: 12.5px; color: var(--text-2); max-width: 100%; }
input[type=file]::file-selector-button { font: inherit; font-weight: 600; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 11px; margin-right: 10px; cursor: pointer; }
input[type=file]::file-selector-button:hover { border-color: var(--accent); }
::selection { background: rgba(82, 100, 217, .45); color: #fff; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
/* Scrollbars: thin and dark everywhere (Firefox + Chromium) */
* { scrollbar-width: thin; scrollbar-color: #2b3747 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2b3747; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #3a4a60; background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-corner { background: transparent; }
label.field { display: grid; gap: 5px; font-size: 12.5px; color: var(--text-2); font-weight: 600; text-align: left; }
.form { display: grid; gap: 12px; }
.error { color: var(--hot); font-size: 13px; min-height: 18px; margin: 0; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 28px; text-align: center; }
.login .form { margin-top: 18px; }

/* shell */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
aside.side { background: var(--surface); border-right: 1px solid var(--line-soft); padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow: auto; z-index: 30; }
.brand { display: block; padding: 2px 8px 16px; }
.brand img { display: block; width: 150px; height: auto; }
.login-logo { display: block; width: 232px; max-width: 100%; height: auto; margin: 4px auto 2px; }
.login-sub { margin: 4px 0 0; }
.grp { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 12px 10px 4px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px; color: var(--text-2); font-weight: 600; cursor: pointer; text-decoration: none; border: 0; background: transparent; text-align: left; width: 100%; }
.nav:hover { background: var(--surface-2); color: var(--text); }
.nav.active { background: var(--surface-3); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--muted); display: grid; gap: 3px; }
.side-foot b { color: var(--text-2); }
.top { position: sticky; top: 0; z-index: 20; background: rgba(10, 14, 21, .86); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: 12px; padding: 10px 24px; min-height: 55px; }
.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); padding: 4px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-soft); white-space: nowrap; }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.pill.stale { color: var(--warm); } .pill.stale i { background: var(--warm); }
.pill[hidden] { display: none; }
.sys { display: flex; align-items: center; gap: 18px; min-width: 0; overflow: hidden; }
.sys-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
.sys-item svg.ic { width: 15px; height: 15px; color: var(--muted); flex: none; }
.sys-l { color: var(--muted); }
.sys-item b { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.sys-item.warm b { color: var(--warm); }
.sys-item.hot b { color: var(--hot); }
@media (max-width: 900px) { .sys-l { display: none; } .sys { gap: 14px; } }
@media (max-width: 560px) { .sys-item.wide { display: none; } .sys { gap: 12px; } }
.top .right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.burger { display: none; }
main { padding: 22px 24px 48px; min-width: 0; }
h1 { margin: 0 0 2px; font-size: 22px; } h2 { margin: 0; font-size: 15px; } h3 { margin: 0 0 8px; font-size: 13.5px; }
.head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head .right { margin-left: auto; display: flex; gap: 8px; }
.banner { padding: 10px 14px; border-radius: 12px; margin: 0 0 16px; font-size: 13px; }
.banner.bad { background: var(--hot-soft); color: var(--hot); }
.banner.warn { background: var(--warm-soft); color: var(--warm); }
.banner.info { background: var(--accent-soft); color: var(--text-2); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head .right { margin-left: auto; display: flex; gap: 6px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi .lbl { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi .val { font-size: 26px; font-weight: 700; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .val small { font-size: 13px; color: var(--muted); font-weight: 600; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 10px; }
.bar b { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bar b.ok { background: var(--ok); } .bar b.warm { background: var(--warm); } .bar b.hot { background: var(--hot); }
svg.spark { width: 100%; height: 38px; margin-top: 8px; display: block; }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.grid2e { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stack { display: grid; gap: 14px; align-content: start; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.row:last-child { border-bottom: 0; }
.row .r { margin-left: auto; text-align: right; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; padding: 6px 8px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.trunc { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.st i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st.ok { color: var(--ok); background: var(--ok-soft); } .st.warn { color: var(--warm); background: var(--warm-soft); } .st.bad { color: var(--hot); background: var(--hot-soft); } .st.off { color: var(--muted); background: var(--surface-2); }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-weight: 600; white-space: nowrap; }

/* tabs */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: 11px; }
.tab { border: 0; background: transparent; color: var(--text-2); padding: 5px 12px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.tab.active { background: var(--surface-3); color: var(--text); }

/* charts */
.chart { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 180px auto; column-gap: 8px; }
.chart-empty { grid-column: 1 / -1; padding: 24px 0; }
.chart-y { display: flex; flex-direction: column; justify-content: space-between; margin: -7px 0; font-size: 11px; line-height: 14px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-plot { position: relative; min-width: 0; }
.chart-plot svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart-x { grid-column: 2; position: relative; height: 22px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-x span { position: absolute; top: 6px; transform: translateX(-50%); white-space: nowrap; }
.chart-x span.first { transform: none; }
.chart-x span.last { transform: translateX(-100%); }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .hover-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .tip { position: absolute; top: 4px; z-index: 2; pointer-events: none; background: var(--surface-3); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font-size: 12px; white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px 14px; }
.core { font-size: 12px; color: var(--text-2); }
.core .bar { margin-top: 4px; }

/* events */
.ev { display: grid; grid-template-columns: 74px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.ev:last-child { border-bottom: 0; }
.ev time { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.ev.fail span { color: var(--hot); }

/* placeholder */

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(5, 8, 12, .7); display: grid; place-items: center; padding: 16px; z-index: 100; }
.modal { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; max-height: calc(100vh - 32px); overflow: auto; }
.modal h2 { margin-bottom: 4px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.qr { width: 220px; height: 220px; margin: 10px auto; background: #fff; border-radius: 10px; padding: 6px; }
.qr svg { width: 100%; height: 100%; display: block; }
.secret { font-family: var(--mono); font-size: 13px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; word-break: break-all; user-select: all; }

/* toast */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: var(--surface-3); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 13px; max-width: 360px; }
.toast.bad { border-color: rgba(255, 93, 93, .5); color: var(--hot); }

@media (max-width: 1150px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid2, .grid2e { grid-template-columns: 1fr; } }
@media (max-width: 800px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  aside.side { position: fixed; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  aside.side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .5); }
  .burger { display: inline-flex; }
  main { padding: 16px; } .top { padding: 10px 16px; }
  .kpis { grid-template-columns: 1fr; }
  .hide-m { display: none; }
}
/* Cards side by side as far as the width allows */
.auto-grid { display: grid; gap: 14px; align-items: start; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); }
.auto-grid.w640 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 640px), 1fr)); }
.auto-grid.w720 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 720px), 1fr)); }
.auto-grid.w900 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 900px), 1fr)); }
@media (min-width: 1800px) { main { padding: 26px 36px 56px; } }
.res-grid { display: grid; gap: 14px; align-items: start; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 2400px) { .res-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1150px) { .res-grid { grid-template-columns: 1fr; } }
