/* Лайв-помощник. Без сборки: один файл, тема — по системной настройке.
   Цвет в интерфейсе означает состояние (можно / осторожно / стоп); акцент — только действие и текущий раздел. */
:root {
  color-scheme: light dark;
  /* нейтральные: едва холодные, оттенок — к акценту */
  --bg: oklch(0.972 0.004 262);
  --surface: #ffffff; /* графики проверены на этой подложке */
  --sunken: oklch(0.957 0.006 262);
  --ink: oklch(0.24 0.02 262);
  --ink-2: oklch(0.41 0.02 262);
  --muted: oklch(0.5 0.018 262);
  --line: oklch(0.905 0.006 262);
  --line-strong: oklch(0.8 0.012 262);
  --accent: oklch(0.47 0.19 264); /* цвет значка приложения */
  --accent-hover: oklch(0.41 0.19 264);
  --on-accent: #ffffff;
  --accent-soft: oklch(0.95 0.028 264);
  --ok: oklch(0.45 0.12 152); --ok-bg: oklch(0.955 0.04 152); --ok-solid: oklch(0.62 0.16 152);
  --warn: oklch(0.45 0.1 68); --warn-bg: oklch(0.955 0.055 90); --warn-solid: oklch(0.77 0.15 78);
  --bad: oklch(0.5 0.18 27); --bad-bg: oklch(0.957 0.028 25); --bad-solid: oklch(0.58 0.2 27);
  --info: var(--ink-2); --info-bg: var(--sunken);
  --shadow: 0 1px 2px oklch(0.24 0.02 262 / 0.05);
  --shadow-pop: 0 10px 32px oklch(0.24 0.02 262 / 0.18);

  --radius: 14px; --radius-sm: 9px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --gap: var(--s4);
  --side: 236px;
  --control: 40px;
  --z-sticky: 10; --z-nav: 20; --z-menu: 30; --z-banner: 100;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* цвета рядов на графиках: проверенная палитра, порядок менять нельзя */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
  --chart-axis: #c3c7cd;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101317;
    --surface: #191d23; /* графики проверены на этой подложке */
    --sunken: oklch(0.265 0.012 262);
    --ink: oklch(0.93 0.008 262);
    --ink-2: oklch(0.8 0.012 262);
    --muted: oklch(0.7 0.014 262);
    --line: oklch(0.31 0.014 262);
    --line-strong: oklch(0.42 0.016 262);
    --accent: oklch(0.76 0.12 264);
    --accent-hover: oklch(0.83 0.1 264);
    --on-accent: oklch(0.2 0.05 264);
    --accent-soft: oklch(0.31 0.06 264);
    --ok: oklch(0.82 0.15 152); --ok-bg: oklch(0.3 0.05 152); --ok-solid: oklch(0.7 0.16 152);
    --warn: oklch(0.86 0.12 85); --warn-bg: oklch(0.32 0.05 80); --warn-solid: oklch(0.79 0.14 80);
    --bad: oklch(0.8 0.12 25); --bad-bg: oklch(0.31 0.06 25); --bad-solid: oklch(0.66 0.19 25);
    --shadow: none;
    --shadow-pop: 0 10px 32px oklch(0 0 0 / 0.5);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --chart-axis: #3a414c;
  }
}

/* --- основа ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: var(--s5); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 0.9375rem/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "SF Pro Text", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; text-underline-offset: 0.18em; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.012em; text-wrap: balance; }
h1 { font-size: 1.5rem; line-height: 1.2; }
h2 { font-size: 1.0625rem; line-height: 1.3; }
h3 { font-size: 0.9375rem; line-height: 1.35; margin: var(--s5) 0 var(--s2); }
h2 a, h3 a { color: inherit; }
p { margin: 0 0 var(--s3); }
p:last-child { margin-bottom: 0; }
small, .muted { color: var(--muted); }
small { font-size: 0.8125rem; }
b, strong { font-weight: 650; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--ok); } .neg { color: var(--bad); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.skip { position: absolute; left: var(--s3); top: -60px; z-index: var(--z-banner); padding: var(--s2) var(--s3); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.skip:focus { top: var(--s3); }

/* --- каркас: меню слева, на телефоне — панель внизу ----------------------------- */
body:not(.bare) { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100dvh; }
.side {
  position: sticky; top: 0; align-self: start; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--s5); padding: var(--s5) var(--s3);
  background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 var(--s2); font-weight: 650; font-size: 1rem; color: var(--ink); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 6px; }
.side-nav { display: flex; flex-direction: column; gap: var(--s4); }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-title { padding: 0 var(--s2) var(--s1); font-size: 0.75rem; color: var(--muted); }
.side-nav a {
  display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 var(--s2);
  border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 500;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.side-nav a:hover { background: var(--sunken); color: var(--ink); text-decoration: none; }
.side-nav a.on { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.side-nav a.on .icon { color: var(--accent); }
main { width: 100%; max-width: 1120px; margin: 0 auto; padding: var(--s6) var(--s6) var(--s7); min-width: 0; }
body.bare main { max-width: none; padding: var(--s4); }
.tabbar { display: none; }

@media (max-width: 899px) {
  body:not(.bare) { display: block; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; padding: var(--s3) var(--s4); border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .side-nav { display: none; }
  main { padding: var(--s4) var(--s4) calc(88px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-nav);
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar > a, .tabbar summary {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px;
    font-size: 0.6875rem; font-weight: 500; color: var(--muted); cursor: pointer; list-style: none; user-select: none;
  }
  .tabbar > a:hover { text-decoration: none; }
  .tabbar .icon { width: 22px; height: 22px; }
  .tabbar summary::-webkit-details-marker { display: none; }
  .tabbar > a.on, .tabbar details.on > summary, .tabbar details[open] > summary { color: var(--accent); font-weight: 650; }
  .tabbar details { position: relative; }
  .tabbar .more-menu {
    position: absolute; right: var(--s2); bottom: calc(100% + var(--s2)); z-index: var(--z-menu); min-width: 220px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: var(--s2);
  }
  .tabbar .more-menu a { display: flex; align-items: center; gap: var(--s3); min-height: 46px; padding: 0 var(--s3); color: var(--ink); border-radius: var(--radius-sm); font-size: 0.9375rem; }
  .tabbar .more-menu a:hover { text-decoration: none; background: var(--sunken); }
  .tabbar .more-menu a.on { background: var(--accent-soft); font-weight: 600; }
  .tabbar .more-menu .icon { width: 20px; height: 20px; color: var(--ink-2); }
}

/* --- страница ------------------------------------------------------------------ */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s3) var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-head .sub { margin: var(--s1) 0 0; color: var(--muted); }
.page-head .row { gap: var(--s2); }
main > h1 { margin-bottom: var(--s5); }
.lead { max-width: 72ch; color: var(--ink-2); margin-bottom: var(--s5); text-wrap: pretty; }
.section-title { display: flex; align-items: baseline; gap: var(--s2); margin: var(--s6) 0 var(--s3); }
.section-title .count { font-size: 0.8125rem; font-weight: 500; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s5); margin-bottom: var(--gap); box-shadow: var(--shadow); }
.card > h2:first-child, .card-head { margin-bottom: var(--s3); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card > .muted, .card > p.muted { max-width: 78ch; }
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }
.grid { margin-bottom: var(--gap); }
.grid > .card { margin-bottom: 0; }
.row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: var(--s3); }
.note { color: var(--muted); font-size: 0.8125rem; max-width: 80ch; margin-top: var(--s3); }
@media (max-width: 899px) { .card { padding: var(--s4); } .grid { grid-template-columns: 1fr; } }

/* --- значки состояния ----------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 550; line-height: 1.5; background: var(--sunken); color: var(--ink-2); white-space: nowrap; }
.badge.st-working, .badge.r-win { background: var(--ok-bg); color: var(--ok); }
.badge.st-warmup { background: var(--accent-soft); color: var(--accent); }
.badge.st-suspected, .badge.r-pending { background: var(--warn-bg); color: var(--warn); }
.badge.st-cut, .badge.r-loss { background: var(--bad-bg); color: var(--bad); }
/* светофор конторы: цвет дублируется словом */
.light { display: inline-flex; align-items: center; gap: 7px; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; color: var(--ok); }
.light::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--ok-solid); flex: none; }
.light.warn { color: var(--warn); } .light.warn::before { background: var(--warn-solid); }
.light.block { color: var(--bad); } .light.block::before { background: var(--bad-solid); }
.light.off { color: var(--muted); } .light.off::before { background: var(--line-strong); }

/* --- цифры ---------------------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(156px, 1fr)); gap: var(--s4) var(--s5); }
.tile { min-width: 0; }
.tile .k { color: var(--muted); font-size: 0.8125rem; line-height: 1.35; }
.tile .v { margin-top: 2px; font-size: 1.375rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.015em; line-height: 1.25; }
.tile .v small { font-weight: 500; letter-spacing: 0; }
.tile > small { display: block; margin-top: 2px; }
.tiles.lead-first .tile:first-child .v { font-size: 1.875rem; }
@media (max-width: 640px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
  .tiles.lead-first .tile:first-child { grid-column: 1 / -1; }
  .tile .v { font-size: 1.25rem; }
}

.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s2) var(--s4); margin: var(--s3) 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv dd small { font-variant-numeric: normal; }

.meters { display: grid; gap: var(--s3); margin: var(--s4) 0 0; }
.meter-line { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.meter-line .k { color: var(--ink-2); }
.meter-line .v { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.meter-line .v small { font-weight: 400; }
.meter > small { display: block; margin-top: 2px; }
.bar { height: 6px; border-radius: 999px; background: var(--sunken); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--ok-solid); }
.bar.warn > i { background: var(--warn-solid); } .bar.block > i { background: var(--bad-solid); }
.bar.plain > i { background: var(--line-strong); }

/* --- карточка конторы на «Сегодня» ------------------------------------------------- */
.bk-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.bk-head h3 { margin: 0 0 var(--s1); font-size: 1.0625rem; }
.bk-figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); margin-top: var(--s4); padding: var(--s3) 0; border-block: 1px solid var(--line); }
.bk-figures .k { display: block; color: var(--muted); font-size: 0.75rem; }
.bk-figures .v { display: block; font-size: 1.0625rem; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bk-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s4); }

/* --- сообщения и проверки ------------------------------------------------------- */
.flash, .callout { border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: var(--gap); background: var(--ok-bg); color: var(--ok); max-width: 90ch; }
.flash.flash-error, .callout.bad { background: var(--bad-bg); color: var(--bad); }
.callout.warn { background: var(--warn-bg); color: var(--warn); }
.callout.info { background: var(--info-bg); color: var(--info); }
.callout a, .flash a { color: inherit; text-decoration: underline; }
.card > .callout:last-child { margin-bottom: 0; }
.checks { list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; gap: var(--s1); }
.checks li { position: relative; padding: 7px 12px 7px 34px; border-radius: var(--radius-sm); font-size: 0.875rem; line-height: 1.45; background: var(--info-bg); color: var(--info); }
.checks li::before { content: "i"; position: absolute; left: 11px; top: 7px; width: 14px; text-align: center; font-weight: 700; }
.checks li.ok { background: var(--ok-bg); color: var(--ok); } .checks li.ok::before { content: "✓"; }
.checks li.warn { background: var(--warn-bg); color: var(--warn); } .checks li.warn::before { content: "!"; }
.checks li.block { background: var(--bad-bg); color: var(--bad); font-weight: 600; } .checks li.block::before { content: "✕"; }

/* --- формы ---------------------------------------------------------------------- */
label { display: block; font-size: 0.8125rem; color: var(--ink-2); margin-bottom: var(--s1); }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; min-height: var(--control); padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 1rem;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
textarea { min-height: 76px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; margin: 0; }
input[type=file]::file-selector-button { margin-right: var(--s3); padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
input[type=file] { width: 100%; padding: 10px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; }
.fields { display: grid; gap: var(--s3) var(--s4); grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
.fields.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fields.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 640px) { .fields.cols-3, .fields.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.field-inline { display: flex; align-items: center; gap: var(--s2); min-height: var(--control); }
.field-inline label { margin: 0; font-size: 0.9375rem; color: var(--ink); }
.form-actions { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s4); }
.filters { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: end; margin-bottom: var(--gap); }
.filters > div { flex: 1 1 150px; max-width: 220px; }
@media (max-width: 640px) {
  /* на телефоне фильтры — одна строка с прокруткой вбок, чтобы не отодвигать список */
  .filters { flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(-1 * var(--s4)); padding: 0 var(--s4) var(--s1); scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .filters > div { flex: 0 0 148px; }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--control); padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; list-style: none; white-space: nowrap;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.btn:hover { text-decoration: none; background: var(--sunken); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.quiet:hover { background: var(--sunken); color: var(--ink); }
.btn.danger { color: var(--bad); border-color: color-mix(in oklch, var(--bad) 45%, var(--surface)); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.danger.solid { background: var(--bad-solid); border-color: var(--bad-solid); color: #fff; }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 48px; font-size: 1rem; }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 0.8125rem; font-weight: 550; }
.btn.win { color: var(--ok); } .btn.loss { color: var(--bad); }
.btn.win:hover { background: var(--ok-bg); } .btn.loss:hover { background: var(--bad-bg); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
@media (pointer: coarse) { :root { --control: 46px; } .btn.sm { min-height: 38px; } }

details > summary { cursor: pointer; }
summary.btn::-webkit-details-marker { display: none; }
details.plain > summary { display: inline-flex; align-items: center; gap: 6px; padding: var(--s2) 0; color: var(--accent); font-weight: 550; list-style: none; }
details.plain > summary::-webkit-details-marker { display: none; }
details.plain > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 0.15s var(--ease); margin-right: 2px; }
details.plain[open] > summary::before { transform: rotate(45deg) translate(-2px, -2px); }
details.plain > summary b { color: var(--ink); }
details.box { border-top: 1px solid var(--line); margin-top: var(--s4); padding-top: var(--s2); }
/* группы правил в настройках: плотный список с волосяными разделителями */
form.stack > details.plain { margin-top: 0; border-top: 1px solid var(--line); }
form.stack > details.plain:first-of-type { border-top: 0; }
form.stack > details.plain > summary { padding: var(--s3) 0; }

/* --- таблицы -------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--s5)); padding: 0 var(--s5); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { padding: 9px var(--s2); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th:first-child, td:first-child { padding-left: 0; } th:last-child, td:last-child { padding-right: 0; }
th { color: var(--muted); font-weight: 500; font-size: 0.75rem; white-space: nowrap; vertical-align: bottom; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.date { white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
td .sub { display: block; color: var(--muted); font-size: 0.8125rem; margin-top: 1px; }
td .sub.neg { color: var(--bad); } td .sub.pos { color: var(--ok); }
td b a, td a.plain { color: var(--ink); }
.actions { display: flex; gap: var(--s1); flex-wrap: wrap; justify-content: flex-end; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line-strong); border-bottom: 0; }
.card.flush { padding-bottom: var(--s2); }
@media (max-width: 899px) { .table-wrap { margin: 0 calc(-1 * var(--s4)); padding: 0 var(--s4); } }
@media (max-width: 560px) { .hide-sm { display: none !important; } th, td { padding: 9px 5px; } }

/* --- настройки -------------------------------------------------------------------- */
.rules { display: grid; gap: var(--s3) var(--s5); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin: var(--s2) 0 var(--s4); }
.rule { display: grid; grid-template-columns: minmax(0, 1fr) 128px; gap: var(--s3); align-items: center; }
.rule label { margin: 0; color: var(--ink); font-size: 0.875rem; }
.rule label .sub { display: block; color: var(--muted); font-size: 0.75rem; }
.rule-input { display: flex; align-items: center; gap: 6px; }
.rule-input input { text-align: right; font-variant-numeric: tabular-nums; }
.rule:has(select) { grid-template-columns: 1fr; }
.unit { color: var(--muted); min-width: 14px; }
table.schedule input { min-width: 68px; min-height: 36px; padding: 6px 8px; text-align: right; }
table.schedule td { vertical-align: middle; }

/* --- текст стратегии ---------------------------------------------------------------- */
.md { line-height: 1.6; overflow-wrap: anywhere; max-width: 78ch; }
.md h1 { font-size: 1.25rem; margin: var(--s5) 0 var(--s2); }
.md h2 { font-size: 1.0625rem; margin: var(--s5) 0 var(--s2); padding-top: var(--s4); border-top: 1px solid var(--line); }
.md h3 { font-size: 0.9375rem; margin: var(--s4) 0 6px; }
.md > :first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.md ul, .md ol { padding-left: 22px; margin: 6px 0 var(--s3); }
.md li { margin: var(--s1) 0; }
.md table { display: block; overflow-x: auto; margin: var(--s3) 0; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; white-space: normal; }
.md th:first-child, .md td:first-child { padding-left: 10px; } .md th:last-child, .md td:last-child { padding-right: 10px; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: var(--s4) 0; }
.md li.task { list-style: none; margin-left: -22px; }
.md li.task label { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 7px 8px; font-size: 0.9375rem; color: var(--ink); border-radius: var(--radius-sm); cursor: pointer; transition: background-color 0.15s var(--ease); }
.md li.task label:hover { background: var(--sunken); }
.md li.task input { margin-top: 2px; }
.md li.task input:checked + span { color: var(--muted); text-decoration: line-through; }

/* --- графики: тонкие линии, волосяная сетка, подписи — цветом текста, а не ряда ------ */
.grid.charts { grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); margin-bottom: var(--gap); }
.chart { margin: var(--s3) 0 0; --ygut: 58px; --rgut: 12px; }
.chart.with-labels { --rgut: 84px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s1) 14px; margin-bottom: 10px; font-size: 0.8125rem; color: var(--ink); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart .key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; flex: none; }
.chart-body { display: grid; grid-template-columns: var(--ygut) 1fr; }
.chart-y { position: relative; }
.chart-y span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-plot { position: relative; height: 220px; margin-right: var(--rgut); touch-action: pan-y; outline: none; border-radius: 4px; }
.chart-plot:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.chart-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart-plot .gridline { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-plot .axis { stroke: var(--chart-axis); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-plot .limit { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.chart-plot .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart-plot .area { opacity: 0.1; stroke: none; }
.chart-dot { position: absolute; width: 8px; height: 8px; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 2px var(--surface); pointer-events: none; }
.chart-end { position: absolute; left: 100%; margin-left: 10px; transform: translateY(-50%); font-size: 0.78rem; color: var(--ink); white-space: nowrap; max-width: 70px; overflow: hidden; text-overflow: ellipsis; }
.chart-limit { position: absolute; left: 6px; transform: translateY(-115%); font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.chart-cross { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--chart-axis); pointer-events: none; }
.chart-tip { position: absolute; top: 4px; z-index: var(--z-sticky); pointer-events: none; white-space: nowrap; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 9px; font-size: 0.8rem; box-shadow: var(--shadow-pop); }
.chart-tip .tip-head { color: var(--muted); margin-bottom: 3px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 6px; }
.chart-tip .tip-row b { font-variant-numeric: tabular-nums; }
.chart-tip .tip-row span { color: var(--muted); }
.chart-x { position: relative; height: 22px; margin: 6px var(--rgut) 0 var(--ygut); }
.chart-x span { position: absolute; transform: translateX(-50%); font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-x span:first-child { transform: none; }
.chart-x span:last-child { transform: translateX(-100%); }
.chart-table { max-height: 300px; overflow-y: auto; }
@media (max-width: 560px) {
  /* на узком экране подписи дат через одну — иначе они слипаются */
  .chart-x span:nth-child(even) { display: none; }
}

/* --- вход --------------------------------------------------------------------------- */
.login { max-width: 400px; margin: 14vh auto 0; }
.login .brand { padding: 0; margin-bottom: var(--s5); font-size: 1.125rem; }

/* --- плашка «приложение остановлено» --------------------------------------------------- */
.offline { position: fixed; left: 0; right: 0; top: 0; z-index: var(--z-banner); padding: var(--s3) var(--s4); background: var(--bad-solid); color: #fff; font-size: 0.9375rem; box-shadow: var(--shadow-pop); }
@media (prefers-color-scheme: dark) { .offline { color: #1b0b0a; } }
.offline.nudge { animation: nudge 0.35s; }
@keyframes nudge { 25% { transform: translateY(6px); } 60% { transform: translateY(-3px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
