/* ============================================================
   DriveCar CRM — дизайн-система
   ============================================================ */

:root {
  /* поверхности */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f9;

  /* текст */
  --text: #0f172a;
  --text-2: #475569;
  --muted: #7c879b;

  /* границы */
  --border: #e6eaf3;
  --border-2: #f0f3f9;

  /* акценты */
  --primary: #2b56e8;
  --primary-h: #1f45cc;
  --primary-soft: #eaf0ff;
  --green: #0f9d58;
  --green-soft: #e6f7ee;
  --amber: #c77700;
  --amber-soft: #fdf3e2;
  --red: #dc2743;
  --red-soft: #fdecef;
  --violet: #6d47d9;
  --violet-soft: #f0ecfd;

  /* тени */
  --sh-1: 0 1px 2px rgba(15, 23, 42, .04);
  --sh-2: 0 4px 16px rgba(15, 23, 42, .06);
  --sh-3: 0 16px 40px rgba(15, 23, 42, .16);

  /* геометрия */
  --r-xs: 8px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --r-xl: 24px;

  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --hdr-h: calc(56px + var(--safe-t));

  --radius: var(--r-lg); /* совместимость */
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--red); min-height: 18px; font-size: 13px; font-weight: 500; }
.pad { padding: 4px 16px 16px; }
.c { text-align: center; }

::selection { background: var(--primary-soft); }

/* ---------- Вход ---------- */
.login-screen {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 90% at 20% 0%, #24449b 0%, #101828 55%, #080d18 100%);
  padding: 22px;
}
.login-card {
  background: var(--surface); padding: 34px 26px calc(26px + var(--safe-b));
  border-radius: var(--r-xl); width: 100%; max-width: 372px;
  box-shadow: 0 32px 70px rgba(0, 0, 0, .45);
  display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.login-logo { font-size: 50px; line-height: 1; }
.logo { font-weight: 800; font-size: 21px; letter-spacing: -.3px; }
.login-card input { padding: 15px 14px; font-size: 16px; }

/* ---------- Шапка ---------- */
header {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(180deg, #131c31 0%, #0f1626 100%);
  color: #fff;
  padding: calc(9px + var(--safe-t)) 14px 9px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06), 0 6px 20px rgba(8, 13, 24, .28);
}
.hdr-main { flex: 1; min-width: 0; }
.hdr-title { font-size: 17px; font-weight: 700; letter-spacing: -.2px; line-height: 1.2; }
.hdr-sub { font-size: 11.5px; color: rgba(255, 255, 255, .55); margin-top: 1px; }
.hdr-brand { flex: 0 0 auto; font-size: 12px; font-weight: 700; color: #fff; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); padding: 3px 10px; border-radius: 999px; white-space: nowrap; letter-spacing: .2px; }
.hdr-btn {
  background: rgba(255, 255, 255, .1); color: #fff; border: none;
  width: 38px; height: 38px; border-radius: 12px; font-size: 18px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background .15s;
}
.hdr-btn:active { background: rgba(255, 255, 255, .22); }
.hdr-btn.spin { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main {
  padding: 14px 14px calc(var(--nav-h) + var(--safe-b) + 28px);
  max-width: 660px; margin: 0 auto;
}

/* ---------- Нижняя навигация ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
  display: flex;
}
.nav-btn {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  position: relative; padding-top: 4px;
  transition: color .15s;
}
.nav-btn .nav-ico {
  font-size: 20px; line-height: 1; position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 46px; height: 28px; border-radius: 999px;
  transition: background .18s, transform .18s;
}
.nav-btn.active { color: var(--primary); }
.nav-btn.active .nav-ico { background: var(--primary-soft); }
.nav-btn:active .nav-ico { transform: scale(.9); }

/* счётчик на иконке навигации */
.nav-badge {
  position: absolute; top: -3px; right: 2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--red); color: #fff;
  border-radius: 999px; font-size: 10.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Метрики ---------- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 13px 14px; box-shadow: var(--sh-1);
  position: relative; overflow: hidden;
}
.card::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--border); border-radius: 0 3px 3px 0;
}
.card .num { font-size: 23px; font-weight: 800; margin-top: 1px; letter-spacing: -.6px; }
.card .lbl { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.card.c-green .num { color: var(--green); }
.card.c-green::after { background: var(--green); }
.card.c-red .num { color: var(--red); }
.card.c-red::after { background: var(--red); }
.card.c-yellow .num { color: var(--amber); }
.card.c-yellow::after { background: var(--amber); }

/* ---------- Панели ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px; margin-bottom: 14px;
  box-shadow: var(--sh-1);
}
.panel h2 { font-size: 15px; margin-bottom: 12px; letter-spacing: -.2px; }

/* компактная панель-подсказка с действием */
.panel--tool { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.panel--tool .muted { font-size: 12px; }

/* ---------- Заголовок раздела ---------- */
.sec-head {
  display: flex; align-items: center; gap: 8px;
  margin: 2px 0 10px; min-height: 26px;
}
.sec-title { font-size: 13px; font-weight: 700; color: var(--text-2); letter-spacing: -.1px; }
.sec-count {
  background: var(--surface-3); color: var(--text-2);
  border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 700;
}
.sec-head .spacer { flex: 1; }

/* ---------- Поиск ---------- */
.search { position: relative; margin-bottom: 10px; }
.search input {
  padding-left: 40px; background: var(--surface); min-height: 46px;
  box-shadow: var(--sh-1); font-size: 15px;
}
.search::before {
  content: '⌕'; position: absolute; left: 14px; top: 50%; transform: translateY(-52%);
  font-size: 22px; color: var(--muted); pointer-events: none; font-weight: 700;
}
.search .search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: none; background: var(--surface-3); color: var(--text-2);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 15px;
}

/* ---------- Списки-карточки ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px; display: flex; flex-direction: column; gap: 9px;
  box-shadow: var(--sh-1);
  position: relative;
  transition: box-shadow .18s, transform .18s;
}
.item:active { transform: scale(.995); }
.item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.item-id { display: flex; align-items: center; gap: 11px; min-width: 0; }
.item-title { font-weight: 700; font-size: 15.5px; letter-spacing: -.2px; }
.item-sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.item-badges { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; flex-shrink: 0; max-width: 52%; }

/* аватар с инициалами */
.avatar {
  width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: #fff; letter-spacing: .3px;
  box-shadow: inset 0 -2px 6px rgba(0, 0, 0, .12);
}

.item-kv {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; font-size: 13.5px;
  background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 12px;
}
.item-kv .k { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .2px; }
.item-kv .v { font-weight: 600; }
.item-kv .cell { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.item-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.item-actions .btn { flex: 1; text-align: center; min-width: 96px; }

.empty {
  text-align: center; color: var(--muted); padding: 46px 16px; font-size: 14px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--r-lg);
}
.empty .empty-ico { font-size: 34px; display: block; margin-bottom: 8px; opacity: .55; }

/* акценты состояния карточки */
.item-debtor { border-color: #f6bcc5; background: linear-gradient(180deg, #fffafb 0%, var(--surface) 60%); }
.item-fines { box-shadow: inset 3px 0 0 var(--amber), var(--sh-1); }
.item--new {
  border-color: #b9c9fb;
  background: linear-gradient(180deg, #f7faff 0%, var(--surface) 62%);
  box-shadow: 0 6px 20px rgba(43, 86, 232, .10);
}
/* подсветка карточки при переходе с главной */
.item--focus { animation: focus-pulse 1.6s ease-out; }
@keyframes focus-pulse {
  0%, 100% { box-shadow: var(--sh-1); }
  20%, 60% { box-shadow: 0 0 0 4px rgba(43, 86, 232, .28), var(--sh-2); }
}

.item-flag {
  position: absolute; top: -8px; left: 14px;
  background: var(--primary); color: #fff;
  font-size: 10px; font-weight: 800; letter-spacing: .6px;
  padding: 3px 9px; border-radius: 999px;
  box-shadow: 0 4px 10px rgba(43, 86, 232, .38);
}

/* строка «чипов-рисков» */
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Сворачиваемые карточки (водители, авто) ---------- */
.item--fold { gap: 0; padding: 11px 13px; }
.item--fold .item-head { cursor: pointer; align-items: center; }
.item--fold .item-title { font-size: 15px; }
.item--fold .item-id > div { min-width: 0; }
/* строка-подпись не должна переносом ломать высоту ряда */
.item--fold .item-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item--fold .item-badges { align-items: center; max-width: 58%; flex-wrap: nowrap; }
.item--fold .item-body { display: none; flex-direction: column; gap: 9px; margin-top: 11px; }
.item--fold.is-open .item-body { display: flex; }
.item--fold.is-open { padding-bottom: 13px; }

.fold-ico {
  color: var(--muted); font-size: 15px; line-height: 1; margin-left: 2px;
  transition: transform .2s; flex-shrink: 0;
}
.item--fold.is-open .fold-ico { transform: rotate(180deg); }

/* метки-предупреждения, видные не разворачивая карточку */
.flag-dot {
  width: 24px; height: 24px; border-radius: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px;
}
.flag-dot--bad { background: var(--red-soft); }
.flag-dot--warn { background: var(--amber-soft); }

/* разделитель групп в списке (На машине / Без авто, В работе / Свободные) */
.list-sep {
  grid-column: 1 / -1;
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); padding: 6px 2px 0;
}
.list-sep:first-child { padding-top: 0; }

/* ---------- Быстрый блок новых заявок (дашборд) ---------- */
.quick {
  background: linear-gradient(135deg, #21387d 0%, #2b56e8 100%);
  border-radius: var(--r-lg); padding: 14px; margin-bottom: 14px;
  color: #fff; box-shadow: 0 12px 28px rgba(43, 86, 232, .28);
}
.quick-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.quick-head b { font-size: 15px; }
.quick-head .sec-count { background: rgba(255, 255, 255, .2); color: #fff; }
.quick-list { display: flex; flex-direction: column; gap: 7px; }
.quick-item {
  background: rgba(255, 255, 255, .12); border-radius: var(--r-sm);
  padding: 10px 12px; display: flex; align-items: center; gap: 10px;
  cursor: pointer; border: none; width: 100%; text-align: left; color: #fff;
  font-family: inherit; font-size: 14px;
  transition: background .15s;
}
.quick-item:active { background: rgba(255, 255, 255, .24); }
.quick-item .qi-main { flex: 1; min-width: 0; }
.quick-item .qi-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-item .qi-sub { font-size: 12px; color: rgba(255, 255, 255, .7); }
.quick-item .qi-go { font-size: 17px; opacity: .8; }
.quick-all {
  margin-top: 10px; width: 100%; background: #fff; color: var(--primary);
  border: none; border-radius: var(--r-sm); padding: 11px; font-weight: 700;
  font-size: 14px; cursor: pointer; font-family: inherit;
}

/* ---------- Бейджи ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent;
}
.b-green { background: var(--green-soft); color: var(--green); border-color: #c5ecd7; }
.b-yellow { background: var(--amber-soft); color: var(--amber); border-color: #f5dfb4; }
.b-red { background: var(--red-soft); color: var(--red); border-color: #f7c6ce; }
.b-teal { background: #d7f3f5; color: #0c8b96; border-color: #b6e6ea; }
.b-blue { background: var(--primary-soft); color: var(--primary); border-color: #ccd9fb; }
.b-orange { background: #fdeede; color: #b3600a; border-color: #f6d4ae; }
.b-gray { background: var(--surface-3); color: var(--muted); border-color: var(--border); }

/* заметка распознавания, когда номер документа пришлось отбросить: серым её не замечают */
.ocr-warn {
  font-size: 13px; font-weight: 600; color: #b3600a;
  background: #fdeede; border: 1px solid #f6d4ae; border-radius: 10px;
  padding: 7px 10px; margin-top: 2px;
}

/* ---------- Кнопки ---------- */
.btn {
  padding: 11px 15px; border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--surface); cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text);
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; font-family: inherit;
  transition: transform .12s, background .15s, border-color .15s, box-shadow .15s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 6px 16px rgba(43, 86, 232, .26);
}
.btn-primary:active { background: var(--primary-h); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: var(--surface-2); border-color: transparent; color: var(--text-2); }
.btn-big { padding: 14px 18px; font-size: 16px; border-radius: var(--r); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; min-height: 38px; border-radius: var(--r-sm); }
/* фирменный знак WhatsApp на кнопках: сразу видно, какая кнопка пишет человеку */
.wa-ico { width: 16px; height: 16px; flex: 0 0 auto; fill: #25d366; }
.btn-primary .wa-ico, .btn-danger .wa-ico, .btn-go .wa-ico { fill: currentColor; }

/* GO — заявка чистая, остался только страховой класс: спросить его у клиента в WhatsApp */
.btn-go {
  background: var(--green); border-color: var(--green); color: #fff; font-weight: 800; letter-spacing: .4px;
  box-shadow: 0 6px 16px rgba(15, 157, 88, .28);
}

.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + var(--safe-b) + 18px); z-index: 30;
  width: 58px; height: 58px; border-radius: 20px; border: none;
  background: linear-gradient(135deg, #3a68f5 0%, var(--primary) 100%);
  color: #fff; font-size: 27px; line-height: 1; cursor: pointer;
  box-shadow: 0 12px 28px rgba(43, 86, 232, .45);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.fab:active { transform: scale(.92); }

/* ---------- Свёрнутые действия ---------- */
.act-more { border-top: 1px dashed var(--border); padding-top: 9px; margin-top: 1px; }
.act-more > summary {
  list-style: none; cursor: pointer; user-select: none;
  font-size: 13px; font-weight: 600; color: var(--muted);
  display: flex; align-items: center; gap: 6px; padding: 3px 0;
}
.act-more > summary::-webkit-details-marker { display: none; }
.act-more > summary::after { content: '⌄'; margin-left: auto; font-size: 17px; line-height: 1; transition: transform .2s; }
.act-more[open] > summary::after { transform: rotate(180deg); }
.act-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px; margin-top: 9px;
}
.act-grid .btn { width: 100%; min-width: 0; }

/* ---------- Чипы / фильтры ---------- */
.filters { display: flex; gap: 7px; margin-bottom: 12px; }
.scroll-x { overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }
.chip {
  border: 1.5px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 8px 15px; cursor: pointer; font-size: 13.5px; font-weight: 600; white-space: nowrap;
  min-height: 40px; color: var(--text-2); font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s, border-color .15s;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 4px 12px rgba(43, 86, 232, .24); }
.chip .chip-n {
  background: var(--surface-3); color: var(--text-2);
  border-radius: 999px; padding: 0 6px; font-size: 11.5px; font-weight: 800; min-width: 18px; text-align: center;
}
.chip.active .chip-n { background: rgba(255, 255, 255, .25); color: #fff; }
.chip--alert:not(.active) { border-color: #f6c9d1; color: var(--red); }
.chip--alert:not(.active) .chip-n { background: var(--red-soft); color: var(--red); }

/* липкая панель фильтров */
.sticky-bar {
  position: sticky; top: var(--hdr-h); z-index: 18;
  background: var(--bg); padding: 6px 0 2px;
  margin: -6px 0 0;
}

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { flex: 1; min-width: 120px; }
.check-inline { flex-direction: row !important; align-items: center; gap: 8px; color: var(--text) !important; font-size: 14px !important; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-left: 5px; }
.nav-ico .dot { position: absolute; top: 1px; right: 6px; border: 2px solid #fff; width: 11px; height: 11px; }
.dot-off { background: var(--red); }
.dot-on { background: var(--green); }
.dot-qr { background: var(--amber); }

/* ---------- Поля ввода ---------- */
input, select, textarea {
  padding: 12px; border: 1.5px solid var(--border); border-radius: 12px;
  font-size: 16px; font-family: inherit; background: var(--surface); color: var(--text);
  width: 100%; min-height: 46px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3.5px var(--primary-soft);
}
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--primary); }
label { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .2px; }
label > input, label > select, label > textarea { text-transform: none; letter-spacing: 0; }
label:has(> input[type=checkbox]) {
  flex-direction: row; align-items: center; gap: 10px;
  color: var(--text); font-size: 14px; font-weight: 500; text-transform: none; letter-spacing: 0;
}

/* ---------- Кнопки-фото ---------- */
.photo-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-btn {
  border: 2px dashed var(--border); border-radius: var(--r);
  padding: 18px 8px;
  display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: center;
  font-size: 13.5px; font-weight: 600; color: var(--text); cursor: pointer; text-align: center;
  background: var(--surface-2); gap: 6px; text-transform: none; letter-spacing: 0;
  transition: border-color .15s, background .15s;
}
.photo-btn.has-file { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.photo-btn .file-cnt { width: 100%; font-size: 12px; color: var(--green); font-weight: 700; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Загрузка файлов ---------- */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--r-lg); background: var(--surface);
  padding: 30px 16px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.upload-zone.drag { border-color: var(--primary); background: var(--primary-soft); }
.upload-ico { font-size: 40px; }
.result { margin-top: 12px; font-size: 14px; }
.result .ok { color: var(--green); }

/* ---------- Модалка / шторка ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(8, 13, 24, .55);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
  animation: fade .16s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 10px 18px calc(18px + var(--safe-b));
  width: 100%; max-width: 660px;
  display: flex; flex-direction: column; gap: 12px; max-height: 92dvh; overflow: auto;
  animation: sheet-up .24s cubic-bezier(.2, .9, .3, 1);
  box-shadow: var(--sh-3);
}
@keyframes sheet-up { from { transform: translateY(60px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 42px; height: 5px; border-radius: 3px; background: var(--border); margin: 2px auto 4px; flex-shrink: 0; }
.modal-card h3 { font-size: 17px; letter-spacing: -.2px; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions .btn { flex: 1; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* меню «Ещё» */
.sheet-menu .modal-card { gap: 4px; }
.menu-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; border: none; background: none; text-align: left;
  padding: 14px 12px; font-size: 15.5px; font-weight: 600; color: var(--text);
  border-radius: var(--r); cursor: pointer; font-family: inherit;
}
.menu-item:active { background: var(--surface-2); }
.menu-item .mi-ico {
  width: 38px; height: 38px; border-radius: 11px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}

/* ---------- WhatsApp ---------- */
.wa-panel { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 8px 0 12px; }
.wa-panel img { width: 220px; height: 220px; border: 1px solid var(--border); border-radius: var(--r); }
.wa-status { font-size: 16px; font-weight: 700; }
.wa-panel code { background: var(--surface-2); padding: 3px 7px; border-radius: 6px; font-size: 12px; word-break: break-all; }

.history-body { max-height: 62dvh; overflow: auto; }
.settings-grid { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Прогресс-бары ---------- */
.pct-bar { background: var(--surface-3); border-radius: 6px; height: 8px; flex: 1; overflow: hidden; display: inline-block; vertical-align: middle; }
.pct-bar > i { display: block; height: 100%; background: var(--green); border-radius: 6px; }
.pct-bar.low > i { background: var(--red); }
.pct-bar.mid > i { background: var(--amber); }
.pct-row { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }

.receipt-link { color: var(--primary); text-decoration: none; font-weight: 600; }

/* ---------- Проверки: долги / штрафы / КБМ ---------- */
.ins-line { font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.debt-details, .fine-details { font-size: 13px; }
.debt-details > summary, .fine-details > summary {
  cursor: pointer; font-weight: 600; user-select: none; padding: 3px 0;
}
.debt-details > summary { color: #b91c1c; }
.fine-details > summary { color: #b45309; }
.debt-list, .fine-list { margin-top: 7px; display: flex; flex-direction: column; gap: 7px; }
.debt-item { border-left: 3px solid var(--red); background: var(--red-soft); border-radius: var(--r-xs); padding: 8px 11px; }
.fine-item { border-left: 3px solid #f97316; background: #fff7ed; border-radius: var(--r-xs); padding: 8px 11px; }
.fine-item--paid { border-left-color: #94a3b8; background: var(--surface-2); opacity: .85; }
.debt-item__h, .fine-item__h { font-weight: 600; }
.debt-item__b, .fine-item__b { font-size: 12px; }

.kbm-iin-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; }
.kbm-estimate {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 11px 13px; font-size: 13px; color: var(--text);
  display: flex; flex-direction: column; gap: 4px;
}
.kbm-estimate b { color: var(--primary); }
.kbm-estimate .warn { color: var(--amber); }

.car-thumb { width: 54px; height: 42px; border-radius: 10px; object-fit: cover; background: var(--surface-3); flex-shrink: 0; }
.car-thumb--empty { display: flex; align-items: center; justify-content: center; font-size: 22px; }
.car-photo-wrap { display: flex; flex-direction: column; gap: 8px; }
.car-photo-preview { width: 100%; max-height: 180px; object-fit: cover; border-radius: var(--r); }

/* ---------- Тосты ---------- */
.toast-wrap {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  z-index: 200; display: flex; flex-direction: column; gap: 8px;
  width: min(92vw, 440px); pointer-events: none;
}
.toast {
  background: #131c31; color: #fff; border-radius: var(--r);
  padding: 12px 14px; font-size: 14px; font-weight: 500; line-height: 1.4;
  box-shadow: var(--sh-3); display: flex; gap: 9px; align-items: flex-start;
  animation: toast-in .22s cubic-bezier(.2, .9, .3, 1);
  pointer-events: auto; white-space: pre-line;
}
.toast.out { animation: toast-out .2s ease-in forwards; }
.toast .t-ico { font-size: 16px; line-height: 1.3; flex-shrink: 0; }
.toast--ok { background: #0d6b3e; }
.toast--err { background: #9f1d33; }
.toast--warn { background: #8a5200; }
@keyframes toast-in { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateY(10px); opacity: 0; } }

/* ---------- Скелетоны ---------- */
.skeleton { display: flex; flex-direction: column; gap: 10px; }
.sk-card {
  height: 108px; border-radius: var(--r-lg); border: 1px solid var(--border);
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 240% 100%; animation: sk 1.15s ease-in-out infinite;
}
@keyframes sk { from { background-position: 130% 0; } to { background-position: -30% 0; } }

/* ---------- Планшет / десктоп ---------- */
@media (min-width: 700px) {
  .cards { grid-template-columns: repeat(4, 1fr); }
  main { max-width: 760px; }
  .item-kv { grid-template-columns: repeat(3, 1fr); }
  .modal { align-items: center; }
  .modal-card { border-radius: var(--r-xl); max-height: 88vh; }
  .sheet-menu { align-items: flex-end; }
  .sheet-menu .modal-card { border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .toast-wrap { bottom: 24px; }
}

/* ---------- Сегмент-переключатель (Календарь | Список) ---------- */
.seg {
  display: flex; background: var(--surface-3); border-radius: 12px;
  padding: 3px; margin-bottom: 12px; gap: 2px;
}
.seg-btn {
  flex: 1; border: none; background: transparent; cursor: pointer;
  padding: 9px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 700;
  color: var(--muted); font-family: inherit; transition: background .15s, color .15s, box-shadow .15s;
}
.seg-btn.active {
  background: var(--surface); color: var(--text);
  box-shadow: var(--sh-1);
}

/* ---------- Календарь оплат ---------- */
.paycal-toolbar {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 10px;
}
.paycal-month {
  border: none; background: none; cursor: pointer; font-family: inherit;
  font-size: 16px; font-weight: 800; letter-spacing: -.2px; color: var(--text);
  padding: 6px 10px; border-radius: 10px; min-width: 120px;
}
.paycal-month:active { background: var(--surface-3); }

.paycal-legend {
  display: flex; flex-wrap: wrap; gap: 10px 14px;
  font-size: 11.5px; color: var(--muted); font-weight: 600;
  margin: 2px 0 10px; padding: 0 2px;
}
.paycal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.pc-dot {
  width: 10px; height: 10px; border-radius: 3px; display: inline-block;
  flex-shrink: 0;
}

/* навигация по дням: окно всегда влезает в экран, листаем стрелками */
.paycal-daynav {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 0 0 8px;
}
.paycal-daynav .btn[disabled] { opacity: .35; pointer-events: none; }
.paycal-hint {
  color: var(--muted); font-weight: 600; font-size: 12px;
  min-width: 96px; text-align: center;
}

.paycal {
  overflow-x: auto;
  overflow-y: visible;
  max-height: none;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-1);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: auto;
}

.paycal-grid { min-width: min-content; }

.paycal-row {
  display: flex; align-items: stretch;
  border-bottom: 1px solid var(--border-2);
}
.paycal-row:last-child { border-bottom: none; }
.paycal-row.is-miss { background: #fff8f8; }
.paycal-row.is-free { opacity: .72; }

.paycal-side {
  position: sticky; left: 0; z-index: 2;
  width: 166px; flex-shrink: 0;
  padding: 6px 8px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  cursor: default;
}
.paycal-row.is-miss .paycal-side { background: #fff8f8; }
.paycal-row.is-free .paycal-side { background: var(--surface-2); }
.paycal-side[onclick] { cursor: pointer; }
.paycal-side[onclick]:active { background: var(--primary-soft); }

.paycal-plate { font-weight: 800; font-size: 13px; letter-spacing: -.1px; line-height: 1.2; }
.paycal-drv {
  font-size: 11px; color: var(--muted); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.paycal-badge { margin-top: 3px; }
.paycal-badge .badge { font-size: 10px; padding: 2px 6px; }

/* индикаторы состояния авто в календаре: страховка / штрафы / БАКАД.
   строкой под ФИО водителя */
.paycal-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.cal-chips { display: flex; flex-direction: row; gap: 3px; flex-shrink: 0; }
.cal-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  font-size: 13px; font-weight: 800; line-height: 1;
  color: #fff; border: 1px solid transparent;
  user-select: none;
}
.cal-chip[onclick] { cursor: pointer; }
.cal-chip[onclick]:hover { filter: brightness(1.06); }
.cal-chip[onclick]:active { transform: scale(.92); }
.cal-chip--ok  { background: #22a35a; }
.cal-chip--bad { background: #dc2743; }
.cal-chip--unk { background: var(--surface-2); border-color: var(--border-2); color: #94a3b8; }
.cal-chip.is-busy { opacity: .45; pointer-events: none; }
/* красную не пропустить: мягкая пульсация */
.cal-chip--bad { box-shadow: 0 0 0 0 rgba(220, 60, 60, .45); animation: calChipPulse 2.4s ease-out infinite; }
@keyframes calChipPulse {
  0%   { box-shadow: 0 0 0 0 rgba(220, 60, 60, .40); }
  70%  { box-shadow: 0 0 0 5px rgba(220, 60, 60, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 60, 60, 0); }
}
@media (prefers-reduced-motion: reduce) { .cal-chip--bad { animation: none; } }

.paycal-days {
  display: flex; gap: 3px; padding: 6px 8px;
  align-items: center;
}

.paycal-dh {
  width: 28px; height: 22px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--muted);
}
.paycal-dh.is-today {
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 6px;
}

.paycal-head {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.paycal-head .paycal-side {
  background: var(--surface-2);
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .2px;
  z-index: 4;
}
.paycal-corner { justify-content: center; }

.paycal-cell {
  width: 28px; height: 28px; flex-shrink: 0;
  border: none; border-radius: 7px; padding: 0; cursor: pointer;
  background: #e8ebf2;
  transition: transform .1s, box-shadow .1s;
}
.paycal-cell:active:not(:disabled) { transform: scale(.9); }
.paycal-cell:disabled { cursor: default; opacity: .55; }
.paycal-cell.is-today { box-shadow: inset 0 0 0 2px var(--primary); }

.paycal-cell.pc-matched,
.pc-dot.pc-matched { background: #22a35a; }
.paycal-cell.pc-pending,
.pc-dot.pc-pending { background: #46c37b; }
.paycal-cell.pc-prev,
.pc-dot.pc-prev { background: #b7e4a5; }
.paycal-cell.pc-not_found,
.pc-dot.pc-not_found { background: #f97316; }
.paycal-cell.pc-rejected,
.pc-dot.pc-rejected { background: #94a3b8; }
.paycal-cell.pc-free,
.pc-dot.pc-free { background: #22b8cf; }
.paycal-cell.pc-off,
.pc-dot.pc-off { background: #8a94a6; }
.paycal-cell.pc-none,
.pc-dot.pc-none { background: #dc2743; }
.paycal-cell.pc-na,
.pc-dot.pc-na { background: #e8ebf2; }

@media (min-width: 700px) {
  .paycal-side { width: 186px; }
  .paycal-drv { font-size: 12px; }
  .cal-chip { width: 24px; height: 24px; font-size: 13px; }
  .paycal-cell, .paycal-dh { width: 30px; }
  .paycal-cell { height: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* отчёт: доход по месяцам */
.rep-bymonth { margin: 12px 0; }
.rep-bymonth-title { font-weight: 600; margin: 0 0 6px; color: #334155; }
.rep-bymonth-list { display: flex; flex-direction: column; gap: 6px; }
.rep-mrow { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: #fff; border: 1px solid #e5e9f0; border-radius: 10px; cursor: pointer; }
.rep-mrow:hover { border-color: #46c37b; background: #f6fdf9; }
.rep-mrow.is-active { border-color: #46c37b; box-shadow: 0 0 0 2px rgba(70, 195, 123, .15); }
.rep-mname { font-weight: 600; color: #1e293b; }
.rep-msum { font-weight: 700; color: #16a34a; margin-left: auto; }
.rep-mcnt { color: #94a3b8; font-size: 12px; min-width: 62px; text-align: right; }
