@font-face { font-family: "Manrope"; src: url("/static/fonts/Manrope.ttf") format("truetype"); font-weight: 200 800; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #f4f2ee; --surface: #fcfcfb; --surface-2: #efedf3; --line: #e3e0e8; --grid: #e8e6ec;
  --ink: #1c1a20; --ink-2: #55525c; --ink-3: #6f6c77;
  --accent: #6250d6; --accent-ink: #4a3aa7; --accent-soft: #ebe8fb; --on-accent: #fff;
  --good: #0a7d0a; --warning: #8a6100; --serious: #b34a1e; --critical: #c02f2f;
  --good-soft: #e5f4e5; --warning-soft: #fbf1d9; --serious-soft: #fbe9e1; --critical-soft: #fae6e6;
  --shadow: 0 1px 2px rgb(30 20 50 / .05);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #131116; --surface: #1c1a20; --surface-2: #27242c; --line: #322f38; --grid: #2d2a33;
    --ink: #f0eef3; --ink-2: #c3c0ca; --ink-3: #a09ca8;
    --accent: #9085e9; --accent-ink: #b5adf2; --accent-soft: #2c2748; --on-accent: #16131f;
    --good: #5fcf5f; --warning: #fab219; --serious: #ec835a; --critical: #f07272;
    --good-soft: #1b2e1b; --warning-soft: #33290f; --serious-soft: #35211a; --critical-soft: #3a1e1e;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131116; --surface: #1c1a20; --surface-2: #27242c; --line: #322f38; --grid: #2d2a33;
  --ink: #f0eef3; --ink-2: #c3c0ca; --ink-3: #a09ca8;
  --accent: #9085e9; --accent-ink: #b5adf2; --accent-soft: #2c2748; --on-accent: #16131f;
  --good: #5fcf5f; --warning: #fab219; --serious: #ec835a; --critical: #f07272;
  --good-soft: #1b2e1b; --warning-soft: #33290f; --serious-soft: #35211a; --critical-soft: #3a1e1e;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.5 "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif; font-feature-settings: "tnum"; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 14px; font-weight: 700; margin: 0 0 10px; }
p { margin: 0 0 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.nw { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.top-gap { margin-top: 16px; }
.bottom-gap { margin-bottom: 12px; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }

.layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 16px; color: var(--ink); padding: 0 10px; }
.brand:hover { text-decoration: none; }
.moon { color: var(--accent); }
.menu { display: flex; flex-direction: column; gap: 2px; }
.menu a { color: var(--ink-2); padding: 7px 10px; border-radius: 7px; font-weight: 500; }
.menu a:hover { background: var(--surface-2); text-decoration: none; }
.menu a[aria-current] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.side-foot { margin-top: auto; display: flex; justify-content: space-between; padding: 0 10px; }
.btn-link { all: unset; color: var(--ink-3); cursor: pointer; font-size: 13px; }
.btn-link:hover { color: var(--ink); }
.btn-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.main { padding: 22px 28px 48px; min-width: 0; max-width: 1320px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 16px; }
.head-tools { min-width: 0; max-width: 100%; }
.crumb { display: block; color: var(--ink-3); font-size: 12px; margin-bottom: 2px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow); min-width: 0; }
.block { padding: 16px 18px; margin-bottom: 14px; }
.flush { overflow: hidden; margin-bottom: 14px; }
.pad { padding: 16px 18px 10px; margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; align-items: start; }
.grid2 > .chart, .grid2 > .block { margin: 0; }
.grid-chart { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 14px; align-items: start; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.tiles-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { padding: 13px 15px; display: flex; flex-direction: column; gap: 2px; color: inherit; }
a.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile-label { color: var(--ink-2); font-size: 12px; font-weight: 500; }
.tile-value { font-size: 25px; font-weight: 700; letter-spacing: -.02em; line-height: 1.3; }
.tile-note { color: var(--ink-3); font-size: 11.5px; line-height: 1.35; }
.delta { font-weight: 700; color: var(--ink-2); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg a { padding: 4px 11px; border-radius: 6px; color: var(--ink-2); font-size: 13px; font-weight: 500; white-space: nowrap; }
.seg a:hover { text-decoration: none; color: var(--ink); }
.seg a[aria-current] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: var(--shadow); }
.chips { margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--ink-3); font-size: 12px; font-weight: 500; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th a { color: inherit; }
th a[aria-current] { color: var(--ink); font-weight: 700; }
td { padding: 7px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.flush th:first-child, .flush td:first-child { padding-left: 18px; }
.flush th:last-child, .flush td:last-child { padding-right: 18px; }
.block th:first-child, .block td:first-child { padding-left: 0; }
.block th:last-child, .block td:last-child { padding-right: 0; }
.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tw { overflow-x: auto; }
.funnel .wide { width: 34%; min-width: 90px; vertical-align: middle; }
.hbar { display: block; }
.hbar .track { fill: var(--surface-2); }
.hbar .fill { fill: var(--accent); }

.chart { padding: 14px 16px; }
.chart figcaption { margin-bottom: 6px; font-size: 13px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--ink-3); font-size: 11px; }
.chart .bar { fill: var(--accent); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: color-mix(in srgb, var(--accent) 10%, transparent); }
.chart-table summary { color: var(--ink-3); font-size: 12px; cursor: pointer; margin-top: 4px; }
.chart-table .tw { max-height: 220px; overflow-y: auto; }
.tip { position: fixed; z-index: 10; background: var(--ink); color: var(--surface); font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 6px; pointer-events: none; white-space: nowrap; }
.tip[hidden] { display: none; }
.empty { color: var(--ink-3); margin: 0; padding: 18px; text-align: center; }

.status { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-ok, .status-good { background: var(--good-soft); color: var(--good); }
.status-warning { background: var(--warning-soft); color: var(--warning); }
.status-serious { background: var(--serious-soft); color: var(--serious); }
.status-critical, .status-fail { background: var(--critical-soft); color: var(--critical); }
.status-off { background: var(--surface-2); color: var(--ink-2); }
.alerts { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 7px; }
.alerts li { display: flex; gap: 9px; align-items: baseline; }
.flash { padding: 9px 13px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.flash-good { background: var(--good-soft); color: var(--good); }
.flash-warning { background: var(--warning-soft); color: var(--warning); }
.flash-critical { background: var(--critical-soft); color: var(--critical); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 500; white-space: nowrap; margin: 1px 0; }
.tag-accent { background: var(--accent-soft); color: var(--accent-ink); }
.count { background: var(--critical); color: #fff; border-radius: 99px; padding: 0 6px; font-size: 11px; }

input, select, textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; min-width: 0; max-width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
input[type="checkbox"] { accent-color: var(--accent); }
.btn { display: inline-block; font: inherit; font-weight: 600; font-size: 13px; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-danger { background: var(--critical); color: #fff; border-color: var(--critical); }
:root[data-theme="dark"] .btn-danger { color: #1c0c0c; }
.search { display: flex; gap: 8px; margin-bottom: 10px; }
.search input { flex: 1; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-form label { color: var(--ink-2); font-size: 13px; }
.check { display: inline-flex; gap: 5px; align-items: center; }
.short { width: 74px; }
.mid { width: 150px; }
.stack { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.stack textarea { width: 100%; resize: vertical; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.link-out { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0 0; }
code { background: var(--surface-2); border-radius: 5px; padding: 3px 7px; font-size: 12.5px; overflow-wrap: anywhere; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 14px 0; }
.danger { border-top: 1px solid var(--line); padding-top: 12px; }
.danger summary { color: var(--critical); font-weight: 600; cursor: pointer; }
.danger p { margin-top: 8px; }

.user-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -8px 0 12px; color: var(--ink-3); }
.mini-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.mini-stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; display: flex; flex-direction: column; }
.mini-stats span { color: var(--ink-3); font-size: 12px; }
.mini-stats strong { font-size: 17px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 7px 12px; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a[aria-current] { color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.facts { display: grid; grid-template-columns: minmax(110px, auto) minmax(0, 1fr); gap: 5px 14px; margin: 0; }
.facts dt { color: var(--ink-3); font-size: 13px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 5px; }
.phrase { margin: 0 0 14px; padding: 12px 18px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 10px 10px 0; font-size: 15px; }
.chapter { border-bottom: 1px solid var(--grid); }
.chapter:last-of-type { border-bottom: 0; }
.chapter summary { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; padding: 8px 0; cursor: pointer; list-style-position: inside; }
.chapter summary > span:first-child { font-weight: 600; margin-right: auto; }
.chapter summary::before { content: "›"; color: var(--ink-3); transition: transform .1s; }
.chapter[open] summary::before { transform: rotate(90deg); }
.chapter summary::-webkit-details-marker { display: none; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 72ch; padding-bottom: 12px; line-height: 1.6; }
.code { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; overflow: auto; max-height: 480px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 12px; }
details > summary { cursor: pointer; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.file { margin: 0; overflow: hidden; }
.file img { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: var(--surface-2); }
.file .pdf { display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 5; background: var(--surface-2); font-weight: 600; }
.file figcaption { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: min(100%, 340px); padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.login h1 { margin-bottom: 8px; }
.login label { font-size: 13px; color: var(--ink-2); }
.login .flash { margin: 0; }

@media (max-width: 1180px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .grid2, .grid-chart { grid-template-columns: minmax(0, 1fr); }
  .tiles-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; }
  .side-foot { margin: 0; gap: 14px; padding: 0; }
  .menu { flex-direction: row; order: 3; width: 100%; overflow-x: auto; }
  .menu a { white-space: nowrap; }
  .main { padding: 16px 16px 40px; }
  .tiles, .tiles-4, .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-value { font-size: 21px; }
  .block { padding: 14px; }
  /* График масштабируется целиком: подписи в единицах viewBox, на телефоне нужны крупнее */
  .chart .axis { font-size: 20px; }
  .hide-sm, .steps .wide { display: none; }
  .steps th { white-space: normal; vertical-align: bottom; }
  .steps td.nw { white-space: normal; }
}
@media (forced-colors: active) { .chart .bar, .hbar .fill { fill: CanvasText; } }
