:root {
  color-scheme: light;
  /* основа */
  /* палитра FuelRoute: основной #0B1F33, акцент #F5A623, фон #E5EBF7, карточки #FFFFFF */
  --bg: #e5ebf7;
  --panel: #ffffff;
  --field: #ffffff;
  --soft: #f3f6fb;
  --soft2: #e9eef7;
  --ink: #0b1f33;
  --muted: #56657a;
  --muted-2: #9ba8ba;
  --line: #dbe2ee;
  --line-strong: #c3cddd;
  --track: #cfd8e6;
  /* тёмно-синий — главный цвет, оранжевый — акцент */
  --brand: #0b1f33;
  --accent: #1a365d;
  --accent-dark: #0b1f33;
  --accent-soft: #e8eef8;
  --accent-line: #b9c7de;
  --on-accent: #ffffff;
  --amber: #f5a623;
  --amber-dark: #e08e0b;
  --amber-ink: #8f5600;
  /* статусы: зелёный — готово, жёлтый — внимание, красный — ошибка, синий — в работе */
  --ok: #1d8656;
  --ok-soft: #e5f4ec;
  --ok-ink: #15653f;
  --warn-soft: #fff3dc;
  --warn-ink: #8a5300;
  --warn-line: #e8d09c;
  --info-soft: #e6eefb;
  --info-ink: #24508c;
  --danger: #b3392b;
  --danger-soft: #fbece9;
  --danger-line: #f0cbc5;
  /* тени и фокус */
  --shadow: 0 12px 32px rgba(21, 34, 56, 0.08);
  --shadow-sm: rgba(21, 34, 56, 0.12);
  --shadow-accent: rgba(29, 58, 99, 0.12);
  --focus: rgba(29, 58, 99, 0.16);
  --backdrop: rgba(10, 18, 32, 0.45);
}

/* тёмная тема — включается сама, когда телефон/компьютер в тёмном режиме */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b1522;
    --brand: #e5eaf2;
    --amber-dark: #f5a623;
    --panel: #142033;
    --field: #1b2636;
    --soft: #1a2433;
    --soft2: #222e40;
    --ink: #e5eaf2;
    --muted: #97a3b5;
    --muted-2: #5f6d80;
    --line: #283447;
    --line-strong: #3a475a;
    --track: #3a475a;
    --accent: #4a78b8;
    --accent-dark: #3a659f;
    --accent-soft: #1d2c44;
    --accent-line: #36507a;
    --on-accent: #ffffff;
    --amber: #f5a623;
    --amber-ink: #f5b54a;
    --ok: #3fbf86;
    --ok-soft: #15301f;
    --ok-ink: #7bd8aa;
    --warn-soft: #36290f;
    --warn-ink: #f1c46e;
    --warn-line: #5a4620;
    --info-soft: #172a45;
    --info-ink: #93bbef;
    --danger: #f08070;
    --danger-soft: #3a1d1c;
    --danger-line: #5c2e2b;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    --shadow-sm: rgba(0, 0, 0, 0.4);
    --shadow-accent: rgba(0, 0, 0, 0.35);
    --focus: rgba(74, 120, 184, 0.35);
    --backdrop: rgba(0, 0, 0, 0.6);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 650;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

button:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 26px;
}

.topbar,
.section-head,
.preview-head,
.row-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 20px;
  padding: 2px 2px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.05;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.state-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--muted);
  padding: 9px 13px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.state-pill.ready {
  border-color: var(--accent-line);
  background: var(--ok-soft);
  color: var(--ok-ink);
}

.workbench {
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.controls-panel {
  display: grid;
  gap: 20px;
}

.field {
  display: grid;
  gap: 9px;
}

label {
  color: var(--ink);
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 4px var(--focus);
}

textarea {
  min-height: 152px;
  resize: vertical;
  line-height: 1.45;
}

input[type="file"] {
  padding: 8px;
}

input[type="file"]::file-selector-button {
  border: 0;
  border-radius: 6px;
  background: var(--soft2);
  color: var(--ink);
  min-height: 30px;
  margin-right: 10px;
  padding: 0 12px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--soft);
}

.segmented label {
  position: relative;
  min-width: 0;
  cursor: pointer;
  font-weight: 600;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  min-height: 42px;
  place-items: center;
  color: var(--muted);
  padding: 0 8px;
  text-align: center;
}

.segmented input:checked + span {
  background: var(--accent);
  color: var(--on-accent);
}

.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ghost {
  border-color: var(--line);
  background: var(--soft);
  color: var(--ink);
}

.primary,
button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  min-width: 178px;
}

.primary:hover,
button.primary:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
  color: var(--on-accent);
}

.preview-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.row-editor {
  display: grid;
  gap: 12px;
}

.row-editor-head h2 {
  font-size: 18px;
}

.rows {
  display: grid;
  gap: 10px;
}

.record-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.75fr) minmax(150px, 1.25fr) 42px;
  gap: 8px;
  align-items: center;
}

.icon-button {
  min-width: 42px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted-2);
  font-size: 22px;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
}

.advanced {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.advanced summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-weight: 700;
}

.grid-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.grid-fields label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.preview-panel {
  min-height: 430px;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  align-content: start;
}

.check-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
}

.check-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.check-panel h3 {
  margin: 0;
  font-size: 15px;
}

.check-panel-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.check-list {
  display: grid;
  gap: 8px;
}

.check-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
  padding: 9px 10px;
}

.check-mark {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
}

.check-item.ok .check-mark {
  background: var(--ok-soft);
  color: var(--ok-ink);
}

.check-item.error .check-mark {
  background: var(--danger-soft);
  color: var(--danger);
}

.check-item strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
}

.check-item p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.messages {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.message {
  border-radius: 7px;
  padding: 10px 12px;
  background: var(--ok-soft);
  color: var(--ok-ink);
  font-size: 14px;
  line-height: 1.35;
}

.message.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  z-index: 1;
}

td {
  font-size: 14px;
  line-height: 1.35;
}

td:nth-child(1),
td:nth-child(5) {
  color: var(--muted);
  font-weight: 650;
  white-space: nowrap;
}

td:nth-child(2) {
  font-weight: 700;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  margin-top: 14px;
  border-radius: 7px;
  background: var(--accent-dark);
  color: var(--on-accent);
  padding: 0 16px;
  text-decoration: none;
  font-weight: 700;
}

.history-section {
  margin-top: 22px;
  padding-bottom: 12px;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  padding: 14px;
}

.history-item strong {
  display: block;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.history-item p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.history-item a {
  color: var(--accent-dark);
  font-weight: 700;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .preview-head,
  .section-head,
  .row-editor-head {
    align-items: stretch;
    flex-direction: column;
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .primary {
    width: 100%;
  }

  .preview-actions {
    width: 100%;
  }

  .preview-actions button {
    flex: 1 1 160px;
  }

  .state-pill {
    align-self: flex-start;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: 12px;
  }

  .panel {
    padding: 14px;
  }

  h1 {
    font-size: 28px;
  }

  .brand {
    gap: 11px;
  }

  .grid-fields,
  .record-row {
    grid-template-columns: 1fr;
  }

  .icon-button {
    width: 100%;
    min-height: 38px;
    font-size: 20px;
  }

  .inline-actions button,
  .row-editor-head button {
    width: 100%;
  }

  table {
    min-width: 560px;
  }
}

/* ---------- Реестр доверенностей ---------- */

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.hint.warn {
  color: var(--danger);
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  border-radius: 7px 7px 0 0;
  background: transparent;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  box-shadow: none;
  transform: none;
}

.tabs button.active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
}

.reg-login {
  display: grid;
  gap: 12px;
  max-width: 460px;
}

.reg-login form input {
  flex: 1 1 200px;
}

#regMain {
  display: grid;
  gap: 18px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.tile {
  display: grid;
  gap: 2px;
  justify-items: start;
  min-height: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  font-weight: 600;
}

.tile strong {
  font-size: 30px;
  line-height: 1.1;
}

.tile span {
  color: var(--muted);
  font-size: 13px;
}

.tile.hang strong {
  color: var(--warn-ink);
}

.tile.burn strong {
  color: var(--danger);
}

.tile.done strong {
  color: var(--ok);
}

.reg-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.reg-toolbar select,
.reg-toolbar input {
  width: auto;
  flex: 1 1 180px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chips button,
.reg-actions button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}

.chips button {
  background: var(--soft);
  color: var(--ink);
  border-color: var(--line);
}

.chips button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.reg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 14px;
}

.text-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.text-panel textarea {
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

/* сбросить общие правила колонок у таблиц реестра */
.reg-table td:nth-child(n) {
  color: var(--ink);
  font-weight: 500;
  white-space: normal;
}

.reg-table td:nth-child(1),
.reg-table td:nth-child(4),
.reg-table td:nth-child(5) {
  white-space: nowrap;
}

.reg-table small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.reg-table small.problem {
  color: var(--danger);
}

.reg-row {
  cursor: pointer;
}

.reg-row:hover td,
.reg-row:focus td {
  background: var(--soft);
  outline: none;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--soft2);
  color: var(--muted);
}

.badge.live {
  background: var(--info-soft);
  color: var(--info-ink);
}

.badge.hang {
  background: var(--warn-soft);
  color: var(--warn-ink);
}

.badge.burn,
.badge.burned {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.burned {
  background: var(--danger);
  color: var(--on-accent);
}

.badge.done {
  background: var(--ok-soft);
  color: var(--ok-ink);
}

.trips-panel {
  display: grid;
  gap: 12px;
}

.reg-dialog {
  width: min(560px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.reg-dialog::backdrop {
  background: var(--backdrop);
}

.reg-dialog form {
  display: grid;
  gap: 14px;
}

.reg-dialog .wide {
  grid-column: 1 / -1;
}

.edit-log {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 860px) {
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pills {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .tabs button {
    flex: 1;
    padding: 0 8px;
    font-size: 14px;
  }

  .reg-actions button {
    flex: 1 1 45%;
  }
}

/* атрибут hidden должен побеждать display: grid у панелей */
[hidden] {
  display: none !important;
}

/* ---------- Телефон: ничего не должно распирать страницу ---------- */

/* элементы сетки по умолчанию не сжимаются уже своего содержимого — разрешаем */
.panel > *,
#regMain > *,
.controls-panel > *,
.field > *,
.text-panel > * {
  min-width: 0;
}

@media (max-width: 860px) {
  /* iPhone увеличивает страницу при фокусе на поле со шрифтом меньше 16px */
  input,
  select,
  textarea,
  .text-panel textarea {
    font-size: 16px;
  }
}

@media (max-width: 640px) {
  /* таблицы реестра и рейсов — карточками, без горизонтальной прокрутки */
  .table-wrap:has(.reg-table) {
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .reg-table {
    min-width: 0;
  }

  .reg-table thead {
    display: none;
  }

  .reg-table,
  .reg-table tbody,
  .reg-table tr,
  .reg-table td {
    display: block;
    width: 100%;
  }

  .reg-table tr {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--field);
    padding: 6px 12px;
  }

  .reg-table td,
  .reg-table td:nth-child(n) {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 8px;
    padding: 5px 0;
    border-bottom: 0;
    border-top: 1px dashed var(--line);
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .reg-table td:first-child {
    border-top: 0;
  }

  .reg-table td > * {
    grid-column: 2;
  }

  .reg-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
  }

  .reg-table td:empty,
  .reg-table td[data-label=""] {
    display: none;
  }

  .badge {
    white-space: normal;
  }

  .reg-row:hover td,
  .reg-row:focus td {
    background: transparent;
  }
}

/* ---------- Версия и обновления ---------- */

.version-pill {
  min-height: 0;
  margin-left: 6px;
  padding: 1px 8px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok-ink);
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
  box-shadow: none;
}

.version-pill:hover {
  transform: none;
  box-shadow: none;
  background: var(--accent-soft);
}

.update-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  background: var(--ok-soft);
  color: var(--ok-ink);
  font-weight: 600;
}

.update-banner button {
  width: auto;
}

.whats-new {
  display: grid;
  gap: 12px;
  max-height: 60vh;
  overflow: auto;
}

.whats-new h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.whats-new ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

#whatsNew {
  display: none;
}

#whatsNew[open] {
  display: grid;
  gap: 14px;
}

/* ---------- Выравнивание (v42) ---------- */

.row-editor-head button {
  white-space: nowrap;
  min-height: 38px;
  font-size: 14px;
}

.inline-actions,
.reg-actions {
  align-items: stretch;
}

.file-button {
  justify-content: center;
  text-align: center;
}

/* панель реестра: фильтры, список и поиск одной высоты */
.reg-toolbar .chips button,
.reg-toolbar select,
.reg-toolbar input {
  min-height: 40px;
  height: 40px;
}

.reg-toolbar select,
.reg-toolbar input {
  padding-top: 6px;
  padding-bottom: 6px;
}

.reg-table th {
  white-space: nowrap;
}

#tripWrap:not([hidden]) {
  display: grid;
  gap: 12px;
}

.text-panel .section-head {
  align-items: center;
}

@media (max-width: 860px) {
  .text-panel .section-head {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

@media (max-width: 520px) {
  /* доверенность — одной строкой: номер, водитель, удалить */
  .record-row {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr) 44px;
  }

  .record-row .icon-button {
    width: 44px;
    min-height: 44px;
    font-size: 20px;
  }

  /* пары кнопок — рядом, одинаковой высоты */
  .inline-actions button,
  .reg-actions button,
  .reg-actions .file-button {
    flex: 1 1 40%;
    width: auto;
    min-width: 0;
    min-height: 44px;
    white-space: normal;
    line-height: 1.15;
  }

  .text-panel .inline-actions {
    width: 100%;
  }

}

@media (max-width: 520px) {
  /* главная кнопка рейсов — на всю ширину, «Разобрать» и «Очистить» — парой под ней */
  #pasteTrips {
    flex-basis: 100%;
  }
}

/* ---------- Подбор машин ---------- */

.fleet {
  display: grid;
  gap: 16px;
}

.fleet > * {
  min-width: 0;
}

/* верхняя строка: план, единица, точный режим, сколько машин */
.fleet-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  padding: 14px 18px;
}

.fleet-plan {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.fleet-plan input {
  width: 140px;
  min-height: 46px;
  font-size: 24px;
  font-weight: 750;
}

.fleet-bar select {
  width: auto;
  min-height: 46px;
  padding: 8px 10px;
  margin-left: -8px;
}

.fleet-bar-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
}

.fleet-bar-count b {
  color: var(--ink);
}

/* переключатель */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-track {
  position: relative;
  width: 40px;
  height: 24px;
  border-radius: 999px;
  background: var(--track);
  transition: background 0.16s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--field);
  box-shadow: 0 1px 3px var(--shadow-sm);
  transition: transform 0.16s ease;
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(16px);
}

.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 4px var(--focus);
}

/* варианты */
.fleet-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  align-items: start;
}

.fleet-card {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.fleet-card.best {
  border-color: var(--accent-line);
  box-shadow: 0 10px 26px var(--shadow-accent);
}

.fleet-card.empty {
  grid-column: 1 / -1;
}

.fleet-card header,
.fleet-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fleet-rank {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.fleet-card:not(.best) .fleet-rank {
  color: var(--muted);
}

.fleet-diff {
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 13px;
  font-weight: 700;
}

.fleet-diff.exact { background: var(--ok-soft); color: var(--ok-ink); }
.fleet-diff.under { background: var(--warn-soft); color: var(--warn-ink); }
.fleet-diff.over { background: var(--info-soft); color: var(--info-ink); }

.fleet-total {
  margin: 0;
  font-size: 28px;
  font-weight: 750;
  line-height: 1.1;
}

.fleet-total small {
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
}

.fleet-lines {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.fleet-lines li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.fleet-lines .who {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fleet-lines .who.unknown {
  color: var(--warn-ink);
}

.fleet-lines .vol {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.fleet-lines li.partial .vol {
  color: var(--warn-ink);
}

.fleet-partial {
  margin: 0;
  color: var(--warn-ink);
  font-size: 13px;
}

.fleet-card footer {
  color: var(--muted);
  font-size: 13px;
}

.fleet-copy {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  font-size: 13px;
  box-shadow: none;
}

.fleet-copy:hover {
  transform: none;
  box-shadow: none;
  background: var(--accent-soft);
}

/* список машин */
.fleet-list-panel {
  display: grid;
  gap: 10px;
}

.fleet-list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.fleet-count {
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
}

.fleet-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.tool {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: none;
}

.tool:hover {
  transform: none;
  box-shadow: none;
  background: var(--accent-soft);
}

.tool.primary-tool {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.tool-sep {
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: var(--line);
}

.fleet-list {
  display: grid;
}

.fleet-empty {
  padding: 12px 0;
}

.fleet-sync {
  margin-top: 4px;
}

/* строка машины: [вкл] [номер] [водитель] [секции] [рейсов] [×] */
.fr {
  display: grid;
  grid-template-columns: 22px 140px minmax(270px, 1fr) minmax(0, 1.4fr) 64px 32px;
  gap: 10px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.fr:last-child {
  border-bottom: 0;
}

.fr-head {
  padding: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.fr input {
  min-height: 36px;
  padding: 6px 9px;
}

.fr.off > :not(.fr-check) {
  opacity: 0.4;
}

.fr-check {
  display: flex;
  align-items: center;
  height: 36px;
}

.fr-check input {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.fr-name {
  font-weight: 700;
}

.fr-driver {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.fr-driver small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fr-driver small.warn {
  color: var(--warn-ink);
}

.fr-sections {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
}

.sec-boxes {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.sec-box {
  display: grid;
  justify-items: center;
  gap: 1px;
  font-weight: 500;
}

.fr .sec-box input {
  width: 74px;
  font-size: 15px;
  padding: 6px 4px;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sec-box small {
  min-height: 11px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
}

.sec-add {
  width: 30px;
  min-height: 36px;
  height: 36px;
  padding: 0;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 600;
  box-shadow: none;
}

.sec-add:hover {
  transform: none;
  box-shadow: none;
  background: var(--accent-soft);
}

.sec-total {
  display: flex;
  align-items: center;
  height: 36px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.fr-trips {
  text-align: center;
}

.fr-del {
  width: 32px;
  min-height: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  font-size: 22px;
  box-shadow: none;
}

.fr-del:hover {
  transform: none;
  box-shadow: none;
  color: var(--danger);
  background: var(--danger-soft);
}

@media (max-width: 860px) {
  .fleet-bar-count {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .fleet-bar {
    padding: 12px 14px;
  }

  .fleet-plan input {
    width: 120px;
  }

  .fleet-results {
    grid-template-columns: 1fr;
  }

  .fr-head {
    display: none;
  }

  /* машина — компактная карточка из трёх строк */
  .fr {
    grid-template-columns: 22px minmax(0, 1fr) 60px 32px;
    grid-template-areas:
      "check name trips del"
      ". driver driver driver"
      ". sections sections sections";
    gap: 8px;
    padding: 10px 0;
  }

  .fr-check { grid-area: check; }
  .fr-name { grid-area: name; }
  .fr-trips { grid-area: trips; }
  .fr-del { grid-area: del; }
  .fr-driver { grid-area: driver; }
  .fr-sections { grid-area: sections; }

  .fr .sec-box input {
    width: 76px;
    padding: 6px 2px;
    font-size: 16px;
  }

  .fr-trips-wrap small {
    display: block;
  }

  .fleet-tools {
    width: 100%;
  }

  .fleet-tools .tool {
    flex: 1 1 auto;
    justify-content: center;
    min-height: 36px;
  }

  .tool-sep {
    display: none;
  }
}

/* числовые поля без стрелок */
.fleet input[type="number"]::-webkit-outer-spin-button,
.fleet input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.fleet input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.fr-trips-wrap {
  display: grid;
  justify-items: center;
  gap: 1px;
  font-weight: 500;
}

.fr-trips-wrap small {
  display: none;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
}

@media (max-width: 640px) {
  .fr-trips-wrap { grid-area: trips; }
}

@media (max-width: 640px) {
  /* секции ровной сеткой: окошки, «+» и итог — ячейки одной сетки */
  .fr-sections {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    gap: 6px;
  }

  .fr-sections .sec-boxes {
    display: contents;
  }

  .fr .sec-box input {
    width: 100%;
  }

  .sec-add {
    width: 100%;
  }

  .sec-total {
    justify-content: flex-start;
    white-space: nowrap;
  }
}

/* подпись под водителем и сменщики-кнопки */
.fr-driver-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  min-width: 0;
}

.drv-chips {
  display: contents;
}

.drv-chip {
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid var(--warn-line);
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn-ink);
  font-size: 12px;
  font-weight: 600;
  box-shadow: none;
}

.drv-chip:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

@media (max-width: 640px) {
  .drv-chip {
    min-height: 30px;
    padding: 0 10px;
    font-size: 13px;
  }
}

.fr-driver-meta small:empty {
  display: none;
}

/* ---------- Шапка, логотип, статусы, вкладки (v46) ---------- */

.topbar,
.topbar:is(*) {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand-text h1 {
  font-size: 24px;
  font-weight: 750;
  line-height: 1.1;
}

.brand-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.version-pill {
  margin-left: 0;
  border-color: var(--line);
  background: var(--soft2);
  color: var(--muted);
}

.version-pill:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

/* статусы: точка + короткий текст; на телефоне только точка, текст — по нажатию */
.pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.state-pill,
button.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: default;
}

.state-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--amber);
}

.state-pill.ready,
button.state-pill.ready {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

.state-pill.ready::before {
  background: var(--ok);
}

/* вкладки: сверху на компьютере */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  box-shadow: none;
}

.tabs button:hover {
  background: transparent;
  color: var(--ink);
}

.tabs button.active {
  border-bottom-color: var(--amber);
  color: var(--ink);
}

.tabs svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
}

.tab-short {
  display: none;
}

/* ---------- Телефон: компактная шапка и вкладки внизу ---------- */

@media (max-width: 640px) {
  .app-shell {
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }

  .topbar {
    margin-bottom: 12px;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }

  .brand-text h1 {
    font-size: 20px;
  }

  .brand-sub {
    font-size: 12px;
  }

  .pills {
    flex-wrap: nowrap;
  }

  .state-pill,
  button.state-pill {
    width: 32px;
    min-width: 32px;
    padding: 0;
    justify-content: center;
    overflow: hidden;
    font-size: 0;
    cursor: pointer;
  }

  .state-pill.open,
  button.state-pill.open {
    width: auto;
    padding: 0 11px;
    font-size: 12px;
  }

  .state-pill::before {
    width: 10px;
    height: 10px;
  }

  .tabs {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    margin: 0;
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    border-bottom: 0;
    background: var(--panel);
    box-shadow: 0 -6px 20px var(--shadow-sm);
  }

  .tabs button {
    flex-direction: column;
    gap: 3px;
    min-height: 56px;
    padding: 4px 0 2px;
    border-bottom: 0;
    border-top: 3px solid transparent;
    font-size: 12px;
  }

  .tabs button,
  .tabs button:is(*) {
    flex: none;
    width: auto;
  }

  .tabs button.active {
    border-top-color: var(--amber);
    border-bottom: 0;
    color: var(--accent);
  }

  .tabs svg {
    width: 22px;
    height: 22px;
  }

  .tab-long {
    display: none;
  }

  .tab-short {
    display: inline;
  }
}

/* название FuelRoute */
.wordmark {
  letter-spacing: -0.02em;
}

.wordmark {
  color: var(--brand);
}

.wordmark span {
  color: var(--amber);
  font-weight: inherit;
}

/* ---------- Надёжная раскладка для Safari (iPhone) ---------- */

.brand-logo {
  display: block;
}

.tabs button {
  display: block;
}

.tab-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@media (max-width: 640px) {
  .tabs button {
    display: block;
    min-width: 0;
    padding: 0;
  }

  .tab-inner {
    flex-direction: column;
    gap: 3px;
    min-height: 52px;
  }

  .tabs {
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    backdrop-filter: saturate(1.4) blur(10px);
  }
}

/* ---------- Пачки доверок ---------- */

.batches-panel {
  display: grid;
  gap: 12px;
}

.batch-stock {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.batch-stock .hint {
  margin: 0;
}

.stock-chip {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  align-items: baseline;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  min-width: 180px;
}

.stock-chip strong {
  font-size: 24px;
  line-height: 1.1;
  color: var(--ok);
}

.stock-chip span {
  font-weight: 600;
}

.stock-chip small {
  grid-column: 2;
  color: var(--muted);
}

.stock-chip.low {
  border-color: var(--warn-line);
  background: var(--warn-soft);
}

.stock-chip.low strong,
.stock-chip.low span {
  color: var(--warn-ink);
}

.batch-form .grid-fields {
  margin-top: 0;
}

.batch-form .wide {
  grid-column: 1 / -1;
}

.batch-form .hint {
  margin: 10px 0;
}

.batch-list summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-weight: 700;
}

.batch-list .table-wrap {
  margin-top: 10px;
}

.batch-table td:nth-child(6) {
  white-space: normal;
  min-width: 180px;
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-accent);
}

@media (max-width: 640px) {
  .stock-chip {
    flex: 1 1 100%;
  }
}

/* ---------- Дубли ---------- */

.badge.dupe {
  margin-left: 6px;
  background: var(--warn-soft);
  color: var(--warn-ink);
  border: 1px solid var(--warn-line);
}

.chips button.chip-warn {
  border-color: var(--warn-line);
  color: var(--warn-ink);
}

.chips button.chip-warn.active {
  background: var(--warn-ink);
  border-color: var(--warn-ink);
  color: var(--panel);
}

.reg-dialog .edit-delete {
  margin-left: auto;
}

/* ---------- Водители ---------- */

.drivers {
  display: grid;
  gap: 16px;
}

#drvMain {
  display: grid;
  gap: 16px;
}

.drv-form .wide {
  grid-column: 1 / -1;
}

.drivers .section-head input[type="search"] {
  max-width: 260px;
}

.pin-box {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--ok);
  border-radius: 8px;
  background: var(--ok-soft);
}

.pin-box .eyebrow {
  margin: 0;
}

.pin-who {
  margin: 4px 0 0;
  font-weight: 700;
}

.pin-code {
  margin: 6px 0;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 0.25em;
  color: var(--ok-ink);
  font-variant-numeric: tabular-nums;
}

.pin-box textarea {
  width: 100%;
  font-size: 14px;
}

.drv-actions {
  white-space: nowrap;
}

.drv-actions button {
  margin: 2px 4px 2px 0;
  padding: 6px 10px;
  font-size: 13px;
}

@media (max-width: 640px) {
  .tabs {
    grid-template-columns: repeat(4, 1fr);
  }

  .drivers .section-head input[type="search"] {
    max-width: none;
  }

  .drv-actions {
    white-space: normal;
  }
}

.drv-table td:nth-child(2) {
  white-space: nowrap;
}

.drv-table td a {
  color: var(--accent-dark);
  text-decoration: none;
}

.drv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.drv-actions button {
  margin: 0;
}

/* ---------- Входящие рейсы ---------- */

.inbox-panel {
  display: grid;
  gap: 12px;
  border-color: var(--amber);
}

.inbox-all {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}

.inbox-table input[type="checkbox"],
.inbox-all input {
  width: 20px;
  height: 20px;
}

.inbox-table td small {
  display: block;
}

.inbox-actions input {
  flex: 1 1 220px;
  min-width: 0;
}

.tab-inner {
  position: relative;
}

.tab-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--amber);
  color: #1b1300;
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 640px) {
  .tab-badge {
    position: absolute;
    top: -2px;
    right: -14px;
    margin: 0;
  }
}

/* ---------- Вкладка «Рейсы»: реестр рейсов ---------- */

.trips-tab,
#tripsMain {
  display: grid;
  gap: 16px;
}

.trip-log-panel {
  display: grid;
  gap: 12px;
}

.log-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.log-toolbar select,
.log-toolbar input[type="search"] {
  flex: 1 1 170px;
  min-width: 0;
}

.log-custom {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 260px;
}

.log-custom[hidden] {
  display: none;
}

.log-custom input {
  flex: 1 1 0;
  min-width: 0;
}

.log-tiles .tile {
  cursor: default;
}

.log-table td small {
  display: block;
  color: var(--muted);
}

@media (min-width: 641px) {
  .log-table td:nth-child(6) {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  .tabs {
    grid-template-columns: repeat(5, 1fr);
  }

  .tabs button {
    font-size: 11px;
  }

  .log-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- Справочники ---------- */

.dir-nav {
  flex-wrap: wrap;
}

.dir-nav[hidden] {
  display: none;
}

.dir-panel {
  display: grid;
  gap: 10px;
}

.dir-panel .hint {
  margin: 0;
}

.dir-table tr.off td {
  opacity: 0.55;
}

.dir-check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  flex-direction: row !important;
  font-weight: 600;
}

.dir-check input {
  width: 20px;
  height: 20px;
}

#dirFields label[hidden] {
  display: none;
}

@media (max-width: 640px) {
  .dir-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dir-nav button {
    min-width: 0;
    padding-left: 4px;
    padding-right: 4px;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 360px) {
  .dir-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.fleet-actions {
  display: inline-flex;
  gap: 6px;
}

/* ---------- Подбор машин: налив → слив ---------- */

.fleet-route {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  flex: 1 1 100%;
}

.fleet-route label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  flex: 1 1 220px;
  min-width: 0;
}

.fleet-route select {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

.fleet-route-arrow {
  color: var(--muted);
  font-weight: 700;
}

.fleet-route-line {
  margin: -4px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 640px) {
  .fleet-route-arrow {
    display: none;
  }

  .fleet-route label {
    flex-basis: 100%;
  }

  .fleet-route label > :first-child {
    min-width: 60px;
  }
}

/* ---------- Фирменный стиль v58: кнопки, статусы, логотип ---------- */

.brand-pic {
  display: block;
  flex: 0 0 auto;
  line-height: 0;
}

/* оранжевая кнопка — «добавить / создать» (как «+ Создать заявку» в макете) */
button.cta,
.cta {
  border-color: var(--amber);
  background: var(--amber);
  color: #1b1300;
  font-weight: 750;
  box-shadow: 0 6px 14px rgba(245, 166, 35, 0.25);
}

button.cta:hover {
  border-color: var(--amber-dark);
  background: var(--amber-dark);
  color: #1b1300;
}

/* главная — тёмно-синяя, скругления и лёгкая тень как в макете */
button,
.primary {
  border-radius: 10px;
}

button.primary {
  box-shadow: 0 6px 14px rgba(11, 31, 51, 0.16);
}

/* статусы-пилюли с цветной точкой: зелёный — готово, оранжевый — в работе/внимание,
   серо-синий — ждёт, красный — ошибка/сгорела */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
}

.badge::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge.live::before {
  background: #3f76c4;
}

.badge.hang {
  background: #fff1dc;
  color: #9a5b00;
}

.badge.hang::before {
  background: var(--amber);
}

.badge.done::before {
  background: #22a06b;
}

.badge.burn::before {
  background: #d9483b;
}

.badge.burned::before {
  background: #fff;
}

.badge.dead::before {
  background: var(--muted-2);
}

@media (prefers-color-scheme: dark) {
  .badge.hang {
    background: var(--warn-soft);
    color: var(--warn-ink);
  }
}

/* карточки чуть мягче, как в макете */
.panel {
  border-radius: 14px;
}

.tool.cta {
  border-color: var(--amber);
  background: var(--amber);
  color: #1b1300;
}

.tool.cta:hover {
  background: var(--amber-dark);
  border-color: var(--amber-dark);
}

.slogan {
  margin: 0 0 6px;
  color: var(--amber-ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ---------- Планы вывоза (v59) ---------- */
.plans-panel .section-head { align-items: center; }
.plans-list { display: grid; gap: 12px; }
.plans-list:empty { display: none; }
.plan-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--panel, #fff);
}
.plan-card.is-complete { border-color: #9ad8bb; }
.plan-card.is-closed { opacity: .72; background: var(--soft); }
.plan-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.plan-route { margin: 0; font-size: 18px; line-height: 1.25; }
.plan-meta { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.plan-late { color: #c23a2e; font-weight: 700; }
.plan-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.plan-actions button { padding: 6px 12px; font-size: 13px; }
.danger-text { color: #c23a2e; }
.plan-progress { display: flex; align-items: center; gap: 10px; margin: 12px 0 10px; }
.plan-bar {
  flex: 1;
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--soft2);
}
.plan-bar-done { background: var(--amber); }
.plan-bar-pending {
  background: repeating-linear-gradient(135deg, rgba(245, 166, 35, .55) 0 6px, rgba(245, 166, 35, .25) 6px 12px);
}
.plan-card.is-complete .plan-bar-done { background: #22a06b; }
.plan-pct { font-weight: 800; min-width: 44px; text-align: right; }
.plan-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.plan-stat { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 10px; background: var(--soft); min-width: 0; }
.plan-stat strong { font-size: 18px; white-space: nowrap; }
.plan-stat-label, .plan-stat-sub { font-size: 12px; color: var(--muted); }
.plan-stat-left { background: #fff4e0; }
.plan-stat-left strong { color: var(--amber-ink); }
.plan-drivers { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.plan-drivers-label { font-weight: 700; }
.plan-closed-toggle { justify-self: start; background: none; border: 0; color: var(--accent); padding: 4px 0; font-weight: 700; box-shadow: none; }
.plan-form { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; background: var(--soft); }
.plan-form h3 { margin: 0 0 10px; }
.plan-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; margin-bottom: 12px; }
.plan-form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.plan-form-wide { grid-column: 1 / -1; }
@media (max-width: 720px) {
  .plan-card-head { flex-direction: column; }
  .plan-actions { justify-content: flex-start; }
  .plan-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan-form-grid { grid-template-columns: 1fr 1fr; }
}
@media (prefers-color-scheme: dark) {
  .plan-stat-left { background: #2a2113; }
  .plan-card.is-complete { border-color: #1f6b4a; }
}

/* ---------- Смены водителей (v60) ---------- */
.shifts-panel .section-head { align-items: center; }
.shift-summary { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.shift-chip { padding: 4px 10px; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--muted); }
.shift-chip.on { color: #16774d; border-color: #9ad8bb; background: #e9f7f0; }
.shift-chip.soon { color: #9a5b00; border-color: #f3cf8f; background: #fff1dc; }
.shift-chip.warn { color: #b3261e; border-color: #f0b4ae; background: #fdecea; }
.shift-list { display: grid; gap: 8px; }
.shift-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.shift-item:has(.is-warn) { border-color: #f0b4ae; background: #fff8f7; }
.shift-row { display: grid; grid-template-columns: minmax(170px, 1.4fr) 110px minmax(200px, 1.6fr) 100px auto; gap: 12px; align-items: center; }
.shift-row > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.shift-row .shift-change { align-items: flex-start; }
.shift-car, .shift-muted { font-size: 13px; color: var(--muted); }
.shift-act button { padding: 6px 12px; font-size: 13px; }
.shift-warn { margin: 6px 0 0; font-size: 13px; font-weight: 700; color: #b3261e; }
.shift-off { margin: 10px 0 0; }
.shift-edit { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.shift-edit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; margin-bottom: 10px; }
.shift-edit-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.shift-history { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.shift-history .inline-actions { margin-bottom: 10px; }
.shift-table td.num { text-align: right; }
.shift-table tr.is-open td { background: #f1faf5; }
@media (max-width: 720px) {
  .shift-row { grid-template-columns: 1fr auto; }
  .shift-row .shift-since, .shift-row .shift-trips { flex-direction: row; gap: 6px; }
  .shift-row .shift-change { grid-column: 1 / -1; }
  .shift-row .shift-act { grid-row: 1; grid-column: 2; }
  .shift-edit-grid { grid-template-columns: 1fr 1fr; }
}
@media (prefers-color-scheme: dark) {
  .shift-chip.on { background: #12291f; border-color: #1f6b4a; color: #6fd3a4; }
  .shift-chip.soon { background: #2a2113; border-color: #6b4a14; color: #f5b54a; }
  .shift-chip.warn { background: #2c1614; border-color: #7a2c25; color: #f08b80; }
  .shift-item:has(.is-warn) { background: #231715; border-color: #7a2c25; }
  .shift-warn { color: #f08b80; }
  .shift-table tr.is-open td { background: #12241c; }
}
@media (max-width: 720px) {
  .shift-row .shift-since, .shift-row .shift-trips { align-items: baseline; }
}

/* ---------- Шапка v61: колокольчик, индикатор связи, боковая панель на компьютере ---------- */
.page-title,
.side-brand,
.side-foot {
  display: none;
}

.pills {
  align-items: center;
}

.bell-wrap {
  position: relative;
}

.bell-wrap[hidden] {
  display: none;
}

button.bell {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--ink);
  box-shadow: none;
}

button.bell:hover,
button.bell[aria-expanded="true"] {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.bell-count {
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border: 2px solid var(--bg);
  border-radius: 999px;
  background: var(--amber);
  color: #1b1300;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.bell-count.danger {
  background: #d9483b;
  color: #fff;
}

.bell-count[hidden] {
  display: none;
}

.bell-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  width: min(380px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(11, 31, 51, 0.18);
}

.bell-panel[hidden] {
  display: none;
}

.bell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.bell-head strong {
  font-size: 16px;
}

button.bell-link {
  min-height: 0;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  box-shadow: none;
}

.bell-link[hidden] {
  display: none;
}

.bell-sys {
  margin-bottom: 8px;
}

.bell-list {
  display: grid;
  gap: 4px;
}

button.bell-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 0;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: var(--soft);
  color: var(--ink);
  text-align: left;
  font-weight: 400;
  box-shadow: none;
}

button.bell-item:hover {
  background: var(--accent-soft);
}

.bell-item.is-read {
  background: transparent;
  opacity: 0.7;
}

.bell-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  margin-top: 5px;
  border-radius: 50%;
  background: #3f76c4;
}

.lvl-danger .bell-dot { background: #d9483b; }
.lvl-warn .bell-dot { background: var(--amber); }
.lvl-ok .bell-dot { background: #22a06b; }

.bell-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.bell-title {
  font-size: 14px;
  font-weight: 700;
}

.bell-detail {
  color: var(--muted);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.bell-empty {
  margin: 6px 0 2px;
  padding: 14px 10px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--muted);
  text-align: center;
}

/* индикатор связи */
.sys-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.sys-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa7b8;
}

.sys-status[data-state="ok"] .sys-dot {
  background: #22a06b;
  box-shadow: 0 0 0 3px rgba(34, 160, 107, 0.2);
}

.sys-status[data-state="down"] .sys-dot {
  background: #d9483b;
  box-shadow: 0 0 0 3px rgba(217, 72, 59, 0.2);
}

.sys-status[data-state="down"] {
  color: #c23a2e;
}

@media (max-width: 640px) {
  button.bell {
    width: 32px;
    height: 32px;
    min-height: 32px;
  }

  button.bell svg {
    width: 18px;
    height: 18px;
  }

  .bell-panel {
    position: fixed;
    top: calc(64px + env(safe-area-inset-top));
    right: 12px;
    left: 12px;
    width: auto;
  }
}

/* ---------- Компьютер: разделы слева тёмной панелью ---------- */
@media (min-width: 1100px) {
  body {
    padding-left: 236px;
  }

  .app-shell {
    width: min(1240px, 100%);
    padding: 22px 32px 32px;
  }

  .topbar .brand {
    display: none;
  }

  .page-title {
    display: block;
    min-width: 0;
  }

  .page-title .eyebrow {
    margin: 0 0 2px;
  }

  .page-title h1 {
    margin: 0;
    font-size: 26px;
    line-height: 1.15;
    color: var(--brand);
  }

  .tabs {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 236px;
    margin: 0;
    padding: 20px 14px 18px;
    overflow: hidden auto;
    border: 0;
    background: #0b1f33;
    color: #e5eaf2;
  }

  .side-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 4px 22px;
  }

  .side-logo {
    display: block;
    width: 40px;
    height: 40px;
    object-fit: contain;
  }

  .side-word {
    margin: 0;
    color: #fff;
    font-size: 21px;
    font-weight: 750;
    letter-spacing: -0.02em;
    line-height: 1.1;
  }

  .side-word span {
    color: var(--amber);
  }

  .side-sub {
    margin: 1px 0 0;
    color: #8fa0b6;
    font-size: 12.5px;
  }

  .tabs button,
  .tabs button:is(*) {
    display: block;
    width: 100%;
    min-height: 46px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #b7c3d3;
    font-weight: 600;
  }

  .tabs button:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
  }

  .tabs button.active {
    border: 0;
    background: rgba(245, 166, 35, 0.15);
    box-shadow: inset 3px 0 0 var(--amber);
    color: #fff;
  }

  .tabs .tab-inner {
    justify-content: flex-start;
    gap: 12px;
  }

  .tabs .tab-badge {
    position: static;
    margin-left: auto;
  }

  .side-foot {
    position: relative;
    display: grid;
    gap: 8px;
    margin-top: auto;
    padding: 70px 6px 0;
    color: #ffffff;
  }

  .side-route {
    position: absolute;
    right: -14px;
    bottom: 42px;
    left: -14px;
    width: calc(100% + 28px);
    height: 150px;
    pointer-events: none;
  }

  .side-foot .sys-status {
    position: relative;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: #cfd8e4;
  }

  .side-foot .sys-status[data-state="down"] {
    color: #ff9c92;
  }

  .side-slogan {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0;
    color: #8fa0b6;
    font-size: 12px;
    font-weight: 600;
  }

  button.side-version {
    min-height: 0;
    padding: 1px 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: transparent;
    color: #b7c3d3;
    font-size: 11.5px;
    font-weight: 700;
    box-shadow: none;
  }

  button.side-version:hover {
    border-color: var(--amber);
    color: #fff;
  }

  .bell-panel {
    width: 400px;
  }
}

@media (min-width: 1100px) and (prefers-color-scheme: dark) {
  .tabs {
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    background: #07111d;
  }
}

/* v61: доводка */
.sys-status { flex-wrap: wrap; row-gap: 0; }
.sys-time { flex-basis: 100%; padding-left: 16px; font-size: 11.5px; font-weight: 500; opacity: 0.75; }
.sys-time:empty { display: none; }

@media (min-width: 641px) and (max-width: 1099px) {
  .tab-long { display: none; }
  .tab-short { display: inline; }
}

@media (max-width: 380px) {
  .brand-company { display: none; }
}

@media (min-width: 1100px) {
  .tabs button,
  .tabs button:is(*) {
    text-align: left;
    font-size: 15px;
  }
  .tabs .tab-long { line-height: 1.2; }
  .tabs button,
  .tabs button:is(*) { min-height: 44px; padding-top: 6px; padding-bottom: 6px; }
  .tabs .side-route {
    position: absolute;
    right: -14px;
    bottom: 96px;
    left: -14px;
    width: calc(100% + 28px);
    height: 130px;
  }
  .side-foot { padding-top: 120px; }
  .side-slogan { flex-direction: column; align-items: flex-start; gap: 6px; }
  button.side-version { width: auto; }
}
@media (min-width: 1100px) {
  .tabs button.side-version,
  .tabs button.side-version:is(*) {
    display: inline-block;
    width: auto;
    min-height: 0;
    padding: 1px 9px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    font-size: 11.5px;
  }
}

/* v62: справочник «Машины» */
.dir-sub { color: var(--muted); font-size: 12px; font-weight: 600; }

/* v64: калибровка секций из справочника «Машины» */
.fr .sec-ro {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 74px;
  min-height: 38px;
  padding: 6px 4px;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.fr-sections.from-dir { align-items: center; }
.sec-src {
  align-self: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--soft2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.fr.off .sec-ro { opacity: 0.55; }
.fleet-lines .secs {
  grid-column: 1 / -1;
  margin-top: -3px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 640px) {
  .fr .sec-ro { width: 100%; }
}
@media (max-width: 640px) {
  .fr-sections .sec-src { grid-column: 1 / -1; justify-self: start; }
}

/* ---------- v66: «Заявки» по шагам ---------- */
.req-wizard { display: grid; gap: 14px; max-width: 980px; }
.req-step[hidden], .req-wizard [hidden] { display: none !important; }
.req-files { padding: 0; }
.req-files > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}
.req-files > summary::-webkit-details-marker { display: none; }
.req-files-title { font-weight: 800; margin-right: 4px; }
.req-chip {
  padding: 3px 10px;
  border-radius: 999px;
  background: #fff1dc;
  color: #9a5b00;
  font-size: 13px;
  font-weight: 700;
}
.req-chip.ok { background: #e9f7f0; color: #16774d; }
.req-files-toggle { margin-left: auto; color: var(--accent); font-size: 13px; font-weight: 700; }
.req-files[open] .req-files-toggle { visibility: hidden; }
.req-files-body { display: grid; gap: 16px; padding: 4px 16px 16px; border-top: 1px solid var(--line); }
.req-files-body .field:first-child { margin-top: 12px; }

.req-stepper { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.req-stepper button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  text-align: left;
  box-shadow: none;
}
.req-stepper b {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--soft2);
  color: var(--muted);
  font-size: 14px;
}
.req-stepper span { display: grid; gap: 1px; min-width: 0; font-weight: 700; }
.req-stepper small { overflow: hidden; color: var(--muted); font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.req-stepper small:empty { display: none; }
.req-stepper li.current button { border-color: var(--amber); color: var(--ink); box-shadow: 0 0 0 3px rgba(245, 166, 35, .18); }
.req-stepper li.current b { background: var(--amber); color: #1b1300; }
.req-stepper li.done b { background: #22a06b; color: #fff; }
.req-stepper li.done button { color: var(--ink); }

.req-step-title { margin: 0; font-size: 20px; }
.req-nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.req-nav .primary { min-width: 220px; }
.req-step[data-step="3"] { display: grid; gap: 12px; }
.req-step[data-step="3"] .req-nav { justify-content: flex-start; }

@media (max-width: 640px) {
  .req-stepper { gap: 6px; }
  .req-stepper button { flex-direction: column; gap: 4px; min-height: 64px; padding: 8px 4px; text-align: center; }
  .req-stepper span { justify-items: center; font-size: 12.5px; }
  .req-stepper small { display: none; }
  .req-nav .primary { flex: 1; min-width: 0; }
}

/* ---------- v67: меньше на экране — свёрнутые блоки, «⋯ Ещё», подвкладки ---------- */
.fold-head { align-items: center; }
.fold-title { display: grid; gap: 6px; min-width: 0; }
.fold-title h2 { margin: 0; }
.fold-title .shift-summary { margin: 0; }
.fold-sum { color: var(--muted); font-size: 13px; font-weight: 600; }
button.fold-btn {
  flex: none;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  box-shadow: none;
}
button.fold-btn:hover { background: var(--accent-soft); }
[data-fold].folded { padding-top: 14px; padding-bottom: 14px; }
[data-fold] [data-fold-body] { display: grid; gap: 12px; margin-top: 12px; }
[data-fold] [data-fold-body][hidden] { display: none; }
.fleet-list-panel .fleet-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fleet-list-panel .fleet-tools { justify-content: flex-start; }
.shift-history-btn { justify-self: start; }

/* реестр: плитки — это фильтры; дубли и «все» — чипами */
#regFilters [data-filter="active"],
#regFilters [data-filter="hang"],
#regFilters [data-filter="burn"],
#regFilters [data-filter="done"] { display: none; }
.tile.selected { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(245, 166, 35, .2); }

.more-menu { position: relative; }
.more-menu > summary {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}
.more-menu > summary::-webkit-details-marker { display: none; }
.more-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: grid;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 16px 34px rgba(11, 31, 51, .16);
}
.more-pop button {
  justify-content: flex-start;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 600;
  box-shadow: none;
}
.more-pop button:hover { background: var(--accent-soft); }

/* подвкладки */
[data-panes] [data-pane]:not(.pane-on) { display: none !important; }
.sub-nav { margin-bottom: 2px; }
.sub-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--amber); color: #1b1300; font-size: 12px; font-weight: 800; }
.sub-count:empty { display: none; }
.sub-nav button[hidden] { display: none; }

@media (max-width: 640px) {
  .fold-head { flex-direction: row !important; align-items: flex-start !important; text-align: left !important; }
  .fold-head .cta { padding: 0 12px; }
  .reg-more { margin-left: auto; }
  .sub-nav { overflow-x: auto; flex-wrap: nowrap; }
  .sub-nav button { flex: none; }
}
.fold-head { justify-content: flex-start !important; flex-wrap: wrap; gap: 10px 12px; }
.fold-head .fold-title { flex: 1 1 260px; }
@media (max-width: 640px) {
  .fold-head .fold-title { flex: 1 1 0; }
  .batches-panel .fold-head .fold-title { flex-basis: 100%; }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 6px !important; }
  .tile { padding: 8px 8px 9px; border-radius: 10px; }
  .tile strong { font-size: 22px; }
  .tile span { font-size: 11px; line-height: 1.2; }
}
.clamp-hint { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.clamp-hint::before { content: "ⓘ "; color: var(--accent); font-weight: 700; }
.clamp-hint.open { display: block; -webkit-line-clamp: unset; }

/* ---------- v68: таблицы по дням + компактные карточки на телефоне ---------- */
.reg-table tr.grp-row td { padding: 0; background: var(--soft); border-top: 1px solid var(--line); }
.reg-table tr.grp-row:first-child td { border-top: 0; }
button.grp-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 800;
  box-shadow: none;
}
button.grp-btn::before { content: "›"; display: inline-block; width: 12px; color: var(--muted); font-size: 18px; line-height: 1; transition: transform .15s; }
.grp-row.open button.grp-btn::before { transform: rotate(90deg); }
.grp-meta { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 600; }
.reg-table tr[hidden] { display: none !important; }

@media (max-width: 640px) {
  .reg-table tr.grp-row { margin: 14px 0 6px; padding: 0; border: 0; background: transparent; }
  .reg-table tr.grp-row:first-child { margin-top: 0; }
  .reg-table tr.grp-row td,
  .reg-table tr.grp-row td:nth-child(n) { display: block; padding: 0; border: 0; background: transparent; }
  .reg-table tr.grp-row td::before { display: none; }
  button.grp-btn { min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }

  /* доверка — компактная карточка: № и статус, водитель, контрагент и даты мелко */
  #regBody tr.reg-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    column-gap: 10px;
    row-gap: 2px;
    margin-bottom: 6px;
    padding: 9px 12px;
  }
  #regBody tr.reg-row td,
  #regBody tr.reg-row td:nth-child(n) { display: block; padding: 0; border: 0; grid-template-columns: none; }
  #regBody tr.reg-row td::before { display: none; }
  #regBody tr.reg-row td:nth-child(1) { grid-row: 1; grid-column: 1; font-size: 16px; }
  #regBody tr.reg-row td:nth-child(6) { grid-row: 1; grid-column: 2 / 4; justify-self: end; }
  #regBody tr.reg-row td:nth-child(3) { grid-row: 2; grid-column: 1 / -1; }
  #regBody tr.reg-row td:nth-child(3) small { display: inline; margin-left: 6px; }
  #regBody tr.reg-row td:nth-child(3) > div { display: inline; }
  #regBody tr.reg-row td:nth-child(2),
  #regBody tr.reg-row td:nth-child(4),
  #regBody tr.reg-row td:nth-child(5) { grid-row: 3; color: var(--muted); font-size: 12.5px; }
  #regBody tr.reg-row td:nth-child(2) { grid-column: 1; }
  #regBody tr.reg-row td:nth-child(4) { grid-column: 2; }
  #regBody tr.reg-row td:nth-child(5) { grid-column: 3; }
  #regBody tr.reg-row td:nth-child(4)::before { display: inline; content: "прогр. "; font-size: 12.5px; font-weight: 400; }
  #regBody tr.reg-row td:nth-child(5)::before { display: inline; content: "до "; font-size: 12.5px; font-weight: 400; }
  #regBody tr.reg-row td:nth-child(7) { grid-row: 4; grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
  #regBody tr.reg-row td:nth-child(7):empty { display: none; }

  /* рейс — компактная карточка: маршрут и масса, водитель · ТТН · доверка, заказчик и сумма */
  #logBody tr.reg-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
    row-gap: 2px;
    margin-bottom: 6px;
    padding: 9px 12px;
  }
  #logBody tr.reg-row td,
  #logBody tr.reg-row td:nth-child(n) { display: block; padding: 0; border: 0; grid-template-columns: none; }
  #logBody tr.reg-row td::before { display: none; }
  #logBody tr.reg-row td:nth-child(1) { display: none; }
  #logBody tr.reg-row td:nth-child(2) { grid-row: 1; grid-column: 1; font-weight: 700; }
  #logBody tr.reg-row td:nth-child(6) { grid-row: 1; grid-column: 2; font-weight: 800; }
  #logBody tr.reg-row td:nth-child(6)::after { content: " т"; font-weight: 600; }
  #logBody tr.reg-row td:nth-child(8) { grid-row: 2; grid-column: 1; font-size: 13px; color: var(--muted); }
  #logBody tr.reg-row td:nth-child(5) { grid-row: 2; grid-column: 2; font-size: 13px; color: var(--muted); text-align: right; }
  #logBody tr.reg-row td:nth-child(5)::before { display: inline; content: "№ "; font-size: 13px; font-weight: 400; }
  #logBody tr.reg-row td:nth-child(3) { grid-row: 3; grid-column: 1; font-size: 12.5px; }
  #logBody tr.reg-row td:nth-child(3) small { display: none; }
  #logBody tr.reg-row td:nth-child(3) .badge { font-size: 11.5px; padding: 1px 8px 1px 6px; }
  #logBody tr.reg-row td:nth-child(4) { grid-row: 3; grid-column: 2; font-size: 12.5px; color: var(--muted); text-align: right; }
  #logBody tr.reg-row td:nth-child(4)::before { display: inline; content: "ТТН "; font-size: 12.5px; font-weight: 400; }
  #logBody tr.reg-row td:nth-child(7) { display: none; }
  #logBody tr.reg-row td:nth-child(9) { display: none; }
}

/* ---------- today: сводка на главной страницe ---------- */
.today {
  padding: 16px;
  overflow-y: auto;
}

.today h2 {
  margin: 0 0 20px;
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
}

.today-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.card {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.card-status-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.status-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.status-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

@media (max-width: 640px) {
  .today {
    padding: 12px;
  }

  .today h2 {
    font-size: 20px;
    margin-bottom: 16px;
  }

  .today-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .card {
    padding: 12px;
    border-radius: 10px;
  }

  .card-value {
    font-size: 24px;
  }

  .card-status-inner {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-top: 2px;
  }

  .status-label {
    font-size: 11px;
  }

  .status-value {
    font-size: 16px;
  }
}

/* ---------- version update indicator ---------- */
@keyframes pulse-version {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.7), 1px solid var(--accent-line); }
  50% { box-shadow: 0 0 0 6px rgba(245, 166, 35, 0); }
}

.version-pill.version-update {
  animation: pulse-version 2s infinite;
}

.version-pill.version-update::before {
  content: "●";
  position: absolute;
  right: -3px;
  top: -3px;
  font-size: 10px;
  color: #f5a623;
}
