:root {
  color-scheme: light;
  --bg: #ffffff;
  --side: #fafaf9;
  --panel: #ffffff;
  --hover: #f3f3f1;
  --active: #e9e9e6;
  --line: #ebebe8;
  --line-strong: #d9d9d4;
  --text: #1c1c1b;
  --muted: #6f6f69;
  --link: #1f68c0;
  --focus: #2a78d6;
  --on-primary: #ffffff;
  --code: #f3f3f1;
  --ok: #1d7a35;
  --ok-soft: #e8f5ea;
  --warn: #8a5a00;
  --warn-soft: #fdf1dc;
  --bad: #b3261e;
  --bad-soft: #fdeaea;
  --info: #1c5fb0;
  --info-soft: #e8f1fb;
  --none: #66665f;
  --none-soft: #f0f0ee;
  --dot-bad: #d03b3b;
  --series: #2a78d6;
  --series-bad: #d03b3b;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --axis: #898781;
  --wash: rgba(28, 28, 27, .05);
  --tip-shadow: 0 6px 20px rgba(28, 28, 27, .14);
  --tab-shadow: 0 1px 2px rgba(28, 28, 27, .12);
  --if-light: inline-flex;
  --if-dark: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #161615;
    --side: #1b1b1a;
    --panel: #1c1c1b;
    --hover: #252524;
    --active: #2f2f2d;
    --line: #2c2c2a;
    --line-strong: #3a3a37;
    --text: #efefeb;
    --muted: #a3a39c;
    --link: #85b7eb;
    --focus: #3987e5;
    --on-primary: #161615;
    --code: #252524;
    --ok: #6fd08a;
    --ok-soft: #16321d;
    --warn: #eebb5d;
    --warn-soft: #35280f;
    --bad: #f29a9a;
    --bad-soft: #3b1a1a;
    --info: #85b7eb;
    --info-soft: #12283f;
    --none: #b3b3ac;
    --none-soft: #2a2a28;
    --series: #3987e5;
    --series-bad: #d03b3b;
    --grid: #2c2c2a;
    --baseline: #383835;
    --axis: #898781;
    --wash: rgba(239, 239, 235, .06);
    --tip-shadow: 0 6px 20px rgba(0, 0, 0, .5);
    --tab-shadow: 0 1px 2px rgba(0, 0, 0, .5);
    --if-light: none;
    --if-dark: inline-flex;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161615;
  --side: #1b1b1a;
  --panel: #1c1c1b;
  --hover: #252524;
  --active: #2f2f2d;
  --line: #2c2c2a;
  --line-strong: #3a3a37;
  --text: #efefeb;
  --muted: #a3a39c;
  --link: #85b7eb;
  --focus: #3987e5;
  --on-primary: #161615;
  --code: #252524;
  --ok: #6fd08a;
  --ok-soft: #16321d;
  --warn: #eebb5d;
  --warn-soft: #35280f;
  --bad: #f29a9a;
  --bad-soft: #3b1a1a;
  --info: #85b7eb;
  --info-soft: #12283f;
  --none: #b3b3ac;
  --none-soft: #2a2a28;
  --series: #3987e5;
  --series-bad: #d03b3b;
  --grid: #2c2c2a;
  --baseline: #383835;
  --axis: #898781;
  --wash: rgba(239, 239, 235, .06);
  --tip-shadow: 0 6px 20px rgba(0, 0, 0, .5);
  --tab-shadow: 0 1px 2px rgba(0, 0, 0, .5);
  --if-light: none;
  --if-dark: inline-flex;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-wrap: break-word;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 28px; line-height: 1.2; font-weight: 700; margin: 0 0 6px; letter-spacing: -.02em; text-wrap: balance; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
p { margin: 0 0 10px; }
code { background: var(--code); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
pre { white-space: pre-wrap; word-break: break-word; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sub { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
td > .sub, dd > .sub { margin-top: 2px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.mt { margin-top: 20px; }
.empty { color: var(--muted); margin: 4px 0; }
.icon { flex: none; display: block; }

/* каркас */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side);
  box-shadow: inset -1px 0 0 var(--line);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 2px 8px; color: var(--text); }
a.brand:hover { text-decoration: none; }
.mark { flex: none; display: block; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.2; letter-spacing: -.01em; }
.brand-sub { color: var(--muted); font-size: 12px; line-height: 1.3; overflow-wrap: anywhere; }
.side nav { display: flex; flex-direction: column; gap: 1px; }
.side nav a {
  color: var(--text);
  padding: 7px 10px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}
.side nav a .icon { color: var(--muted); }
.side nav a:hover { background: var(--hover); text-decoration: none; }
.side nav a.on { background: var(--active); font-weight: 600; }
.side nav a.on .icon { color: var(--text); }
.nav-group { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 14px 10px 4px; }
.count {
  margin-left: auto;
  background: var(--warn-soft); color: var(--warn); border-radius: 999px;
  font-size: 11.5px; line-height: 18px; padding: 0 7px; min-width: 20px; text-align: center; font-weight: 600;
}
.count.bad { background: var(--bad-soft); color: var(--bad); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.side-foot form { margin: 0; }
.logout {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border: 0; border-radius: 10px; background: none; color: var(--text);
  font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
}
.logout .icon { color: var(--muted); }
.logout:hover { background: var(--hover); }
.me { display: flex; align-items: center; gap: 8px; padding: 0 2px 0 8px; }
.me-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.me-name { font-size: 13px; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-sub { color: var(--muted); font-size: 11.5px; line-height: 1.3; overflow-wrap: anywhere; }
.avatar {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--active); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 600;
}
.avatar.small { width: 22px; height: 22px; font-size: 11px; }
.avatar.small .icon { width: 13px; height: 13px; color: var(--muted); }
.icon-btn {
  flex: none; width: 28px; height: 28px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.if-light { display: var(--if-light); }
.if-dark { display: var(--if-dark); }
.main { padding: 32px 40px 64px; width: 100%; max-width: 1120px; margin: 0 auto; }

.page-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 20px; }
.page-head > div { min-width: 0; }
.page-head p { max-width: 62ch; margin-bottom: 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; justify-content: flex-end; }
.head-actions form { margin: 0; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 2px; }

/* переключатели и фильтры */
.tabs {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px;
  background: var(--hover); max-width: 100%; overflow-x: auto; flex: none; scrollbar-width: none;
}
.tabs a { padding: 5px 14px; border-radius: 999px; color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--tab-shadow); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 16px; }
.filters .btn { padding: 5px 14px; }
.pill-select {
  position: relative; display: inline-flex; flex-direction: row; align-items: center; gap: 6px;
  padding-left: 12px; border-radius: 999px; background: var(--hover);
  font-size: 13px; color: var(--muted); max-width: 100%; cursor: pointer;
}
.pill-select:hover { background: var(--active); }
.pill-select:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.pill-select::after {
  content: ""; position: absolute; right: 13px; top: 50%; width: 6px; height: 6px; margin-top: -5px;
  border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted);
  transform: rotate(45deg); pointer-events: none;
}
.pill-select select {
  appearance: none; -webkit-appearance: none; field-sizing: content;
  border: 0; border-radius: 0; background: none; outline: 0;
  padding: 5px 30px 5px 0; min-width: 0; max-width: 230px;
  color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
}
.filters-reset { font-size: 13px; color: var(--muted); padding: 0 6px; }
.more { text-align: center; margin: 4px 0 16px; }

/* карточки */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 22px;
  margin-bottom: 16px;
}
.card.flush { padding: 0; border-radius: 16px; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
.flush > .card-head { padding: 16px 20px 10px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 16px; margin-bottom: 16px; }
.grid2 > .card { margin-bottom: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 16px; }
.tile { color: var(--text); display: flex; flex-direction: column; gap: 8px; margin: 0; }
.tile:hover { border-color: var(--line-strong); background: var(--side); text-decoration: none; }
.tile-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.tile-top h3 { margin: 0; }
.tile-text { color: var(--muted); font-size: 13.5px; margin: 0 0 4px; }
.tile-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 12px; margin: auto 0 0; font-size: 12.5px; }
.tile-facts dt { color: var(--muted); }
.tile-facts dd { margin: 0; }
.tile-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.prose { white-space: pre-line; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px 18px; color: var(--text); display: flex; flex-direction: column; gap: 6px;
}
a.stat:hover { border-color: var(--line-strong); background: var(--side); text-decoration: none; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 15px; font-weight: 600; }
.stat-value.big { font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.stat-note { font-size: 12.5px; line-height: 1.4; color: var(--muted); }

/* график */
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--series); }
.swatch.bad { background: var(--series-bad); }
.chart { display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 10px; margin-top: 18px; }
.y-axis { position: relative; height: 200px; color: var(--axis); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.y-axis span { position: absolute; right: 0; line-height: 1; transform: translateY(50%); }
.plot { position: relative; height: 200px; }
.grid-line { position: absolute; left: 0; right: 0; height: 1px; background: var(--grid); }
.grid-line.base { background: var(--baseline); }
.bars { position: absolute; inset: 0; display: flex; gap: 2px; }
.slot {
  flex: 1 1 0; min-width: 0; height: 100%;
  display: flex; align-items: flex-end; justify-content: center;
  border-radius: 6px 6px 0 0;
}
.slot:hover, .slot:focus-visible { background: var(--wash); }
.slot:focus-visible { outline-offset: -2px; }
.bar { position: relative; width: 100%; max-width: 24px; display: flex; flex-direction: column; gap: 2px; }
.bar.one { min-height: 3px; }
.bar.both { min-height: 6px; }
.seg { flex: 1 1 0; min-height: 2px; background: var(--series); display: block; }
.seg.bad { background: var(--series-bad); }
.bar > .seg:first-child { border-radius: 4px 4px 0 0; }
.slot:hover .seg, .slot:focus-visible .seg { filter: brightness(1.12); }
.tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 5;
  min-width: 128px; padding: 8px 10px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line-strong); box-shadow: var(--tip-shadow);
  color: var(--muted); font-size: 12.5px; line-height: 1.5; white-space: nowrap;
  pointer-events: none; visibility: hidden;
}
.tip-l .tip { left: 0; transform: none; }
.tip-r .tip { left: auto; right: 0; transform: none; }
.slot:hover .tip, .slot:focus-visible .tip, .slot:focus .tip { visibility: visible; }
.tip-title { margin-bottom: 2px; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-row strong { color: var(--text); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.key { width: 12px; height: 2px; border-radius: 1px; background: var(--series); flex: none; }
.key.bad { background: var(--series-bad); }
.x-axis {
  grid-column: 2; display: flex; gap: 2px; margin-top: 6px; min-height: 17px;
  color: var(--axis); font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.x-axis span { flex: 1 1 0; min-width: 0; display: flex; justify-content: center; white-space: nowrap; }
.twin { margin-top: 12px; font-size: 13px; }
.twin summary { color: var(--muted); cursor: pointer; width: max-content; max-width: 100%; }
.twin-table { max-height: 280px; overflow-y: auto; margin-top: 8px; }

/* значки */
.badge {
  display: inline-block; font-size: 12.5px; line-height: 1.5; padding: 1px 10px;
  border-radius: 999px; white-space: nowrap; font-weight: 500;
  background: var(--none-soft); color: var(--none);
}
dd .badge, .stat .badge { white-space: normal; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info, .badge.accent { background: var(--info-soft); color: var(--info); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; background: var(--muted); }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--dot-bad); }
.conn { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); }
.conn:last-child { border-bottom: 0; }
.conn > div { min-width: 0; }
.who { display: inline-flex; align-items: center; gap: 8px; }

/* таблицы */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 12.5px; font-weight: 600; color: var(--text);
  border-bottom: 1px solid var(--line); padding: 9px 12px; white-space: nowrap;
}
th.right { text-align: right; }
td { border-bottom: 1px solid var(--line); padding: 11px 12px; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.flush th:first-child, .flush td:first-child { padding-left: 20px; }
.flush th:last-child, .flush td:last-child { padding-right: 20px; }
.flush td.empty { padding-block: 18px; }
table.wide { min-width: 700px; }
td.what { min-width: 230px; }
.rows tr { position: relative; }
.rows tbody tr:hover td { background: var(--side); }
.row-link { color: var(--text); }
.row-link:hover { text-decoration: none; }
.row-link::after { content: ""; position: absolute; inset: 0; }
.clamp {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden; max-width: 340px;
}
dl.kv { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: 10px 16px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 13px; }
dl.kv dd { margin: 0; }

/* формы и кнопки */
.btn {
  font: inherit; font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent; background: var(--hover); color: var(--text);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; white-space: nowrap;
  display: inline-block;
}
.btn:hover { background: var(--active); text-decoration: none; }
.btn.primary { background: var(--text); color: var(--on-primary); }
.btn.primary:hover { background: var(--text); opacity: .86; }
.btn.ghost { background: transparent; border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--hover); }
.btn.wide { width: 100%; padding: 10px; }
.form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
input, textarea, select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 8px 12px; max-width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.pill-select select:focus { outline: 0; }
.help { margin-top: -8px; }
form.inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }

.flash { border-radius: 12px; padding: 9px 14px; margin: 0 0 14px; background: var(--ok-soft); color: var(--ok); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.flash.bad { background: var(--bad-soft); color: var(--bad); }

/* подтверждения, журнал, лог */
.approval-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.approval h3 { margin: 2px 0 8px; font-size: 16px; }
.reason { background: var(--code); border-radius: 12px; padding: 9px 12px; margin-top: 12px; font-size: 13.5px; }
details.out { border-bottom: 1px solid var(--line); padding: 9px 0; }
details.out:last-child { border-bottom: 0; }
details.out summary { cursor: pointer; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
details.out pre { background: var(--code); border-radius: 12px; padding: 10px 12px; margin: 10px 0 4px; max-height: 420px; overflow: auto; }
details.out.blocked summary strong { color: var(--bad); }
ol.log { list-style: none; margin: 0; padding: 0; max-height: 460px; overflow: auto; }
ol.log li { padding: 4px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
ol.log li:last-child { border-bottom: 0; }
ol.log li.error pre { color: var(--bad); }
ol.log li.warn pre { color: var(--warn); }

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 12px; }
.shots figure { margin: 0; }
.shots img { width: 100%; border: 1px solid var(--line); border-radius: 12px; display: block; }
.shots figcaption { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; }
.login { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; padding: 26px; margin: 0; }
.login .brand { padding: 0; }

@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; overflow: visible; box-shadow: inset 0 -1px 0 var(--line); padding: 12px 16px; gap: 10px; }
  .brand { padding: 0; }
  .side nav { flex-direction: row; gap: 2px; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
  .side nav a { flex: none; white-space: nowrap; }
  .nav-group { display: none; }
  .side-foot { margin: 0; flex-direction: row-reverse; align-items: center; justify-content: space-between; }
  .logout { width: auto; padding: 5px 8px; }
  .me { padding: 0; min-width: 0; }
  .main { padding: 20px 16px 48px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-head .tabs { align-self: flex-start; }
  .head-actions { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .x-axis span:not(.narrow) { visibility: hidden; }
  .card { padding: 16px; }
  .card.flush { padding: 0; }
  dl.kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  dl.kv dd { margin-bottom: 10px; }
  table.fit-narrow { min-width: 0; }
  .fit-narrow .hide-narrow { display: none; }
  .fit-narrow td.what { min-width: 0; }
}
@media (max-width: 420px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
}
@media (forced-colors: active) {
  .seg, .swatch, .key { background: CanvasText; }
  .seg.bad, .swatch.bad, .key.bad { background: Highlight; }
}
