/* Платформа хозяина: тёмное меню слева, светлое рабочее поле, жёлтые кнопки такси.
   Блок «Заметки» внутри — как «Заметки» на айфоне: белый лист, золотые значки. */

:root {
  --ground: #f4f3ef;          /* рабочее поле */
  --panel: #ffffff;           /* панели и таблицы */
  --hover: #faf9f5;
  --ink: #1c1b17;
  --mute: #67645b;            /* вторичный текст: 5.4:1 на поле, 5.9:1 на белом */
  --line: #e7e4db;
  --line-strong: #d3cfc3;
  --fill2: #efede7;           /* поиск, переключатели */
  --rail: #1d1c18;
  --rail-2: #2a2924;
  --rail-ink: #ecebe5;
  --rail-mute: #a4a093;
  --accent: #f5c400;          /* жёлтый такси: кнопки и метки */
  --accent-press: #e3b500;
  --on-accent: #1c1b17;
  --accent-ink: #8a6300;      /* жёлтый для текста на белом: 5.2:1 */
  --accent-soft: #fff3c4;
  --bad: #c42b1c;
  --bad-soft: #fdebe8;
  --warn: #8f5a00;
  --warn-soft: #fff1d6;
  --good: #1e7b3c;
  --good-soft: #e2f3e6;
  --good-strong: #2f9d55;
  --focus: #b88a00;
  --radius: 14px;
  --shadow-pop: 0 24px 64px rgba(28, 27, 23, .22), 0 2px 8px rgba(28, 27, 23, .08);
  --toast-shadow: 0 10px 30px rgba(28, 27, 23, .16);
  /* заметки (как на айфоне) */
  --paper: #ffffff;
  --paper-bar: rgba(255, 255, 255, .94);
  --note-tint: #9e6b00;
  --note-tint-soft: rgba(245, 197, 24, .28);
  --n-group: #f2f2f7;
  --n-fill: rgba(118, 118, 128, .12);
  --sep: rgba(60, 60, 67, .2);
  --on-tint: #ffffff;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #121210;
    --panel: #1b1a17;
    --hover: #22211d;
    --ink: #f1efe8;
    --mute: #a9a598;
    --line: #2d2b26;
    --line-strong: #403d36;
    --fill2: #26241f;
    --rail: #0b0b09;
    --rail-2: #1d1c18;
    --accent-ink: #ffd23f;
    --accent-soft: rgba(245, 196, 0, .16);
    --bad: #ff8a7a;
    --bad-soft: rgba(255, 98, 77, .15);
    --warn: #ffc466;
    --warn-soft: rgba(255, 170, 0, .15);
    --good: #6bd690;
    --good-soft: rgba(70, 200, 115, .14);
    --good-strong: #46c072;
    --focus: #ffd23f;
    --shadow-pop: 0 24px 64px rgba(0, 0, 0, .6);
    --toast-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    --paper: #000000;
    --paper-bar: rgba(0, 0, 0, .9);
    --note-tint: #ffd60a;
    --note-tint-soft: rgba(255, 214, 10, .3);
    --n-group: #1c1c1e;
    --n-fill: rgba(118, 118, 128, .24);
    --sep: rgba(84, 84, 88, .65);
    --on-tint: #000000;
  }
}

/* --- основа ----------------------------------------------------------------------------------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--ground); scrollbar-color: var(--line-strong) transparent; }
body {
  margin: 0; min-height: 100vh; background: var(--ground); color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; caret-color: var(--accent-ink);
}
::selection { background: var(--accent-soft); color: var(--ink); }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
svg { display: block; flex: none; }
h1, h2 { text-wrap: balance; }
.num, .kpi-value, .big-number, table.grid td { font-variant-numeric: tabular-nums; }
.bad { color: var(--bad); }
.good { color: var(--good); }
.warn { color: var(--warn); }
.quiet { color: var(--mute); }
.small { font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* --- каркас: меню слева, на телефоне — снизу --------------------------------------------------- */
.rail {
  position: fixed; inset: 0 auto 0 0; z-index: 10; width: 248px; display: flex; flex-direction: column;
  padding: 18px 12px 12px; background: var(--rail); color: var(--rail-ink); overflow-y: auto;
  scrollbar-color: var(--rail-2) transparent;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; color: #fff; font-size: 19px; font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 9px; }
.rail-nav { display: grid; gap: 2px; }
.rail-group { margin: 18px 12px 6px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--rail-mute); }
.nav-link {
  display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: 10px;
  color: var(--rail-ink); font-size: 15px; font-weight: 500; transition: background .15s ease;
}
.nav-link:hover { background: var(--rail-2); text-decoration: none; }
.nav-link svg { color: var(--rail-mute); }
.nav-link.accent svg { color: var(--accent); }
.nav-link[aria-current] { background: rgba(245, 196, 0, .14); color: #ffe07a; }
.nav-link[aria-current] svg { color: var(--accent); }
.rail-me {
  margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 6px 4px 12px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.rail-who { flex: 1; min-width: 0; display: grid; }
.rail-who b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-who small { font-size: 12px; color: var(--rail-mute); }
.rail-me .icon-btn { color: var(--rail-mute); }
.rail-me .icon-btn:hover { background: var(--rail-2); color: var(--rail-ink); }

.view { margin-left: 248px; min-height: 100vh; padding: 28px 32px 56px; outline: none; }
.page { max-width: 1320px; margin: 0 auto; }
@media (prefers-reduced-motion: no-preference) {
  .page { animation: rise .34s cubic-bezier(.16, 1, .3, 1); }
}
@keyframes rise { from { transform: translateY(6px); opacity: .55; } }

.tabbar { display: none; }

/* --- шапка страницы ----------------------------------------------------------------------------- */
.head { margin: 0 0 20px; }
.crumb { display: inline-flex; align-items: center; gap: 2px; margin: 0 0 8px -4px; color: var(--accent-ink); font-size: 14px; font-weight: 600; }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head h1 { font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -.015em; margin: 0; }
.head .sub { margin: 6px 0 0; color: var(--mute); font-size: 15px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.section-title { font-size: 19px; font-weight: 700; margin: 28px 0 12px; }

/* --- кнопки ------------------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 42px; padding: 0 16px;
  border-radius: 11px; font-size: 15px; font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: background .15s ease, box-shadow .15s ease, transform .1s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-press); }
.btn.dark { background: var(--ink); color: var(--panel); }
.btn.dark:hover { opacity: .88; }
.btn.ghost { color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn.ghost:hover { background: var(--fill2); }
.btn.small { height: 34px; padding: 0 11px; border-radius: 9px; font-size: 14px; }
.btn.wide { width: 100%; }
.note-btn svg { color: var(--mute); }
.note-btn.has svg { color: var(--accent-ink); }
.note-cta { background: var(--accent-soft); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(184, 138, 0, .35); }
.note-cta svg { color: var(--accent-ink); }
.note-cta:hover { background: var(--accent); }
.note-cta:hover svg { color: var(--on-accent); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; color: var(--ink); }
.icon-btn:hover { background: var(--fill2); }
.icon-btn:disabled { opacity: .3; cursor: default; background: none; }

/* --- панели ------------------------------------------------------------------------------------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: start; }
.cards .panel { padding: 18px 20px 20px; overflow: hidden; }
.cards .panel > h2 { font-size: 17px; font-weight: 650; margin: 0 0 12px; }
.cards .panel > table.grid { width: calc(100% + 40px); margin: 0 -20px; }
.cards .panel > table.grid:last-child { margin-bottom: -20px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px 12px; }
.panel-head h2 { font-size: 17px; font-weight: 650; margin: 0; }
.panel-head p { margin: 2px 0 0; }
.panel-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--fill2); color: var(--ink); flex: none; }
.panel-ico.bad { background: var(--bad-soft); color: var(--bad); }
.panel-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 20px;
  border-top: 1px solid var(--line); color: var(--accent-ink); font-size: 14px; font-weight: 600;
}
.notice {
  display: flex; align-items: center; gap: 10px; margin: 0 0 16px; padding: 12px 16px; border-radius: 12px;
  background: var(--warn-soft); color: var(--ink);
}
.notice svg { color: var(--warn); }

/* --- цифры дня ---------------------------------------------------------------------------------- */
.kpis {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; margin: 0 0 20px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.kpi { background: var(--panel); padding: 16px 18px 15px; min-width: 0; }
.kpi-label { display: flex; align-items: center; gap: 7px; margin: 0 0 10px; color: var(--mute); font-size: 13px; font-weight: 500; }
.kpi-value { margin: 0; font-size: 26px; line-height: 1.1; font-weight: 700; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value small { font-size: 15px; font-weight: 500; color: var(--mute); letter-spacing: 0; }
.kpi-sub { margin: 7px 0 0; color: var(--mute); font-size: 13px; }

/* --- главная: смена слева, штрафы и долги справа ------------------------------------------------- */
.board { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.board-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
@media (min-width: 1600px) {
  .board { grid-template-columns: minmax(0, 1fr) 340px; }
  .board-side { grid-template-columns: minmax(0, 1fr); }
}
.shift-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); gap: 28px; align-items: end; padding: 18px 20px 14px; }
.daynav { display: flex; align-items: center; gap: 4px; margin: 0 0 6px -8px; }
.daynav h2 { font-size: 19px; font-weight: 700; margin: 0 4px; white-space: nowrap; }
.shift-sum { margin: 0; font-size: 15px; color: var(--mute); }
.shift-sum b { color: var(--ink); font-size: 22px; font-weight: 700; margin: 0 2px; }
.pct { display: inline-block; margin-left: 10px; padding: 2px 8px; border-radius: 999px; background: var(--good-soft); color: var(--good); font-size: 13px; font-weight: 600; vertical-align: 2px; }
.progress { display: block; width: 100%; height: 6px; margin: 10px 0 8px; }
.progress .track { fill: var(--fill2); }
.progress .fill { fill: var(--good-strong); }
.shift-top p.small { margin: 0; }
.hours { margin: 0; }
.hours svg { width: 100%; height: 52px; }
.hours .bar { fill: var(--line-strong); }
.hours .bar.on { fill: var(--accent); }
.hours .base { fill: var(--line); }
.hours-axis { display: flex; justify-content: space-between; margin-top: 4px; color: var(--mute); font-size: 11px; font-variant-numeric: tabular-nums; }
.table-foot { margin: 0; padding: 12px 20px 14px; border-top: 1px solid var(--line); }

.side-list { overflow: hidden; }
.side-item { display: block; padding: 12px 20px; border-top: 1px solid var(--line); }
.side-item p { margin: 5px 0 0; }
.side-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
a.side-item:hover { background: var(--hover); text-decoration: none; }

/* --- поиск, отборы, порядок --------------------------------------------------------------------- */
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); }
.panel > .toolbar-row:first-child { border-top: 0; }
.toolbar-row > div { min-width: 0; max-width: 100%; }             /* обёртка отбора сжимается, отбор листается */
.search {
  flex: 1 1 220px; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  border-radius: 10px; background: var(--fill2); color: var(--mute);
}
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; color: var(--ink); font: inherit; font-size: 15px; outline: none; }
.search:focus-within { box-shadow: 0 0 0 2px var(--focus); }
.search input::placeholder { color: var(--mute); }
.seg { display: inline-flex; max-width: 100%; gap: 2px; padding: 3px; border-radius: 11px; background: var(--fill2); overflow-x: auto; scrollbar-width: none; }
.seg button, .seg-link {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 8px;
  color: var(--mute); font-size: 14px; font-weight: 500; white-space: nowrap; text-decoration: none;
}
.seg-link:hover { text-decoration: none; color: var(--ink); }
.seg button[aria-pressed="true"], .seg-link[aria-current="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); font-weight: 600; }
.seg .count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--line); color: var(--ink); font-size: 12px; font-weight: 600; }
.page-seg { margin: 0 0 20px; }
.select { position: relative; display: inline-flex; align-items: center; }
.select svg { position: absolute; right: 10px; color: var(--mute); pointer-events: none; }
.select select {
  appearance: none; height: 40px; padding: 0 34px 0 12px; border: 0; border-radius: 10px; background: var(--fill2);
  color: var(--ink); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
}

/* --- таблицы ------------------------------------------------------------------------------------ */
table.grid { width: 100%; border-collapse: collapse; font-size: 15px; }
table.grid th {
  padding: 10px 16px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap;
  color: var(--mute); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}
table.grid td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid th:first-child, table.grid td:first-child { padding-left: 20px; }
table.grid th:last-child, table.grid td:last-child { padding-right: 20px; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: var(--hover); }
table.grid td small { display: block; margin-top: 3px; color: var(--mute); font-size: 13px; }
table.grid tfoot td { border-top: 1px solid var(--line); border-bottom: 0; }
table.grid.compact td { padding-top: 10px; padding-bottom: 10px; }
.num { text-align: right; white-space: nowrap; }
td.acts, th.acts { text-align: right; white-space: nowrap; width: 1%; }
td.cell-who { min-width: 220px; }
td.acts > * + * { margin-left: 8px; }
.strong-link { font-weight: 600; }
table.grid td small.phone-only { display: none; }

.person { display: flex; align-items: center; gap: 12px; min-width: 0; color: inherit; }
.person:hover { text-decoration: none; }
.person:hover b { text-decoration: underline; text-underline-offset: 3px; }
.person-text { display: grid; min-width: 0; }
.person-text b { font-weight: 600; }
.person-text small { color: var(--mute); font-size: 13px; }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; font-size: 13px; font-weight: 700; flex: none; }
.avatar.t0 { background: #fde6d8; color: #8a3b12; }
.avatar.t1 { background: #e1eafc; color: #1e4fa3; }
.avatar.t2 { background: #e2f2e2; color: #256b2c; }
.avatar.t3 { background: #f6e1f0; color: #8a2a6e; }
.avatar.t4 { background: #fff0c4; color: #745200; }
.avatar.t5 { background: #e0f0f2; color: #1f6672; }
@media (prefers-color-scheme: dark) {
  .avatar.t0 { background: #3d2417; color: #ffbe98; }
  .avatar.t1 { background: #1b2a45; color: #a9c6ff; }
  .avatar.t2 { background: #1b3320; color: #a5e0ac; }
  .avatar.t3 { background: #3a1c33; color: #f3b3e2; }
  .avatar.t4 { background: #3a2f0d; color: #ffd86b; }
  .avatar.t5 { background: #15333a; color: #9ad9e3; }
}

/* госномер — как табличка: белая, с синей полосой KZ слева и регионом справа */
.plate {
  display: inline-flex; align-items: stretch; height: 26px; border: 1.5px solid #1a1a1a; border-radius: 5px;
  background: #ffffff; color: #111111; overflow: hidden; white-space: nowrap; vertical-align: middle;
  font: 700 14px/1 "Segoe UI", Roboto, -apple-system, Arial, sans-serif; letter-spacing: .03em;
}
.plate .kz { display: flex; align-items: center; padding: 0 4px; background: #007aa0; color: #ffffff; font-size: 9px; letter-spacing: .02em; }
.plate b { display: flex; align-items: center; padding: 0 6px; }
.plate .reg { display: flex; align-items: center; padding: 0 5px; border-left: 1.5px solid #1a1a1a; }
.cell-car .plate + small { margin-top: 5px; }

.chip {
  display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.quiet { background: var(--fill2); color: var(--mute); }
td .chip + .chip { margin: 4px 0 0 4px; }

/* --- карточка водителя и разделы ----------------------------------------------------------------- */
.facts { display: grid; gap: 9px; margin: 0; }
.facts div { display: flex; justify-content: space-between; gap: 14px; }
.facts dt { color: var(--mute); }
.facts dd { margin: 0; text-align: right; font-weight: 500; }
.big-number { margin: 0 0 14px; font-size: 30px; line-height: 1.1; font-weight: 700; letter-spacing: -.015em; }
.car-line { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; color: var(--mute); }
.note-first { margin: 0 0 14px; font-size: 16px; line-height: 1.45; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.plain-list li:first-child { border-top: 0; padding-top: 0; }
.plain-list li:last-child { padding-bottom: 0; }
.plain-list small { display: block; margin-top: 3px; color: var(--mute); font-size: 13px; }
.menu-list { overflow: hidden; }
.menu-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 0 20px; border-top: 1px solid var(--line); font-size: 16px; text-align: left; }
.menu-item:first-child { border-top: 0; }
.menu-item span { flex: 1; }
.menu-item svg:first-child { color: var(--accent-ink); }
.menu-item svg:last-child { color: var(--mute); }
.menu-item:hover { background: var(--hover); text-decoration: none; }
.report-link { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.report-link:first-of-type { border-top: 0; padding-top: 0; }
.report-link span:not(.panel-ico) { flex: 1; display: grid; }
.report-link small { color: var(--mute); font-size: 13px; }
.report-link:hover { text-decoration: none; }
.report-link:hover b { text-decoration: underline; text-underline-offset: 3px; }
.period { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.period .btn { grid-column: 1 / -1; }
.frame { height: calc(100vh - 170px); min-height: 420px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #ffffff; }
.frame iframe { display: block; width: 100%; height: 100%; border: 0; }

/* --- поля ввода ----------------------------------------------------------------------------------- */
.field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field > span, .field > legend { padding: 0; color: var(--mute); font-size: 13px; font-weight: 600; }
.field input, .field select {
  width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--panel); color: var(--ink); font: inherit; font-size: 17px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
.seg-field { display: flex; width: 100%; }
.seg-field label { flex: 1; position: relative; }
.seg-field input { position: absolute; opacity: 0; pointer-events: none; }
.seg-field span { display: flex; align-items: center; justify-content: center; height: 38px; border-radius: 8px; color: var(--mute); font-size: 15px; font-weight: 600; cursor: pointer; }
.seg-field input:checked + span { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.seg-field input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

/* --- окно «Принять оплату» ------------------------------------------------------------------------- */
.dialog {
  width: min(440px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 18px;
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow-pop);
}
.dialog::backdrop { background: rgba(20, 19, 16, .45); }
@media (prefers-reduced-motion: no-preference) {
  .dialog[open] { animation: pop .22s cubic-bezier(.16, 1, .3, 1); }
}
@keyframes pop { from { transform: translateY(8px) scale(.985); opacity: .6; } }
.pay-form { display: grid; gap: 16px; padding: 20px 22px 22px; }
.pay-head { display: flex; align-items: center; justify-content: space-between; }
.pay-head h2 { margin: 0; font-size: 20px; font-weight: 700; }
.pay-who { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--fill2); }
.pay-who span { display: grid; min-width: 0; }
.pay-who small { color: var(--mute); font-size: 13px; }
.pay-note { margin: 0; color: var(--mute); font-size: 13px; line-height: 1.45; }
.pay-error { margin: 0; color: var(--bad); font-size: 14px; font-weight: 500; }
.pay-error[hidden] { display: none; }
.pay-foot { display: flex; justify-content: flex-end; gap: 10px; }

/* --- состояния -------------------------------------------------------------------------------------- */
.empty { padding: 44px 20px; text-align: center; color: var(--mute); line-height: 1.45; }
.empty b { display: block; margin-bottom: 6px; color: var(--ink); font-size: 17px; }
.empty .btn { margin-top: 16px; }
.skeleton i { display: block; height: 58px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
@media (prefers-reduced-motion: no-preference) { .skeleton i { animation: breathe 1.2s ease-in-out infinite alternate; } }
@keyframes breathe { to { opacity: .45; } }
.toast {
  position: fixed; z-index: 30; left: 50%; bottom: 28px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; max-width: min(560px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--panel); box-shadow: var(--toast-shadow);
  font-size: 15px;
}
.toast button { color: var(--accent); font-weight: 700; }
.toast[hidden] { display: none; }
.login { max-width: 360px; margin: 22vh auto 0; padding: 0 24px; text-align: center; }
.login .mark { margin: 0 auto 18px; border-radius: 14px; }
.login h1 { margin: 0 0 10px; font-size: 28px; }
.login p { margin: 0; color: var(--mute); line-height: 1.45; }

/* --- блок «Заметки»: лист как на айфоне ---------------------------------------------------------------- */
.view.paper { background: var(--paper); }
html:has(.view.paper), html:has(.view.paper) body { background: var(--paper); }
.view.paper .page { max-width: 760px; }
.notes { font-size: 17px; line-height: 1.3; caret-color: var(--note-tint); }
.notes ::selection { background: var(--note-tint-soft); }
.nbar {
  position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 44px; margin: -16px -12px 4px; padding: 0 4px; background: var(--paper-bar);
}
.nbar-left { justify-self: start; }
.nbar-right { justify-self: end; display: flex; gap: 2px; }
.nbar-mid { color: var(--mute); font-size: 13px; text-align: center; white-space: nowrap; }
.nback, .ntool { display: flex; align-items: center; justify-content: center; gap: 2px; min-width: 44px; min-height: 44px; padding: 0 8px; color: var(--note-tint); font-size: 17px; }
.nback svg { margin-left: -6px; }
.ntool:hover, .nback:hover { text-decoration: none; opacity: .75; }
.nlarge { margin: 2px 0 4px; font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: .01em; }
.ncount { margin: 0 0 14px; color: var(--mute); font-size: 15px; }
.nlist { overflow: hidden; border-radius: 12px; background: var(--n-group); }
.nrow { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 11px 16px; text-align: left; cursor: pointer; }
.nrow + .nrow::before { content: ""; position: absolute; top: 0; right: 0; left: 16px; border-top: .5px solid var(--sep); }
.nrow.icon-row + .nrow::before { left: 52px; }
.nrow:active { background: var(--n-fill); }
.nrow:hover { text-decoration: none; }
.nico { color: var(--note-tint); flex: none; }
.nrow .grow { flex: 1; min-width: 0; }
.ntitle { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ntitle.plain { font-weight: 400; }
.nsub { display: block; margin-top: 2px; color: var(--mute); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nsub time { margin-right: 6px; color: var(--ink); opacity: .72; }
.nsub .bad { color: var(--bad); }
.nvalue { color: var(--mute); font-variant-numeric: tabular-nums; }
.nchev { color: var(--mute); opacity: .55; flex: none; }
.nsection { margin: 22px 0 8px; font-size: 22px; font-weight: 700; }
.nsearch { display: flex; align-items: center; gap: 6px; height: 36px; margin: 0 0 14px; padding: 0 8px; border-radius: 10px; background: var(--n-fill); color: var(--mute); }
.nsearch input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; color: var(--ink); font: inherit; font-size: 17px; outline: none; }
.nhint { margin: 10px 4px 0; color: var(--mute); font-size: 13px; line-height: 1.4; }
.nempty { margin: 64px 32px; text-align: center; color: var(--mute); line-height: 1.45; }
.nempty b { display: block; margin-bottom: 6px; color: var(--ink); font-size: 20px; }
.pin-mark { display: inline-block; margin-left: 6px; color: var(--note-tint); vertical-align: -2px; }

.note .date { margin: 4px 0 14px; text-align: center; color: var(--mute); font-size: 13px; }
.note h2 { margin: 0 0 4px; font-size: 28px; line-height: 34px; font-weight: 700; }
.note .meta { margin: 0 0 14px; color: var(--mute); font-size: 15px; }
.editor { min-height: 55vh; padding-bottom: 40vh; outline: none; white-space: pre-wrap; word-wrap: break-word; font-size: 17px; line-height: 1.35; }
.editor.own::first-line { font-size: 28px; font-weight: 700; line-height: 1.25; }
.editor:empty::before { content: attr(data-placeholder); color: var(--mute); }
.editor.free { min-height: 6em; padding-bottom: 30vh; }
.editor.free.with-card { padding-bottom: 12px; }
.editor[contenteditable="false"] { cursor: default; }
.tail { height: 30vh; cursor: text; }
.divider { margin: 22px 0 14px; border: 0; border-top: .5px solid var(--sep); }
.note .label { margin: 0 0 6px; color: var(--mute); font-size: 13px; }
.months { display: flex; align-items: center; justify-content: space-between; margin: 0 -8px 10px; }
.months button { display: flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 8px; color: var(--note-tint); font-size: 15px; }
.months button:disabled { visibility: hidden; }
.months span { font-size: 15px; font-weight: 600; }
table.sheet { width: 100%; border-collapse: collapse; font-size: 16px; font-variant-numeric: tabular-nums; }
.sheet th, .sheet td { padding: 7px 8px; border: 1px solid var(--sep); text-align: left; vertical-align: top; }
.sheet th { font-weight: 600; }
.sheet td:first-child { width: 1%; white-space: nowrap; }
.sheet .wd { margin-left: 4px; color: var(--mute); font-size: 13px; }
.sheet .was { display: block; color: var(--mute); font-size: 13px; }
.sheet tr.unpaid td:first-child, .sheet tr.part td:first-child { color: var(--bad); }
.sheet tr.today td { font-weight: 600; }
.sheet .missing { color: var(--bad); font-size: 13px; }
.sheet tfoot td { color: var(--mute); font-size: 14px; }
.sheet .empty-note { color: var(--mute); text-align: center; }
.note .debt { margin: 16px 0 2px; font-size: 20px; font-weight: 700; }
.note .debt.bad b { color: var(--bad); }
.note .debt.good b { color: var(--good); }
.note .split { margin: 0 0 10px; color: var(--mute); font-size: 15px; }
.note .items { margin: 10px 0 0; padding: 0; list-style: none; font-size: 16px; line-height: 1.5; }
.note .toll { margin: 8px 0 0; color: var(--mute); font-size: 15px; }
.note .readonly { margin: 10px 0 0; color: var(--mute); font-size: 13px; }
.note-hint { margin: 10px 0 0; }
.pending { margin: 12px 0 0; padding: 12px 14px 14px; border-radius: 12px; background: var(--n-fill); }
.pending-title { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.pending ul { margin: 0; padding: 0 0 0 18px; font-size: 15px; line-height: 1.45; font-variant-numeric: tabular-nums; }
.pending .known { margin: 8px 0 0; color: var(--mute); font-size: 14px; line-height: 1.4; }
.pending .problem { margin: 8px 0 0; color: var(--bad); font-size: 14px; line-height: 1.4; }
.pending .known:first-child, .pending .problem:first-child { margin-top: 0; }
.nprimary { display: block; width: 100%; min-height: 44px; margin: 12px 0 0; border-radius: 12px; background: var(--note-tint); color: var(--on-tint); font-size: 17px; font-weight: 600; }
.nprimary:active { opacity: .8; }
.nprimary:disabled { opacity: .45; cursor: default; }

/* --- ширина экрана ----------------------------------------------------------------------------------- */
@media (max-width: 1360px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2, .span-3 { grid-column: 1 / -1; }
}
@media (max-width: 1023px) {
  .rail { display: none; }
  .view { margin-left: 0; padding: 20px 16px calc(92px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; z-index: 10; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(5, 1fr);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line);
  }
  .tab { display: grid; justify-items: center; gap: 3px; padding: 4px 0; color: var(--mute); font-size: 11px; font-weight: 600; }
  .tab:hover { text-decoration: none; }
  .tab[aria-current] { color: var(--ink); }
  .tab[aria-current] svg { color: var(--accent-ink); }
  .view.paper ~ .tabbar { background: var(--paper); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .nbar { margin-top: -20px; padding-top: env(safe-area-inset-top); }
}
@media (max-width: 760px) {
  .head h1 { font-size: 24px; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 22px; }
  .board-side, .cards { grid-template-columns: minmax(0, 1fr); }
  .shift-top { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 16px 16px 12px; }
  .toolbar-row { padding: 12px 16px; }
  .toolbar-row .seg { order: 3; width: 100%; }
  .toolbar-row > div { flex: 1 1 100%; }
  .cards .panel { padding: 16px; }
  .cards .panel > table.grid { width: calc(100% + 32px); margin: 0 -16px; }
  .cards .panel > table.grid:last-child { margin-bottom: -16px; }
  /* таблица на телефоне — карточки: кто и что сверху, цифры попарно, кнопки внизу */
  table.grid, table.grid tbody, table.grid tfoot { display: block; }
  table.grid thead { display: none; }
  table.grid tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  table.grid tbody tr:last-child { border-bottom: 0; }
  table.grid td, table.grid td:first-child, table.grid td:last-child { display: block; padding: 0; border: 0; text-align: left; }
  table.grid td.num { text-align: right; }
  table.grid td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--mute); font-size: 12px; font-weight: 500; }
  table.grid td.cell-who, table.grid td.acts { grid-column: 1 / -1; min-width: 0; }
  table.grid td.acts { display: flex; gap: 8px; width: auto; }
  table.grid td.acts > * + * { margin-left: 0; }
  table.grid td.acts .btn { flex: 1; height: 40px; }
  table.grid tfoot tr { border-top: 1px solid var(--line); }
  /* водители: имя и долг, номер и оплата, кнопки */
  table.people tr { grid-template-areas: "who debt" "car state" "acts acts"; align-items: center; }
  table.people td.cell-who { grid-area: who; grid-column: auto; }
  table.people td.cell-debt { grid-area: debt; }
  table.people td.cell-car { grid-area: car; }
  table.people td.cell-state { grid-area: state; text-align: right; }
  table.people td.cell-due { display: none; }
  table.people td.acts { grid-area: acts; }
  table.people td[data-label]::before { display: none; }
  table.people td.cell-who { min-width: 0; }
  table.grid td small.phone-only { display: block; }
  .dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .pay-foot .btn { flex: 1; }
  .frame { height: calc(100vh - 230px); }
  .nlarge { font-size: 30px; line-height: 36px; }
}
