@font-face {
  font-family: "Flex"; font-style: normal; font-display: swap;
  font-weight: 100 1000; font-stretch: 25% 151%;
  src: url("vendor/roboto-flex-latin-full-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+2264-2265, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Flex"; font-style: normal; font-display: swap;
  font-weight: 100 1000; font-stretch: 25% 151%;
  src: url("vendor/roboto-flex-cyrillic-full-normal.woff2") format("woff2-variations");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* Цвета уровней — по мотивам аварийной сигнализации X.733 (critical / major / minor).
   Палитра проверена на различимость при дальтонизме для обеих тем. */
:root {
  color-scheme: light;
  --bg: #E4E9EE;
  --surface: #F7F9FA;
  --surface-2: #EEF2F5;
  --line: #CDD6DE;
  --ink: #142029;
  --ink-2: #47566A;
  --muted: #6B7A8A;
  --critical: #C3262E;
  --important: #C97200;
  --minor: #3D7CC4;
  --critical-soft: #F6DEDF;
  --important-soft: #F7E7D2;
  --minor-soft: #DCE7F4;
  --focus: #2F6FD0;
  --radius-s: 4px;
  --radius-m: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141A20; --surface: #1C242C; --surface-2: #232D37; --line: #2F3B47;
    --ink: #E6ECF1; --ink-2: #A9B6C3; --muted: #84919E;
    --critical: #DC3C4A; --important: #BC8A1C; --minor: #4F8FD6;
    --critical-soft: #3A1F25; --important-soft: #3A2E17; --minor-soft: #1F2E42; --focus: #6FA3F0;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141A20; --surface: #1C242C; --surface-2: #232D37; --line: #2F3B47;
  --ink: #E6ECF1; --ink-2: #A9B6C3; --muted: #84919E;
  --critical: #DC3C4A; --important: #BC8A1C; --minor: #4F8FD6;
  --critical-soft: #3A1F25; --important-soft: #3A2E17; --minor-soft: #1F2E42; --focus: #6FA3F0;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 15px/1.45 "Flex", system-ui, sans-serif; font-variant-numeric: tabular-nums;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand {
  text-decoration: none; font-size: 22px; font-weight: 820; font-stretch: 140%; letter-spacing: -0.01em;
}
.brand span { font-weight: 300; }
.views { display: flex; gap: 4px; }
.views a {
  text-decoration: none; padding: 6px 12px; border-radius: var(--radius-s); color: var(--ink-2);
}
.views a[aria-current="page"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.search { flex: 1; max-width: 560px; }
.search input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--bg);
}
.theme {
  display: flex; margin-left: auto; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden;
}
.theme button {
  border: 0; background: none; padding: 6px 10px; cursor: pointer; color: var(--ink-2); font-size: 13.5px;
}
.theme button + button { border-left: 1px solid var(--line); }
.theme .short { display: none; }
.theme button[aria-checked="true"] { background: var(--ink); color: var(--surface); font-weight: 600; }
.lang + .theme { margin-left: 0; }   /* переключатель языка стоит перед темой и сам прижимается вправо */
.lang button { letter-spacing: 0.02em; }
.srcbtn {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: none; border-radius: var(--radius-s); padding: 6px 10px; cursor: pointer;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: #2E9D5B; }
.dot.bad { background: var(--critical); }

.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px;
  padding: 10px 20px; color: var(--ink-2); font-size: 14px;
}
.tog { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.tog input { accent-color: var(--ink); }
.active-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.active-tags button {
  border: 1px solid var(--ink); background: var(--ink); color: var(--surface);
  border-radius: var(--radius-s); padding: 2px 8px; cursor: pointer; font-size: 13px;
}
.active-tags button::after { content: " ×"; }
.linkish { border: 0; background: none; padding: 0; color: var(--focus); cursor: pointer; text-decoration: underline; }

/* ---------- ленты ---------- */
.lanes {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 0 20px 40px;
  align-items: start;
}
.lane-switch { display: none; }
.lane { min-width: 0; }
.lane-head {
  display: grid; grid-template-columns: 1fr auto; align-items: end; column-gap: 12px;
  padding: 14px 16px 12px; background: var(--surface); border-radius: var(--radius-m) var(--radius-m) 0 0;
  border-top: 6px solid var(--lvl);
  position: sticky; top: var(--top-h, 57px); z-index: 5;
  box-shadow: 0 1px 0 var(--line);
}
.lane[data-level="critical"] { --lvl: var(--critical); --lvl-soft: var(--critical-soft); }
.lane[data-level="important"] { --lvl: var(--important); --lvl-soft: var(--important-soft); }
.lane[data-level="minor"] { --lvl: var(--minor); --lvl-soft: var(--minor-soft); }
.lane-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
/* главный акцент страницы: счётчики уровней как табло аварий */
.lane-count {
  grid-row: 1 / span 2; grid-column: 2; justify-self: end;
  font-size: 46px; line-height: 0.9; font-weight: 900; font-stretch: 151%; color: var(--lvl);
  letter-spacing: -0.02em;
}
.lane-rule { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); max-width: 32ch; }
.atom { grid-column: 1; font-size: 12.5px; color: var(--ink-2); margin-top: 6px; justify-self: start; }

.cards { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: 0 0 var(--radius-m) var(--radius-m); }
.card {
  position: relative; padding: 12px 16px 12px 18px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 2px 2px 0;
  background: var(--lvl);
}
.card:hover { background: var(--surface-2); }
.card:last-child { border-bottom: 0; }
.card-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cid { font-weight: 650; font-stretch: 88%; font-size: 14px; }
.score {
  font-weight: 800; font-size: 13px; padding: 1px 6px; border-radius: var(--radius-s);
  background: var(--lvl-soft); color: var(--ink);
}
.metric { font-size: 12.5px; color: var(--ink-2); }
.flag { font-size: 12px; font-weight: 700; color: var(--critical); }
.when { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.card h3 { margin: 4px 0 2px; font-size: 14.5px; font-weight: 560; line-height: 1.35; overflow-wrap: anywhere; }
.card p.sum {
  margin: 0; color: var(--ink-2); font-size: 13.5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tag {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: var(--radius-s);
  font-size: 12px; padding: 0 6px; line-height: 20px; cursor: pointer;
}
.tag:hover { border-color: var(--ink-2); color: var(--ink); }
.tag.hot { border-color: var(--critical); color: var(--critical); font-weight: 650; }
.tag.v { font-weight: 650; color: var(--ink); }
.reasons { margin-top: 6px; font-size: 12px; color: var(--muted); }
.more {
  display: block; width: 100%; margin-top: 8px; padding: 10px; border: 1px dashed var(--line);
  background: none; border-radius: var(--radius-m); cursor: pointer; color: var(--ink-2);
}
.empty { padding: 24px 16px; color: var(--muted); font-size: 14px; }

/* ---------- карточка-деталь ---------- */
.scrim { position: fixed; inset: 0; background: rgb(10 16 22 / 0.35); z-index: 30; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); z-index: 40;
  background: var(--surface); border-left: 6px solid var(--lvl, var(--line)); overflow-y: auto;
}
.drawer-inner { padding: 22px 26px 40px; }
.close { position: absolute; top: 12px; right: 14px; border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--ink-2); }
.d-id { font-size: 26px; font-weight: 850; font-stretch: 120%; margin: 0 40px 4px 0; overflow-wrap: anywhere; }
.d-title { margin: 0 0 14px; font-size: 17px; font-weight: 560; }
.d-grid { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; margin: 14px 0; }
.d-grid dt { color: var(--muted); }
.d-grid dd { margin: 0; overflow-wrap: anywhere; }
.d-sum { max-width: 72ch; }
.d-sum.ru { font-size: 15.5px; }
.d-sec { font-size: 14px; font-weight: 700; margin: 22px 0 6px; }
.d-list { margin: 0; padding-left: 18px; font-size: 14px; }
.d-list li { margin: 3px 0; overflow-wrap: anywhere; }
.kids { list-style: none; padding: 0; margin: 0; }
.kids li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; cursor: pointer; }

/* ---------- статистика ---------- */
.stats {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 0 20px 40px;
}
.stat-filters { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; }
.stat-filters label { display: inline-flex; gap: 8px; align-items: center; color: var(--ink-2); }
.stat-filters select { padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
.hint { margin: 0; color: var(--muted); font-size: 13px; max-width: 70ch; }
.counters { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; background: var(--line); border-radius: var(--radius-m); overflow: hidden; }
.counter { background: var(--surface); padding: 12px 16px; }
.counter b { display: block; font-size: 34px; line-height: 1; font-weight: 900; font-stretch: 140%; }
.counter span { font-size: 13px; color: var(--ink-2); }
.counter.critical { border-top: 4px solid var(--critical); }
.counter.important { border-top: 4px solid var(--important); }
.counter.minor { border-top: 4px solid var(--minor); }
.panel { margin: 0; background: var(--surface); border-radius: var(--radius-m); padding: 14px 16px 16px; min-width: 0; }
.panel.wide { grid-column: 1 / -1; }
.panel figcaption { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin-bottom: 10px; }
.panel h3 { margin: 0; font-size: 15px; font-weight: 650; }
.panel .sub { font-size: 12.5px; color: var(--muted); }
.panel .linkish { margin-left: auto; font-size: 13px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--ink-2); }
.legend .k::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend .critical::before { background: var(--critical); }
.legend .important::before { background: var(--important); }
.legend .minor::before { background: var(--minor); }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 320px; }
.table-box { max-height: 320px; overflow: auto; font-size: 13.5px; }
.table-box table { border-collapse: collapse; width: 100%; }
.table-box th, .table-box td { text-align: right; padding: 4px 10px; border-bottom: 1px solid var(--line); }
.table-box th:first-child, .table-box td:first-child { text-align: left; }
.tagcloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tagcloud .tag { font-size: 13px; line-height: 24px; }
.tagcloud .tag i { font-style: normal; color: var(--muted); margin-left: 4px; }

dialog { border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); color: var(--ink); max-width: min(720px, 94vw); padding: 18px 22px; }
dialog::backdrop { background: rgb(10 16 22 / 0.35); }
dialog table { border-collapse: collapse; font-size: 13.5px; width: 100%; }
dialog td, dialog th { padding: 5px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
dialog form { margin-top: 12px; text-align: right; }
dialog button { border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius-s); padding: 6px 14px; cursor: pointer; }

/* ---------- адаптив ---------- */
@media (max-width: 1100px) {
  .counters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .top { flex-wrap: wrap; gap: 10px 14px; padding: 10px 16px; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
  .srcbtn span { display: none; }
  .views a { padding: 6px 8px; }
  .theme button { padding: 4px 9px; font-size: 15px; }
  .theme .full { display: none; }
  .theme .short { display: inline-flex; }
  .theme button { display: inline-flex; align-items: center; padding: 6px 9px; }
  .filters { padding: 10px 16px; }
  .lanes { grid-template-columns: 1fr; padding: 0 16px 40px; }
  .lane-switch {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
    position: sticky; top: var(--top-h, 98px); z-index: 6; background: var(--bg); padding-bottom: 6px;
  }
  .lane-switch button {
    border: 0; border-top: 4px solid transparent; background: var(--surface); border-radius: var(--radius-s);
    padding: 8px 4px; font-size: 13px; cursor: pointer;
  }
  .lane-switch button b { display: block; font-size: 18px; font-stretch: 130%; font-weight: 850; }
  .lane-switch [data-lane="critical"][aria-selected="true"] { border-top-color: var(--critical); }
  .lane-switch [data-lane="important"][aria-selected="true"] { border-top-color: var(--important); }
  .lane-switch [data-lane="minor"][aria-selected="true"] { border-top-color: var(--minor); }
  .lane { display: none; }
  .lane.on { display: block; }
  .lane-head { position: static; grid-template-columns: 1fr; }
  .lane-count { display: none; }  /* число уже в переключателе */
  .stats { grid-template-columns: 1fr; padding: 0 16px 40px; }
  .counters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer-inner { padding: 18px 16px 40px; }
}
@media (prefers-reduced-motion: no-preference) {
  .drawer:not([hidden]) { animation: slide 160ms ease-out; }
  @keyframes slide { from { transform: translateX(24px); opacity: 0.6; } }
}
@media print { .top, .filters, .more { display: none; } }
