/* Веб-админка доступа к боту. Один файл стилей на все страницы; стили страницы -- static/pages/<имя>.css (до 80 строк,
   только токены отсюда). Инлайн-стилей нет (CSP style-src 'self'): цвет графиков и чипов задается классом.
   Темы: светлая по умолчанию, темная по системе (кроме data-theme="light") или по data-theme="dark".
   Цвета: палитра дашборда Snowflake Cost Monitor (cds), см. токены ниже. */

:root {
  color-scheme: light;
  /* Палитра дашборда Snowflake Cost Monitor (cds): теплые серые, нейтральный акцент, цвет только у данных и статусов. */
  --bg: #f9f9f7; --panel: #ffffff; --text: #0b0b0b; --muted: #898781;
  --line: rgba(11, 11, 11, .1); --line-strong: rgba(11, 11, 11, .2);
  --accent: #0b0b0b; --accent-text: #ffffff; --link: #184f95;
  --ok-bg: #edf8ec; --ok: #006300; --err-bg: #fef1f1; --err: #8e2626; --warn-bg: #fdf3e0; --warn: #734500;
  --chip: #f0efec; --on: #006300; --off: #8e2626;
  --panel-2: #f9f9f7; --hover: #f3f3f0; --shadow: none;
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, .12), 0 2px 6px rgba(0, 0, 0, .08);
  --good-text: #006300; --bad-text: #8e2626;
  /* Смыслы доступа: текст на заливке, рамка. */
  --lv-allow: #006300; --lv-allow-bg: #edf8ec;
  --lv-alerts: #734500; --lv-alerts-bg: #fdf3e0;
  --lv-deny: #52514e; --lv-deny-bg: #f0efec; --lv-deny-line: #d03b3b;
  --lv-member: #006300;
  --lv-admin: #ffffff; --lv-admin-bg: #0b0b0b;
  --grant: #4a3aa7; --grant-bg: #f4f3fe;
  --override: #256abf;
  --conflict: #863311; --conflict-bg: #fdf2ed;
  --unknown: #898781;
  /* Ряды графиков. Ключи доступа (порядок стека prod, +lp, +pd, +pd+lp, ?) и категории s-1..s-8: категориальная и
     последовательная палитры дашборда, проверены валидатором dataviz для обеих тем. */
  --k-prod: #2a78d6; --k-lp: #1baf7a; --k-pd: #6250d6; --k-pdlp: #e87ba4; --k-unk: #c3c2b7;
  --s-1: #2a78d6; --s-2: #eb6834; --s-3: #1baf7a; --s-4: #eda100;
  --s-5: #e87ba4; --s-6: #008300; --s-7: #6250d6; --s-8: #e34948;
  --st-good: #0ca30c; --st-warn: #fab219; --st-serious: #ec835a; --st-crit: #d03b3b; --st-muted: #c3c2b7;
  --q-0: #cde2fb; --q-1: #9ec5f4; --q-2: #6da7ec; --q-3: #3987e5; --q-4: #1c5cab; --q-z: #f0efec;
  --lvl-1: #eaf2fd; --lvl-2: #cde2fb; --lvl-3: #9ec5f4;
  --grid: #eae9e4; --axis: #c3c2b7; --hatch: rgba(255, 255, 255, .7); --hatch-conflict: #ae461c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0b0b; --panel: #1a1a19; --text: #f0efec; --muted: #898781;
    --line: rgba(255, 255, 255, .1); --line-strong: rgba(255, 255, 255, .2);
    --accent: #f0efec; --accent-text: #0b0b0b; --link: #6da7ec;
    --ok-bg: #11260f; --ok: #0ca30c; --err-bg: #3c0e0e; --err: #ec7e7e; --warn-bg: #311a00; --warn: #db9300;
    --chip: #2c2c2a; --on: #0ca30c; --off: #ec7e7e;
    --panel-2: #151515; --hover: #20201f; --shadow: none;
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, .32), 0 2px 6px rgba(0, 0, 0, .2);
    --good-text: #0ca30c; --bad-text: #ec7e7e;
    --lv-allow: #0ca30c; --lv-allow-bg: #11260f;
    --lv-alerts: #db9300; --lv-alerts-bg: #311a00;
    --lv-deny: #c3c2b7; --lv-deny-bg: #2c2c2a; --lv-deny-line: #e66767;
    --lv-member: #0ca30c;
    --lv-admin: #0b0b0b; --lv-admin-bg: #f0efec;
    --grant: #a096eb; --grant-bg: #1d1649;
    --override: #6da7ec;
    --conflict: #ec835a; --conflict-bg: #371407;
    --unknown: #898781;
    --k-prod: #3987e5; --k-lp: #199e70; --k-pd: #9085e9; --k-pdlp: #d55181; --k-unk: #5f5e5a;
    --s-1: #3987e5; --s-2: #d95926; --s-3: #199e70; --s-4: #c98500;
    --s-5: #d55181; --s-6: #008300; --s-7: #9085e9; --s-8: #e66767;
    --st-muted: #5f5e5a;
    --q-0: #0d366b; --q-1: #184f95; --q-2: #256abf; --q-3: #3987e5; --q-4: #86b6ef; --q-z: #20201f;
    --lvl-1: #16243a; --lvl-2: #1a3253; --lvl-3: #1f4472;
    --grid: #2c2c2a; --axis: #383835; --hatch: rgba(11, 11, 11, .65); --hatch-conflict: #ec835a;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0b; --panel: #1a1a19; --text: #f0efec; --muted: #898781;
  --line: rgba(255, 255, 255, .1); --line-strong: rgba(255, 255, 255, .2);
  --accent: #f0efec; --accent-text: #0b0b0b; --link: #6da7ec;
  --ok-bg: #11260f; --ok: #0ca30c; --err-bg: #3c0e0e; --err: #ec7e7e; --warn-bg: #311a00; --warn: #db9300;
  --chip: #2c2c2a; --on: #0ca30c; --off: #ec7e7e;
  --panel-2: #151515; --hover: #20201f; --shadow: none;
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, .32), 0 2px 6px rgba(0, 0, 0, .2);
  --good-text: #0ca30c; --bad-text: #ec7e7e;
  --lv-allow: #0ca30c; --lv-allow-bg: #11260f;
  --lv-alerts: #db9300; --lv-alerts-bg: #311a00;
  --lv-deny: #c3c2b7; --lv-deny-bg: #2c2c2a; --lv-deny-line: #e66767;
  --lv-member: #0ca30c;
  --lv-admin: #0b0b0b; --lv-admin-bg: #f0efec;
  --grant: #a096eb; --grant-bg: #1d1649;
  --override: #6da7ec;
  --conflict: #ec835a; --conflict-bg: #371407;
  --unknown: #898781;
  --k-prod: #3987e5; --k-lp: #199e70; --k-pd: #9085e9; --k-pdlp: #d55181; --k-unk: #5f5e5a;
  --s-1: #3987e5; --s-2: #d95926; --s-3: #199e70; --s-4: #c98500;
  --s-5: #d55181; --s-6: #008300; --s-7: #9085e9; --s-8: #e66767;
  --st-muted: #5f5e5a;
  --q-0: #0d366b; --q-1: #184f95; --q-2: #256abf; --q-3: #3987e5; --q-4: #86b6ef; --q-z: #20201f;
  --lvl-1: #16243a; --lvl-2: #1a3253; --lvl-3: #1f4472;
  --grid: #2c2c2a; --axis: #383835; --hatch: rgba(11, 11, 11, .65); --hatch-conflict: #ec835a;
}

/* --- Основа --- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); overflow-x: hidden;
  font: 13px/1.4 "Anthropic Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font-size: 17px; line-height: 1.3; margin: 2px 0 8px; font-weight: 650; }
h2 { font-size: 14px; margin: 18px 0 6px; font-weight: 600; }
h3 { font-size: 13px; margin: 0 0 4px; font-weight: 600; }
p { margin: 6px 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
code, .id, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.id { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.name { font-weight: 500; overflow-wrap: anywhere; }
p.note, .muted { color: var(--muted); }
p.note { margin: 2px 0 10px; max-width: 900px; font-size: 12px; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
td.num { white-space: nowrap; }

/* --- Шапка --- */

.top { background: var(--panel); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 12px 16px; max-width: 1280px; margin: 0 auto; padding: 6px 16px 2px; }
.brand { display: inline-flex; align-items: baseline; gap: 6px; font-weight: 650; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .sub { font-weight: 400; color: var(--muted); }
.search { flex: 1; display: flex; justify-content: center; margin: 0; min-width: 0; }
.search-box { position: relative; display: block; width: 100%; max-width: 440px; }
.search-box input[type=search] { width: 100%; padding-left: 30px; background: var(--panel-2); }
.search-box .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.account { position: relative; margin-left: auto; }
.account > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px;
  border: 1px solid var(--line); border-radius: 6px; min-height: 30px; white-space: nowrap; max-width: 180px; overflow: hidden;
  text-overflow: ellipsis; }
.account > summary::-webkit-details-marker { display: none; }
.account > summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted); transform: rotate(45deg) translateY(-2px); margin-left: 2px; }
.account[open] > summary { background: var(--hover); }
.account .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 240px; padding: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-pop); }
.account .menu a, .account .menu .link { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px;
  color: var(--text); font-size: 14px; }
.account .menu a:hover, .account .menu .link:hover { background: var(--hover); text-decoration: none; }
.account .menu form { margin: 0; }
.theme-switch { padding: 4px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.theme-switch .label { display: block; font-size: 12px; color: var(--muted); margin: 0 6px 6px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; border: 0; border-radius: 0; min-height: 32px; font-size: 13px; background: transparent; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on, .seg button[aria-pressed="true"] { background: var(--chip); font-weight: 600; }
.sections { display: flex; gap: 2px; max-width: 1280px; margin: 0 auto; padding: 0 10px; overflow-x: auto;
  scrollbar-width: none; }
.sections::-webkit-scrollbar { display: none; }
.sections a { display: inline-flex; align-items: center; gap: 5px; padding: 6px 9px 7px; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap; }
.sections a:hover { color: var(--text); text-decoration: none; }
.sections a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; line-height: 18px;
  text-align: center; background: var(--warn-bg); color: var(--warn); font-weight: 600; font-variant-numeric: tabular-nums; }
.critbar { background: var(--err-bg); color: var(--err); border-bottom: 1px solid var(--line); }
.critbar div { max-width: 1280px; margin: 0 auto; padding: 8px 16px; font-weight: 500; }
.critbar a { color: inherit; text-decoration: underline; }
.badge { font-size: 11px; padding: 1px 8px; border-radius: 10px; margin-left: 6px; vertical-align: 1px; font-weight: 600; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* --- Сетка --- */

main { padding: 12px 16px 24px; max-width: 1280px; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; }
.page-head h1 { margin-bottom: 4px; }
.page-head > .hint { align-self: center; margin: 0 auto 0 -8px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; box-shadow: var(--shadow);
  margin: 0 0 12px; min-width: 0; }
.panel > h2:first-child { margin-top: 0; }
.panel > h2 { font-size: 13px; }
.panel .scroll { border: 0; border-radius: 0; box-shadow: none; margin: 0 -12px; }
.panel .scroll table th:first-child, .panel .scroll table td:first-child { padding-left: 12px; }
.scroll { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
  margin: 0 0 12px; }
.grid-2 { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.grid-2 > .side { order: -1; }
@media (min-width: 960px) {
  .grid-2 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .grid-2 > .side { order: 0; }
}
.cols { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; margin-bottom: 12px; }
.cards .panel { margin: 0; }
.cards .panel h3 { margin: 0 0 4px; font-size: 14px; }
.tiles { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 0 0 12px; }
.narrow { max-width: 440px; }
.stack label, .stack .label-like { display: block; margin: 10px 0 4px; color: var(--muted); }
.stack input, .stack select, .stack textarea { width: 100%; }
.stack button { margin-top: 14px; }
.row-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-form input[type=text] { flex: 1 1 260px; min-width: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }

/* --- Таблицы --- */

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid var(--line); }
thead th, tr:first-child > th { background: var(--panel-2); }
th { font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td, table tr:hover > td { background: var(--hover); }
th.sortable { cursor: pointer; user-select: none; }
th[aria-sort="ascending"]::after { content: " \2191"; }
th[aria-sort="descending"]::after { content: " \2193"; }
:target, tr:target > td { scroll-margin-top: 80px; }
tr:target > td { background: var(--warn-bg); }

/* --- Кнопки и поля --- */

button, .button { font: inherit; font-size: 12px; line-height: 1.2; padding: 5px 10px; min-height: 28px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
button:hover, .button:hover { border-color: var(--line-strong); text-decoration: none; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger:hover { border-color: var(--off); color: var(--off); }
button[disabled] { opacity: .45; cursor: default; border-color: var(--line); }
button.link { border: none; background: none; color: var(--link); padding: 0; min-height: 0; font-size: 12px; }
button.small, form.inline button { font-size: 12px; padding: 2px 8px; min-height: 24px; }
input[type=text], input[type=search], input[type=password], input[type=number], select, textarea { font: inherit;
  padding: 4px 8px; min-height: 28px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); max-width: 100%; }
textarea { min-height: 80px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); vertical-align: -3px; }
form.inline { display: inline-flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 0; }
@media (pointer: coarse) {
  button, .button, input[type=text], input[type=search], input[type=password], select { min-height: 40px; }
  button.small, form.inline button { min-height: 36px; }
}

/* --- Чипы и источник --- */

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 0 7px; border-radius: 999px; font-size: 11px;
  line-height: 17px; background: var(--chip); color: var(--text); border: 1px solid transparent; white-space: nowrap;
  font-weight: 500; }
.chip.big { font-size: 12px; padding: 0 8px; line-height: 19px; font-weight: 600; }
.chip .icon { width: 12px; height: 12px; }
.chip.lv-allow { color: var(--lv-allow); background: var(--lv-allow-bg); }
.chip.lv-alerts { color: var(--lv-alerts); background: var(--lv-alerts-bg); }
.chip.lv-deny { color: var(--lv-deny); background: var(--lv-deny-bg); border-color: var(--lv-deny-line); }
.chip.lv-member { color: var(--lv-member); background: transparent; border: 1px dashed var(--lv-member); }
.chip.lv-admin { color: var(--lv-admin); background: var(--lv-admin-bg); }
.chip.grant { color: var(--grant); background: var(--grant-bg); }
/* Моноширинный только у сегментов ключа (+pd, +lp): фразы с классом grant ("pd выдан (оверрайд)", "только по гранту")
   в моноширинном выглядят чужеродно. */
.key .chip.grant { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.chip.profile { background: var(--chip); }
.chip.off { color: var(--muted); background: transparent; border-color: var(--line); }
.chip.env { color: var(--muted); background: transparent; padding-left: 0; padding-right: 0; }
.chip.override { color: var(--override); background: transparent; border: 1px dashed var(--override); }
.chip.conflict { color: var(--conflict); background: var(--conflict-bg); }
.chip.conflict::before { content: "!"; font-weight: 700; }
.chip.unknown { color: var(--unknown); background: transparent; border: 1px dotted var(--unknown); }
.chip.st-crit, .chip.st-warn, .chip.st-info, .chip.st-good, .chip.st-serious { background: var(--chip); }
.chip.st-crit::before, .chip.st-warn::before, .chip.st-good::before, .chip.st-serious::before, .chip.st-info::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); }
.chip.st-crit { --c: var(--st-crit); color: var(--bad-text); }
.chip.st-warn { --c: var(--st-warn); }
.chip.st-serious { --c: var(--st-serious); }
.chip.st-good { --c: var(--st-good); }
.chip.st-info { --c: var(--link); }
.key { display: inline-flex; flex-wrap: nowrap; }
.key .chip { border-radius: 0; }
.key .chip:first-child { border-radius: 999px 0 0 999px; }
.key .chip:last-child { border-radius: 0 999px 999px 0; }
.key .chip:only-child { border-radius: 999px; }
.state { font-weight: 600; }
.state.on { color: var(--on); }
.state.off { color: var(--off); }
.src { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 10px; background: var(--chip);
  color: var(--muted); margin-left: 4px; white-space: nowrap; }
.source { display: grid; gap: 2px; justify-items: start; }
/* Источник значения (env и файл) -- в подсказке ячейки; на виду только отклонения: перекрывает .env, только файл,
   дубль записи. Обычное "только .env" и строка источников не показываются. */
.source .src-line, .source .src-tag.env, .source.locked .src-tag { display: none; }
.source .src-tag { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.source .src-tag.override { color: var(--override); border-bottom: 1px dashed var(--override); }
.source .src-tag.override::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--override); }
.source .src-tag.dup { color: var(--muted); }
.source .src-tag.file { color: var(--override); }
.source.locked .src-tag { color: var(--muted); }
.source form.inline { margin: 0; }

/* Подсказка "?" у заголовка: пояснение панели живет в title, а не в абзаце. */
.hint { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; margin-left: 6px;
  border-radius: 50%; border: 1px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 600;
  vertical-align: 2px; cursor: help; }
.hint:hover, .hint:focus-visible { border-color: var(--accent); color: var(--accent); }

/* --- Сообщения --- */

.flash { padding: 6px 10px; border-radius: 6px; margin: 0 0 10px; overflow-wrap: anywhere; font-size: 12px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.empty { color: var(--muted); margin: 8px 0; }
.failed { display: flex; align-items: center; gap: 6px; color: var(--warn); background: var(--warn-bg); padding: 8px 12px;
  border-radius: 8px; margin: 8px 0; }
.stub { color: var(--muted); }

/* --- Плитки --- */

.tile { display: grid; gap: 1px; align-content: start; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; color: var(--text); box-shadow: var(--shadow); min-width: 0; }
a.tile:hover { border-color: var(--line-strong); text-decoration: none; }
.tile-label { font-size: 11px; color: var(--muted); }
.tile-value { font-size: 18px; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.tile-sub { font-size: 11px; color: var(--muted); }
.tile .chart-spark { margin-top: 2px; }
.delta { font-size: 11px; font-weight: 600; padding: 0 5px; border-radius: 999px; background: var(--chip); color: var(--muted);
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.good { color: var(--good-text); }
.delta.bad { color: var(--bad-text); }
.delta.neu { color: var(--text); }

/* --- Фильтры, легенда, "Цифрами" --- */

.filters { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; }
.filters a { padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--text); font-size: 12px;
  background: var(--panel); white-space: nowrap; }
.filters a:hover { border-color: var(--line-strong); text-decoration: none; }
.filters a.on { background: var(--text); border-color: var(--text); color: var(--panel); }
.filters .n { color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }
.filters a.on .n { color: inherit; opacity: .75; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 2px 12px; padding: 0; margin: 6px 0 0; font-size: 11px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend a { color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.legend .share-value { color: var(--muted); font-variant-numeric: tabular-nums; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c, var(--muted)); flex: none; }
details.numbers { margin-top: 8px; }
details.numbers > summary, details.more > summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.numbers table { font-size: 12px; margin-top: 6px; }
details.numbers td, details.numbers th { padding: 4px 8px; }

/* --- Матрица --- */

.matrix { font-size: 12px; }
.matrix th, .matrix td { padding: 4px 7px; white-space: nowrap; }
.matrix thead th { position: sticky; top: 0; z-index: 2; }
.matrix tbody th { position: sticky; left: 0; z-index: 1; background: var(--panel); font-weight: 500; color: var(--text);
  font-size: 12px; }
.matrix thead th:first-child { left: 0; z-index: 3; }
.matrix td.cell { text-align: center; }
.matrix tr.group th { background: var(--panel-2); color: var(--muted); font-size: 12px; }
.matrix .lvl-1 { background: var(--lvl-1); }
.matrix .lvl-2 { background: var(--lvl-2); }
.matrix .lvl-3 { background: var(--lvl-3); }
.matrix .conflict, .matrix tr.conflict > th { background: var(--conflict-bg); color: var(--conflict); }
.matrix .sub { display: block; font-size: 11px; color: var(--muted); }

/* --- Трасса, последствия, очередь --- */

.trace .steps { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 4px; }
.trace .step { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid transparent; }
.trace .step.decisive { border-color: var(--accent); background: var(--hover); }
.trace .step.v-skip { color: var(--muted); }
.trace .step .detail { grid-column: 2; font-size: 12px; color: var(--muted); }
.trace .verdict { justify-self: start; }
.trace .sum { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.warnings { margin: 8px 0 0; padding-left: 18px; color: var(--warn); }
.impact { list-style: none; padding: 0; margin: 8px 0 12px; display: grid; gap: 6px; }
.impact li { display: flex; gap: 8px; align-items: baseline; padding: 6px 10px; border-radius: 6px; background: var(--panel-2);
  border-left: 3px solid var(--line); }
.impact li.sev-crit { border-left-color: var(--st-crit); }
.impact li.sev-warn { border-left-color: var(--st-warn); }
/* Очередь: одна строка на пункт -- точка важности, тип, заголовок, деталь в одну строку (целиком в подсказке),
   действия и время справа. Без рамок карточек: строки разделены линией. */
.attention { list-style: none; padding: 0; margin: 0; }
.att { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 2px 10px; align-items: center;
  padding: 5px 0; border-bottom: 1px solid var(--line); }
.att:last-child { border-bottom: 0; }
.att .bar { display: none; }
.att .att-main { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.att .att-head { display: flex; align-items: baseline; gap: 6px; flex: none; max-width: 70%; min-width: 0; }
.att .att-head b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .att-head .chip { flex: none; }
.att .att-head .chip:not([class*="st-"]) { background: none; color: var(--muted); padding: 0; }
/* Важность -- только точка: текст чипа остается для чтения с экрана. */
.att .att-head .chip[class*="st-"] { font-size: 0; gap: 0; padding: 0; background: none; line-height: 1; }
.att .att-detail { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0; }
.att .att-time { order: 3; color: var(--muted); font-size: 11px; white-space: nowrap; }
.att .att-actions { order: 2; display: flex; gap: 4px; align-items: center; justify-content: flex-end; }
.att .att-actions form { margin: 0; }
.att .att-actions a { font-size: 12px; padding: 0 4px; }
.att .att-actions button { min-height: 22px; padding: 1px 7px; font-size: 11px; }
@media (max-width: 760px) {
  .att { grid-template-columns: minmax(0, 1fr) auto; }
  .att .att-main { grid-column: 1 / -1; flex-wrap: wrap; }
  .att .att-head { max-width: 100%; }
  .att .att-head b { white-space: normal; }
  .att .att-actions { order: 2; justify-content: flex-start; flex-wrap: wrap; min-width: 0; }
  .att .att-time { align-self: start; padding-top: 3px; }
}

/* --- Копирование, diff, иконки --- */

.copy { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.copy code { overflow-wrap: anywhere; }
.icon-btn { min-height: 26px; padding: 3px 6px; color: var(--muted); }
.icon-btn.copied { color: var(--ok); border-color: var(--ok); }
.icon { width: 14px; height: 14px; flex: none; vertical-align: -2px; }
pre.diff { font-size: 12px; line-height: 1.5; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 0; overflow-x: auto; margin: 8px 0; }
pre.diff span { display: block; padding: 0 12px; white-space: pre; }
pre.diff .d-add { background: var(--ok-bg); color: var(--ok); }
pre.diff .d-del { background: var(--err-bg); color: var(--err); }
pre.diff .d-hunk { color: var(--muted); }

/* --- Графики --- */

.chart { display: block; width: 100%; height: auto; max-width: 760px; overflow: visible; }
.chart-spark, .chart-minibar { display: inline-block; width: auto; max-width: none; vertical-align: middle; }
.chart-flow.vertical { max-width: 420px; }
.chart text { font-size: 12px; fill: var(--muted); }
.chart .label { fill: var(--text); }
.chart .value { fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .tick, .chart .label { paint-order: stroke; stroke: var(--panel); stroke-width: 3px; stroke-linejoin: round; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .mark { fill: var(--c, var(--s-1)); stroke: var(--panel); stroke-width: 1px; }
.chart .hit { fill: transparent; }
.chart .hatch { pointer-events: none; stroke: none; }
.chart .partial .mark { fill-opacity: .55; }
.chart .day.hl .mark, .chart .mark.hl { stroke: var(--text); stroke-width: 1.5px; }
.chart .day.hl .hit { fill: var(--hover); }
.chart .line { fill: none; stroke: var(--c, var(--s-1)); stroke-width: 2px; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.partial { stroke-dasharray: 3 3; }
.chart .dot { stroke: var(--panel); stroke-width: 1.5px; }
.chart .dot.hl { stroke: var(--text); }
.chart-spark .last { stroke: var(--panel); stroke-width: 1px; }
.chart .bar-bg { fill: var(--chip); }
.chart .part { fill: var(--text); fill-opacity: .45; pointer-events: none; stroke: none; }
.chart .link { stroke: var(--c, var(--s-1)); stroke-opacity: .32; }
.chart a:hover .link, .chart .link:hover { stroke-opacity: .55; }
.chart .node { stroke: none; }
.chart a:hover .mark { fill-opacity: .85; }
.chart .cell { stroke: none; }
.chart .q-0 { fill: var(--q-0); } .chart .q-1 { fill: var(--q-1); } .chart .q-2 { fill: var(--q-2); }
.chart .q-3 { fill: var(--q-3); } .chart .q-4 { fill: var(--q-4); } .chart .q-z { fill: var(--q-z); }
.chart-share { height: 16px; max-width: none; border-radius: 4px; }
.chart-share .mark { stroke-width: 2px; vector-effect: non-scaling-stroke; }
.share { margin: 4px 0 12px; }
.chart-caption { min-height: 1.45em; margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.hatch-line { stroke: var(--hatch); stroke-width: 2; }
.hatch-conflict-line { stroke: var(--hatch-conflict); stroke-width: 2; }
svg.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Ряды: класс задает цвет через --c; графики, образцы легенды и полосы берут его. */
.k-prod { --c: var(--k-prod); } .k-lp { --c: var(--k-lp); } .k-pd { --c: var(--k-pd); }
.k-pdlp { --c: var(--k-pdlp); } .k-unk { --c: var(--k-unk); }
.s-1 { --c: var(--s-1); } .s-2 { --c: var(--s-2); } .s-3 { --c: var(--s-3); } .s-4 { --c: var(--s-4); }
.s-5 { --c: var(--s-5); } .s-6 { --c: var(--s-6); } .s-7 { --c: var(--s-7); } .s-8 { --c: var(--s-8); }
.st-good { --c: var(--st-good); } .st-warn { --c: var(--st-warn); } .st-serious { --c: var(--st-serious); }
.st-crit { --c: var(--st-crit); } .st-muted { --c: var(--st-muted); }
.chart .lv-allow, .sw.lv-allow { --c: var(--lv-allow); } .chart .lv-alerts, .sw.lv-alerts { --c: var(--s-4); }
.chart .lv-deny, .sw.lv-deny { --c: var(--st-muted); } .chart .lv-member, .sw.lv-member { --c: var(--s-3); }
.chart .lv-admin, .sw.lv-admin { --c: var(--lv-admin-bg); } .chart .grant, .sw.grant { --c: var(--k-pd); }
.chart .override, .sw.override { --c: var(--override); } .chart .conflict, .sw.conflict { --c: var(--conflict); }
.chart .unknown, .sw.unknown { --c: var(--k-unk); }

/* --- Общие классы страниц: раньше повторялись в стилях нескольких разделов --- */

.nowrap { white-space: nowrap; }
/* Длинные значения без пробелов (FQN, тексты ошибок) переносятся где угодно, чипы рядом не сжимаются. */
.wrap, .wrap span:not(.chip) { overflow-wrap: anywhere; min-width: 0; }
.wrap .chip { flex: none; }
.crumbs { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
/* Шапка панели: заголовок слева, ссылка или переключатель периода справа. */
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px;
  margin: 0 0 10px; }
.panel-head h2 { margin: 0; }
.panel-head > a { font-size: 13px; white-space: nowrap; }
.panel-head .filters { margin: 0; }
.shown { font-size: 12px; margin: 0 0 6px; }
.warn-line { display: flex; gap: 6px; align-items: baseline; color: var(--warn); font-size: 13px; }
.warn-line .icon { flex: none; align-self: flex-start; margin-top: 2px; }
details.more { margin: 8px 0 16px; }
details.more > summary ~ * { margin-top: 8px; }
/* Образцы легенды уровней прав (матрица Snowflake): чтение, запись или передача, владение. */
.sw.lvl-1 { --c: var(--lvl-1); } .sw.lvl-2 { --c: var(--lvl-2); } .sw.lvl-3 { --c: var(--lvl-3); }
.sw.lvl-1, .sw.lvl-2, .sw.lvl-3 { border: 1px solid var(--line); }

/* --- С JS и без --- */

html.js .nojs-only, html.nojs .js-only { display: none !important; }
.only-narrow { display: none; }
@media (max-width: 640px) { .only-wide { display: none; } .only-narrow { display: block; } }

/* Вкладки: без JS -- раскрывающиеся блоки. */
.tabbar { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 10px; overflow-x: auto; }
.tabbar .tab { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); }
.tabbar .tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs-on > details > summary { display: none; }
.tabs-on > details:not(.tab-on) { display: none; }

/* Сворачиваемая панель: заголовок в summary, стрелка слева; открытая -- как обычная панель. */
details.panel.fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.panel.fold > summary::-webkit-details-marker { display: none; }
details.panel.fold > summary::before { content: ""; flex: none; width: 6px; height: 6px; border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); }
details.panel.fold[open] > summary::before { transform: rotate(45deg); }
details.panel.fold > summary h2 { margin: 0; }
details.panel.fold[open] > summary { margin-bottom: 8px; }
.head-links { margin: -4px 0 10px; font-size: 12px; }
.filters.jump { margin: 0; }

/* Пакетная панель: липнет к низу, когда что-то отмечено. */
.batch { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 10px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; }
.batch.has-checked { position: sticky; bottom: 8px; z-index: 5; box-shadow: var(--shadow-pop);
  border-color: var(--accent); }

/* --- Отдельные страницы каркаса --- */

.login { max-width: 380px; margin: 10vh auto; }
.login label { display: block; margin: 10px 0 4px; color: var(--muted); }
.login input { width: 100%; }
.login button { margin-top: 16px; width: 100%; font-size: 14px; }
.confirm .note-field label { display: block; margin: 12px 0 4px; font-weight: 600; }
.confirm .note-field textarea { width: 100%; font-family: inherit; min-height: 72px; }
.check-row { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0; }
.check-row label { display: inline-flex; gap: 6px; align-items: center; }

/* --- Телефон --- */

@media (max-width: 760px) {
  .top-row { flex-wrap: wrap; padding: 8px 12px 4px; }
  .search { order: 3; flex-basis: 100%; }
  .search-box { max-width: none; }
  .sections { padding: 0 6px; }
}
@media (max-width: 640px) {
  main { padding: 12px; }
  h1 { font-size: 18px; }
  .panel { padding: 12px; }
  .panel .scroll { margin: 0 -12px; }
  .panel .scroll table th:first-child, .panel .scroll table td:first-child { padding-left: 12px; }
  th, td { padding: 7px 8px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile-value { font-size: 19px; }
  .chart text { font-size: 22px; }
  .chart-flow.vertical text, .chart-spark text { font-size: 12px; }
  .account > summary { max-width: 140px; }
  /* Таблицы-карточки: строка становится карточкой, подпись колонки из data-label. */
  table.cards-sm, .cards-sm tbody, .cards-sm tr, .cards-sm td { display: block; width: 100%; }
  .cards-sm thead, .cards-sm tr.head { display: none; }
  .cards-sm tr { border-bottom: 1px solid var(--line); padding: 8px 12px; }
  .cards-sm tr:last-child { border-bottom: 0; }
  .cards-sm td { border: 0; padding: 4px 0; }
  .cards-sm td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted);
    font-weight: 600; margin-bottom: 1px; }
  .cards-sm td:first-child::before { display: none; }
  .cards-sm td.num[data-label] { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
  .cards-sm td.num[data-label]::before { display: inline; margin: 0; }
  .panel .scroll .cards-sm td:first-child, .scroll .cards-sm td:first-child { padding-left: 0; }
  .cards-sm tbody tr:hover td, .cards-sm tr:hover > td { background: none; }
}
