/* Кабинет курьера Courier Hub.
 *
 * Дизайн-система перенесена из макета Claude Design («Кабинет курьера») — та же
 * палитра и та же пластика, что в панели логиста. Отличия от макета:
 *
 *  — без CDN и без Instrument Sans: кабинет обязан открываться в подвале без
 *    сети, а у этого шрифта нет кириллицы (unicode-range только latin);
 *  — рамки телефона из макета здесь нет: это и есть телефон. На широком экране
 *    колонка центрируется, а не растягивается на всю ширину.
 *
 * Всё рассчитано на палец: минимальная цель — 44 px, основные действия внизу
 * экрана, ничего важного не прячется под таб-бар (см. --tabbar).
 */

:root {
  --brand: #2f5cff;
  --brand-dark: #1f45d6;
  --brand-soft: #e8edfb;
  --brand-shadow: rgba(47, 92, 255, .28);
  --brand-line: #cfd9f0;
  --brand-tint: #f5f8ff;
  --selection: #d8e2ff;

  --navy: #171d3d;
  --navy-line: #2a3159;
  --navy-chip: #2b3566;
  --navy-border: #39406b;
  --navy-text: #b9c2e0;
  --navy-muted: #8b96c4;
  --navy-label: #7a84b1;

  --ink: #101426;
  --ink-2: #3a4666;
  --ink-3: #5a6682;
  --ink-4: #66708d;
  --ink-5: #9aa3bd;   /* только декор и неактивное */

  --bg: #f4f6fb;
  --surface: #fff;
  --field: #f7f9fd;
  --chip-bg: #eef2fa;
  --outer-bg: #e9ecf4;

  --line: #e3e8f2;
  --line-soft: #edf1f8;
  --line-row: #f2f5fa;
  --line-input: #dbe2f0;

  --green: #12b673;
  --green-text: #0b7f52;
  --green-deep: #0a7a4e;
  --green-bg: #dff7ec;
  --green-line: #bfeeda;
  --green-tint: #f2fcf7;

  --red: #d21b54;
  --red-bg: #ffe9f0;
  --red-line: #ffd3e0;

  --orange: #ef8b1f;
  --orange-text: #a65c00;
  --orange-bg: #fff2e0;
  --orange-line: #f3d6a4;

  --note-bg: #fff8e8;
  --note-line: #ffe4b0;
  --note-text: #8a5b00;

  --purple: #7a5cff;
  --purple-bg: #f3ecff;
  --purple-text: #5b34c7;
  --cyan: #00b8d4;

  /* Шкала радиусов. Однотипное — одним токеном; вложенное = внешний − отступ
     (кнопка сегмента = радиус .seg − 3px). Круги (50%), капсулы и
     круглые точки считаются от размера и в шкалу не входят. */
  --r-xs: 6px;     /* мелкие метки: клавиша ⌘K, вид в палитре */
  --r-pill: 7px;   /* пилюли и мелкие чипы */
  --r-sm: 8px;     /* малые кнопки, пункты меню */
  --r-ctl: 9px;    /* поля и обычные кнопки */
  --r-box: 10px;   /* плашки, меню, тосты, «коробки» */
  --r-card: 12px;  /* карточки списков, крупные кнопки и поля */
  --radius: 14px;  /* основные карточки и панели */
  --r-lg: 16px;    /* окна и выделенные карточки */
  --r-sheet: 22px;   /* шторки и крупные поверхности */
  --scrim: rgba(16, 20, 38, .5);
  --ring: 0 0 0 3px rgba(47, 92, 255, .14);
  --shadow-card: 0 1px 2px rgba(16, 20, 38, .04);
  --shadow-pop: 0 14px 36px rgba(16, 20, 38, .16);
  --shadow-raise: 0 4px 14px rgba(16, 20, 38, .08);
  --shadow-overlay: 0 24px 60px rgba(16, 20, 38, .4);
  --shadow-toast: 0 12px 32px rgba(16, 20, 38, .35);
  --shadow-seg: 0 1px 2px rgba(16, 20, 38, .08);

  /* Шкала слоёв: одна на всю систему, числа не придумываются на месте. */
  --z-raised: 1;
  --z-sticky: 10;
  --z-dropdown: 20;
  --z-nav: 30;
  --z-page: 40;
  --z-banner: 45;
  --z-modal: 50;
  --z-palette: 60;
  --z-toast: 70;

  --ease-out: cubic-bezier(.2, 0, 0, 1);
  --tabbar: 74px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

/* Атрибут hidden обязан побеждать любой display из наших правил.

   Экран входа объявлен как `display:flex`, и это молча перебивало браузерное
   `[hidden] { display: none }` — после входа форма с PIN оставалась висеть над
   кабинетом. Одно правило закрывает весь класс таких ошибок. */
[hidden] { display: none !important; }


html { -webkit-text-size-adjust: 100%; }
/* Пока открыта карточка заказа или шторка, страница под ними не едет: иначе
   после «←» курьер оказывался в другом месте списка. Блокируем ТОЛЬКО html:
   на body ломаются sticky-элементы. Прокрутка внутри слоёв (.detail-body,
   .sheet-scroll) работает — это отдельные контейнеры. */
html.is-locked { overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  /* Двойной тап по кнопке на телефоне не должен зумить страницу. */
  touch-action: manipulation;
  /* Адрес или комментарий без пробелов («сызранова23-1к2…», ссылка) иначе
     распирал страницу втрое шире экрана вместе с нижним меню. */
  overflow-wrap: anywhere;
}

/* Подписи и короткие значения не рвутся по буквам: правило на body нужно
   адресам, но у метки min-content обязан быть словом, а не одной буквой. */
.pill, .now-meta, .dark-label, .section-label, .detail-label, .stat-label,
.card-time, .card-num, .tab, .seg-btn b { overflow-wrap: normal; }

a { color: var(--brand); text-decoration: none; }
input::placeholder, textarea::placeholder { color: var(--ink-4); }
::selection { background: var(--selection); }

/* Палец, а не мышь: подсветка нажатия браузером и выделение текста на кнопках
   только мешают. */
button, a, input, textarea, [role="button"] { -webkit-tap-highlight-color: transparent; }
.key, .tab, .seg-btn, .btn, .option, .pin-cell {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

/* Кольцо фокуса с клавиатуры — одно на всю систему. Мышь и палец его не
   вызывают (:focus-visible), поэтому на телефоне ничего не меняется. */
:where(button, a[href], [role="button"], [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
/* Внутри прокручиваемых и обрезающих контейнеров кольцо — внутрь, иначе его срезает край. */
:where(.seg-btn, .tab, .key, .option):focus-visible { outline-offset: -2px; }
:where(.dark-card, .toast) :focus-visible { outline-color: #fff; }

@keyframes screenIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

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

/* ------------------------------------------------------------------ каркас */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background: var(--bg);
}
@media (min-width: 560px) {
  body { background: var(--outer-bg); }
  .app { box-shadow: 0 0 0 1px var(--line); }
}

.screen { padding: 12px 16px 18px; display: flex; flex-direction: column; gap: 14px; animation: screenIn .18s var(--ease-out) both; }
.has-tabbar { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 14px); }

/* Пока /me не ответил, экран не должен быть пустым: на мобильной сети это секунды. */
.splash { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; }

.page-title { font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; text-wrap: balance; }
.page-sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; text-wrap: pretty; }
.head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.section-label {
  font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3);
}
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 4px; }
.section-head .muted { font-size: 13px; color: var(--ink-3); }
.stack { display: flex; flex-direction: column; gap: 9px; }
/* Пустой список в экране-колонке всё равно занимает место: между соседями
   остаётся gap экрана, и у «Смены» без отметок перед «Добавить выезд» зияла
   дыра. Списки очищает clear() без пробельных узлов, поэтому :empty срабатывает. */
.screen > .stack:empty { display: none; }

/* ------------------------------------------------------------------ кнопки */
.btn {
  height: 48px; padding: 0 16px; border: 1px solid var(--line-input); background: var(--surface);
  border-radius: var(--r-card); font: inherit; font-size: 15px; font-weight: 500; color: var(--ink);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { border: 0; background: var(--brand); color: #fff; font-weight: 600; box-shadow: 0 4px 12px var(--brand-shadow); }
/* Серый «выключен» вместо полупрозрачного синего: на солнце его не спутать с рабочей кнопкой. */
.btn-primary:disabled { background: var(--chip-bg); color: var(--ink-3); box-shadow: none; opacity: 1; }
.btn-danger { border-color: var(--red-line); color: var(--red); }
.btn-quiet { height: 44px; border: 0; background: transparent; color: var(--ink-3); box-shadow: none; }
.btn-sm { height: 44px; font-size: 14px; border-radius: var(--r-card); }
.btn-lg { height: 52px; }
.btn-xl { height: 52px; font-size: 16px; font-weight: 600; padding: 0 8px; gap: 6px; white-space: nowrap; }
.btn-xl svg { width: 19px; height: 19px; }
@media (max-width: 359px) { .btn-xl { font-size: 15px; padding: 0 6px; } }
.btn-main { height: 56px; font-size: 17px; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-list { justify-content: flex-start; text-align: left; }
:where(.seg-btn, .option, .tab, .avatar, .detail-back, .dark-btn):active { opacity: .72; }

/* ------------------------------------------------------------------ поля */
.input, input[type="tel"], input[type="text"], input[type="password"], textarea {
  width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--line-input);
  border-radius: var(--r-card); background: var(--surface); font: inherit;
  /* 16px — не эстетика: на iOS поле с меньшим шрифтом заставляет Safari
     зумить страницу при фокусе, и вернуть масштаб человек уже не может. */
  font-size: 16px;
  color: var(--ink); outline: none; transition: border-color .14s var(--ease-out), box-shadow .14s var(--ease-out);
}
textarea { height: auto; padding: 11px 14px; resize: vertical; }
input:focus, textarea:focus { border-color: var(--brand); box-shadow: var(--ring); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field-hint { font-size: 12px; color: var(--ink-4); font-weight: 400; }
.error { min-height: 20px; font-size: 13px; color: var(--red); font-weight: 500; margin: 0; }

/* ------------------------------------------------------------------ карточки */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px;
}
.card-tap {
  cursor: pointer; transition: border-color .14s var(--ease-out), box-shadow .14s var(--ease-out); width: 100%;
  text-align: left; font: inherit; color: inherit; display: block;
}
.card-tap:active { border-color: var(--brand-line); box-shadow: var(--shadow-raise); }
.card-lg { border-radius: var(--r-lg); padding: 16px; }
#trips-list .card { padding: 11px 13px; }
.card-rows { padding: 4px 16px; }

/* Типографика карточек списков: «Дальше сегодня», «Отмечено сегодня», «Выезды»,
   «Требуют отметки». Раньше жила в JS инлайном и расходилась между экранами. */
.card-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.card-time { font-size: 15px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.card-time.is-none { font-weight: 500; color: var(--ink-3); }
.card-num { font-size: 13px; color: var(--ink-3); margin-left: auto; white-space: nowrap; }
.card-stamp { flex: 1; min-width: 0; font-size: 13px; color: var(--ink-3); }
.card-addr { font-size: 15px; font-weight: 500; line-height: 1.35; margin-top: 6px; }
/* Комментарий курьеру — инструкция, а не примечание: тоньше основного адреса,
   но темнее подписи. */
.card-comment { font-size: 13px; font-weight: 500; color: var(--ink-2); margin-top: 3px; }
.card-sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.card-row { display: flex; align-items: center; gap: 12px; }
.card-main { flex: 1; min-width: 0; }
.card-title { display: block; font-size: 14px; font-weight: 500; line-height: 1.35; }
.card-title.is-clipped { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
.card-foot .card-meta { margin-top: 0; }
.card-pay { font-size: 13px; font-weight: 500; white-space: nowrap; color: var(--ink-2); }
.card-pay.is-held { color: var(--orange-text); }

.dark-card { background: var(--navy); border-radius: var(--r-lg); padding: 16px; color: #fff; }
.dark-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dark-label { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--navy-muted); white-space: nowrap; }
.dark-value { font-size: 20px; font-weight: 600; letter-spacing: -.01em; margin-top: 4px; line-height: 1.2; }
@media (max-width: 359px) { .dark-value { font-size: 18px; } }
.dark-value-xl { font-size: 36px; font-weight: 600; letter-spacing: -.03em; margin-top: 6px; line-height: 1.05; }
.dark-note { font-size: 13px; color: var(--navy-muted); margin-top: 6px; }
/* Правая колонка («Заработано») не сжимается: на 320 px левой подписи хватает
   места, а правой по букве в строку — нет. */
.dark-card .head-row { gap: 8px; }
.dark-card .head-row > div:first-child { min-width: 0; }
.dark-card .head-row > div:last-child { flex: none; text-align: right; }
.dark-chip {
  display: inline-flex; align-items: center; height: 21px; padding: 0 8px; border-radius: var(--r-pill);
  background: var(--navy-chip); color: var(--navy-text); font-size: 11px; font-weight: 600;
}
.progress-track { height: 6px; border-radius: 3px; background: var(--navy-chip); margin-top: 14px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--green); width: 0; transition: width .3s var(--ease-out); }
.progress-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.progress-foot span { font-size: 13px; color: var(--navy-text); }
.dark-btn {
  height: 44px; padding: 0 14px; border-radius: var(--r-card); font: inherit; font-size: 13px; font-weight: 500;
  border: 1px solid var(--navy-border); background: transparent; color: var(--navy-text); cursor: pointer; flex: none;
}

/* «Сейчас»: один текущий заказ, одно главное действие. Порядок чтения сверху
   вниз — что за заказ, когда, куда, что сказал логист, как связаться, что обещать. */
.now-card {
  background: var(--surface); border: 1.5px solid var(--brand); border-radius: var(--r-lg); padding: 14px;
  box-shadow: 0 6px 20px rgba(47, 92, 255, .12);
}
.now-head { display: flex; align-items: center; gap: 8px; }
.now-meta { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.now-more {
  margin-left: auto; height: 44px; min-width: 44px; padding: 0 2px 0 10px; border: 0; background: transparent;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--brand-dark); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: flex-end; gap: 2px; white-space: nowrap;
}
/* На 320 слово не помещается рядом с номером: остаётся стрелка 44×44 с aria-label. */
@media (max-width: 359px) { .now-more span { display: none; } }
.now-time {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin-top: 6px;
  font-size: 15px; font-weight: 600; color: var(--ink-2);
}
.now-time svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.now-time small { font-weight: 400; color: var(--ink-3); font-size: 13px; }
.now-addr { font-size: 20px; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; margin-top: 6px; text-wrap: pretty; }
.now-comment, .detail-comment {
  margin-top: 8px; padding: 8px 10px; border-radius: var(--r-box); background: var(--field);
  border: 1px solid var(--line); font-size: 14px; font-weight: 500; color: var(--ink); line-height: 1.35;
}
.now-note { font-size: 13px; color: var(--ink-3); margin-top: 6px; }
.now-card .btn-row { margin-top: 14px; }
.now-card .btn-main { margin-top: 10px; }

.stat-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 10px; border-top: 3px solid var(--brand); }
.stat--green { border-top-color: var(--green); }
.stat--purple { border-top-color: var(--purple); }
.stat-label { font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); hyphens: manual; }
.stat-value { font-size: 23px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; line-height: 1.1; }
.stat-note { font-size: 11px; color: var(--ink-4); }

.profile-card { display: flex; align-items: center; gap: 13px; }
.profile-info { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.profile-name { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.profile-phone { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.profile-state { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.profile-on { color: var(--green-text); font-weight: 500; }
.app-mark { text-align: center; font-size: 12px; color: var(--ink-5); margin-top: 4px; }

.row-line { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line-row); }
.row-line:last-child { border-bottom: 0; }
.row-line-main { flex: 1; min-width: 0; }
.row-line-main b { display: block; font-size: 14px; font-weight: 400; }
.row-line-main small { display: block; font-size: 12px; color: var(--ink-4); margin-top: 1px; }
.row-line-value { font-size: 15px; font-weight: 500; white-space: nowrap; }
.row-line-total b { font-size: 15px; font-weight: 600; }
.row-line-total .row-line-value { font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.row-line-date { width: 68px; flex: none; font-size: 14px; }
.row-line-meta { flex: 1; min-width: 0; font-size: 13px; color: var(--ink-3); }
.is-today .row-line-date { font-weight: 600; }
.is-today .row-line-value { color: var(--brand); }

/* Строки сведений в карточке заказа: подпись фиксированной ширины, значение
   занимает остаток и переносится по словам. Без этого «Состав» получал нулевую
   ширину и рисовался по букве в строку. */
.detail-row { align-items: baseline; }
.detail-row .row-line-meta { flex: 0 0 104px; overflow-wrap: normal; }
.detail-row .row-line-value { flex: 1 1 auto; min-width: 0; white-space: normal; text-align: right; font-size: 14px; }
/* Длинные значения (состав) — блоком: подпись сверху, значение слева. */
.detail-row.is-block { flex-direction: column; align-items: stretch; gap: 4px; }
.detail-row.is-block .row-line-meta { flex: none; }
.detail-row.is-block .row-line-value { text-align: left; font-weight: 400; color: var(--ink-2); }

.note-box { background: var(--note-bg); border: 1px solid var(--note-line); border-radius: var(--radius); padding: 13px 14px; font-size: 13px; color: var(--note-text); }
.empty { padding: 40px 12px; text-align: center; color: var(--ink-4); font-size: 14px; }
.card-rows .empty { padding: 14px 0; text-align: left; color: var(--ink-3); }
.muted { color: var(--ink-4); }

/* Старые заказы: дата доставки давно прошла. Держим их отдельно и приглушённо,
   чтобы курьер не принял такой заказ за сегодняшнюю работу. Ровно так один
   заказ с 8 марта отметили в августе, и начислилась оплата за поездку,
   которой не было. */
.hint {
  margin: -2px 0 8px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink-3);
  text-wrap: pretty;
}
.card.is-stale {
  background: var(--field);
  border-style: dashed;
}


/* ------------------------------------------------------------------ пилюли */
.pill {
  display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill-blue-solid { background: var(--brand); color: #fff; }
.pill-blue { background: var(--brand-soft); color: var(--brand-dark); }
.pill-grey { background: var(--chip-bg); color: var(--ink-3); }
.pill-green { background: var(--green-bg); color: var(--green-deep); }
.pill-orange { background: var(--orange-bg); color: var(--orange-text); }
.pill-red { background: var(--red-bg); color: var(--red); }

.avatar {
  /* 44 px, а не 38 как в макете: это единственный способ попасть в профиль
     с экрана смены, и палец в перчатке в 38 промахивается. */
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 22px; background: var(--brand-soft);
  color: var(--brand-dark); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  display: grid; place-items: center;
}
.avatar-lg { width: 54px; height: 54px; border-radius: 27px; font-size: 17px; }

/* сегментированный переключатель (фильтры выездов) */
.seg { display: flex; gap: 3px; padding: 3px; background: var(--chip-bg); border-radius: var(--r-card); }
.seg-btn {
  flex: 1; height: 44px; border: 0; border-radius: calc(var(--r-card) - 3px); font: inherit; font-size: 13px;
  cursor: pointer; transition: background .14s var(--ease-out); background: transparent; color: var(--ink-3);
}
.seg-btn.is-on { background: var(--surface); box-shadow: var(--shadow-seg); color: var(--ink); font-weight: 600; }
#trip-filter .seg-btn { padding: 0 4px; white-space: nowrap; }
@media (max-width: 339px) { #trip-filter .seg-btn { font-size: 12px; } }

/* --------------------------------------------------------------- таб-бар */
/* Сплошной фон без размытия: через полупрозрачную подложку просвечивал текст
   карточек, и подписи вкладок читались хуже. */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-nav);
  max-width: 480px; margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px));
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; border: 0; background: transparent; font: inherit; font-size: 12px; font-weight: 500;
  color: var(--ink-3); cursor: pointer; padding: 0;
}
.tab-icon {
  width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
/* Активность не только цветом: при бликах на солнце вес и штрих читаются лучше. */
.tab.is-active { color: var(--brand); font-weight: 600; }
.tab.is-active .tab-icon { stroke-width: 2.2; }
.tab-badge {
  position: absolute; top: 9px; right: calc(50% - 26px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}

/* ------------------------------------------------------------------ вход */
.login {
  padding: 32px 22px calc(22px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh;
}
.login-head { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-mark { width: 52px; height: 52px; flex: none; border-radius: var(--r-lg); background: var(--brand); display: grid; place-items: center; color: #fff; font-size: 22px; font-weight: 600; }
.login-title { font-size: 23px; font-weight: 600; letter-spacing: -.02em; text-wrap: balance; }
.login-sub { font-size: 14px; color: var(--ink-3); text-align: center; margin-bottom: 20px; text-wrap: pretty; }
.login-phone { margin-bottom: 18px; }
.login-pin { margin-bottom: 8px; }
.login-foot { margin-top: auto; padding-top: 14px; text-align: center; font-size: 13px; color: var(--ink-3); }
/* Пока сервер проверяет PIN, кнопки «Войти» может не быть на экране (см. ниже),
   поэтому «идёт вход» показываем самой формой. */
.login.is-busy .pin-cells, .login.is-busy .keypad { opacity: .55; pointer-events: none; }
#login-btn { height: 52px; margin-top: 14px; }

.pin-cells { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pin-cell {
  height: 54px; display: grid; place-items: center; border-radius: var(--r-card); font-size: 30px; line-height: 1;
  border: 1.5px solid var(--line-input); background: var(--surface); transition: border-color .14s var(--ease-out), box-shadow .14s var(--ease-out);
}
.pin-cell.is-next { border-color: var(--brand); box-shadow: var(--ring); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 6px; }
.key {
  height: 52px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-card);
  font: inherit; font-size: 21px; font-weight: 500; color: var(--ink); cursor: pointer;
  transition: background .12s var(--ease-out);
}
.key:active { background: var(--brand-soft); }
/* Тихая клавиша «Очистить» на месте бывшей пустой клетки: без рамки и фона, чтобы не
   спорить с цифрами, но и не оставлять «дырку» в сетке. Пока PIN пуст, она бледная. */
.key-quiet { border-color: transparent; background: transparent; font-size: 15px; font-weight: 500; color: var(--ink-3); }
.key-quiet:active { background: var(--chip-bg); }
.key-quiet:disabled { opacity: .4; cursor: default; }
.key-quiet:disabled:active { background: transparent; }
@media (max-width: 359px) { .key-quiet { font-size: 14px; } }

/* Низкие экраны (iPhone SE: 568 px, а с панелями браузера и почти любой телефон:
   полная раскладка занимает ~760 px): марка в одну строку с заголовком, клавиши
   ниже. «Войти» не нужна — четвёртая цифра сама отправляет (pushPin → doLogin),
   а после ошибки PIN стирается, и повторный ввод снова отправляет. */
@media (max-height: 780px) {
  .login { padding: 14px 20px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .login-head { flex-direction: row; align-items: center; gap: 10px; margin-bottom: 4px; }
  .login-mark { width: 36px; height: 36px; border-radius: var(--r-box); font-size: 17px; }
  .login-title { font-size: 21px; }
  .login-sub { text-align: left; margin-bottom: 14px; }
  .login-phone { margin-bottom: 10px; }
  .login-pin { margin-bottom: 0; }
  .error { margin-top: 4px; }
  .pin-cell, .key, .login input { height: 48px; }
  .keypad { gap: 8px; margin-top: 4px; }
  #login-btn { display: none; }
  .login-foot { padding-top: 6px; }
}

/* --------------------------------------------------- полоса состояния сети */
.net-banner {
  position: sticky; top: 0; z-index: var(--z-banner); padding: 9px 18px; font-size: 13px; font-weight: 500;
  text-align: center;
  /* Чужие неотправленные отметки идут второй строкой через \n. */
  white-space: pre-line;
}
.net-banner.is-offline { background: var(--orange-bg); color: var(--orange-text); }
.net-banner.is-pending { background: var(--brand-soft); color: var(--brand-dark); }
.net-banner.is-foreign { background: var(--orange-bg); color: var(--orange-text); }

/* ------------------------------------------------------------ карточка заказа */
/* Карточка открывается ПОД полосой сети (--net-h ставит renderBanner): курьер
   отмечает отсюда и обязан видеть, что сети нет. Полоса лежит выше карточки по
   слою и остаётся на месте. */
.detail {
  position: fixed; top: var(--net-h, 0px); right: 0; bottom: 0; left: 0; z-index: var(--z-page);
  background: var(--bg); display: flex; flex-direction: column;
  max-width: 480px; margin: 0 auto; animation: fadeIn .16s var(--ease-out) both;
}
.detail-head {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.detail-back {
  width: 44px; height: 44px; flex: none; border: 1px solid var(--line-input); background: var(--surface);
  border-radius: var(--r-card); font: inherit; font-size: 17px; color: var(--ink-2); cursor: pointer;
  display: grid; place-items: center;
}
.detail-title { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
/* iPhone SE (320–389): «Заказ 116377С» и плашка «Ждёт отправки» не помещались
   в строку, и заголовок рвался на две. Заголовок и плашка не переносятся, зазор
   меньше, кегль на 1 px ниже. */
@media (max-width: 389px) {
  .detail-head { gap: 8px; }
  .detail-title { font-size: 15px; white-space: nowrap; }
  #detail-pill .pill { white-space: nowrap; }
}
.detail-body {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 14px 16px 12px;
  display: flex; flex-direction: column; gap: 12px;
}
/* Подвал прилипает: главное действие всегда под большим пальцем, без прокрутки. */
.detail-foot {
  flex: none; display: flex; gap: 8px;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg); border-top: 1px solid var(--line);
}
.detail-foot .btn { height: 56px; border-radius: var(--radius); white-space: nowrap; }
.detail-foot .btn-call { flex: none; }
.detail-foot .btn-primary { flex: 1; min-width: 0; padding: 0 10px; font-size: 17px; }
@media (max-width: 389px) { .detail-foot .btn-primary { font-size: 16px; } }
.detail-foot .btn-wait { flex: 1; min-width: 0; white-space: normal; line-height: 1.2; font-size: 14px; }
/* На 320 звонок — только иконка 56×56 (aria-label), иначе главная кнопка рвётся на две строки. */
@media (max-width: 359px) {
  .detail-foot .btn-call span { display: none; }
  .detail-foot .btn-call { width: 56px; padding: 0; }
}
.detail-label { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.detail-addr { font-size: 20px; font-weight: 650; letter-spacing: -.01em; margin-top: 5px; line-height: 1.25; text-wrap: pretty; }

.badge { display: block; padding: 9px 12px; border-radius: var(--r-card); font-size: 13px; font-weight: 500; }
.badge-surprise { background: var(--purple-bg); color: var(--purple-text); }
.badge-warn { background: var(--orange-bg); color: var(--orange-text); }
.badge-money { background: var(--green-bg); color: var(--green-deep); }
.badge-danger { background: var(--red-bg); color: var(--red); }

/* Заказ ушёл из работы без отметки. Рамка по периметру, а не полоса слева и не
   цветной фон: карточка и так стоит в отдельном разделе, и заливать её значит
   спорить с бейджами внутри. */
.card.is-attention { border: 1.5px solid var(--orange-line); }

/* Отметка, которую сервер не принял: та же рамка, что у «Требуют отметки»,
   но цветом отказа. Причина — словами сервера, красным под заголовком. */
.card.is-rejected { border: 1.5px solid var(--red-line); }
.card-reason { font-size: 13px; font-weight: 500; color: var(--red); margin-top: 3px; }

/* -------------------------------------------------- обещание времени клиенту */
/* Тот же сегмент-контрол, что фильтр выездов, но в две строки: курьер обязан
   видеть не «через 30 мин», а то самое время, которое прочитает клиент. Без
   второй строки он обещает одно, а уходит другое. */
.seg-eta { flex-wrap: nowrap; }
.seg-eta .seg-btn {
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  height: 56px; line-height: 1.15; padding: 0 4px; color: var(--ink);
}
.seg-eta .seg-btn b { font-weight: 600; font-size: 15px; white-space: nowrap; }
/* «через» вынесено в подпись над кнопками: «через 1,5 часа» в кнопку шириной
   80 px не влезало и рвалось на две строки. */
.eta-caption { font-size: 13px; font-weight: 500; color: var(--ink-3); margin: 8px 0 6px; }
.eta-compact .eta-caption { margin-top: 14px; }
.seg-eta .seg-btn small { font-size: 12px; color: var(--ink-3); }
.seg-eta .seg-btn.is-on { color: var(--brand); }
.seg-eta .seg-btn.is-on small { color: var(--brand); }
.seg-eta .seg-more { flex: 0 0 54px; color: var(--ink-3); font-size: 14px; font-weight: 500; }

.eta-compact { margin-top: 12px; }
.eta-confirm { margin-top: 10px; }
.eta-confirm .btn-quiet { margin-top: 4px; }
.eta-state {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 14px; font-weight: 600; line-height: 1.35;
}
/* Текст, который прочитал клиент. Показывается дословно — курьеру не нужно
   гадать, что именно было обещано, когда он звонит уточнять. */
.eta-quote { font-size: 12px; color: var(--ink-3); margin-top: 5px; line-height: 1.35; }

/* ------------------------------------------------------------------ шторка */
.sheet { position: fixed; inset: 0; z-index: var(--z-modal); max-width: 480px; margin: 0 auto; }
.sheet-backdrop { position: fixed; inset: 0; background: var(--scrim); animation: fadeIn .16s var(--ease-out) both; }
/* --kb — высота экранной клавиатуры (app.js): на iPhone она ложится поверх
   страницы, и поле «Куда ездили» оказывалось под ней.
   Тело — колонка: прокручивается список (.sheet-scroll), а подвал с кнопками
   (.sheet-foot) всегда виден. Раньше «Отправить отметку» лежала после семи
   вариантов и уходила за край экрана. */
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: var(--kb, 0px); background: var(--surface);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: 0 -14px 40px rgba(16, 20, 38, .22);
  max-height: calc(88vh - var(--kb, 0px));
  max-height: calc(88dvh - var(--kb, 0px));
  display: flex; flex-direction: column; overflow: hidden; animation: sheetIn .2s var(--ease-out) both;
}
.sheet-scroll { overflow-y: auto; overscroll-behavior: contain; min-height: 0; padding: 8px 18px; }
.sheet-foot {
  flex: none; padding: 8px 18px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--surface); border-top: 1px solid var(--line);
}
.sheet-foot .error { margin-bottom: 6px; }
.sheet-foot .btn-quiet { margin-top: 4px; }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line-input); margin: 0 auto 14px; }
.sheet-title { font-size: 19px; font-weight: 600; letter-spacing: -.02em; text-wrap: balance; }
.sheet-sub { font-size: 13px; color: var(--ink-3); margin-top: 3px; text-wrap: pretty; }
/* Без сети шторка говорит это ДО нажатия: курьер решает, звонить ли логисту. */
.sheet-sub.is-offline { color: var(--orange-text); font-weight: 600; }
.sheet-scroll .stack { margin-top: 14px; gap: 8px; }
.sheet-scroll > .field { margin-top: 10px; }

.option {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: var(--r-card);
  font: inherit; cursor: pointer; text-align: left; background: var(--surface);
  border: 1.5px solid var(--line); min-height: 56px;
  transition: border-color .14s var(--ease-out), background .14s var(--ease-out);
}
.option.is-on { border-color: var(--brand); background: var(--brand-tint); }
.option-mark {
  width: 22px; height: 22px; flex: none; border-radius: 11px; border: 1.5px solid var(--line-input);
  background: var(--surface); transition: border-color .14s var(--ease-out), border-width .14s var(--ease-out);
}
.option.is-on .option-mark { border: 7px solid var(--brand); }
.option-text { display: flex; flex-direction: column; line-height: 1.3; flex: 1; min-width: 0; }
.option-text b { font-size: 15px; font-weight: 600; }
.option-text small { font-size: 13px; color: var(--ink-3); margin-top: 1px; }
/* «Доставлен» — самый частый выбор: находится боковым зрением. */
.option.is-good .option-text b { color: var(--green-deep); }

/* ------------------------------------------------------------------ тост */
/* Тост не ловит нажатия: он лежит над кнопками шторки и карточки, и тап
   «сквозь» него обязан дойти до кнопки. */
.toast {
  position: fixed; left: 18px; right: 18px;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 14px);
  z-index: var(--z-toast); max-width: 444px; margin: 0 auto; pointer-events: none;
  display: flex; align-items: center; gap: 10px; padding: 13px 15px;
  background: var(--navy); color: #fff; border-radius: var(--r-card);
  box-shadow: var(--shadow-toast); font-size: 14px;
  animation: toastIn .2s var(--ease-out) both;
}
/* Пока открыта шторка, внизу кнопки — тост уходит наверх. */
body:has(.sheet:not([hidden])) .toast { bottom: auto; top: calc(12px + env(safe-area-inset-top, 0px)); }
.toast-dot { width: 8px; height: 8px; border-radius: 4px; background: var(--green); flex: none; }
.toast.is-bad .toast-dot { background: var(--red); }
