/* Панель и страница политики. Палитра — та же, что в приложении: Material 3 из синего
   #2F6FDB (HCT), голубая страница и белые карточки, все пары текст/фон ≥ 4.5:1 (WCAG AA).
   Насыщенный синий — шапка и главное действие; оранжевый/красный/зелёный — только статусы. */
:root {
  --bg: #eef4ff;
  --surface: #ffffff;
  --surface-2: #e0e9f7;
  --border: #b5c8e1;
  --text: #141c26;
  --muted: #36485d;
  --accent: #0056be;
  --accent-soft: #dde9ff;
  --on-accent: #ffffff;
  --accent-strong: #0056be;
  --on-accent-strong: #ffffff;
  --ok: #006c53;
  --warn: #895200;
  --bad: #ba1a1a;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b141e;
    --surface: #18202a;
    --surface-2: #222b35;
    --border: #36485d;
    --text: #dae3f1;
    --muted: #b5c8e1;
    --accent: #afc6ff;
    --accent-soft: #003c70;
    --on-accent: #002d6c;
    --accent-strong: #002d56;
    --on-accent-strong: #dde9ff;
    --ok: #6edab6;
    --warn: #ffb86a;
    --bad: #ffb4ab;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 13px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--surface-2);
  padding: 1px 5px; border-radius: 4px; }
h1 { font-size: 26px; line-height: 1.25; margin: 8px 0 6px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; color: var(--accent); }
h3 { font-size: 16px; margin: 0; font-weight: 600; }
.lead { color: var(--muted); max-width: 70ch; margin: 0 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.spaced { margin-top: 20px; }

/* Шапка — фирменный синий, как верхняя панель приложения; текст на ней ≥ 4.5:1 */
.top { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px; background: var(--accent-strong); color: var(--on-accent-strong);
  box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.brand { color: inherit; font-weight: 700; white-space: nowrap; letter-spacing: .01em; }
.top nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.top nav::-webkit-scrollbar { display: none; }
.top nav a { color: inherit; padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
.top nav a:hover { background: rgb(255 255 255 / .14); text-decoration: none; }
.top nav a[aria-current] { background: rgb(255 255 255 / .24); font-weight: 600; }
.top a:focus-visible, .top button:focus-visible { outline-color: var(--on-accent-strong); }
.top button.link { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.who { margin-left: auto; display: flex; gap: 12px; align-items: center; color: inherit; white-space: nowrap; }

main { max-width: 1120px; margin: 0 auto; padding: 24px; }
main.narrow { max-width: 720px; padding-top: 48px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 + .card, .grid2 + section { margin-top: 16px; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
/* Главная цифра (первая плитка) — на насыщенном синем, чтобы взгляд начинал с неё */
.tiles .tile:first-child { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent-strong); }
.tiles .tile:first-child .label, .tiles .tile:first-child .hint { color: inherit; opacity: .92; }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .hint { color: var(--muted); font-size: 12.5px; min-height: 1em; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; }
th, td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.pill { display: inline-block; font-size: 12.5px; padding: 2px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.pill.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }

progress.meter { appearance: none; width: 100%; height: 10px; border: 0; border-radius: 999px;
  background: var(--surface-2); overflow: hidden; margin: 4px 0 10px; }
progress.meter::-webkit-progress-bar { background: var(--surface-2); }
progress.meter::-webkit-progress-value { background: var(--ok); border-radius: 999px; }
progress.meter::-moz-progress-bar { background: var(--ok); border-radius: 999px; }
progress.meter.warn::-webkit-progress-value { background: var(--warn); }
progress.meter.warn::-moz-progress-bar { background: var(--warn); }
progress.meter.bad::-webkit-progress-value { background: var(--bad); }
progress.meter.bad::-moz-progress-bar { background: var(--bad); }

.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--accent); opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart .bar.over { fill: var(--bad); }
.chart .guide { stroke: var(--muted); stroke-dasharray: 4 4; stroke-width: 1; }
.chart .guide-label, .chart .axis { fill: var(--muted); font-size: 11px; }

form.inline { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
form.stack { display: grid; gap: 12px; }
form.limits { display: grid; grid-template-columns: repeat(5, 1fr) auto; gap: 10px; align-items: end; margin-top: 14px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { display: inline-flex; gap: 4px; align-items: center; }
input { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; min-width: 0; min-height: 40px; }
input:hover, form.filters select:hover { border-color: var(--muted); }
input:focus, form.filters select:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); outline: none; }
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Кнопки: высота 40px (удобно и мышью, и пальцем), состояния — слоем поверх цвета, как в Material 3 */
button { font: inherit; font-weight: 550; color: var(--on-accent); background: var(--accent); border: 0; border-radius: 999px;
  padding: 8px 18px; cursor: pointer; min-height: 40px; transition: background-color .15s, box-shadow .15s; }
button:hover { background: color-mix(in srgb, var(--accent) 92%, var(--on-accent)); box-shadow: 0 1px 2px rgb(0 0 0 / .18); }
button:active { background: color-mix(in srgb, var(--accent) 88%, var(--on-accent)); box-shadow: none; }
button:disabled { opacity: .45; cursor: default; box-shadow: none; }
button.secondary { color: var(--accent); background: var(--accent-soft); }
button.secondary:hover { background: color-mix(in srgb, var(--accent-soft) 88%, var(--accent)); }
button.danger { color: var(--surface); background: var(--bad); }
button.danger:hover { background: color-mix(in srgb, var(--bad) 90%, var(--text)); }
button.link, button.link:hover, button.link:active { background: none; color: var(--accent); padding: 0; min-height: 0;
  font-weight: 500; box-shadow: none; }
button.link:hover { text-decoration: underline; }
button.link.danger { color: var(--bad); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.user h3 + .muted { margin-top: 2px; }

details { border-top: 1px solid var(--border); padding: 10px 0; }
details:first-of-type { border-top: 0; }
summary { cursor: pointer; font-weight: 550; }
ul.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }

.flash { background: var(--accent-soft); color: var(--text); padding: 10px 14px; border-radius: 8px; }
.error { color: var(--bad); }
.callout { background: var(--accent-soft); border-left: 3px solid var(--accent); padding: 12px 14px;
  border-radius: 6px; margin: 12px 0; }
code.copy { display: block; margin-top: 6px; padding: 8px; word-break: break-all; user-select: all; }

.login { max-width: 420px; margin: 48px auto; }
.login form { display: grid; gap: 10px; margin-top: 16px; }
.login input { font: 18px/1.3 ui-monospace, Consolas, monospace; letter-spacing: .06em; text-align: center; }

/* Конспект в «Материалах» — тот же рендер, что в приложении */
.note h1, .note h2, .note h3 { margin-top: 1.2em; }
.note .properties { font-size: 13px; margin-bottom: 16px; }
.note .properties th { width: 140px; }
.note .callout-title { font-weight: 600; margin-bottom: 4px; }
.note div.callout, .note details.callout { background: var(--accent-soft); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 6px; margin: 12px 0; }
.note .math { font-family: ui-monospace, Consolas, monospace; background: var(--surface-2); padding: 0 4px; border-radius: 4px; }
.note .math.block { display: block; padding: 10px; margin: 10px 0; overflow-x: auto; }
.note pre { background: var(--surface-2); padding: 12px; border-radius: 8px; overflow-x: auto; }
.note .tag { background: var(--accent-soft); padding: 0 6px; border-radius: 999px; font-size: 13px; }
.note .unresolved { opacity: .6; }
.note li.task { list-style: none; margin-left: -1.2em; }
.note .checkbox { display: inline-block; width: 14px; height: 14px; border: 1.5px solid var(--muted);
  border-radius: 4px; margin-right: 8px; vertical-align: -2px; }
.note .task.done .checkbox { background: var(--accent); border-color: var(--accent); }
.note .task.done .task-text { color: var(--muted); text-decoration: line-through; }
.note mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; }
.note img { max-width: 100%; }
.table-wrap { overflow-x: auto; }

/* Страница политики */
main.narrow h1 { font-size: 30px; }
main.narrow h2 { font-size: 18px; margin-top: 28px; }
main.narrow p { max-width: 68ch; }

@media (max-width: 860px) {
  .grid2, .tiles { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  form.limits { grid-template-columns: 1fr 1fr; }
  .top { gap: 12px; padding: 0 16px; }
  button { min-height: 44px; }
  .who span { display: none; }
  main { padding: 16px; }
}
@media (max-width: 520px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile .value { font-size: 21px; }
  .brand { display: none; }
}

/* Фильтр материалов */
form.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 0 0 16px; }
form.filters select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; min-width: 160px; max-width: 320px; }

/* Формулы — читаемый текст, а не код; Dataview — таблицы и задачи как в Obsidian */
.note .math { font-family: "Cambria Math", "STIX Two Math", Georgia, serif; font-style: italic; background: none; padding: 0; }
.note .math.block { text-align: center; font-size: 1.1em; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 .12em; line-height: 1.2; }
.frac > .num { border-bottom: 1px solid currentColor; padding: 0 .2em .05em; }
.frac > .den { padding: .05em .2em 0; }
.frac > .bar { display: none; }
.sqrt > .rad { border-top: 1px solid currentColor; padding: 0 .1em; }
.over { text-decoration: overline; }
.eq-no { float: right; font-style: normal; color: var(--muted); }
.note .dataview { margin: 8px 0 16px; }
.note .dv-empty, .note .dv-src { color: var(--muted); font-size: .9em; }

/* Без анимаций для тех, кто отключил их в системе */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
