/* ═══════════════════════════════════════════════════════════════════════════
   НарКомбот — панель ЦК. Material 3, кумачовая палитра.
   Раскладка: слева сайдбар 240px, контент одной колонкой до 1100px,
   на телефоне сайдбар превращается в нижнюю панель.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --primary: #BE0F17; --on-primary: #FFFFFF;
  --primary-container: #FFDAD6; --on-primary-container: #410004;
  --secondary: #775652; --secondary-container: #FFDAD6; --on-secondary-container: #2C1512;
  --tertiary: #6D5C2F; --tertiary-container: #F8DFA7; --on-tertiary-container: #241A00;
  --success: #2E6B4F; --success-container: #CBEFD9; --on-success-container: #0C2018;
  --error: #BA1A1A; --error-container: #FFDAD6; --on-error-container: #410002;
  --surface: #FFF8F7; --s-low: #FFF0EE; --s-c: #FCEAE7; --s-high: #F7E4E1; --s-highest: #F1DEDC;
  --on-surface: #201A19; --on-surface-var: #534341;
  --outline: #857370; --outline-var: #D8C2BE;
  --e1: 0 1px 2px rgba(0,0,0,.20), 0 1px 3px 1px rgba(0,0,0,.10);
  --e2: 0 1px 2px rgba(0,0,0,.20), 0 2px 6px 2px rgba(0,0,0,.10);
  --scrim: rgba(32,26,25,.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #FFB4AB; --on-primary: #690005;
    --primary-container: #93000A; --on-primary-container: #FFDAD6;
    --secondary: #E7BDB8; --secondary-container: #5D3F3B; --on-secondary-container: #FFDAD6;
    --tertiary: #DBC48D; --tertiary-container: #534519; --on-tertiary-container: #F8DFA7;
    --success: #8FD6AE; --success-container: #1C4535; --on-success-container: #CBEFD9;
    --error: #FFB4AB; --error-container: #93000A; --on-error-container: #FFDAD6;
    --surface: #1A1110; --s-low: #201A19; --s-c: #251D1C; --s-high: #2F2726; --s-highest: #3A3130;
    --on-surface: #F1DEDC; --on-surface-var: #D8C2BE;
    --outline: #A08C8A; --outline-var: #534341;
    --e1: 0 1px 3px rgba(0,0,0,.45); --e2: 0 2px 8px rgba(0,0,0,.5);
    --scrim: rgba(255,255,255,.06);
  }
}

html[data-theme="light"] {
  --primary: #BE0F17; --on-primary: #FFFFFF;
  --primary-container: #FFDAD6; --on-primary-container: #410004;
  --secondary: #775652; --secondary-container: #FFDAD6; --on-secondary-container: #2C1512;
  --tertiary: #6D5C2F; --tertiary-container: #F8DFA7; --on-tertiary-container: #241A00;
  --success: #2E6B4F; --success-container: #CBEFD9; --on-success-container: #0C2018;
  --error: #BA1A1A; --error-container: #FFDAD6; --on-error-container: #410002;
  --surface: #FFF8F7; --s-low: #FFF0EE; --s-c: #FCEAE7; --s-high: #F7E4E1; --s-highest: #F1DEDC;
  --on-surface: #201A19; --on-surface-var: #534341;
  --outline: #857370; --outline-var: #D8C2BE;
  --scrim: rgba(32,26,25,.06);
}

html[data-theme="dark"] {
  --primary: #FFB4AB; --on-primary: #690005;
  --primary-container: #93000A; --on-primary-container: #FFDAD6;
  --secondary: #E7BDB8; --secondary-container: #5D3F3B; --on-secondary-container: #FFDAD6;
  --tertiary: #DBC48D; --tertiary-container: #534519; --on-tertiary-container: #F8DFA7;
  --success: #8FD6AE; --success-container: #1C4535; --on-success-container: #CBEFD9;
  --error: #FFB4AB; --error-container: #93000A; --on-error-container: #FFDAD6;
  --surface: #1A1110; --s-low: #201A19; --s-c: #251D1C; --s-high: #2F2726; --s-highest: #3A3130;
  --on-surface: #F1DEDC; --on-surface-var: #D8C2BE;
  --outline: #A08C8A; --outline-var: #534341;
  --e1: 0 1px 3px rgba(0,0,0,.45); --e2: 0 2px 8px rgba(0,0,0,.5);
  --scrim: rgba(255,255,255,.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Классы вроде .skeleton/.banner задают display — без !important они
   перебивают атрибут hidden, и «скрытые» блоки остаются на экране. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--surface); color: var(--on-surface);
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans",
               "Liberation Sans", "PT Sans", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

input, select, textarea, button { font: inherit; color: inherit; }
input[type=checkbox] { accent-color: var(--primary); width: 20px; height: 20px; }
input::placeholder, textarea::placeholder { color: var(--on-surface-var); opacity: .7; }
::selection { background: var(--primary-container); color: var(--on-primary-container); }

@keyframes shimmer { 0% { background-position: -500px 0 } 100% { background-position: 500px 0 } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }
@keyframes popIn { from { opacity: 0; transform: scale(.94) } to { opacity: 1; transform: none } }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

button { transition: background-color .2s cubic-bezier(.2,0,0,1), color .2s ease,
                     border-color .2s ease, transform .12s ease; }
button:active:not(:disabled) { transform: scale(.96); }
tbody tr { transition: background-color .18s ease; }
tbody tr:hover { background: var(--scrim); }

/* ═══ КАРКАС ═══════════════════════════════════════════════════════════════ */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; flex: 0 0 240px;
  background: var(--s-low);
  display: flex; flex-direction: column;
  padding: 18px 12px;
  position: sticky; top: 0; height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }

.brand .mark {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 22px;
  background: var(--primary); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}

.brand .title { font-size: 17px; font-weight: 600; line-height: 20px; }
.brand .sub { font-size: 11.5px; letter-spacing: .03em; color: var(--on-surface-var); }

.nav-list { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 0 18px;
  border: 0; border-radius: 26px;
  background: transparent; color: var(--on-surface-var);
  font-size: 14.5px; font-weight: 600; text-align: left;
  cursor: pointer; width: 100%;
}

.nav-item:hover { background: var(--s-c); color: var(--on-surface); }
.nav-item.active { background: var(--secondary-container); color: var(--on-secondary-container); }
.nav-item .ico { font-size: 17px; width: 22px; text-align: center; flex: 0 0 22px; }
.nav-item .lbl { flex: 1; min-width: 0; }

.nav-badge {
  min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px;
  background: var(--primary); color: var(--on-primary);
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
  display: none; align-items: center; justify-content: center;
}

.nav-badge.show { display: flex; animation: popIn .3s cubic-bezier(.2,0,0,1) both; }
.nav-badge.calm { background: var(--tertiary-container); color: var(--on-tertiary-container); }

.side-foot { border-top: 1px solid var(--outline-var); padding-top: 12px; margin-top: 12px; }

.side-user { display: flex; align-items: center; gap: 10px; padding: 4px 8px 10px; min-width: 0; }

.side-user .ava {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 18px;
  background: var(--tertiary-container); color: var(--on-tertiary-container);
  display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 600;
}

.side-user .who { min-width: 0; }
.side-user .nm { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user .rl { font-size: 12px; color: var(--on-surface-var); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.side-actions { display: flex; gap: 8px; }

.icon-btn {
  min-height: 44px; padding: 0 16px; border-radius: 22px;
  border: 1px solid var(--outline); background: transparent; color: var(--on-surface);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}

.icon-btn:hover { background: var(--s-c); }
.icon-btn.square { width: 44px; flex: 0 0 44px; padding: 0; font-size: 16px; }

main { flex: 1; min-width: 0; padding: 24px 24px 40px; }
.page { max-width: 1100px; margin: 0 auto; }
section.tab[hidden] { display: none; }

.page-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin: 0 4px 16px;
}

.page-head h1 { margin: 0; font-size: 24px; font-weight: 500; line-height: 32px; }
.page-head .meta { font-size: 13px; color: var(--on-surface-var); }

/* ═══ KPI ══════════════════════════════════════════════════════════════════ */

.kpis {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px; margin-bottom: 20px;
}

.kpi {
  background: var(--s-low); border-radius: 28px; padding: 16px; min-width: 0;
  animation: popIn .36s cubic-bezier(.2,0,0,1) both;
}

.kpi .top { display: flex; align-items: center; gap: 8px; }

.kpi .chip {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 22px;
  background: var(--s-highest); color: var(--on-surface-var);
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}

.kpi .chip.primary { background: var(--primary-container); color: var(--on-primary-container); }
.kpi .chip.success { background: var(--success-container); color: var(--on-success-container); }
.kpi .chip.tertiary { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.kpi .k { font-size: 12px; line-height: 15px; color: var(--on-surface-var); min-width: 0; }
.kpi .v { font-size: 30px; font-weight: 400; line-height: 36px; font-variant-numeric: tabular-nums; margin-top: 10px; }
.kpi .sub { font-size: 12px; line-height: 16px; color: var(--on-surface-var); margin-top: 4px; }
.kpi .sub.good { color: var(--success); }
.kpi .sub.bad { color: var(--error); }

/* ═══ КАРТОЧКИ ═════════════════════════════════════════════════════════════ */

.card {
  background: var(--s-low); border-radius: 32px; overflow: hidden;
  margin-bottom: 16px; animation: fadeUp .34s cubic-bezier(.2,0,0,1) both;
}

.card-head {
  padding: 16px 20px 12px; display: flex; align-items: center;
  justify-content: space-between; gap: 10px; flex-wrap: wrap;
}

.card-head h2 { margin: 0; font-size: 16px; font-weight: 600; line-height: 22px; }

.tag {
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
  background: var(--s-highest); color: var(--on-surface-var); white-space: nowrap;
}

.tag.success { background: var(--success-container); color: var(--on-success-container); }
.tag.tertiary { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.card-body { padding: 4px 20px 20px; }
.hint { font-size: 13px; line-height: 19px; color: var(--on-surface-var); }

.banner {
  display: flex; gap: 14px; align-items: flex-start;
  border-radius: 28px; padding: 16px 20px; margin-bottom: 16px;
  background: var(--error-container); color: var(--on-error-container);
  font-size: 14px; line-height: 20px;
}

.banner.info { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.banner strong { display: block; font-size: 15px; margin-bottom: 2px; }

/* ═══ ФОРМЫ ════════════════════════════════════════════════════════════════ */

.field {
  display: block; background: var(--s-highest); border-radius: 28px;
  padding: 10px 22px 8px; min-width: 0;
}

.field > span { display: block; font-size: 12px; color: var(--on-surface-var); margin-bottom: 2px; }

.field input, .field select, .field textarea {
  width: 100%; min-height: 34px; padding: 0;
  background: transparent; border: 0; outline: none;
  font-size: 15px; font-weight: 500;
}

.field textarea {
  min-height: 76px; resize: vertical; font-weight: 400; line-height: 22px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px;
}

.field input[type=number] { font-variant-numeric: tabular-nums; }
.field.disabled { opacity: .5; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; align-items: start; }
.form-col { display: grid; gap: 12px; align-content: start; min-width: 0; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; padding: 8px 20px; background: var(--s-c); border-radius: 28px;
}

.switch-row .lbl { font-size: 15px; font-weight: 500; }
.switch-row .sub { font-size: 12px; color: var(--on-surface-var); }

.sw {
  position: relative; width: 52px; height: 32px; flex: 0 0 52px;
  border-radius: 999px; border: 2px solid var(--outline);
  background: var(--s-highest); padding: 0; cursor: pointer;
}

.sw::after {
  content: ""; position: absolute; top: 50%; left: 14px;
  transform: translate(-50%, -50%);
  width: 16px; height: 16px; border-radius: 50%; background: var(--outline);
  transition: all .25s cubic-bezier(.2,0,0,1);
}

.sw.on { background: var(--primary); border-color: var(--primary); }
.sw.on::after { left: 34px; width: 24px; height: 24px; background: var(--on-primary); }
.sw:disabled { cursor: not-allowed; opacity: .6; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip-btn {
  display: flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--outline); background: transparent; color: var(--on-surface);
  font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
}

.chip-btn:hover { background: var(--s-c); }
.chip-btn.on { background: var(--secondary-container); color: var(--on-secondary-container); border-color: transparent; }
.chip-btn.wide { flex: 1 1 160px; min-height: 52px; justify-content: center; line-height: 1.25; }

.btn {
  min-height: 48px; padding: 0 24px; border: 0; border-radius: 24px;
  background: var(--primary); color: var(--on-primary);
  font-size: 15px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}

.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.tonal { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn.outline { background: transparent; border: 1px solid var(--outline); color: var(--on-surface); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 13.5px; border-radius: 20px; }
.btn.big { min-height: 52px; padding: 0 26px; border-radius: 28px; }

.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.result { font-size: 14px; font-weight: 500; line-height: 20px; animation: toastIn .3s ease both; }
.result.ok { color: var(--success); }
.result.err { color: var(--error); }

/* ═══ ВЫБОР ПОЛУЧАТЕЛЕЙ ════════════════════════════════════════════════════ */

.picker { border-radius: 28px; background: var(--s-c); overflow: hidden; min-width: 0; }

.picker-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 16px; flex-wrap: wrap;
}

.picker-head .count { font-size: 14px; font-weight: 500; }
.picker-head .count b { color: var(--primary); font-variant-numeric: tabular-nums; }
.picker-search { width: 100%; min-height: 48px; padding: 0 16px; background: var(--s-highest); border: 0; outline: none; font-size: 15px; }
.picker-list { max-height: 300px; overflow-y: auto; overflow-x: hidden; }

.picker-list label {
  display: flex; align-items: center; gap: 12px; min-height: 48px;
  padding: 6px 16px; border-bottom: 1px solid var(--outline-var);
  cursor: pointer; min-width: 0;
}

.picker-list label.picked { background: var(--primary-container); color: var(--on-primary-container); }
.picker-list .nm { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-list .hh { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--on-surface-var); white-space: nowrap; }

/* ═══ ТАБЛИЦЫ ══════════════════════════════════════════════════════════════ */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
  text-align: left; padding: 8px 16px; font-size: 12px; font-weight: 600;
  color: var(--on-surface-var); border-bottom: 1px solid var(--outline-var); white-space: nowrap;
}

td { padding: 11px 16px; border-bottom: 1px solid var(--outline-var); }
th.r, td.r { text-align: right; }
th.c, td.c { text-align: center; }
td.num { font-variant-numeric: tabular-nums; font-weight: 600; }
td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
td.muted { color: var(--on-surface-var); }
.nowrap { white-space: nowrap; }

.pill {
  display: inline-block; padding: 5px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  background: var(--s-highest); color: var(--on-surface-var);
}

.pill.ok { background: var(--success-container); color: var(--on-success-container); }
.pill.bad { background: var(--error-container); color: var(--on-error-container); }
.pill.wait { background: var(--tertiary-container); color: var(--on-tertiary-container); }

.place {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 22px;
  background: var(--s-highest); color: var(--on-surface-var);
  font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums;
}

.place.gold { background: var(--primary); color: var(--on-primary); }
.place.silver { background: var(--primary-container); color: var(--on-primary-container); }

.bar { display: flex; align-items: center; gap: 10px; }
.bar .track { flex: 1; height: 8px; border-radius: 999px; background: var(--s-highest); min-width: 40px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 999px; background: var(--primary); transition: width .6s cubic-bezier(.2,0,0,1); }
.bar .pct { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--on-surface-var); min-width: 34px; text-align: right; }

/* Карточки вместо таблиц на телефоне */
.cards { display: none; gap: 10px; padding: 0 12px 14px; }
.cards .row { background: var(--s-c); border-radius: 28px; padding: 14px 18px; animation: fadeUp .3s cubic-bezier(.2,0,0,1) both; }
.cards .row .t { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cards .row .nm { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cards .row .sub { font-size: 12.5px; color: var(--on-surface-var); margin-top: 4px; }
.cards .row .facts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.cards .row .facts span {
  padding: 6px 12px; border-radius: 999px; background: var(--s-highest);
  font-size: 12.5px; font-variant-numeric: tabular-nums;
}

/* ═══ ГРАФИКИ ══════════════════════════════════════════════════════════════ */

/* Оси и сетка — тонкие, сплошные, на шаг от поверхности: они фон, а не данные. */
.c-grid { stroke: var(--outline-var); stroke-width: 1; }
.c-axis { stroke: var(--outline); stroke-width: 1; }

/* Текст никогда не носит цвет данных — только чернила интерфейса. */
.c-ax { fill: var(--on-surface-var); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.c-name { font-size: 12.5px; }
.c-val { fill: var(--on-surface); font-size: 12.5px; font-weight: 600; }

/* Хит-зона крупнее марки: попасть курсором и клавишей Tab должно быть легко. */
.c-hit { cursor: default; outline: none; }
.c-hit:hover, .c-hit.hot { fill: var(--scrim); }
.c-hit:focus-visible { fill: var(--scrim); stroke: var(--primary); stroke-width: 2; }

.chart-tip {
  position: fixed; z-index: 200; pointer-events: none;
  background: var(--s-highest); color: var(--on-surface);
  border-radius: 14px; padding: 9px 13px; font-size: 13px; line-height: 18px;
  box-shadow: var(--e2); max-width: 260px;
}

/* Таблица-двойник: значения доступны и без наведения. */
.table-view { border-top: 1px solid var(--outline-var); }

.table-view summary {
  padding: 12px 20px; font-size: 13.5px; font-weight: 600;
  color: var(--on-surface-var); cursor: pointer; list-style: none;
}

.table-view summary::-webkit-details-marker { display: none; }
.table-view summary::before { content: "▸ "; }
.table-view[open] summary::before { content: "▾ "; }
.table-view summary:hover { color: var(--primary); }

/* ═══ ЖУРНАЛ ═══════════════════════════════════════════════════════════════ */

.log-item {
  display: grid; grid-template-columns: auto 1fr; gap: 14px;
  padding: 14px 20px; border-top: 1px solid var(--outline-var); min-width: 0;
}

.log-item .ic {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 999px;
  background: var(--s-highest); color: var(--on-surface-var);
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}

.log-item .ic.gift { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.log-item .ic.norm { background: var(--primary-container); color: var(--on-primary-container); }
.log-item .ic.warn { background: var(--error-container); color: var(--on-error-container); }
.log-item .ic.good { background: var(--success-container); color: var(--on-success-container); }
.log-item .hd { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.log-item .ty { font-size: 14px; font-weight: 600; }
.log-item .dt { font-size: 12.5px; color: var(--on-surface-var); font-variant-numeric: tabular-nums; }
.log-item .tx { font-size: 14px; line-height: 21px; color: var(--on-surface-var); margin-top: 4px; white-space: pre-line; overflow-wrap: anywhere; }

/* ═══ ПУСТО / ЗАГРУЗКА ═════════════════════════════════════════════════════ */

.empty { padding: 40px 16px; text-align: center; }
.empty .em { font-size: 32px; line-height: 1; }
.empty .ttl { font-size: 16px; font-weight: 600; margin-top: 12px; }
.empty .tx { font-size: 14px; color: var(--on-surface-var); margin-top: 6px; }

.skeleton { display: grid; gap: 12px; }

.skeleton .bar-sk, .skeleton .box {
  border-radius: 28px;
  background: linear-gradient(90deg, var(--s-low) 0%, var(--s-high) 45%, var(--s-low) 85%);
  background-size: 500px 100%; animation: shimmer 1.1s linear infinite;
}

.skeleton .bar-sk { height: 28px; width: 220px; border-radius: 999px; }
.skeleton .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.skeleton .box { height: 112px; }

/* ═══ ТОСТЫ ════════════════════════════════════════════════════════════════ */

#toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px; max-width: min(420px, 92vw);
}

.toast {
  background: var(--s-highest); color: var(--on-surface);
  border-radius: 20px; padding: 13px 18px; font-size: 14px; line-height: 20px;
  box-shadow: var(--e2); animation: toastIn .28s cubic-bezier(.2,0,0,1) both;
}

.toast.ok { background: var(--success-container); color: var(--on-success-container); }
.toast.err { background: var(--error-container); color: var(--on-error-container); }

/* ═══ НИЖНЯЯ ПАНЕЛЬ (ТЕЛЕФОН) ══════════════════════════════════════════════ */

.bottom-nav { display: none; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  main { padding: 12px 12px 104px; }

  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--s-c);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    display: flex; justify-content: space-around; gap: 2px;
  }

  .bottom-nav button {
    flex: 1 1 0; min-width: 0; min-height: 56px; border: 0; background: transparent;
    color: var(--on-surface-var); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 2px;
  }

  .bottom-nav button.active { color: var(--on-secondary-container); }

  .bottom-nav .ico {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    width: 60px; max-width: 100%; height: 32px; border-radius: 999px;
    font-size: 16px; background: transparent;
    transition: background-color .25s cubic-bezier(.2,0,0,1);
  }

  .bottom-nav button.active .ico { background: var(--secondary-container); }
  .bottom-nav .lbl { font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

  .bottom-nav .dot {
    position: absolute; top: -2px; right: 8px;
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--primary); color: var(--on-primary);
    font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
    display: none;
  }

  .bottom-nav .dot.show { display: block; }

  /* Шторка «Ещё» — разделы, не влезшие в пять целей нижней панели. */
  .more-sheet {
    position: absolute; right: 8px; bottom: calc(100% + 8px);
    background: var(--s-highest); border-radius: 24px; padding: 8px;
    box-shadow: var(--e2); min-width: 200px;
    display: flex; flex-direction: column; gap: 4px;
    animation: popIn .2s cubic-bezier(.2,0,0,1) both;
  }

  /* Перебиваем колоночную раскладку кнопок нижней панели: в шторке пункты
     идут строкой «иконка — подпись», как в сайдбаре. */
  .more-sheet .nav-item {
    flex-direction: row; align-items: center; justify-content: flex-start;
    min-height: 48px; padding: 0 16px; gap: 12px; text-align: left;
  }

  .more-sheet .nav-item .ico { width: 22px; height: auto; background: none; }
  .more-sheet .nav-item .lbl { font-size: 14.5px; flex: 1; }

  .mobile-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 6px 4px 14px; position: sticky; top: 0; z-index: 15;
    background: var(--surface);
  }

  .page-head h1 { font-size: 22px; }
  .kpis { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .card { border-radius: 28px; }
  .card-head, .card-body { padding-left: 16px; padding-right: 16px; }
  .table-wrap.mobile-cards { display: none; }
  .cards { display: grid; }
  #access-form { grid-template-columns: 1fr !important; }
  .chart-tip { max-width: 220px; }
}

@media (min-width: 901px) { .mobile-bar { display: none; } }
