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

:root {
  --brand: #2f5cff;
  --brand-dark: #1f45d6;
  --brand-soft: #e8edfb;

  --navy: #171d3d;
  --navy-chip: #2b3566;
  --navy-text: #b9c2e0;
  --navy-muted: #8b96c4;

  --ink: #101426;
  --ink-2: #3a4666;
  --ink-3: #64708c;
  --ink-4: #8b93ab;
  --ink-5: #9aa3bd;

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

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

  --green: #12b673;
  --green-text: #0e9c63;
  --green-deep: #0b7f52;
  --green-bg: #dff7ec;

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

  --orange-text: #c96f00;
  --orange-bg: #fff2e0;

  --purple: #7a5cff;

  --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%; }

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;
}

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

@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; transition-duration: .01ms !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: #e9ecf4; }
  .app { box-shadow: 0 0 0 1px var(--line); }
}

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

.page-title { font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.page-sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.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-4);
}
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head .muted { font-size: 13px; color: var(--ink-4); }
.stack { display: flex; flex-direction: column; gap: 9px; }

/* ------------------------------------------------------------------ кнопки */
.btn {
  height: 48px; padding: 0 16px; border: 1px solid var(--line-input); background: var(--surface);
  border-radius: 13px; 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; -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; }
.btn-primary { border: 0; background: var(--brand); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(47, 92, 255, .28); }
.btn-danger { border-color: var(--red-line); color: var(--red); }
.btn-quiet { border: 0; background: transparent; color: var(--ink-3); box-shadow: none; }
.btn-sm { height: 44px; font-size: 14px; border-radius: 11px; }
.btn-block { width: 100%; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-list { justify-content: flex-start; text-align: left; }
.link-btn {
  border: 0; background: transparent; padding: 0; font: inherit; font-size: 14px;
  color: var(--brand); font-weight: 500; cursor: pointer;
}

/* ------------------------------------------------------------------ поля */
.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: 12px; background: var(--surface); font: inherit;
  /* 16px — не эстетика: на iOS поле с меньшим шрифтом заставляет Safari
     зумить страницу при фокусе, и вернуть масштаб человек уже не может. */
  font-size: 16px;
  color: var(--ink); outline: none; transition: border-color .14s, box-shadow .14s;
}
textarea { height: auto; padding: 11px 14px; resize: vertical; }
input:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47, 92, 255, .14); }
.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; }
.error[hidden] { display: none; }

/* ------------------------------------------------------------------ карточки */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 14px; -webkit-tap-highlight-color: transparent;
}
.card-tap {
  cursor: pointer; transition: border-color .14s, box-shadow .14s; width: 100%;
  text-align: left; font: inherit; color: inherit; display: block;
}
.card-tap:active { border-color: #cfd9f0; box-shadow: 0 4px 14px rgba(16, 20, 38, .07); }
.card-lg { border-radius: 16px; padding: 16px; }
.card-rows { padding: 4px 16px; }

.dark-card { background: var(--navy); border-radius: 16px; 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); }
.dark-value { font-size: 20px; font-weight: 600; letter-spacing: -.01em; margin-top: 4px; }
.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; }
.dark-chip {
  display: inline-flex; align-items: center; height: 21px; padding: 0 8px; border-radius: 7px;
  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; }
.progress-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 9px; }
.progress-foot span { font-size: 13px; color: var(--navy-text); }
.dark-btn {
  height: 34px; padding: 0 12px; border-radius: 9px; font: inherit; font-size: 13px; font-weight: 500;
  border: 1px solid #39406b; background: transparent; color: var(--navy-text); cursor: pointer; flex: none;
}

.now-card {
  background: var(--surface); border: 1.5px solid var(--brand); border-radius: 16px; padding: 16px;
  box-shadow: 0 6px 20px rgba(47, 92, 255, .12);
}
.now-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.now-meta { font-size: 13px; color: var(--ink-3); }
.now-addr { font-size: 19px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.now-note { font-size: 13px; color: var(--ink-3); margin-top: 4px; }

.stat-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 13px; border-top: 3px solid var(--brand); }
.stat--green { border-top-color: var(--green); }
.stat--purple { border-top-color: var(--purple); }
.stat-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.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); }

.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-4); }
.is-today .row-line-date { font-weight: 600; }
.is-today .row-line-value { color: var(--brand); }

.note-box { background: #fff8e8; border: 1px solid #ffe4b0; border-radius: 14px; padding: 13px 14px; font-size: 13px; color: #8a5b00; }
.empty { padding: 40px 12px; text-align: center; color: var(--ink-4); font-size: 14px; }
.empty[hidden] { display: none; }
.muted { color: var(--ink-4); }

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


/* ------------------------------------------------------------------ пилюли */
.pill {
  display: inline-flex; align-items: center; height: 23px; padding: 0 9px; border-radius: 7px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill-blue { background: var(--brand); color: #fff; }
.pill-blue-soft { background: var(--brand-soft); color: var(--brand); }
.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); 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 { padding: 3px; }

/* сегментированный переключатель (фильтры выездов) */
.seg { display: flex; gap: 3px; padding: 3px; background: var(--chip-bg); border-radius: 11px; }
.seg-btn {
  flex: 1; height: 44px; border: 0; border-radius: 9px; font: inherit; font-size: 13px;
  cursor: pointer; transition: background .14s; background: transparent; color: var(--ink-3);
}
.seg-btn.is-on { background: #fff; box-shadow: 0 1px 2px rgba(16, 20, 38, .08); color: var(--ink); font-weight: 600; }

/* --------------------------------------------------------------- таб-бар */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  max-width: 480px; margin: 0 auto;
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  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));
}
.tabbar[hidden] { display: none; }
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; border: 0; background: transparent; font: inherit; font-size: 11px; font-weight: 500;
  color: var(--ink-4); cursor: pointer; -webkit-tap-highlight-color: transparent; padding: 0;
}
.tab-dot { width: 22px; height: 22px; border-radius: 8px; background: #d6dbe6; transition: background .14s; }
.tab.is-active { color: var(--brand); }
.tab.is-active .tab-dot { background: var(--brand); }
.tab-badge {
  position: absolute; top: 10px; right: calc(50% - 24px); min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: #fff; font-size: 10px; font-weight: 600;
  display: grid; place-items: center;
}
.tab-badge[hidden] { display: none; }

/* ------------------------------------------------------------------ вход */
.login {
  padding: 32px 22px calc(22px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; min-height: 100dvh;
}
.login-head { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-mark { width: 52px; height: 52px; border-radius: 16px; 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; }
.login-sub { font-size: 14px; color: var(--ink-3); text-align: center; }
.login-foot { margin-top: auto; padding-top: 14px; text-align: center; font-size: 13px; color: var(--ink-4); }

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

.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: 13px;
  font: inherit; font-size: 21px; font-weight: 500; color: var(--ink); cursor: pointer;
  transition: background .12s; -webkit-tap-highlight-color: transparent;
}
.key:active { background: var(--brand-soft); }
.key-blank { border: 0; background: transparent; cursor: default; }

/* --------------------------------------------------- полоса состояния сети */
.net-banner {
  position: sticky; top: 0; z-index: 8; padding: 9px 18px; font-size: 13px; font-weight: 500;
  text-align: center;
}
.net-banner[hidden] { display: none; }
.net-banner.is-offline { background: var(--orange-bg); color: var(--orange-text); }
.net-banner.is-pending { background: var(--brand-soft); color: var(--brand); }
.net-banner.is-ok { background: var(--green-bg); color: var(--green-deep); }

/* ------------------------------------------------------------ карточка заказа */
.detail {
  position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column;
  max-width: 480px; margin: 0 auto; animation: fadeIn .16s ease both;
}
.detail[hidden] { display: none; }
.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: 38px; height: 38px; flex: none; border: 1px solid var(--line-input); background: var(--surface);
  border-radius: 12px; 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; }
.detail-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 14px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 12px;
}
.detail-actions { display: flex; flex-direction: column; gap: 9px; margin-top: auto; padding-top: 6px; }
.detail-label { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-4); }
.detail-addr { font-size: 19px; font-weight: 600; letter-spacing: -.01em; margin-top: 5px; line-height: 1.3; }
.detail-note { font-size: 13px; color: var(--ink-3); margin-top: 5px; }

.badge { display: block; padding: 9px 12px; border-radius: 11px; font-size: 13px; font-weight: 500; }
.badge-surprise { background: #f3ecff; color: #5b34c7; }
.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); }

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

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

.eta-box { margin-top: 12px; }
.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-4); margin-top: 5px; line-height: 1.35; }

/* ------------------------------------------------------------------ шторка */
.sheet { position: fixed; inset: 0; z-index: 30; max-width: 480px; margin: 0 auto; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(16, 20, 38, .45); animation: fadeIn .16s ease both; }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface);
  border-radius: 22px 22px 0 0; padding: 8px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -14px 40px rgba(16, 20, 38, .22);
  max-height: 88dvh; overflow-y: auto; animation: sheetIn .2s ease both;
}
.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; }
.sheet-sub { font-size: 13px; color: var(--ink-3); margin-top: 3px; }

.option {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 14px; border-radius: 13px;
  font: inherit; cursor: pointer; text-align: left; background: var(--surface);
  border: 1.5px solid var(--line); transition: border-color .14s, background .14s;
}
.option.is-on { border-color: var(--brand); background: #f5f8ff; }
.option-mark { width: 20px; height: 20px; flex: none; border-radius: 10px; border: 1.5px solid var(--line-input); background: #fff; transition: all .14s; }
.option.is-on .option-mark { border: 6px 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: 500; }
.option-text small { font-size: 12px; color: var(--ink-4); }

/* ------------------------------------------------------------------ тост */
.toast {
  position: fixed; left: 18px; right: 18px;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 14px);
  z-index: 40; max-width: 444px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; padding: 13px 15px;
  background: var(--navy); color: #fff; border-radius: 13px;
  box-shadow: 0 14px 34px rgba(16, 20, 38, .35); font-size: 14px;
  animation: toastIn .2s ease both;
}
.toast[hidden] { display: none; }
.toast-dot { width: 8px; height: 8px; border-radius: 4px; background: var(--green); flex: none; }
.toast.is-bad .toast-dot { background: var(--red); }
