/* ============================================================================
   style.css - дизайн-система дашборда «АвтоГаз 26».
   Визуальный язык: «приборная панель автосервиса + технический чертёж».

   Содержание
     1. Токены (светлая тема)
     2. Тёмная тема
     3. База и типографика
     4. Каркас: сайдбар, шапка, рабочая область
     5. Кнопки и общие мелочи
     6. Смысловой блок, плитки, заголовок-итог, плашка надёжности
     7. Причины потерь, полосы-разрезы, таблица
     8. Расшифровка (боковая панель), словарик, пустые состояния
     9. Автомобильные компоненты (дорога, спидометр, схема, номер, штампы)
    10. Витрина компонентов
    11. Адаптив и уважение к «меньше движения»
   ========================================================================== */

/* ============================ 1. Токены ================================== */
:root {
  /* поверхности: тёплая «бумага» и белые карточки */
  --bg: #f4f2ef;
  --bg-soft: #ece9e4;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --surface-3: #f1efeb;
  --line: #e3ded6;
  --line-strong: #cec7bb;

  /* текст */
  --ink: #1a1e24;
  --ink-2: #4d5560;
  --ink-3: #6b7482;
  --ink-on-accent: #ffffff;

  /* смысловые цвета. `-ink` - вариант для текста (контраст AA), без суффикса - для графики */
  --accent: #0f6ecd;            /* «газовый синий» - пламя пропана */
  --accent-ink: #0b5bab;
  --accent-soft: #e7f0fd;
  --accent-line: #b9d5f6;

  --ok: #15904b;
  --ok-ink: #14713e;
  --ok-soft: #e4f5ea;

  --bad: #cf2f2f;
  --bad-ink: #b52626;
  --bad-soft: #fdeceb;

  --warn: #c9821b;
  --warn-ink: #8a5712;
  --warn-soft: #fdf3e0;

  --neutral: #8a929c;
  --neutral-soft: #edeae5;

  /* «чертёжная» карточка-герой: одинаково тёмная в обеих темах */
  --hero-bg: #0d2740;
  --hero-bg-2: #123354;
  --hero-ink: #eaf2fb;
  --hero-ink-2: #9dbdda;
  --hero-line: rgba(126, 178, 226, .30);
  --hero-accent: #58a9f2;

  /* дорога клиента */
  --road: #575f68;
  --road-2: #3f464e;
  --road-line: #f3f1ec;
  --sign: #0b57a4;
  --sign-2: #094585;
  --sign-ink: #ffffff;

  /* схема машины */
  --car-line: #35506b;
  --car-line-2: #7d93aa;
  --car-body: rgba(20, 70, 120, .06);
  --car-glass: rgba(84, 150, 210, .18);
  --car-tire: #3a4249;
  --car-rim: #c9ced4;
  --gbo: #0f6ecd;
  --gbo-soft: #d8e8fb;

  /* номерной знак */
  --plate-bg: #ffffff;
  --plate-ink: #16181b;
  --plate-line: #23262a;

  /* сетки, тени, радиусы, отступы */
  --grid-line: rgba(30, 50, 80, .05);
  --sh-1: 0 1px 2px rgba(22, 28, 38, .05), 0 6px 16px -10px rgba(22, 28, 38, .25);
  --sh-2: 0 2px 6px rgba(22, 28, 38, .07), 0 18px 40px -22px rgba(22, 28, 38, .40);
  --sh-pop: 0 10px 34px -10px rgba(22, 28, 38, .32);

  --r1: 8px;
  --r2: 12px;
  --r3: 18px;
  --r4: 26px;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  --side-w: 264px;
  --wrap: 1180px;
  --tap: 44px;           /* минимальная кликабельная зона */

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ============================ 2. Тёмная тема =============================
   Три состояния: системная (ничего не проставлено), явная светлая, явная тёмная.
   Блок токенов повторён дважды намеренно - так работает и системная тема,
   и ручной переключатель в сайдбаре.
   ======================================================================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171b;
    --bg-soft: #0f1214;
    --surface: #1c2025;
    --surface-2: #22272d;
    --surface-3: #272d34;
    --line: #2f353c;
    --line-strong: #414951;

    --ink: #eef1f5;
    --ink-2: #b6bfc9;
    --ink-3: #8d97a3;
    --ink-on-accent: #071a2c;

    --accent: #4aa3f0;
    --accent-ink: #8cc4f6;
    --accent-soft: rgba(74, 163, 240, .14);
    --accent-line: rgba(74, 163, 240, .38);

    --ok: #3fb56d;
    --ok-ink: #6ed397;
    --ok-soft: rgba(63, 181, 109, .15);

    --bad: #ef5f5f;
    --bad-ink: #ff8a8a;
    --bad-soft: rgba(239, 95, 95, .15);

    --warn: #e0a44a;
    --warn-ink: #f0c37c;
    --warn-soft: rgba(224, 164, 74, .15);

    --neutral: #7b8592;
    --neutral-soft: rgba(123, 133, 146, .16);

    --road: #414951;
    --road-2: #2b3138;
    --road-line: #d7dde4;
    --sign: #1665bb;
    --sign-2: #0d4e95;

    --car-line: #94b6d8;
    --car-line-2: #5d768f;
    --car-body: rgba(74, 163, 240, .07);
    --car-glass: rgba(84, 150, 210, .14);
    --car-tire: #2a3036;
    --car-rim: #5e666e;
    --gbo: #4aa3f0;
    --gbo-soft: rgba(74, 163, 240, .20);

    --plate-bg: #e9e9e6;
    --plate-ink: #16181b;
    --plate-line: #2c2f33;

    --grid-line: rgba(150, 190, 230, .06);
    --sh-1: 0 1px 2px rgba(0, 0, 0, .34), 0 6px 16px -10px rgba(0, 0, 0, .70);
    --sh-2: 0 2px 6px rgba(0, 0, 0, .40), 0 18px 40px -22px rgba(0, 0, 0, .90);
    --sh-pop: 0 10px 34px -10px rgba(0, 0, 0, .75);
  }
}

:root[data-theme="dark"] {
  --bg: #14171b;
  --bg-soft: #0f1214;
  --surface: #1c2025;
  --surface-2: #22272d;
  --surface-3: #272d34;
  --line: #2f353c;
  --line-strong: #414951;

  --ink: #eef1f5;
  --ink-2: #b6bfc9;
  --ink-3: #8d97a3;
  --ink-on-accent: #071a2c;

  --accent: #4aa3f0;
  --accent-ink: #8cc4f6;
  --accent-soft: rgba(74, 163, 240, .14);
  --accent-line: rgba(74, 163, 240, .38);

  --ok: #3fb56d;
  --ok-ink: #6ed397;
  --ok-soft: rgba(63, 181, 109, .15);

  --bad: #ef5f5f;
  --bad-ink: #ff8a8a;
  --bad-soft: rgba(239, 95, 95, .15);

  --warn: #e0a44a;
  --warn-ink: #f0c37c;
  --warn-soft: rgba(224, 164, 74, .15);

  --neutral: #7b8592;
  --neutral-soft: rgba(123, 133, 146, .16);

  --road: #414951;
  --road-2: #2b3138;
  --road-line: #d7dde4;
  --sign: #1665bb;
  --sign-2: #0d4e95;

  --car-line: #94b6d8;
  --car-line-2: #5d768f;
  --car-body: rgba(74, 163, 240, .07);
  --car-glass: rgba(84, 150, 210, .14);
  --car-tire: #2a3036;
  --car-rim: #5e666e;
  --gbo: #4aa3f0;
  --gbo-soft: rgba(74, 163, 240, .20);

  --plate-bg: #e9e9e6;
  --plate-ink: #16181b;
  --plate-line: #2c2f33;

  --grid-line: rgba(150, 190, 230, .06);
  --sh-1: 0 1px 2px rgba(0, 0, 0, .34), 0 6px 16px -10px rgba(0, 0, 0, .70);
  --sh-2: 0 2px 6px rgba(0, 0, 0, .40), 0 18px 40px -22px rgba(0, 0, 0, .90);
  --sh-pop: 0 10px 34px -10px rgba(0, 0, 0, .75);
}

/* ============================ 3. База ==================================== */
* { box-sizing: border-box; }

/* атрибут hidden должен побеждать любой display у компонента */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.22; letter-spacing: -.01em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

a { color: var(--accent-ink); text-decoration-color: var(--accent-line); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }

button { font: inherit; color: inherit; }

svg { display: block; }

:where(a, button, [tabindex], input, select, textarea):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* цифры одинаковой ширины - таблицы и крупные значения не «прыгают» */
.num, .tile__value, .table td, .gauge, .odo, .headline b, .drill__sum, .block__answer {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  padding: 10px 16px; background: var(--accent); color: var(--ink-on-accent);
  border-radius: 0 0 var(--r1) 0;
}
.skip-link:focus { left: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ============================ 4. Каркас ================================== */
.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ----- сайдбар ----- */
.side {
  position: sticky; top: 0; align-self: start;
  height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 40;
}
.side__top { display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s5) var(--s4) var(--s4); }
.side__close { display: none; }

.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; flex: 1; min-width: 0; }
.brand__mark { width: 38px; height: 38px; flex: none; }
.brand__mark svg { width: 100%; height: 100%; }
.brand__text { display: block; min-width: 0; }
.brand__name { display: block; font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.brand__sub { display: block; font-size: 11.5px; color: var(--ink-3); line-height: 1.25; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: var(--s2) var(--s3); overflow-y: auto; flex: 1; }
.nav__item {
  display: flex; align-items: center; gap: 11px;
  min-height: var(--tap); padding: 8px 10px;
  border-radius: var(--r2);
  color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 14.5px;
  transition: background .14s ease, color .14s ease;
}
.nav__item:hover { background: var(--surface-3); color: var(--ink); }
.nav__item--on { background: var(--accent-soft); color: var(--accent-ink); }
.nav__icon { width: 24px; height: 24px; flex: none; color: currentColor; }
.nav__icon svg { width: 100%; height: 100%; }
.nav__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav__hint { margin: var(--s4) 10px var(--s1); font-size: 11px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3); }

.side__foot { border-top: 1px solid var(--line); padding: var(--s3); display: grid; gap: var(--s3); }

/* статус синхронизации */
.sync { display: grid; gap: 6px; }
.sync__row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.sync__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--neutral); }
.sync__dot--ok { background: var(--ok); }
.sync__dot--bad { background: var(--bad); }
.sync__dot--run { background: var(--warn); animation: pulse 1.3s ease-in-out infinite; }
.sync__note { font-size: 11.5px; color: var(--ink-3); line-height: 1.35; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* переключатель темы */
.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  background: var(--surface-3); border-radius: var(--r2); padding: 3px; }
.theme-switch__btn {
  border: 0; background: none; border-radius: 9px; padding: 7px 4px; cursor: pointer;
  font-size: 12px; font-weight: 700; color: var(--ink-3); min-height: 34px;
}
.theme-switch__btn:hover { color: var(--ink); }
.theme-switch__btn--on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }

.user { display: flex; align-items: center; gap: var(--s2); }
.user__ava { width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.user__text { min-width: 0; flex: 1; }
.user__name { font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user__role { font-size: 11.5px; color: var(--ink-3); }

.side-scrim { position: fixed; inset: 0; background: rgba(12, 16, 22, .45); z-index: 35; }

/* ----- шапка страницы ----- */
.main { display: flex; flex-direction: column; min-width: 0; }

.page-head {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: flex-start; gap: var(--s4);
  padding: var(--s5) var(--s6) var(--s4);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.page-head__text { flex: 1; min-width: 240px; }
.page-head__title { font-size: clamp(22px, 2.4vw, 30px); letter-spacing: -.025em; }
.page-head__sub { margin-top: 5px; color: var(--ink-2); font-size: 14.5px; max-width: 62ch; }

/* страница без периода: выбор скрыт, шапке лишняя высота не нужна */
.page-head--noperiod { row-gap: 0; }

.burger { display: none; }

.view { padding: var(--s5) var(--s6) var(--s7); max-width: var(--wrap); width: 100%; }
.view:focus { outline: none; }
.page-foot { margin-top: auto; padding: var(--s4) var(--s6) var(--s5); color: var(--ink-3); font-size: 12px; }

/* Сетка страницы.
   min-width: 0 у детей обязателен: без него широкая таблица внутри карточки
   растягивает колонку, а вместе с ней и всю страницу. minmax(min(...), 1fr)
   не даёт колонке стать шире самого контейнера на узком экране. */
.grid { display: grid; gap: var(--s5); }
.grid > * { min-width: 0; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.stack { display: grid; gap: var(--s5); }
.stack > * { min-width: 0; }
.stack--tight { gap: var(--s3); }

/* то же правило для всех контейнеров, внутрь которых кладут таблицы и графики */
.block, .block__head, .block__body, .notes, .card, .card__body, .view,
.main, .drill, .drill__body, .kit, .kit__sec, .tiles > *, .scheme { min-width: 0; }

/* ----- выбор периода ----- */
.period { display: grid; gap: 6px; justify-items: end; }
.period__label { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.period__custom { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.period__custom input[type="date"] {
  font: inherit; font-size: 13px; padding: 7px 9px; min-height: 36px;
  border: 1px solid var(--line-strong); border-radius: var(--r1);
  background: var(--surface); color: var(--ink);
}

/* ============================ 5. Кнопки ================================== */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 7px 14px; min-height: 36px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip--on { background: var(--accent); border-color: var(--accent); color: var(--ink-on-accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px; cursor: pointer;
  border-radius: var(--r2); border: 1px solid transparent;
  background: var(--accent); color: var(--ink-on-accent);
  font-weight: 700; font-size: 14.5px; text-decoration: none;
  transition: filter .14s ease, background .14s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { filter: brightness(.94); }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn--soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn--sm { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: var(--r1); }
.btn--wide { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; filter: none; }

/* карточка - основа почти всего */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  box-shadow: var(--sh-1);
}
.card__head { padding: var(--s4) var(--s5) 0; }
.card__body { padding: var(--s5); }
.card__title { font-size: 17px; }

/* ============================ 6. Смысловые блоки ========================= */
.headline {
  display: flex; gap: var(--s4); align-items: flex-start;
  padding: var(--s5) var(--s5) var(--s5) var(--s4);
  background: var(--surface); border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: var(--r3);
  box-shadow: var(--sh-1);
}
.headline__icon { width: 30px; height: 30px; flex: none; color: var(--accent); margin-top: 2px; }
.headline__text { font-size: clamp(18px, 2vw, 23px); font-weight: 700; line-height: 1.32; letter-spacing: -.015em; }
.headline b { color: var(--accent-ink); }

.block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.block__head { padding: var(--s5) var(--s5) var(--s3); }
.block__q { font-size: clamp(17px, 1.7vw, 20px); letter-spacing: -.015em; }
.block__answer {
  margin-top: var(--s2);
  font-size: clamp(24px, 3vw, 34px); font-weight: 800; letter-spacing: -.03em; line-height: 1.16;
  color: var(--ink);
}
.block__answer .u { color: var(--ink-3); font-weight: 700; font-size: .62em; letter-spacing: -.01em; }
.block__body { padding: 0 var(--s5) var(--s4); }
.block__body--flush { padding-left: 0; padding-right: 0; }

.notes { display: grid; gap: var(--s3); padding: 0 var(--s5) var(--s4); }
@media (min-width: 900px) { .notes--pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.note { border-radius: var(--r2); padding: var(--s3) var(--s4); background: var(--surface-2); border: 1px solid var(--line); }
.note--mean { background: var(--surface-2); }
.note--act { background: var(--accent-soft); border-color: var(--accent-line); }
.note__title {
  font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 3px;
}
.note--act .note__title { color: var(--accent-ink); }
.note__text { font-size: 14.5px; color: var(--ink-2); line-height: 1.5; }
.note--act .note__text { color: var(--ink); }

.block__foot {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s3) var(--s5); border-top: 1px solid var(--line); background: var(--surface-2);
}

/* плашка «цифрам за этот период верить рано» */
.banner {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s4); border-radius: var(--r2);
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  color: var(--ink);
}
.banner__icon { width: 24px; height: 24px; flex: none; color: var(--warn-ink); margin-top: 1px; }
.banner__text { font-size: 14.5px; line-height: 1.45; }
.banner__title { font-weight: 700; display: block; margin-bottom: 2px; }

/* ----- плитки показателей ----- */
.tiles { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(min(234px, 100%), 1fr)); }
.tile {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r3);
  padding: var(--s4); box-shadow: var(--sh-1);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.tile:hover { border-color: var(--accent-line); transform: translateY(-1px); box-shadow: var(--sh-2); }
.tile[aria-expanded="true"] { border-color: var(--accent); }
.tile__title { font-size: 13px; font-weight: 700; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.tile__line { display: flex; align-items: baseline; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.tile__value { font-size: clamp(26px, 2.9vw, 34px); font-weight: 800; letter-spacing: -.035em; line-height: 1.05; }
/* длинные суммы не должны ломать сетку плиток */
.tile__value[data-long="1"] { font-size: clamp(22px, 2.3vw, 27px); }
.tile__unit { font-size: 16px; font-weight: 700; color: var(--ink-3); }
.tile__words { font-size: 14px; color: var(--ink-2); margin-top: 2px; font-weight: 600; }
.tile__delta { display: inline-flex; align-items: center; gap: 5px; margin-top: 9px;
  font-size: 13px; font-weight: 700; border-radius: 999px; padding: 3px 9px 3px 6px; }
.tile__delta--good { background: var(--ok-soft); color: var(--ok-ink); }
.tile__delta--bad { background: var(--bad-soft); color: var(--bad-ink); }
.tile__delta--flat { background: var(--neutral-soft); color: var(--ink-2); }
.tile__delta svg { width: 15px; height: 15px; }
.tile__text { font-size: 13px; color: var(--ink-3); margin-top: 9px; line-height: 1.42; }
.tile__more { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px dashed var(--line-strong); display: grid; gap: var(--s2); }
.tile__more[hidden] { display: none; }
.tile__parts { display: grid; gap: 4px; }
.tile__part { display: flex; justify-content: space-between; gap: var(--s3); font-size: 13.5px; }
.tile__part span:first-child { color: var(--ink-2); }
.tile__part span:last-child { font-weight: 700; }
.tile__hintline { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: flex-start; gap: 5px; margin-top: 8px; }
.tile__hintline svg { flex: none; margin-top: 2px; }

/* ============================ 7. Разрезы и таблицы ======================= */
.losses { display: grid; gap: var(--s2); }
.loss {
  border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface-2); overflow: hidden;
}
.loss__btn {
  display: grid; grid-template-columns: 1fr auto; gap: 4px var(--s3); align-items: center;
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: var(--s3) var(--s4); min-height: var(--tap);
}
.loss__btn:hover { background: var(--surface-3); }
.loss__title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.loss__caret { width: 14px; height: 14px; color: var(--ink-3); transition: transform .18s ease; }
.loss[data-open="1"] .loss__caret { transform: rotate(90deg); }
.loss__count { font-weight: 800; font-size: 17px; white-space: nowrap; }
.loss__share { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.loss__track { grid-column: 1 / -1; height: 9px; border-radius: 6px; background: var(--neutral-soft); overflow: hidden; }
.loss__fill { height: 100%; border-radius: 6px; background: var(--bad); }
.loss__body { padding: 0 var(--s4) var(--s4); display: grid; gap: var(--s3); }
.loss__hint { font-size: 13.5px; color: var(--ink-2); line-height: 1.45; }
.loss__reasons { display: grid; gap: 3px; }
.loss__reason { display: flex; justify-content: space-between; gap: var(--s3); font-size: 13.5px;
  padding: 4px 0; border-bottom: 1px dashed var(--line); }
.loss__reason:last-child { border-bottom: 0; }
.loss__reason b { font-variant-numeric: tabular-nums; }

/* полосы-разрезы: филиалы, источники, мастера */
.bars { display: grid; gap: 9px; }
.bar { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.9fr) auto; gap: 10px; align-items: center; }
.bar__label { font-size: 13.5px; color: var(--ink-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar__track { height: 22px; border-radius: 7px; background: var(--surface-3); overflow: hidden; }
.bar__fill { height: 100%; border-radius: 7px; background: var(--accent); transition: width .5s cubic-bezier(.2, .7, .3, 1); }
.bar__value { font-size: 14px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar__sub { grid-column: 2 / -1; font-size: 12px; color: var(--ink-3); margin-top: -5px; }
.bar--click { cursor: pointer; }
.bar--click:hover .bar__label { color: var(--accent-ink); }

/* таблица */
.table-wrap { overflow-x: auto; border-radius: var(--r2); border: 1px solid var(--line); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--ink-3);
  font-size: 12px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .t-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .t-mid { text-align: center; }
.table__sort { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: inherit;
  display: inline-flex; align-items: center; gap: 4px; text-transform: inherit; letter-spacing: inherit; }
.table__sort:hover { color: var(--accent-ink); }
.table__arrow { width: 11px; height: 11px; opacity: .35; }
.table__sort[data-dir] .table__arrow { opacity: 1; color: var(--accent); }
.table__sort[data-dir="desc"] .table__arrow { transform: rotate(180deg); }
.t-lab { display: none; }
.table__total { padding: 9px 14px; font-size: 13px; color: var(--ink-3); border-top: 1px solid var(--line); background: var(--surface-2); }

/* ============================ 8. Расшифровка и мелочи ==================== */
.drill-scrim { position: fixed; inset: 0; background: rgba(10, 14, 20, .46); z-index: 60; animation: fade .18s ease; }
.drill {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: min(920px, 100%);
  display: flex; flex-direction: column;
  background: var(--bg); border-left: 1px solid var(--line);
  box-shadow: var(--sh-2);
  animation: slide-in .22s cubic-bezier(.2, .7, .3, 1);
}
@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(28px); opacity: 0; } }

.drill__head { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--line); background: var(--surface); }
.drill__title { font-size: 18px; flex: 1; }
.drill__sub { font-size: 13px; color: var(--ink-3); margin-top: 3px; }
.drill__close { width: var(--tap); height: var(--tap); flex: none; border-radius: var(--r2);
  border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: 20px; line-height: 1; }
.drill__close:hover { border-color: var(--accent); color: var(--accent-ink); }
.drill__sum { display: flex; gap: var(--s5); flex-wrap: wrap; padding: var(--s3) var(--s5);
  background: var(--surface); border-bottom: 1px solid var(--line); }
.drill__stat { font-size: 13px; color: var(--ink-3); }
.drill__stat b { display: block; font-size: 19px; color: var(--ink); font-weight: 800; }
.drill__body { flex: 1; overflow-y: auto; padding: var(--s4) var(--s5) var(--s6); }
.drill__foot { padding: var(--s3) var(--s5) var(--s5); }

.lead-name { font-weight: 600; }
.lead-out { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700;
  border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.lead-out--won { background: var(--ok-soft); color: var(--ok-ink); }
.lead-out--lost { background: var(--bad-soft); color: var(--bad-ink); }
.lead-out--open { background: var(--warn-soft); color: var(--warn-ink); }
.amo-link { font-size: 13px; white-space: nowrap; font-weight: 600; }

/* словарик */
.gloss {
  border-bottom: 1.5px dotted var(--ink-3); cursor: help; background: none; border-left: 0;
  border-right: 0; border-top: 0; padding: 0; font: inherit; color: inherit;
}
.gloss:hover { border-bottom-color: var(--accent); color: var(--accent-ink); }
.gloss-pop {
  position: absolute; z-index: 80; max-width: 320px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r2);
  box-shadow: var(--sh-pop); padding: var(--s3) var(--s4);
  font-size: 13.5px; line-height: 1.45;
  animation: fade .14s ease;
}
.gloss-pop__term { font-weight: 800; margin-bottom: 3px; font-size: 14px; }

/* пустые состояния, загрузка, ошибка */
.empty, .err {
  display: grid; gap: var(--s3); justify-items: center; text-align: center;
  padding: var(--s6) var(--s4); color: var(--ink-3);
  border: 1px dashed var(--line-strong); border-radius: var(--r2); background: var(--surface-2);
}
.empty__icon, .err__icon { width: 46px; height: 46px; color: var(--line-strong); }
.err { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); color: var(--ink); }
.err__icon { color: var(--bad); }
.err__text { font-size: 15px; max-width: 46ch; }

.loading { display: flex; align-items: center; gap: var(--s3); padding: var(--s5); color: var(--ink-3); font-size: 14px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 2.5px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3));
  background-size: 200% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r1); }
@keyframes shimmer { to { background-position: -200% 0; } }

.stub { display: grid; gap: var(--s3); justify-items: center; text-align: center;
  padding: var(--s7) var(--s4); color: var(--ink-2);
  border: 1px dashed var(--line-strong); border-radius: var(--r3); background: var(--surface-2); }
.stub__title { font-size: 19px; font-weight: 700; color: var(--ink); }

/* график */
.chart { position: relative; width: 100%; }
.chart__box { position: relative; width: 100%; }
.chart canvas { display: block; width: 100% !important; }

/* ============================ 9. Автомобильные компоненты ================ */

/* ----- дорога клиента ----- */
.road { display: grid; gap: var(--s3); }
.road__scroll { overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; }
.road__svg { display: block; width: 100%; min-width: 620px; height: auto; }
.road--v .road__svg { min-width: 0; }
.road__stop, .road__exit, .road__open { cursor: pointer; }
.road__stop:hover .sign-plate, .road__stop:focus-visible .sign-plate { filter: brightness(1.14); }
.road__exit:hover .exit-box, .road__exit:focus-visible .exit-box { filter: brightness(1.08); }
.road__notes { display: grid; gap: 7px; }
.rnote { display: flex; gap: 9px; align-items: flex-start; font-size: 13.5px; color: var(--ink-2); line-height: 1.45; }
.rnote__n { font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rnote__dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--neutral); }
.rnote__body { flex: 1; min-width: 0; }
/* строка, по которой можно сразу что-то сделать: открыть список сделок */
.rnote--act { cursor: pointer; border-radius: var(--r2); margin: -6px -10px; padding: 6px 10px; }
.rnote--act:hover, .rnote--act:focus-visible { background: var(--warn-soft); }
.rnote__dot--warn { background: var(--warn); }
.rnote__dot--ok { background: var(--ok); }
.road-anim { animation: road-in .55s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes road-in { from { opacity: 0; transform: translateX(-14px); } }

/* ----- спидометр ----- */
.gauge { display: block; width: 100%; max-width: 380px; margin: 0 auto; height: auto; }
.gauge__needle { transform-box: fill-box; transform-origin: 50% 100%; transition: transform 1.05s cubic-bezier(.22, 1.1, .36, 1); }

/* ----- схема машины ----- */
/* Схема идёт во всю ширину блока, легенда - под ней в несколько колонок:
   так подписи-выноски внутри чертежа остаются читаемыми. */
.scheme { display: grid; gap: var(--s4); }
.scheme__svg { width: 100%; height: auto; max-width: 1120px; margin: 0 auto; }
.scheme__hot { cursor: pointer; }
.scheme__hot circle.hot-bg { transition: r .18s ease, opacity .18s ease; }
.scheme__hot:hover circle.hot-bg, .scheme__hot:focus-visible circle.hot-bg { opacity: 1; }
.scheme__part { transition: opacity .18s ease; }
.scheme.is-dim .scheme__part { opacity: .35; }
.scheme.is-dim .scheme__part--on { opacity: 1; }
.scheme__legend { display: grid; gap: 2px 10px; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(min(232px, 100%), 1fr)); }
.scheme__legend-title { grid-column: 1 / -1; font-size: 11.5px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 2px; }
.leg {
  display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center;
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: 7px 9px; border-radius: var(--r1); min-height: 38px;
}
.leg:hover, .leg--on { background: var(--accent-soft); }
.leg__dot { width: 11px; height: 11px; border-radius: 50%; background: var(--gbo); flex: none; }
.leg__title { font-size: 13.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leg--on .leg__title, .leg:hover .leg__title { color: var(--ink); font-weight: 600; }
.leg__count { font-size: 13.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.leg__empty .leg__dot { background: var(--line-strong); }
.leg__empty .leg__title, .leg__empty .leg__count { color: var(--ink-3); font-weight: 500; }
/* узел, которого нет на чертеже: например «не распознано» */
.leg--off { border: 1px dashed var(--line-strong); background: var(--surface-2); cursor: help; }
.leg--off .leg__dot { background: none; border: 2px dashed var(--line-strong); }
.leg--off .leg__title { font-style: italic; color: var(--ink-3); }

/* ----- номерной знак ----- */
.plate { display: inline-block; vertical-align: middle; height: 34px; }
.plate svg { height: 100%; width: auto; }
.plate--sm { height: 23px; }
.plate--md { height: 34px; }
.plate--lg { height: 50px; }

/* ----- иконка машины, штамп, одометр ----- */
.caricon { display: inline-block; width: 64px; color: var(--car-line); }
.caricon svg { width: 100%; height: auto; }
.caricon--lg { width: 104px; }

.stamp { display: inline-block; width: 92px; }
.stamp svg { width: 100%; height: auto; }
.stamp--sm { width: 62px; }

.odo { display: inline-block; width: 200px; }
.odo svg { width: 100%; height: auto; }
.odo--sm { width: 158px; }

/* ----- карточка-герой «чертёж» ----- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--r3);
  background:
    linear-gradient(140deg, var(--hero-bg-2), var(--hero-bg) 62%);
  color: var(--hero-ink);
  border: 1px solid rgba(126, 178, 226, .22);
  box-shadow: var(--sh-2);
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--hero-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--hero-line) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(120% 110% at 18% 10%, #000 30%, transparent 78%);
  opacity: .8;
}
.hero__inner { position: relative; display: grid; gap: var(--s4); padding: var(--s5) var(--s5) var(--s4); }
@media (min-width: 860px) {
  .hero__inner { grid-template-columns: minmax(0, 1fr) minmax(0, 46%); align-items: center; padding: var(--s6); }
}
.hero__title { font-size: clamp(21px, 2.6vw, 31px); letter-spacing: -.028em; line-height: 1.16; }
.hero__text { margin-top: var(--s3); color: var(--hero-ink-2); font-size: 15px; line-height: 1.55; max-width: 52ch; }
.hero__text b, .hero__title b { color: var(--hero-accent); }
.hero__art { width: 100%; height: auto; }
.hero__badge { display: inline-flex; align-items: center; gap: 7px; margin-bottom: var(--s3);
  font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--hero-accent); border: 1px solid rgba(126, 178, 226, .35);
  border-radius: 999px; padding: 4px 11px; }
.hero .btn--ghost { background: rgba(255, 255, 255, .08); color: var(--hero-ink); border-color: rgba(126, 178, 226, .4); }
.hero .btn--ghost:hover { background: rgba(255, 255, 255, .15); color: #fff; }

/* ----- указатель топлива ----- */
.fuel { display: block; width: 100%; max-width: 300px; height: auto; }

/* ============================ 10. Витрина ================================ */
.kit { display: grid; gap: var(--s6); }
.kit__sec { display: grid; gap: var(--s4); scroll-margin-top: 120px; }
.kit__h { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap;
  padding-bottom: var(--s2); border-bottom: 2px solid var(--line); }
.kit__h h2 { font-size: 21px; letter-spacing: -.02em; }
.kit__sig { font-family: var(--mono); font-size: 12.5px; color: var(--accent-ink);
  background: var(--accent-soft); border-radius: var(--r1); padding: 3px 8px; }
.kit__note { font-size: 13.5px; color: var(--ink-3); max-width: 76ch; }
.kit__row { display: flex; gap: var(--s4); flex-wrap: wrap; align-items: flex-end; min-width: 0; }
.kit__row > * { min-width: 0; }
.kit__nav { display: flex; gap: 6px; flex-wrap: wrap; padding-bottom: var(--s2); }
.kit__nav a { font-size: 13px; text-decoration: none; color: var(--ink-2); font-weight: 600;
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; background: var(--surface); }
.kit__nav a:hover { border-color: var(--accent); color: var(--accent-ink); }
.sw { display: grid; gap: 5px; width: 104px; }
.sw__box { height: 52px; border-radius: var(--r1); border: 1px solid var(--line); }
.sw__name { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }

/* ============================ 11. Адаптив ================================ */
@media (max-width: 1140px) {
  :root { --side-w: 232px; }
  .view, .page-head, .page-foot { padding-left: var(--s5); padding-right: var(--s5); }
  /* схема стала мельче - подписи-выноски перестают читаться, остаётся легенда */
  .scheme__svg .cs-cap { display: none; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  .side {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw);
    transform: translateX(-102%);
    transition: transform .24s cubic-bezier(.2, .7, .3, 1);
    box-shadow: var(--sh-2);
  }
  .app--menu .side { transform: none; }
  .side__close {
    display: grid; place-items: center; width: 40px; height: 40px; flex: none;
    border: 1px solid var(--line); border-radius: var(--r2); background: var(--surface);
    font-size: 24px; line-height: 1; cursor: pointer; color: var(--ink-2);
  }

  .burger {
    display: grid; align-content: center; gap: 4.5px; flex: none;
    width: 44px; height: 44px; padding: 0 10px; cursor: pointer;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2);
  }
  .burger span { display: block; height: 2px; border-radius: 2px; background: var(--ink-2); }

  .page-head { padding: var(--s4) var(--s4) var(--s3); gap: var(--s3); align-items: center; }
  .page-head__text { min-width: 0; flex: 1 1 60%; }
  .page-head__title { font-size: 20px; }
  .page-head__sub { font-size: 13px; margin-top: 2px; }
  .period { width: 100%; justify-items: stretch; }
  /* без периода шапка на телефоне не должна оставлять пустую полосу */
  .page-head--noperiod { padding-bottom: var(--s4); row-gap: 0; }
  .period .chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 3px; scrollbar-width: none; }
  .period .chips::-webkit-scrollbar { display: none; }

  .view { padding: var(--s4) var(--s4) var(--s7); }
  .page-foot { padding: var(--s4); }

  .block__head, .block__body, .notes, .block__foot { padding-left: var(--s4); padding-right: var(--s4); }
  .headline { padding: var(--s4); }
  .drill { width: 100%; border-left: 0; }
  .drill__head, .drill__sum, .drill__body, .drill__foot { padding-left: var(--s4); padding-right: var(--s4); }

  /* таблица превращается в карточки */
  .table-wrap { border: 0; background: none; overflow: visible; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2);
    margin-bottom: var(--s2); padding: var(--s2) var(--s3);
  }
  .table td { border: 0; padding: 5px 0; display: flex; gap: var(--s3); align-items: baseline;
    justify-content: space-between; text-align: right; }
  .table td.t-num { text-align: right; }
  .table .t-lab { display: block; flex: none; font-size: 12px; font-weight: 700; color: var(--ink-3);
    text-align: left; max-width: 46%; }
  .table td:not(.t-num) { text-align: right; }
  .table__total { border: 1px solid var(--line); border-radius: var(--r2); }

  .bar { grid-template-columns: 1fr auto; }
  .bar__track { grid-column: 1 / -1; grid-row: 2; }
  .bar__sub { grid-column: 1 / -1; grid-row: 3; margin-top: 0; }

  /* на узком экране подписи-выноски не читаются - остаётся легенда под схемой */
  .scheme__svg .cs-cap { display: none; }
}

@media (max-width: 420px) {
  :root { --s5: 16px; --s6: 20px; }
  .tiles { grid-template-columns: 1fr 1fr; gap: var(--s2); }
  .tile { padding: var(--s3); }
  .tile__value { font-size: 24px; }
  .page-head__title { font-size: 18.5px; }
  .drill__sum { gap: var(--s4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .side, .side-scrim, .page-head .period, .burger, .page-foot { display: none !important; }
  .app { display: block; }
  .card, .block, .tile { box-shadow: none; break-inside: avoid; }
}
