/* Панель владельца — стили. Цвета — роли (переменные); светлая и тёмная тема подобраны отдельно.
   Палитра графиков проверена на различимость (в т. ч. при нарушениях цветового зрения). */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --surface-2: #f3f2ee;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6; --series-2: #eb6834; --wash-1: rgba(42, 120, 214, 0.10);
  --accent: #2a78d6; --accent-ink: #ffffff;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-text: #006300; --bad-text: #a82828;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242423;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5; --series-2: #d95926; --wash-1: rgba(57, 135, 229, 0.14);
    --accent: #3987e5; --accent-ink: #ffffff;
    --good-text: #0ca30c; --bad-text: #e66767;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242423;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5; --series-2: #d95926; --wash-1: rgba(57, 135, 229, 0.14);
  --accent: #3987e5; --accent-ink: #ffffff;
  --good-text: #0ca30c; --bad-text: #e66767;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.pad { padding: 24px 16px; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--good-text); }
.neg { color: var(--bad-text); }

/* шапка и вкладки */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.brand.big { font-size: 19px; margin-bottom: 8px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--accent) url("/static/favicon.svg") center/cover; flex: none; }
.top-right { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); position: relative; }
.icon-btn::before { content: "◐"; font-size: 15px; color: var(--ink-2); }
.icon-btn.close::before { content: "✕"; font-size: 14px; }
.ghost-btn { height: 34px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); }
.ghost-btn:hover, .icon-btn:hover { background: var(--surface-2); }
.tabs {
  position: sticky; top: 55px; z-index: 19; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  padding: 8px 12px; background: var(--page); border-bottom: 1px solid var(--border);
}
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 7px 13px; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--ink-2); white-space: nowrap; }
.tab:hover { background: var(--surface-2); }
.tab.active { background: var(--ink); color: var(--page); }
.view { max-width: 1120px; margin: 0 auto; padding: 18px 16px 40px; outline: none; }
.foot { max-width: 1120px; margin: 0 auto; padding: 0 16px 28px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; }

/* карточки */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.card + .card, .grid + .card, .card + .grid, .grid + .grid, .section-title + .card { margin-top: 14px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.section-title { margin: 22px 2px 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.lead { color: var(--ink-2); max-width: 70ch; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.tile .label { font-size: 13px; color: var(--ink-2); }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.25; margin-top: 2px; overflow-wrap: anywhere; }
.tile .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tile .spark { margin-top: 8px; height: 28px; }

/* главный статус */
.hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.hero-dot { width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 20px; color: #fff; background: var(--muted); }
.hero-dot.on { background: var(--good); } .hero-dot.paused { background: var(--warning); color: #0b0b0b; } .hero-dot.unknown { background: var(--serious); }
.hero-title { font-size: 30px; font-weight: 680; letter-spacing: -0.02em; line-height: 1.15; }
.hero-sub { color: var(--ink-2); }
.facts { display: grid; gap: 8px 20px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.fact .k { font-size: 12.5px; color: var(--muted); }
.fact .v { font-size: 14.5px; }

/* метки состояния: цвет + значок + слово, никогда один цвет */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.pill-good::before { background: var(--good); } .pill-mid::before { background: var(--warning); }
.pill-bad::before { background: var(--critical); } .pill-serious::before { background: var(--serious); }
.pill-info::before, .pill-pending::before { background: var(--series-1); }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); margin-top: 10px; }
.alert .mark { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #0b0b0b; background: var(--warning); }
.alert.serious .mark { background: var(--serious); } .alert.critical .mark { background: var(--critical); color: #fff; }

/* полоса хода */
.meter { height: 8px; border-radius: 999px; background: var(--wash-1); overflow: hidden; margin: 8px 0 4px; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--series-1); }
.meter.warn > i { background: var(--warning); } .meter.crit > i { background: var(--critical); }

/* графики */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axisline { stroke: var(--axis); stroke-width: 1; }
.chart .threshold { stroke: var(--serious); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .threshold-label { fill: var(--ink-2); font-size: 11px; }
.chart text { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .s1 { stroke: var(--series-1); } .chart .s2 { stroke: var(--series-2); }
.chart .f1 { fill: var(--series-1); } .chart .f2 { fill: var(--series-2); }
.chart .area { fill: var(--wash-1); stroke: none; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.chart .endlabel { fill: var(--ink-2); font-size: 12px; }
.chart .hit { fill: transparent; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 14px; height: 3px; border-radius: 2px; background: var(--series-1); }
.legend .swatch.k2 { background: var(--series-2); }
.chart-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); font-size: 13px; }
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--ink); color: var(--page); border-color: transparent; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }
.empty { padding: 26px 12px; text-align: center; color: var(--muted); border: 1px dashed var(--axis); border-radius: 12px; }
.tooltip { position: fixed; z-index: 60; pointer-events: none; background: var(--ink); color: var(--page); padding: 7px 10px; border-radius: 9px; font-size: 12.5px; line-height: 1.4; max-width: 260px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); }
.tooltip b { font-weight: 650; }
.tooltip .row { display: flex; align-items: center; gap: 6px; }
.tooltip .sw { width: 9px; height: 9px; border-radius: 50%; background: var(--series-1); flex: none; }
.tooltip .sw.k2 { background: var(--series-2); }

/* таблицы */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.bar-cell .bar { height: 8px; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.bar-cell .bar.k2 { background: var(--series-2); }

/* текст из журнала и снимка */
.prose { color: var(--ink-2); overflow-wrap: anywhere; }
.prose p { margin: 0 0 9px; } .prose ul { margin: 0 0 9px; padding-left: 20px; } .prose li { margin-bottom: 5px; }
.prose b { color: var(--ink); font-weight: 620; }
.prose code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.prose table { font-size: 13px; margin: 6px 0 10px; }
details.entry { border-bottom: 1px solid var(--border); }
details.entry:last-child { border-bottom: 0; }
details.entry > summary { cursor: pointer; padding: 12px 2px; list-style: none; display: flex; gap: 10px; align-items: baseline; }
details.entry > summary::-webkit-details-marker { display: none; }
details.entry > summary::before { content: "›"; color: var(--muted); transition: transform 0.15s; flex: none; }
details.entry[open] > summary::before { transform: rotate(90deg); }
details.entry .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
details.entry .body { padding: 0 2px 14px 18px; }
.search { width: 100%; height: 40px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); padding: 0 12px; font: inherit; }
.search:focus, input:focus, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
pre.output { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-2); }

/* кнопка «стоп» и окна */
.stop-card { border-color: color-mix(in srgb, var(--critical) 35%, var(--border)); }
.danger-btn { height: 42px; padding: 0 18px; border-radius: 11px; border: 0; background: var(--critical); color: #fff; font-weight: 650; }
.danger-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.primary-btn { height: 42px; padding: 0 18px; border-radius: 11px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 650; width: 100%; }
.primary-btn:disabled { opacity: 0.6; }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.45); display: grid; place-items: center; padding: 16px; }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; width: min(860px, 100%); max-height: min(86vh, 900px); display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px; overflow: auto; }
.field { display: grid; gap: 6px; margin: 12px 0; }
.field input { height: 42px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); padding: 0 12px; font: inherit; }

/* вход */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 26px 22px; box-shadow: var(--shadow); }
.login-card form { display: grid; gap: 8px; margin-top: 14px; }
.login-card label { font-size: 13px; color: var(--ink-2); }
.login-card input { height: 44px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); padding: 0 12px; font: inherit; margin-bottom: 6px; }
.login-msg { min-height: 22px; margin: 12px 0 0; color: var(--bad-text); font-size: 14px; overflow-wrap: anywhere; }

@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .hero-title { font-size: 25px; }
  .tile .value { font-size: 23px; }
  .ghost-btn { padding: 0 9px; }
  .topbar .brand span:last-child { display: none; }
  .tabs { top: 55px; }
}
.question-card .answer-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.question-card .answer-btn { min-width: 96px; }
.question-card input[type="text"] { width: 100%; }
.stop-card + .stop-card { margin-top: 12px; }
