
:root { color-scheme: light dark; }

/* Заголовки: раздел-подпись (.section__title) — мелкая метка, заголовок
   экрана и карточки — крупный текст, иначе задача звучит как подпись поля. */
.title { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }
.card-heading { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.3; }

/* ---------- общий каркас ---------- */
.login { max-width: 420px; margin: 24px auto; }
.login__form { gap: 14px; }
.login__form button { justify-content: center; }
.userbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.userbar__who { display: flex; flex-direction: column; gap: 2px; }
.userbar .hint { margin: 0; }
.userbar__exit { margin: 0; }
.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row-between .section__title { margin: 0; }
.back-link { color: var(--text-soft); text-decoration: none; font-size: .92em; }
.back-link:hover { text-decoration: underline; }
.hint { color: var(--text-soft); font-size: .9em; margin: 0; }

/* ---------- чипы дней ---------- */
.day-nav { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.day-nav .hint { font-size: .85em; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-block; padding: 5px 13px; border: 1px solid var(--border-strong);
  border-radius: 999px; text-decoration: none; color: var(--text-soft);
  font-size: .88em; line-height: 1.4; white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.is-current { border-color: var(--accent); color: var(--accent); font-weight: 600; background: transparent; }

/* ---------- смена ---------- */
.shift { display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); flex-wrap: wrap; }
.shift--open { border-left: 4px solid var(--ok, #2e7d32); }
.shift--closed { border-left: 4px solid var(--border-strong); }
.shift__title { font-weight: 600; margin-bottom: 2px; }
.shift__form { margin: 0; }

/* ---------- задачи ---------- */
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-row { display: block; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); text-decoration: none; color: inherit; background: var(--surface); }
.task-row:hover { border-color: var(--accent); }
.task-row--static:hover { border-color: var(--border); }
.task-row__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.task-row__time { font-variant-numeric: tabular-nums; color: var(--text-soft); font-size: .88em; min-width: 84px; }
.task-row__title { font-weight: 600; }
.task-row__title a { color: inherit; text-decoration: none; }
.task-row__title a:hover { text-decoration: underline; }
.task-row__meta { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; font-size: .92em; }
.task-row__foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.task-list--compact .task-row { padding: 9px 11px; }

/* ---------- экран задачи ----------
   Страница одной задачи — не стопка карточек: у неё есть шапка с названием и
   статусом, крупный блок «куда ехать», плотный список деталей и отдельная
   колонка с исполнителем и действиями. */
.task-screen { gap: 14px; }

.task-head { display: flex; flex-direction: column; gap: 10px; }
.task-head__row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.task-head__title { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.015em; line-height: 1.22; max-width: 62ch; }
.task-head__badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; flex: none; }
.task-head__meta { margin: 0; color: var(--text-soft); font-size: .93em; }
.task-head__actions { margin-top: 2px; }

/* Блок адреса: главное, за чем водитель открывает задачу, стоит первым и
   читается крупно, а действия лежат под ним в один ряд. */
.address-card { display: flex; flex-direction: column; gap: 8px; border-left: 3px solid var(--accent); }
.address-card__label { margin: 0; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.address-card__text { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.address-card__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.address-card__actions .map-actions { margin: 0; display: flex; gap: 8px; flex-wrap: wrap; }

/* Контакт: имя и телефон отдельно, чтобы номер читался как номер. */
.contact-card__name { margin: 0; font-weight: 600; }
.contact-card__phone { margin: 0; font-size: 17px; }
.contact-card__phone a { color: var(--accent); text-decoration: none; font-variant-numeric: tabular-nums; }
.contact-card__phone a:hover { text-decoration: underline; }

/* Список «подпись — значение»: колонка подписей фиксированной ширины, поэтому
   значения выстраиваются по одной линии и не прыгают при разной длине
   подписей. На узком экране строки схлопываются в столбик. */
.details { display: flex; flex-direction: column; gap: 0; margin: 0; }
.drow { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 12px; padding: 7px 0; border-top: 1px solid var(--border); }
.drow:first-child { border-top: 0; padding-top: 0; }
.drow:last-child { padding-bottom: 0; }
.drow__label { margin: 0; color: var(--text-soft); font-size: .9em; }
.drow__value { margin: 0; min-width: 0; overflow-wrap: anywhere; line-height: 1.45; }

/* Нижняя полоса задачи: отметки слева, главные кнопки справа. */
.taskbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.taskbar__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-left: auto; }
.taskbar__actions form { margin: 0; }
.marks { flex: 1 1 260px; min-width: 0; }

/* Две колонки в карточке админа: слева суть задачи, справа исполнитель и
   действия. На узком экране колонка становится одной. */
.task-cols { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .85fr); gap: 14px; align-items: start; }
.assignee-card { display: flex; flex-direction: column; gap: 3px; border-left: 3px solid var(--border-strong); }
.assignee-card__label { margin: 0; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.assignee-card__name { margin: 0; font-size: 17px; font-weight: 600; }
.assignee-card__meta { margin: 0; color: var(--text-soft); font-size: .9em; display: flex; flex-direction: column; gap: 2px; }
.assignee-card__shift { color: var(--text-soft); }
/* Зона удаления: одна строка под историей, а не отдельная карточка — иначе
   красная кнопка висит в пустоте и перетягивает внимание с задачи. */
.danger-zone { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 2px; }
.danger-zone .hint { flex: 1 1 220px; }
.move-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.move-form .field { flex: 1 1 150px; }
.move-form button { flex: none; }

/* ---------- сотрудники ----------
   Список — карточки, а не таблица с шестью колонками: в таблице на телефоне
   половина полей уезжала за экран, а кнопка «Изменить» стояла последней.
   Карточка отвечает на вопросы админа: на смене ли, сколько сегодня закрыто,
   нет ли висящих задач и задан ли PIN. */
.team-section { display: flex; flex-direction: column; gap: 10px; }
.team-section__head { display: flex; align-items: center; gap: 8px; }
.team-section__head .section__title { margin: 0; }
.team-section__count { color: var(--text-muted); font-size: .82em; font-variant-numeric: tabular-nums; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; align-items: start; }

.team-card { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-left: 3px solid var(--border-strong); }
.team-card--moving { border-left-color: var(--accent); }
.team-card--done { border-left-color: var(--success, #047857); }
.team-card--off { opacity: .72; }
.team-card--admin { border-left-color: var(--border-strong); }

.team-card__head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.team-avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 650; letter-spacing: .02em;
}
.team-card--off .team-avatar { background: var(--hover); color: var(--text-soft); }
.team-card__who { min-width: 0; flex: 1 1 auto; }
.team-card__name { margin: 0; font-size: 15.5px; font-weight: 600; overflow-wrap: anywhere; }
.team-card__role { margin: 1px 0 0; color: var(--text-soft); font-size: .85em; overflow-wrap: anywhere; }
.team-card__flags { display: flex; gap: 6px; flex-wrap: wrap; }
.team-card__phone { margin: 0; font-size: .95em; }
.team-card__phone a { color: var(--text); text-decoration: none; font-variant-numeric: tabular-nums; }
.team-card__phone a:hover { color: var(--accent); text-decoration: underline; }
.team-card__phone--empty { color: var(--text-muted); font-size: .88em; }
.team-card__progress { display: flex; flex-direction: column; gap: 5px; }
.team-card__count { margin: 0; color: var(--text-soft); font-size: .86em; font-variant-numeric: tabular-nums; }
.team-card__count b { color: var(--text); font-weight: 600; }
.team-card__count--idle { color: var(--text-muted); }
.team-card__actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: auto; padding-top: 2px; }
.team-card__actions form { margin: 0; }
.team-card__link { color: var(--accent); font-size: .9em; text-decoration: none; }
.team-card__link:hover { text-decoration: underline; }

/* ---------- доска на день ---------- */
.board-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.board-head__main { display: flex; flex-direction: column; gap: 3px; }
.board-head__title { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -.015em; }
.board-head__meta { margin: 0; color: var(--text-soft); font-size: .93em; }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; align-items: start; }

/* Карточка сотрудника на доске: сверху кто и смена, под ними полоса
   прогресса, ниже — задачи по времени. Полоса отвечает на вопрос «сколько
   осталось», не заставляя пересчитывать бейджи. */
.crew { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px 12px; border-left: 3px solid var(--border-strong); }
.crew--moving { border-left-color: var(--accent); }
.crew--done { border-left-color: var(--success, #047857); }
.crew--fresh { border-left-color: var(--border-strong); }
.crew__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.crew__who { min-width: 0; }
.crew__name { margin: 0; font-size: 15.5px; font-weight: 600; }
.crew__meta { margin: 2px 0 0; color: var(--text-soft); font-size: .86em; overflow-wrap: anywhere; }
.crew__progress { display: flex; flex-direction: column; gap: 5px; }
.crew__bar { height: 6px; border-radius: 999px; background: var(--hover); overflow: hidden; }
.crew__fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .2s ease; }
.crew__fill--0 { width: 0; }
.crew__fill--10 { width: 10%; }
.crew__fill--20 { width: 20%; }
.crew__fill--30 { width: 30%; }
.crew__fill--40 { width: 40%; }
.crew__fill--50 { width: 50%; }
.crew__fill--60 { width: 60%; }
.crew__fill--70 { width: 70%; }
.crew__fill--80 { width: 80%; }
.crew__fill--90 { width: 90%; }
.crew__fill--100 { width: 100%; }
.crew--done .crew__fill { background: var(--success, #047857); }
.crew__count { margin: 0; color: var(--text-soft); font-size: .86em; font-variant-numeric: tabular-nums; }
.crew__count b { color: var(--text); font-weight: 600; }

/* Задачи в карточке — плотный список: время слева узкой колонкой, название и
   адрес справа. Выполненные гасятся, отменённые зачёркиваются. */
.crew-tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.crew-task { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); }
.crew-task:first-child { border-top: 0; padding-top: 0; }
.crew-task__time { color: var(--text-soft); font-size: .86em; font-variant-numeric: tabular-nums; }
.crew-task__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.crew-task__title { color: inherit; text-decoration: none; font-weight: 550; overflow-wrap: anywhere; }
.crew-task__title:hover { color: var(--accent); text-decoration: underline; }
.crew-task__meta { color: var(--text-soft); font-size: .84em; overflow-wrap: anywhere; }
.crew-task--done .crew-task__title { color: var(--text-soft); }
.crew-task--cancelled .crew-task__title { text-decoration: line-through; color: var(--text-muted, var(--text-soft)); }
.crew__add { align-self: flex-start; color: var(--accent); font-size: .9em; text-decoration: none; }
.crew__add:hover { text-decoration: underline; }

/* ---------- форма задачи ----------
   Поля сгруппированы по смыслу в три карточки, а не идут одной простынёй:
   слева «основное» и «куда ехать» с картой, справа контакт и груз. */
.form-task { display: flex; flex-direction: column; gap: 14px; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .9fr); gap: 14px; align-items: start; }
.fields-grid--single { grid-template-columns: minmax(0, 1fr); }
.window-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
/* Полоса действий внизу формы — обычный блок в потоке, а не sticky: липкая
   полоса без фона наезжала на карту и подсказку под ней. */
.formbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 0 4px; border-top: 1px solid var(--border); }
.formbar__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.formbar__hint { flex: 1 1 240px; text-align: right; }

/* ---------- карточка задачи ---------- */
.pairs-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 22px; }
.pair { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pair--wide { grid-column: 1 / -1; }
.pair__label { font-size: .76em; text-transform: uppercase; letter-spacing: .05em; color: var(--text-soft); }
.pair__value { font-size: 1em; overflow-wrap: anywhere; line-height: 1.45; }
.kpis--tight { gap: 8px; }
/* На телефоне четыре показателя в столбик съедают первый экран: сводка
   становится сеткой 2x2 с компактными отступами. */
@media (max-width: 560px) {
  .kpis, .kpis--tight { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpis .kpi { padding: 10px 12px; }
  .kpis .kpi__value { font-size: 19px; }
  .kpis .kpi__label { font-size: 12px; }
}
.map-actions { margin-top: 2px; }
.map-actions a { text-decoration: none; display: inline-flex; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btn-quiet { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
form .btn-quiet { font-weight: 500; }

/* Ссылка-кнопка: у <a> нет ни padding, ни рамки от стиля <button>, поэтому
   главное действие-ссылка теряло форму и выглядело текстом на плашке. */
a.btn-primary, a.btn-quiet {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: inherit; font-weight: 500;
  line-height: 1.3; text-decoration: none; cursor: pointer;
}
a.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
a.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-contrast); }
a.btn-quiet { background: var(--surface); color: var(--text); }
a.btn-quiet:hover { background: var(--hover); color: var(--text); }
/* Ссылка-кнопка в стопке не растягивается на всю ширину карточки. */
.stack > a.btn-primary, .stack > a.btn-quiet { align-self: flex-start; }

/* Второстепенное действие не должно выглядеть главным: класс .btn-quiet
   оставляет акцент только у одной кнопки в блоке. */
button.btn-quiet { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
button.btn-quiet:hover:not(:disabled) { background: var(--hover); }
button.btn-danger { background: transparent; border-color: var(--danger-border); color: var(--danger); }
button.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
/* Форма с полем и кнопкой в одну строку: кнопка стоит по нижнему краю поля. */
.actions--end { align-items: flex-end; }

/* Кнопки внутри карточек: главная и второстепенная не спорят за внимание,
   но на узком экране занимают всю ширину, чтобы промахнуться было нельзя. */
.actions > form, .actions > a { margin: 0; }
.card--pad > form { margin: 0; }

@media (max-width: 700px) {
  /* Меню в одну строку на телефоне: подписи короче, отступы меньше, и все
     четыре раздела админки видны без горизонтальной прокрутки. */
  .side-nav { gap: 0; padding: 6px 8px; }
  .side-nav a { padding: 6px 7px; font-size: .86em; letter-spacing: -.01em; }
  .pairs-grid { grid-template-columns: minmax(0, 1fr); }
  .day-nav { align-items: flex-start; }
  .task-row__time { min-width: 0; }
  .actions > form, .actions > a { flex: 1 1 auto; }
  .actions > form > button, .actions > a { width: 100%; justify-content: center; }
  .task-cols { grid-template-columns: minmax(0, 1fr); }
  .task-head__title { font-size: 19px; }
  .drow { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .drow__label { font-size: .82em; }
  .taskbar { align-items: stretch; }
  .taskbar__actions { margin-left: 0; width: 100%; }
  .taskbar__actions form { flex: 1 1 auto; }
  .taskbar__actions button { width: 100%; justify-content: center; padding-block: 11px; }
  .address-card__actions > a, .address-card__actions > button { flex: 1 1 auto; justify-content: center; }
  .danger-zone button { width: 100%; justify-content: center; }
  .board-grid { grid-template-columns: minmax(0, 1fr); }
  .team-grid { grid-template-columns: minmax(0, 1fr); }
  .team-card__actions { width: 100%; }
  .team-card__actions > a.btn-quiet { flex: 1 1 auto; justify-content: center; }
  .form-layout { grid-template-columns: minmax(0, 1fr); }
  .crew-task { grid-template-columns: 70px minmax(0, 1fr); gap: 8px; }
  .formbar__actions { width: 100%; }
  .formbar__actions > button, .formbar__actions > a { flex: 1 1 auto; justify-content: center; }
  .formbar__hint { text-align: left; }

  /* История на телефоне: три колонки в 390px не помещаются и давали
     горизонтальную прокрутку. Каждая запись становится мини-карточкой. */
  .table-wrap:has(table.history) { overflow: visible; border: 0; background: none; }
  table.history thead { display: none; }
  table.history, table.history tbody { display: block; width: 100%; }
  table.history tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px;
    padding: 9px 0; border-top: 1px solid var(--border);
  }
  table.history tr:first-child { border-top: 0; padding-top: 0; }
  table.history td { display: block; padding: 0; border: 0; }
  table.history td.num { grid-row: 1; color: var(--text-soft); font-size: .85em; white-space: nowrap; }
  table.history td:nth-child(2) { grid-row: 1; color: var(--text-soft); font-size: .85em; }
  table.history td:nth-child(3) { grid-column: 1 / -1; grid-row: 2; overflow-wrap: anywhere; }
}

/* ---------- встроенная карта Яндекс Карт ---------- */
.map {
  position: relative;
  height: 300px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-sunken);
}
.map__canvas { position: absolute; inset: 0; }
.map__fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 16px; gap: 6px; flex-wrap: wrap;
  color: var(--text-soft); font-size: .9em;
}
.map.is-ready .map__fallback { display: none; }
.map.has-error .map__fallback { color: var(--danger); }
.map-pin {
  width: 22px; height: 22px; border-radius: 50% 50% 50% 0;
  background: var(--accent); border: 2px solid #fff;
  transform: rotate(-45deg);
  box-shadow: 0 1px 4px rgb(0 0 0 / 35%);
  position: relative;
}
.map-pin__label {
  position: absolute; left: 50%; top: -8px; transform: translate(-50%, -100%) rotate(45deg);
  white-space: nowrap; font-size: 12px; font-weight: 600;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 2px 7px; box-shadow: var(--shadow);
}
.map--picker { cursor: crosshair; }
.map-tools { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.map-check { margin-top: 4px; }
@media (max-width: 700px) { .map { height: 240px; } }
