/* Пульт проАвито. Светлая и тёмная тема на одних токенах. Раскладка: шапка с выводом,
   ряд плиток, затем разделы карточками в сетке, которая на телефоне становится одной колонкой. */
:root {
  --bg: #f4f6fa; --panel: #ffffff; --fg: #18202e; --muted: #5d6779; --line: #dfe4ec; --grid: #e9edf3;
  --accent: #2f5fd0; --c1: #2f5fd0; --c2: #e0902a; --c3: #18a3a0; --c4: #8b5bd6; --c5: #d2557d; --c6: #6f7c91; --c7: #4aa35a;
  --chart-muted: #b9c2d0; --ref: #8a94a6;
  --ok: #1f8a4c; --warn: #b8730a; --bad: #d23a3a;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: "SF Pro Display", -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 12px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141c; --panel: #171e29; --fg: #e6ebf3; --muted: #97a2b5; --line: #263042; --grid: #212a39;
    --accent: #6f95f0; --c1: #6f95f0; --c2: #f0aa4a; --c3: #3cc4bf; --c4: #a988ec; --c5: #ec7a9d; --c6: #8d9ab0; --c7: #6cc27b;
    --chart-muted: #3d4a5f; --ref: #7d889c;
    --ok: #4cc27e; --warn: #f0b04a; --bad: #ff6b6b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0f141c; --panel: #171e29; --fg: #e6ebf3; --muted: #97a2b5; --line: #263042; --grid: #212a39;
    --accent: #6f95f0; --c1: #6f95f0; --c2: #f0aa4a; --c3: #3cc4bf; --c4: #a988ec; --c5: #ec7a9d; --c6: #8d9ab0; --c7: #6cc27b;
    --chart-muted: #3d4a5f; --ref: #7d889c;
    --ok: #4cc27e; --warn: #f0b04a; --bad: #ff6b6b; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
.wrap { max-width: 1400px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 28px; }
h1 { font-size: 26px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 600; margin: 0; }
h3 { font-size: 14px; font-weight: 600; margin: 0; }
a { color: var(--accent); }
.head { display: flex; flex-direction: column; gap: 8px; }
.head-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.lede { margin: 0; max-width: 80ch; font-size: 15px; }
.lede b { font-weight: 600; }
.meta { margin: 0; color: var(--muted); font-size: 12px; }
.meta.bad { color: var(--bad); }
.nav { display: flex; flex-wrap: wrap; gap: 6px; }
.nav a, .btn { font-size: 12px; color: var(--fg); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; background: var(--panel); }
.nav a:hover, .btn:hover { border-color: var(--muted); }
.nav { align-items: center; }
.theme-sw { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); padding: 2px; gap: 2px; }
.theme-sw button { display: grid; place-items: center; width: 24px; height: 22px; padding: 0; border: 0; border-radius: 999px; background: none; color: var(--muted); cursor: pointer; }
.theme-sw button:hover { color: var(--fg); }
.theme-sw button[aria-pressed="true"] { background: var(--line); color: var(--fg); }
.theme-sw button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.theme-sw svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sec { display: flex; flex-direction: column; gap: 12px; scroll-margin-top: 12px; }
.sec-note { margin: 0; color: var(--muted); font-size: 12px; max-width: 85ch; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 12px; }
.tile, .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.tile { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.tile.is-bad { border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); }
.tile-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.label { font-size: 12px; color: var(--muted); }
.big { font-family: var(--font-num); font-size: 30px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.15; letter-spacing: -0.01em; }
.sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.flag { font-size: 11px; border-radius: 999px; padding: 1px 8px; white-space: nowrap; border: 1px solid var(--line); color: var(--muted); }
.flag.bad { color: var(--bad); border-color: currentColor; }
.flag.warn { color: var(--warn); border-color: currentColor; }
.flag.ok { color: var(--ok); border-color: currentColor; }
.up { color: var(--ok); } .down { color: var(--bad); }
.bullet { position: relative; height: 10px; border-radius: 5px; background: var(--grid); margin-top: 6px; }
.bullet > div { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; }
.bullet .ghost { opacity: .35; }
.bullet .mark { left: auto; width: 2px; top: -3px; bottom: -3px; border-radius: 0; background: var(--fg); }
.spark { height: 36px; margin-top: 4px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr)); gap: 12px; }
.card { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.card-note { margin: 0; font-size: 12px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
/* Цвет значка легенды - классом: CSP (style-src 'self') режет атрибут style в разметке. */
.legend i.k-c1 { background: var(--c1); } .legend i.k-c2 { background: var(--c2); } .legend i.k-c3 { background: var(--c3); }
.legend i.k-bad { background: var(--bad); } .legend i.k-chart-muted { background: var(--chart-muted); }
.legend i.dash { height: 0; width: 14px; border-top: 2px dashed var(--ref); border-radius: 0; }
.legend i.dash.ok { border-top-color: var(--ok); }
.chart { position: relative; min-height: 220px; }
.chart.sm { min-height: 180px; }
.chart.xs { min-height: 130px; }
.chart svg { display: block; overflow: visible; }
.chart .empty { display: flex; align-items: center; justify-content: center; min-height: inherit; color: var(--muted); font-size: 12px; }
.tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.gridline { stroke: var(--grid); stroke-width: 1; }
.ref { stroke: var(--ref); stroke-width: 1.5; stroke-dasharray: 4 4; fill: none; pointer-events: none; }
.ref.target { stroke: var(--ok); }
.reflabel { fill: var(--muted); font-size: 11px; pointer-events: none; }
.line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.tip { position: absolute; z-index: 3; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.14); padding: 6px 9px; font-size: 12px; min-width: 150px; font-variant-numeric: tabular-nums; }
.tip-h { color: var(--muted); margin-bottom: 2px; }
.tip-r { display: flex; align-items: center; gap: 6px; }
.tip-r .n { flex: 1; }
.sw { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.alerts td:first-child { border-left: 3px solid transparent; white-space: nowrap; }
.alerts tr.critical td:first-child { border-left-color: var(--bad); }
.alerts tr.warning td:first-child { border-left-color: var(--warn); }
.alerts tr.good td:first-child { border-left-color: var(--ok); }
.alerts td.title { font-weight: 600; min-width: 13rem; }
.alerts td.detail { color: var(--muted); min-width: 15rem; }
.alerts td.action { min-width: 12rem; }
td.strong { font-weight: 600; }
.st-bad { color: var(--bad); } .st-warn { color: var(--warn); } .st-ok { color: var(--ok); }
.hbar { display: grid; grid-template-columns: minmax(7rem, max-content) 1fr auto; gap: 6px 10px; align-items: center; font-size: 13px; }
.hbar .bar { height: 14px; border-radius: 4px; background: var(--c1); min-width: 2px; }
.hbar .bar.term-bad { background: var(--chart-muted); } .hbar .bar.term-ok { background: var(--ok); }
.hbar .v { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; }
.card.wide { grid-column: 1 / -1; }
/* Мелкие цифры внутри карточки: подпись, значение, пояснение. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 12px 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .mid { font-family: var(--font-num); font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.stat .mid.bad { color: var(--bad); } .stat .mid.warn { color: var(--warn); } .stat .mid.ok { color: var(--ok); } .stat .mid.muted { color: var(--muted); }
.stat .sub { overflow-wrap: anywhere; }
.empty-note { margin: 0; padding: 16px 0; color: var(--muted); font-size: 12px; text-align: center; }
.hbar > span:first-child, .hbar > span { overflow-wrap: anywhere; }
.list { margin: 0; padding-left: 1.2em; font-size: 12px; color: var(--muted); line-height: 1.6; }
.skeleton { color: transparent !important; background: var(--grid); border-radius: 6px; }
@media (max-width: 640px) { .hide-sm { display: none; } .big { font-size: 26px; } }
@media (prefers-reduced-motion: no-preference) { .tile, .card { transition: border-color .2s; } }

/* Вход */
.lg { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.lg form { width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.lg h1 { font-size: 22px; }
.lg label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.lg input { font: inherit; font-size: 16px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.lg button { font: inherit; font-weight: 600; color: #fff; background: var(--accent); border: 0; border-radius: 8px; padding: 11px; cursor: pointer; }
.lg-err { margin: 0; color: var(--bad); font-size: 13px; }
