:root {
  --dispatch-motion: 160ms;
  --dispatch-soft: #edf5f2;
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --line: #d8ded9;
  --text: #172121;
  --muted: #687574;
  --primary: #116466;
  --primary-dark: #0c4849;
  --accent: #d9a441;
  --danger: #b23b3b;
  --ok: #2f7d57;
  --radius: 8px;
  --shadow: 0 12px 30px rgba(23, 33, 33, 0.08);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

/* Daily dispatch: consistent status controls and a readable delivery hierarchy. */
.dispatch-statuses {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 3px 2px 12px;
  margin-bottom: 8px;
  scrollbar-width: thin;
  scroll-padding-inline: 2px;
}
.dispatch-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.dispatch-status[aria-pressed="true"] {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}
.dispatch-status-count {
  min-width: 24px;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--dispatch-soft);
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.dispatch-status[aria-pressed="true"] .dispatch-status-count {
  background: #ffffff26;
  color: #fff;
}
.dispatch-list-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  margin-bottom: 12px;
}
.dispatch-list-heading h3 { margin: 0; font-size: 16px; }
#todayResultCount { margin-left: 6px; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.dispatch-list-heading .link-button { min-height: 44px; }
.dispatch-empty {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 36px 20px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.dispatch-empty > svg { width: 36px; height: 36px; fill: none; stroke: var(--primary); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.dispatch-empty h4 { margin: 0; font-size: 18px; }
.dispatch-empty p { max-width: 360px; margin: 0 0 4px; color: var(--muted); line-height: 1.6; }
.dispatch-empty button { min-height: 48px; }
.order-card.dispatch-card { border-left: 3px solid var(--line); }
.dispatch-card[data-order-status="unviewed"] { border-left-color: var(--accent); }
.dispatch-card[data-order-status="transit"] { border-left-color: var(--primary); }
.dispatch-card[data-order-status="done"] { border-left-color: var(--ok); }
.dispatch-card .dispatch-vehicle { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.order-card.dispatch-card .dispatch-destination { display: grid; gap: 6px; margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); font-weight: 400; font-size: 14px; overflow-wrap: anywhere; }
.dispatch-caption { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.dispatch-destination > strong { font-size: 17px; line-height: 1.35; }
.dispatch-card .dispatch-cargo { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px; margin-top: 4px; background: var(--dispatch-soft); border-radius: 10px; }
.dispatch-cargo > span { min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
.dispatch-cargo > strong { flex-shrink: 0; font-size: 22px; font-variant-numeric: tabular-nums; }
.dispatch-cargo > strong > span { color: var(--muted); font-size: 14px; font-weight: 500; }
.dispatch-details { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 44px; padding: 8px 0; border: 0; background: transparent; color: var(--primary-dark); text-align: left; font-weight: 600; cursor: pointer; }
:is(button, a, input, select, textarea):focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
@media (max-width: 900px) {
  #todayView .toolbar { grid-template-columns: minmax(0, 1fr); }
  #todayView #statusFilter { display: none; }
  #todayView .dispatch-card .card-line { flex-wrap: wrap; gap: 10px; }
  #todayView .dispatch-card .card-line > strong { flex: 1 1 130px; overflow-wrap: anywhere; }
  #todayView .dispatch-card .card-line .status-select,
  #todayView .dispatch-card .card-line .status-pill { max-width: 100%; min-height: 44px; font-size: 13px; }
}
@media (prefers-reduced-motion: no-preference) {
  .dispatch-status { transition: background-color var(--dispatch-motion), color var(--dispatch-motion), border-color var(--dispatch-motion); }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #172121;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

.login-card .brand {
  margin-bottom: 4px;
}

.login-card .brand h1 {
  color: var(--text);
}

.login-card .brand p {
  color: var(--muted);
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-card input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: #fff;
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.login-help {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  color: inherit;
}

/* Native date controls have an intrinsic width in iOS Safari. Allow them,
   and the grids that contain them, to shrink within the available space. */
input,
select,
textarea,
label,
.content,
.view,
.form-panel,
.waybill-editor-panel,
.waybill-editor,
.waybill-section,
.waybill-task-table,
.waybill-sequence-table,
.waybill-downtime-table {
  min-width: 0;
}

input,
select,
textarea {
  max-width: 100%;
}

input[type="date"]:not(.waybill-native-date),
input[type="time"],
input[type="datetime-local"] {
  -webkit-appearance: none;
  appearance: none;
  min-inline-size: 0;
  max-inline-size: 100%;
  font-variant-numeric: tabular-nums;
  text-align: left;
}

input::-webkit-date-and-time-value {
  min-height: 1.4em;
  text-align: left;
}

input::-webkit-datetime-edit {
  min-width: 0;
  padding: 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  width: 100%;
  min-width: 0;
}

.sidebar {
  background: #172121;
  color: #f7fbf8;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 82px;
  height: 64px;
  flex: 0 0 82px;
  object-fit: contain;
  border-radius: 6px;
}

.mobile-tabbar,
.mobile-more-backdrop {
  display: none;
}

.login-card .brand-logo {
  width: 88px;
  height: 68px;
  flex-basis: 88px;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
}

.brand p,
.role-panel p {
  color: #b9c7c4;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.nav-item {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius);
  background: transparent;
  color: #e9f0ed;
  text-align: left;
  padding: 0 12px;
}

.nav-item.active,
.nav-item:hover {
  background: #263536;
  border-color: rgba(217, 164, 65, 0.7);
}

.role-panel {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.role-panel label {
  color: #d7e2df;
  font-size: 13px;
}

.role-panel select {
  width: 100%;
  min-width: 0;
  border: 1px solid #4a5b5b;
  border-radius: var(--radius);
  background: #243232;
  color: #fff;
  min-height: 42px;
  padding: 0 34px 0 10px;
  text-overflow: ellipsis;
}

.role-panel select:disabled {
  opacity: 1;
  color: #d7e2df;
}

.logout-button {
  min-height: 38px;
  border: 1px solid #4a5b5b;
  border-radius: var(--radius);
  background: transparent;
  color: #f7fbf8;
  font-weight: 700;
}

.logout-button:hover {
  border-color: var(--accent);
}

.content {
  padding: 24px;
  min-width: 0;
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
}

.topbar h2 {
  font-size: 30px;
  line-height: 1.15;
}

.topbar-actions,
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.primary-button,
.ghost-button,
.mini-form button {
  min-height: 42px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

.primary-button {
  background: var(--primary);
  color: white;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.ghost-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric,
.directory-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar input,
.toolbar select,
.form-grid input,
.form-grid select,
.form-grid textarea,
.mini-form input,
.mini-form select,
.mini-form textarea,
.dir-edit-form input,
.dir-edit-form select,
.dir-edit-form textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  min-height: 42px;
  padding: 0 11px;
  width: 100%;
}

.toolbar input {
  max-width: 380px;
}

.toolbar select,
#calendarDate {
  max-width: 220px;
}

.calendar-weekday {
  align-self: center;
  color: var(--text);
  font-size: 14px;
  text-transform: capitalize;
}

.map-attribution {
  display: block;
  margin-top: 18px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.map-attribution a {
  color: inherit;
}

.orders-table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow);
}

.orders-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: #eef5f2;
}

.openable-row,
.openable-card {
  cursor: pointer;
}

.status-pill,
.status-select {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f8faf8;
  min-height: 34px;
  padding: 0 10px;
  color: var(--text);
}

.status-pill,
.order-status-summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}

.status-unviewed {
  color: #76520b;
  background: #fff5d9;
  border-color: #ead18a;
}

.status-viewed {
  color: #315d77;
  background: #e8f2f8;
  border-color: #b9d5e5;
}

.status-transit {
  color: #0e5e60;
  background: #e4f4f3;
  border-color: #acd8d8;
}

.status-done {
  color: #236243;
  background: #e6f4ec;
  border-color: #b7dfc8;
}

.status-canceled {
  color: #8c2c2c;
  background: #f9e7e7;
  border-color: #e5b5b5;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
  font-weight: 700;
}

.danger-link {
  color: var(--danger);
}

.action-spacer {
  flex: 1 1 auto;
  min-width: 18px;
  height: 1px;
}

.soft-button,
.soft-danger-button,
.danger-button {
  min-height: 34px;
  border-radius: var(--radius);
  padding: 0 10px;
  font-weight: 700;
}

.soft-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.soft-danger-button {
  border: 1px solid #efc8c8;
  background: #fff8f8;
  color: var(--danger);
}

.danger-button {
  border: 1px solid var(--danger);
  background: var(--danger);
  color: white;
}

.mobile-list {
  display: none;
}

.order-card,
.driver-day,
.calendar-day,
.archive-item,
.dir-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.order-card {
  display: grid;
  gap: 10px;
}

.card-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.card-line span,
.muted {
  color: var(--muted);
}

.comment-preview {
  margin-top: 6px;
  padding-left: 9px;
  border-left: 3px solid var(--accent);
  color: #4f5d5b;
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.segmented button {
  min-height: 40px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--primary);
  color: white;
}

.calendar-list,
.archive-list {
  display: grid;
  gap: 12px;
}

.driver-day,
.calendar-day {
  display: grid;
  gap: 10px;
  box-shadow: var(--shadow);
}

.driver-day h3,
.calendar-day h3 {
  margin: 0;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.calendar-day-empty {
  box-shadow: none;
  background: #fbfcfb;
}

.trip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  min-width: 0;
}

.trip div {
  min-width: 0;
  overflow-wrap: anywhere;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
  max-width: 920px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.form-panel {
  position: relative;
  max-width: 920px;
}

.form-panel .form-grid {
  max-width: none;
}

.close-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.close-button:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 33, 33, 0.45);
}

.details-modal {
  position: relative;
  width: min(680px, 100%);
  max-height: min(820px, calc(100vh - 36px));
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(23, 33, 33, 0.28);
  padding: 22px;
}

.details-head {
  display: grid;
  gap: 8px;
  padding-right: 42px;
  margin-bottom: 18px;
}

.details-head h3 {
  margin: 0;
  font-size: 24px;
  overflow-wrap: anywhere;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.details-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfb;
}

.details-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

.details-grid dd {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.details-grid a {
  color: var(--primary);
}

.order-address-link {
  color: var(--primary);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.order-address-link:hover {
  text-decoration-color: currentColor;
}

.order-address-link.route-loading {
  cursor: progress;
  opacity: 0.65;
}

.order-address-text {
  display: none;
  color: var(--muted);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.details-wide {
  grid-column: 1 / -1;
}

.details-comment {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #ead38b;
  border-radius: var(--radius);
  background: #fffaf0;
}

.details-comment h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #6a5317;
}

.details-comment p {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.details-modal .row-actions {
  margin-top: 18px;
}

.confirm-modal {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(23, 33, 33, 0.28);
  padding: 20px;
}

.confirm-modal h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.confirm-modal p {
  margin: 0;
  color: var(--muted);
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-grid textarea {
  padding-top: 10px;
  resize: vertical;
}

.details-status {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.details-status label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.details-status .status-select,
.details-status .status-pill {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  font-size: 16px;
  font-weight: 750;
}

.mini-form textarea,
.dir-edit-form textarea {
  padding-top: 10px;
  resize: vertical;
}

.autocomplete {
  position: relative;
  display: block;
}

.suggestions {
  max-height: 280px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: #739f92 transparent;
  scrollbar-gutter: stable;
  touch-action: pan-y;
  grid-auto-rows: max-content;
  position: fixed;
  margin: 0;
  z-index: 1200;
  font-size: 13px;
  font-weight: 700;
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(23, 33, 33, 0.12);
}

.suggestion-item {
  overflow-wrap: anywhere;
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 46px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.suggestion-item:hover,
.suggestion-item:focus,
.suggestion-item[aria-selected="true"] {
  background: #eef5f2;
  outline: none;
}

.suggestion-item span {
  color: var(--muted);
  font-size: 12px;
}

.wide {
  grid-column: 1 / -1;
}

.directory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
}

.directory-block {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.directory-block h3 {
  margin: 0;
}

.mini-form {
  display: grid;
  gap: 8px;
}

.driver-user-fields {
  display: grid;
  gap: 8px;
}

.fleet-editor,
.fleet-vehicles,
.fleet-trailer-list {
  display: grid;
  gap: 8px;
}

.fleet-editor {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(248, 250, 249, 0.72);
}

.fleet-vehicle-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface, #fff);
}

.fleet-vehicle-head,
.fleet-trailer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
}

.fleet-trailer-title {
  color: var(--muted);
  font-weight: 700;
}

.fleet-trailer-list:empty::before {
  content: "У этой машины прицепов нет";
  color: var(--muted);
  font-size: 0.82rem;
}

.driver-user-fields[hidden] {
  display: none;
}

.password-field {
  position: relative;
  display: block;
  width: 100%;
}

.password-field input {
  padding-right: 48px;
}

.password-visibility-button,
.mini-form .password-visibility-button,
.dir-edit-form .password-visibility-button {
  width: 42px;
  min-width: 42px;
  min-height: 38px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.password-field .password-visibility-button {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
}

.password-visibility-button:hover {
  background: rgba(17, 100, 102, 0.08);
  color: var(--primary-dark);
}

.password-field .password-visibility-button:hover {
  transform: translateY(-50%);
}

.password-display .password-visibility-button:hover {
  transform: none;
}

.password-visibility-button svg {
  width: 20px;
  height: 20px;
  margin: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-visibility-button .eye-open,
.password-visibility-button.is-visible .eye-closed {
  display: none;
}

.password-visibility-button.is-visible .eye-open {
  display: block;
}

.password-display {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
}

.password-display .password-visibility-button {
  min-height: 28px;
  width: 32px;
  min-width: 32px;
}

.mini-form button {
  background: #263536;
  color: white;
}

.dir-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.dir-item small {
  color: var(--muted);
}

.waybill-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.waybill-toolbar label {
  display: grid;
  gap: 6px;
  min-width: 220px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.waybill-toolbar input,
.waybill-toolbar select,
.waybill-editor input,
.waybill-editor select,
.waybill-editor textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.waybill-toolbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.waybill-date-field {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 190px;
}

.waybill-date-field #waybillDateDisplay {
  width: 100%;
  padding-right: 46px;
  font-variant-numeric: tabular-nums;
}

.waybill-date-field #waybillDateDisplay:not(:disabled),
.waybill-date-field button:not(:disabled) {
  cursor: pointer;
}

.waybill-date-field button {
  position: absolute;
  right: 4px;
  z-index: 1;
  width: 38px;
  min-width: 38px;
  min-height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--primary);
}

.waybill-date-field button:hover {
  background: #edf5f2;
}

.waybill-date-field button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.waybill-native-date {
  position: absolute;
  width: 1px !important;
  height: 1px;
  min-height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0;
  pointer-events: none;
}

.waybill-summary {
  display: grid;
  gap: 10px;
}

.waybill-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.waybill-card:hover {
  border-color: var(--primary);
}

.waybill-card-head,
.waybill-card-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.waybill-card h3,
.waybill-card p {
  margin: 0;
}

.waybill-card-details {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.waybill-card-details > span {
  display: grid;
  gap: 4px;
  min-width: 180px;
}

.waybill-card-details small {
  color: var(--muted);
}

.waybill-state {
  padding: 5px 9px;
  border-radius: 999px;
  background: #edf1ef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.waybill-state.saved {
  background: #e2f2e9;
  color: var(--ok);
}

.waybill-card .row-actions {
  justify-content: flex-end;
}

.waybill-editor-panel {
  display: grid;
  gap: 14px;
}

.waybill-editor-actions {
  position: sticky;
  bottom: 10px;
  z-index: 4;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.waybill-editor {
  display: grid;
  gap: 14px;
}

.waybill-section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.waybill-section h3 {
  margin: 0 0 14px;
  font-size: 17px;
}

.waybill-grid {
  display: grid;
  gap: 10px;
}

.waybill-grid.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.waybill-grid.three-columns {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.waybill-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.waybill-grid .wide {
  grid-column: 1 / -1;
}

.waybill-trailers {
  display: grid;
  gap: 8px;
}

.waybill-trailers > div {
  display: grid;
  grid-template-columns: 90px minmax(150px, 1.3fr) repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

.waybill-task-table {
  display: grid;
  gap: 6px;
  overflow-x: auto;
}

.waybill-task-table > div {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) repeat(4, 110px);
  gap: 6px;
  min-width: 760px;
}

.waybill-task-row label {
  display: block;
}

.waybill-task-row label > span {
  display: none;
}

.waybill-task-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.form-4c-task-table > #waybillTaskRows,
.waybill-sequence-table > #waybillSequenceRows,
.waybill-downtime-table > #waybillDowntimeRows {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.form-4c-task-table .waybill-task-head,
.form-4c-task-table .waybill-task-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) 110px minmax(170px, 1fr) minmax(170px, 1fr) minmax(130px, 0.8fr) 78px 105px 95px;
  gap: 6px;
  min-width: 1180px;
}

.waybill-sequence-table,
.waybill-downtime-table {
  display: grid;
  gap: 6px;
  overflow-x: auto;
}

.waybill-sequence-head,
.waybill-sequence-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) 72px 125px 105px 105px repeat(2, 105px) 105px repeat(3, 90px) 150px 100px;
  gap: 6px;
  min-width: 1550px;
}

.waybill-downtime-head,
.waybill-downtime-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 90px 190px 190px minmax(180px, 0.8fr);
  gap: 6px;
  min-width: 950px;
}

.waybill-sequence-head,
.waybill-downtime-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.waybill-sequence-row label,
.waybill-downtime-row label {
  display: block;
}

.waybill-sequence-row label > span,
.waybill-downtime-row label > span {
  display: none;
}

.waybill-section h4 {
  margin: 18px 0 10px;
}

#waybillPrint {
  display: none;
}

.print-page {
  font-family: "Times New Roman", serif;
  color: #000;
}

.print-title {
  margin-bottom: 5mm;
  text-align: center;
}

.print-title h1,
.print-title h2,
.print-title p {
  margin: 0 0 1.5mm;
}

.print-title h1 {
  font-size: 18pt;
}

.print-title h2 {
  font-size: 13pt;
}

.print-line {
  min-height: 8mm;
  padding: 2mm;
  border-bottom: 1px solid #000;
}

.print-table {
  width: 100%;
  margin: 3mm 0;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 9pt;
}

.print-table th,
.print-table td {
  height: 8mm;
  padding: 1mm 1.5mm;
  border: 1px solid #000;
  vertical-align: middle;
}

.print-table th {
  font-weight: 400;
  text-align: center;
}

.print-details th {
  width: 20%;
}

.print-section-title {
  margin: 4mm 0 1mm;
  font-size: 10pt;
  letter-spacing: 0;
  text-align: center;
}

.print-form-codes {
  display: grid;
  justify-content: end;
  width: 70mm;
  margin: 0 0 5mm auto;
  border: 1px solid #000;
}

.print-form-codes span {
  padding: 1.5mm 2mm;
  border-bottom: 1px solid #000;
}

.print-form-codes span:last-child {
  border-bottom: 0;
}

.print-notes {
  min-height: 28mm;
  margin-top: 5mm;
  padding: 2mm;
  border: 1px solid #000;
}

.print-notes p {
  margin: 2mm 0 0;
}

.print-signature-lines {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8mm;
  margin-top: 9mm;
  font-size: 9pt;
}

.form-4c-page {
  font-family: "Times New Roman", serif;
  font-size: 7pt;
  line-height: 1.08;
}

.form-4c-page .print-table {
  margin: 0.8mm 0;
  font-size: 6.2pt;
}

.form-4c-page .print-table th,
.form-4c-page .print-table td {
  height: 4.2mm;
  padding: 0.35mm 0.45mm;
  overflow: hidden;
  line-height: 1.02;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
  text-overflow: clip;
}

.form-4c-page .print-table th {
  font-weight: 400;
  text-align: center;
  vertical-align: middle;
}

.form-4c-header {
  display: grid;
  grid-template-columns: 42mm 1fr 78mm;
  gap: 3mm;
  min-height: 25mm;
  align-items: start;
}

.form-4c-stamp {
  padding-top: 4mm;
  text-align: center;
}

.form-4c-title {
  text-align: center;
}

.form-4c-title h1,
.form-4c-title h2,
.form-4c-title p {
  margin: 0 0 1.2mm;
}

.form-4c-title h1 {
  font-size: 13pt;
}

.form-4c-title h2 {
  font-size: 11pt;
}

.form-4c-approved {
  font-size: 6.7pt;
  text-align: left;
}

.form-4c-codes {
  width: 58mm;
  margin-left: auto !important;
}

.form-4c-organization,
.form-4c-accompany {
  min-height: 6mm;
  padding: 1mm 0;
  border-bottom: 0.3mm solid #000;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.form-4c-upper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2mm;
  align-items: start;
}

.form-4c-vehicle-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 31mm;
  gap: 1.5mm;
  align-items: end;
}

.form-4c-vehicle-lines,
.form-4c-trailer-lines {
  display: grid;
  gap: 0;
}

.form-4c-vehicle-lines > div,
.form-4c-trailer-lines > div {
  display: flex;
  align-items: end;
  gap: 1.2mm;
  min-height: 5.1mm;
  white-space: nowrap;
}

.form-4c-vehicle-lines span,
.form-4c-trailer-lines span {
  flex: 0 0 auto;
}

.form-4c-vehicle-lines b,
.form-4c-trailer-lines b {
  flex: 1 1 auto;
  min-width: 10mm;
  min-height: 4mm;
  padding: 0 1mm 0.4mm;
  overflow: hidden;
  border-bottom: 0.25mm solid #000;
  font-weight: 400;
  text-align: center;
}

.form-4c-trailer-lines small {
  display: block;
  font-size: 4.8pt;
  text-align: center;
}

.form-4c-small-codes {
  margin-bottom: 0 !important;
}

.form-4c-small-codes th:first-child {
  width: 72%;
  border-left: 0;
  text-align: right;
}

.form-4c-small-codes td {
  width: 28%;
  text-align: center;
}

.form-4c-details th {
  width: 23%;
  text-align: left;
}

.form-4c-trailers th:first-child,
.form-4c-trailers td:first-child {
  width: 10%;
  text-align: center;
}

.form-4c-page .print-section-title {
  margin: 1.2mm 0 0.5mm;
  font-size: 7pt;
}

.form-4c-lettered {
  max-width: 100%;
  overflow: hidden;
  letter-spacing: 0.75mm !important;
  line-height: 1.15;
  white-space: nowrap;
}

.form-4c-work,
.form-4c-fuel,
.form-4c-tasks,
.form-4c-sequence,
.form-4c-downtime,
.form-4c-results {
  table-layout: fixed;
}

.form-4c-work th {
  font-size: 5.4pt;
}

.form-4c-fuel th {
  font-size: 4.7pt;
}

.form-4c-tasks th {
  font-size: 5.4pt;
}

.form-4c-tasks tbody tr:not(.form-4c-total) td {
  height: 5.2mm;
}

.form-4c-total td:first-child {
  font-weight: 700;
  text-align: right;
}

.form-4c-front-signatures {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr 0.9fr;
  gap: 5mm;
  min-height: 38mm;
  margin-top: 1.5mm;
}

.form-4c-front-signatures p {
  min-height: 5mm;
  margin: 0 0 1mm;
}

.form-4c-owner-lines {
  border-bottom: 0.25mm solid #000;
}

.form-4c-back-caption {
  margin-bottom: 1mm;
  text-align: right;
}

.form-4c-sequence {
  font-size: 5.4pt !important;
}

.form-4c-sequence th {
  font-size: 4.8pt;
}

.form-4c-sequence tbody td {
  height: 5mm;
}

.form-4c-tax,
.form-4c-bottom {
  display: flex;
  justify-content: space-between;
  gap: 8mm;
  padding: 1.5mm 0;
}

.form-4c-back-middle {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 3mm;
}

.form-4c-back-middle .print-notes {
  min-height: 28mm;
  margin: 0;
}

.form-4c-downtime {
  font-size: 5.8pt !important;
}

.form-4c-results {
  font-size: 4.7pt !important;
}

.form-4c-results th,
.form-4c-results td {
  padding-left: 0.2mm !important;
  padding-right: 0.2mm !important;
  text-align: center;
}

.form-4c-page .print-signature-lines {
  gap: 5mm;
  margin-top: 4mm;
  font-size: 6.5pt;
}

.dir-actions,
.dir-edit-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.dir-actions .link-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.dir-edit-form {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
}

.address-fields {
  display: grid;
  gap: 8px;
}

.address-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
}

.mini-form .address-add-button,
.dir-edit-form .address-add-button {
  min-height: 40px;
  border: 1px dashed var(--primary);
  background: transparent;
  color: var(--primary-dark);
  font-weight: 700;
}

.mini-form .address-remove-button,
.dir-edit-form .address-remove-button {
  width: 42px;
  min-height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--danger);
  font-size: 22px;
  line-height: 1;
}

.address-add-button:hover,
.address-remove-button:hover {
  border-color: currentColor;
}

.dir-edit-actions {
  justify-content: flex-end;
}

.dir-edit-actions .primary-button,
.dir-edit-actions .ghost-button {
  min-height: 38px;
}

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px;
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.empty-state strong {
  color: var(--text);
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .waybill-editor-panel:not([hidden]) {
    padding-bottom: 170px;
  }

  .waybill-editor-actions {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(84px + env(safe-area-inset-bottom));
    z-index: 44;
    padding: 8px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 34px rgba(20, 46, 44, 0.22);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .app-shell {
    display: block;
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
    min-height: 0;
    height: auto;
    padding: 14px 12px 16px;
    gap: 12px;
  }

  .brand {
    gap: 10px;
    padding-right: 92px;
  }

  .brand-logo {
    width: 66px;
    height: 52px;
    flex-basis: 66px;
  }

  .brand h1 {
    font-size: 20px;
    line-height: 1.15;
  }

  .brand p {
    display: none;
  }

  .nav {
    display: flex;
    gap: 8px;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    min-width: 0;
    min-height: 38px;
    text-align: center;
    white-space: nowrap;
    padding: 0 14px;
  }

  .role-panel {
    margin-top: 0;
    gap: 7px;
  }

  .role-panel p {
    margin: 0;
  }

  .logout-button {
    position: absolute;
    top: 18px;
    right: 12px;
  }

  .content {
    padding: 16px 12px 24px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions button {
    flex: 1;
    min-width: 0;
  }

  .metrics,
  .directory-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .sidebar {
    padding: 12px 10px 14px;
  }

  .brand {
    padding-right: 86px;
  }

  .brand-logo {
    width: 58px;
    height: 46px;
    flex-basis: 58px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .nav-item {
    min-height: 36px;
    padding: 0 12px;
    font-size: 14px;
  }

  .role-panel label,
  .role-panel p {
    font-size: 12px;
  }

  .role-panel select {
    min-height: 40px;
    font-size: 15px;
  }

  .logout-button {
    width: fit-content;
    min-height: 34px;
    padding: 0 12px;
    color: #b9c7c4;
    font-size: 13px;
    top: 14px;
    right: 10px;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .topbar-actions {
    flex-direction: column;
  }

  .topbar-actions button,
  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .metrics,
  .directory-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .orders-table-wrap {
    display: none;
  }

  .mobile-list {
    display: grid;
    gap: 10px;
  }

  .toolbar input,
  .toolbar select,
  #calendarDate {
    max-width: none;
  }

  .toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .segmented {
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
  }

  .trip {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .trip .row-actions,
  .order-card .row-actions,
  .archive-item .row-actions {
    margin-top: 6px;
  }

  .status-pill,
  .status-select {
    width: fit-content;
    max-width: 100%;
  }

  .modal-backdrop {
    align-items: center;
    padding: 10px;
  }

  .details-modal {
    width: 100%;
    max-width: calc(100vw - 20px);
    height: calc(100svh - 20px);
    max-height: calc(100svh - 20px);
    align-self: center;
    border-radius: var(--radius);
    padding: 18px;
  }

  .details-head h3 {
    font-size: 24px;
  }

  .details-head {
    gap: 8px;
    margin-bottom: 14px;
  }

  .details-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    border: 0;
    border-radius: 0;
    overflow: visible;
  }

  .details-grid div {
    display: block;
    min-height: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
  }

  .details-grid div:last-child {
    border-bottom: 1px solid var(--line);
  }

  .details-grid dt {
    margin: 0 0 5px;
    font-size: 12px;
  }

  .details-grid dd {
    font-size: 16px;
    text-align: left;
  }

  .details-wide {
    grid-column: 1 / -1;
  }

  .details-comment {
    margin-top: 10px;
    padding: 12px;
  }

  .details-comment h4 {
    margin-bottom: 5px;
    font-size: 13px;
  }

  .details-comment p {
    font-size: 16px;
  }

  .details-modal .row-actions {
    margin-top: 14px;
  }
}

@media (max-width: 900px) {
  .waybill-toolbar {
    align-items: stretch;
    flex-direction: column;
    min-width: 0;
  }

  .waybill-toolbar label {
    min-width: 0;
  }

  .waybill-toolbar-actions {
    width: 100%;
    min-width: 0;
    margin-left: 0;
  }

  .waybill-toolbar-actions button {
    flex: 1;
    width: 0;
    min-width: 0;
    min-height: 44px;
  }

  .waybill-card-head {
    align-items: flex-start;
  }

  .waybill-card-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .waybill-card-details > span {
    min-width: 0;
  }

  .waybill-card-details > span:first-child {
    grid-column: 1 / -1;
  }

  .waybill-card .row-actions,
  .waybill-editor-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .waybill-card .row-actions button,
  .waybill-editor-actions button {
    width: 100%;
    min-width: 0;
  }

  .waybill-toolbar input,
  .waybill-toolbar select {
    max-width: 100%;
  }

  .waybill-grid.two-columns,
  .waybill-grid.three-columns {
    grid-template-columns: 1fr;
  }

  .waybill-trailers > div {
    grid-template-columns: 1fr;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
  }

  .waybill-section {
    padding: 14px 12px;
  }

  .waybill-section h3 {
    font-size: 16px;
  }

  .waybill-editor input,
  .waybill-editor select,
  .waybill-editor textarea,
  .waybill-toolbar input,
  .waybill-toolbar select {
    min-height: 44px;
    font-size: 16px;
  }

  .waybill-task-table {
    overflow: visible;
  }

  .waybill-task-head {
    display: none !important;
  }

  .waybill-task-table > .waybill-task-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
    gap: 9px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfcfb;
  }

  .waybill-task-row .task-destination {
    grid-column: 1 / -1;
  }

  .waybill-task-row label {
    display: grid;
    gap: 5px;
    min-width: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  .waybill-task-row label > span {
    display: block;
  }

  .form-4c-task-table > #waybillTaskRows,
  .waybill-sequence-table > #waybillSequenceRows,
  .waybill-downtime-table > #waybillDowntimeRows {
    min-width: 0;
  }

  .form-4c-task-table .waybill-task-row,
  .waybill-sequence-row,
  .waybill-downtime-row {
    grid-template-columns: 1fr 1fr;
    min-width: 0;
    gap: 9px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfcfb;
  }

  .form-4c-task-table .waybill-task-head,
  .waybill-sequence-head,
  .waybill-downtime-head {
    display: none;
  }

  .form-4c-task-table .task-destination,
  .waybill-sequence-row label:first-child,
  .waybill-downtime-row label:first-child {
    grid-column: 1 / -1;
  }

  .waybill-sequence-row label,
  .waybill-downtime-row label {
    display: grid;
    gap: 5px;
    min-width: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  .waybill-sequence-row label > span,
  .waybill-downtime-row label > span {
    display: block;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 0;
  }

  html,
  body {
    width: 297mm;
    height: auto;
    margin: 0;
    padding: 0;
    background: #fff;
  }

  body > *:not(.app-shell),
  .content > *:not(#waybillView),
  .sidebar,
  .topbar,
  .view:not(#waybillView),
  #waybillView > *:not(#waybillPrint) {
    display: none !important;
  }

  .app-shell,
  .content,
  #waybillView,
  #waybillPrint {
    display: block !important;
    width: 297mm;
    min-height: 0;
    padding: 0;
    margin: 0;
    background: #fff;
  }

  .print-page {
    display: block;
    width: 297mm;
    height: 209mm;
    min-height: 0;
    max-height: 209mm;
    padding: 4mm 5mm;
    overflow: hidden;
    break-inside: avoid-page;
    page-break-inside: avoid;
    break-after: auto;
    page-break-after: auto;
  }

  .print-page:not(:last-child) {
    break-after: page;
    page-break-after: always;
  }

  .print-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}

@media (max-width: 390px) {
  .content {
    padding-left: 10px;
    padding-right: 10px;
  }

  .metric,
  .directory-block,
  .order-card,
  .driver-day,
  .calendar-day,
  .archive-item {
    padding: 12px;
  }

  .topbar h2 {
    font-size: 22px;
  }
}

/* Native-feeling mobile experience for iOS and Android */
@media (max-width: 900px) {
  :root {
    --radius: 16px;
    --shadow: 0 10px 32px rgba(20, 46, 44, 0.09);
  }

  html {
    background: #f2f6f4;
    scroll-behavior: smooth;
  }

  body {
    min-height: 100dvh;
    background: #f2f6f4;
    overscroll-behavior-y: contain;
    -webkit-tap-highlight-color: transparent;
  }

  body.mobile-sheet-open {
    overflow: hidden;
  }

  [data-open-order] .order-address-link {
    display: none;
  }

  [data-open-order] .order-address-text {
    display: inline;
  }

  button,
  select,
  input,
  textarea {
    touch-action: manipulation;
  }

  button:active {
    transform: scale(0.98);
  }

  input:focus,
  select:focus,
  textarea:focus {
    border-color: #298587 !important;
    outline: 3px solid rgba(17, 100, 102, 0.12);
  }

  .login-screen {
    min-height: 100dvh;
    place-items: center;
    overflow-y: auto;
    padding: max(24px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
    background:
      radial-gradient(circle at 15% 12%, rgba(217, 164, 65, 0.24), transparent 32%),
      linear-gradient(155deg, #0c2929 0%, #132020 52%, #081515 100%);
  }

  .login-card {
    width: min(440px, calc(100vw - 28px));
    min-width: 0;
    gap: 18px;
    padding: 28px 22px 24px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 28px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  }

  .login-card .brand {
    align-items: center;
    gap: 10px;
    padding: 0;
    margin: 0 0 6px;
  }

  .login-card .brand > div {
    min-width: 0;
  }

  .login-card .brand-logo {
    width: 90px;
    height: 72px;
    flex-basis: 90px;
  }

  .login-card .brand h1 {
    font-size: clamp(23px, 6.4vw, 29px);
    letter-spacing: -0.035em;
  }

  .login-card .brand p {
    display: block;
    margin-top: 5px;
    font-size: 13px;
  }

  .login-card label {
    gap: 8px;
    color: #536362;
    font-size: 14px;
  }

  .login-card input {
    min-height: 56px;
    padding: 0 16px;
    border-radius: 15px;
    background: #f8faf9;
    font-size: 17px;
  }

  .login-card .primary-button {
    min-height: 56px;
    margin-top: 2px;
    border-radius: 16px;
    font-size: 18px;
    box-shadow: 0 10px 24px rgba(17, 100, 102, 0.23);
  }

  .app-shell {
    display: block;
    min-height: 100dvh;
    background: #f2f6f4;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: calc(66px + env(safe-area-inset-top));
    padding: max(8px, env(safe-area-inset-top)) 16px 8px;
    justify-content: center;
    background: rgba(16, 32, 32, 0.96);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 24px rgba(11, 30, 29, 0.15);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .sidebar .brand {
    gap: 10px;
    padding: 0;
  }

  .sidebar .brand-logo {
    width: 54px;
    height: 44px;
    flex-basis: 54px;
  }

  .sidebar .brand h1 {
    font-size: 20px;
    letter-spacing: -0.025em;
  }

  .sidebar .nav,
  .sidebar .role-panel {
    display: none;
  }

  .content {
    padding: 18px 14px calc(104px + env(safe-area-inset-bottom));
  }

  .topbar {
    display: block;
    margin: 0 2px 18px;
  }

  .topbar .eyebrow {
    margin-bottom: 4px;
    color: #73817f;
    font-size: 13px;
    font-weight: 650;
    text-transform: none;
  }

  .topbar h2 {
    font-size: clamp(27px, 8vw, 34px);
    line-height: 1.06;
    letter-spacing: -0.04em;
  }

  .topbar-actions {
    display: none;
  }

  .metrics {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
  }

  .metric {
    min-height: 104px;
    padding: 16px;
    border: 0;
    border-radius: 20px;
  }

  .metric strong {
    margin-top: 4px;
    font-size: 32px;
    letter-spacing: -0.04em;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 14px;
  }

  .toolbar input,
  .toolbar select,
  #calendarDate {
    width: 100%;
    max-width: none;
    min-height: 52px;
    padding: 0 15px;
    border: 1px solid #dce4df;
    border-radius: 16px;
    background: #fff;
    font-size: 16px;
    box-shadow: 0 4px 16px rgba(20, 46, 44, 0.04);
  }

  .mobile-list,
  .calendar-list,
  .archive-list {
    gap: 12px;
  }

  .order-card,
  .driver-day,
  .calendar-day,
  .archive-item,
  .directory-block {
    border: 1px solid rgba(207, 218, 212, 0.85);
    border-radius: 22px;
    box-shadow: var(--shadow);
  }

  .order-card {
    gap: 9px;
    padding: 18px;
    overflow: hidden;
  }

  .order-card .card-line {
    align-items: flex-start;
  }

  .order-card .card-line strong {
    min-width: 0;
    font-size: 20px;
    line-height: 1.2;
    letter-spacing: -0.02em;
  }

  .order-card .card-line .status-select,
  .order-card .card-line .status-pill {
    width: auto;
    max-width: 48%;
    flex: 0 0 auto;
  }

  .order-card .card-line > span {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #edf5f2;
    color: #49615d;
    font-size: 12px;
    font-weight: 750;
  }

  .order-card .card-line > .status-unviewed {
    color: #76520b;
    background: #fff5d9;
    border: 1px solid #ead18a;
  }

  .order-card .card-line > .status-viewed {
    color: #315d77;
    background: #e8f2f8;
    border: 1px solid #b9d5e5;
  }

  .order-card .card-line > .status-transit {
    color: #0e5e60;
    background: #e4f4f3;
    border: 1px solid #acd8d8;
  }

  .order-card .card-line > .status-done {
    color: #236243;
    background: #e6f4ec;
    border: 1px solid #b7dfc8;
  }

  .order-card .card-line > .status-canceled {
    color: #8c2c2c;
    background: #f9e7e7;
    border: 1px solid #e5b5b5;
  }

  .order-card > div:nth-child(3) {
    margin-top: 4px;
    font-size: 17px;
    font-weight: 700;
  }

  .order-card .status-select,
  .order-card .status-pill {
    min-height: 40px;
    padding: 0 13px;
    font-size: 15px;
    font-weight: 750;
  }

  .order-card .row-actions,
  .archive-item .row-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-top: 8px;
    padding-top: 14px;
    border-top: 1px solid #e7ece9;
  }

  .order-card .action-spacer,
  .archive-item .action-spacer {
    display: none;
  }

  .order-card .link-button,
  .order-card .soft-danger-button,
  .archive-item .link-button,
  .archive-item .soft-danger-button {
    min-height: 44px;
    padding: 0 13px;
    border-radius: 13px;
    font-size: 15px;
  }

  .order-card .link-button {
    background: #edf7f5;
    text-align: center;
  }

  .trip {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px 0 0;
  }

  .driver-day,
  .calendar-day {
    padding: 17px;
  }

  .driver-day h3,
  .calendar-day h3 {
    font-size: 18px;
    line-height: 1.25;
  }

  .segmented {
    width: 100%;
    padding: 4px;
    gap: 4px;
    border: 0;
    border-radius: 16px;
    background: #e5ece8;
  }

  .segmented button {
    min-height: 42px;
    border: 0;
    border-radius: 12px;
    font-weight: 700;
  }

  .segmented button.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 3px 12px rgba(20, 46, 44, 0.1);
  }

  .form-panel,
  .form-grid {
    max-width: none;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 18px;
    border: 1px solid rgba(207, 218, 212, 0.85);
    border-radius: 24px;
    box-shadow: var(--shadow);
  }

  .form-grid label {
    gap: 7px;
    font-size: 13px;
  }

  .form-grid input,
  .form-grid select,
  .form-grid textarea,
  .mini-form input,
  .mini-form select,
  .mini-form textarea,
  .dir-edit-form input,
  .dir-edit-form select,
  .dir-edit-form textarea {
    min-height: 52px;
    padding: 0 14px;
    border-radius: 14px;
    font-size: 16px;
  }

  .form-grid textarea,
  .mini-form textarea,
  .dir-edit-form textarea {
    min-height: 112px;
    padding-top: 13px;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .form-actions button,
  .waybill-toolbar-actions button,
  .waybill-editor-actions button {
    min-height: 50px;
    border-radius: 15px;
  }

  .directory-grid {
    gap: 14px;
  }

  .directory-block {
    padding: 17px;
  }

  .dir-item {
    border-radius: 16px;
  }

  .empty-state {
    padding: 30px 20px;
    border-radius: 22px;
    text-align: center;
  }

  .details-modal {
    width: 100%;
    max-width: none;
    height: auto;
    max-height: 92dvh;
    align-self: end;
    padding: 24px 18px calc(20px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 28px 28px 0 0;
    box-shadow: 0 -20px 55px rgba(14, 30, 29, 0.2);
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
    background: rgba(10, 24, 23, 0.58);
    backdrop-filter: blur(3px);
  }

  .details-grid div {
    border-radius: 15px;
    background: #f8faf9;
  }

  .confirm-modal {
    width: calc(100% - 28px);
    margin-bottom: max(14px, env(safe-area-inset-bottom));
    border-radius: 24px;
  }

  .mobile-tabbar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 45;
    min-height: 68px;
    display: flex;
    align-items: stretch;
    padding: 5px 6px;
    border: 1px solid rgba(203, 215, 209, 0.92);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 14px 42px rgba(20, 46, 44, 0.22);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .mobile-tab {
    flex: 1 1 0;
    min-width: 0;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    padding: 5px 2px 3px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: #778481;
    font-size: 10px;
    font-weight: 750;
  }

  .mobile-tab > svg,
  .mobile-create-icon svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-tab svg circle {
    fill: currentColor;
    stroke: none;
  }

  .mobile-tab.active {
    color: var(--primary);
    background: #edf7f5;
  }

  .mobile-tab-create {
    overflow: visible;
  }

  .mobile-tab-create.active {
    background: transparent;
  }

  .mobile-create-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    margin-top: -20px;
    border: 4px solid #f7faf8;
    border-radius: 50%;
    background: linear-gradient(145deg, #168083, #0d5d5f);
    color: #fff;
    box-shadow: 0 8px 20px rgba(17, 100, 102, 0.3);
  }

  .mobile-tab-create > span:last-child {
    margin-top: -1px;
  }

  .mobile-more-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    align-items: end;
    background: rgba(9, 23, 22, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  .mobile-more-sheet {
    max-height: 88dvh;
    overflow: auto;
    padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
    border-radius: 28px 28px 0 0;
    background: #f8faf9;
    box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.22);
    animation: mobile-sheet-in 0.22s ease-out;
  }

  @keyframes mobile-sheet-in {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  .sheet-handle {
    width: 42px;
    height: 5px;
    margin: 0 auto 13px;
    border-radius: 999px;
    background: #c6d0cb;
  }

  .mobile-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
  }

  .mobile-sheet-header h2,
  .mobile-sheet-header p {
    margin: 0;
  }

  .mobile-sheet-header h2 {
    margin-top: 3px;
    font-size: 25px;
    letter-spacing: -0.035em;
  }

  .mobile-sheet-close {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: 0;
    border-radius: 50%;
    background: #e8eeeb;
    color: #53625f;
    font-size: 27px;
    line-height: 1;
  }

  .mobile-user-field {
    display: grid;
    gap: 8px;
    color: #61706e;
    font-size: 13px;
    font-weight: 750;
  }

  .mobile-user-field select {
    width: 100%;
    min-height: 54px;
    padding: 0 14px;
    border: 1px solid #d5dfda;
    border-radius: 15px;
    background: #fff;
    color: var(--text);
    font-size: 16px;
  }

  .mobile-role-hint {
    margin: 8px 2px 16px;
    color: var(--muted);
    font-size: 13px;
  }

  .notification-preference {
    width: 100%;
    min-height: 68px;
    display: grid;
    grid-template-columns: 44px 1fr auto;
    align-items: center;
    gap: 11px;
    margin-bottom: 9px;
    padding: 10px 13px;
    border: 1px solid #dce4df;
    border-radius: 17px;
    background: #fff;
  }

  .notification-copy {
    display: grid;
    gap: 3px;
  }

  .notification-copy strong {
    font-size: 16px;
  }

  .notification-copy small {
    color: var(--muted);
    font-size: 12px;
  }

  .notification-copy small.is-error {
    color: var(--danger);
  }

  .switch {
    position: relative;
    width: 50px;
    height: 30px;
  }

  .switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }

  .switch span {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #cbd5d1;
    transition: background 0.18s ease;
  }

  .switch span::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
    transition: transform 0.18s ease;
  }

  .switch input:checked + span {
    background: var(--primary);
  }

  .switch input:checked + span::after {
    transform: translateX(20px);
  }

  .switch input:disabled + span {
    opacity: 0.55;
  }

  .mobile-more-links {
    display: grid;
    gap: 9px;
  }

  .mobile-more-links button {
    width: 100%;
    min-height: 68px;
    display: grid;
    grid-template-columns: 44px 1fr auto;
    align-items: center;
    gap: 11px;
    padding: 10px 13px;
    border: 1px solid #dce4df;
    border-radius: 17px;
    background: #fff;
    color: var(--text);
    text-align: left;
  }

  .more-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: #e8f4f1;
    color: var(--primary);
    font-size: 21px;
    font-weight: 800;
  }

  .mobile-more-links button > span:nth-child(2) {
    display: grid;
    gap: 3px;
  }

  .mobile-more-links strong {
    font-size: 16px;
  }

  .mobile-more-links small {
    color: var(--muted);
    font-size: 12px;
  }

  .mobile-more-links b {
    color: #8d9996;
    font-size: 28px;
    font-weight: 400;
  }

  .mobile-logout-button {
    width: 100%;
    min-height: 50px;
    margin-top: 15px;
    border: 1px solid #edcccc;
    border-radius: 15px;
    background: #fff7f7;
    color: var(--danger);
    font-weight: 750;
  }

  .waybill-editor-panel {
    scroll-margin-top: calc(78px + env(safe-area-inset-top));
  }

  .waybill-editor {
    gap: 10px;
  }

  .waybill-section {
    overflow: hidden;
    padding: 0 14px 14px;
    border: 1px solid rgba(207, 218, 212, 0.9);
    border-radius: 18px;
    box-shadow: 0 6px 20px rgba(20, 46, 44, 0.06);
  }

  .waybill-section.is-collapsed {
    padding-bottom: 0;
  }

  .waybill-section.is-collapsed > :not(h3) {
    display: none !important;
  }

  .waybill-section h3.waybill-section-toggle {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 12px;
    color: #243433;
    font-size: 16px;
    line-height: 1.25;
    cursor: pointer;
    user-select: none;
  }

  .waybill-section.is-collapsed h3.waybill-section-toggle {
    margin-bottom: 0;
  }

  .waybill-section h3.waybill-section-toggle::after {
    content: "";
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 10px;
    background-color: #edf5f2;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Cpath d='m10 13 5 5 5-5' fill='none' stroke='%23116466' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 0.18s ease;
  }

  .waybill-section.is-collapsed h3.waybill-section-toggle::after {
    transform: rotate(180deg);
  }

  .waybill-grid.two-columns,
  .waybill-grid.three-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .waybill-grid .wide {
    grid-column: 1 / -1;
  }

  .waybill-grid label {
    gap: 5px;
    min-width: 0;
    font-size: 11px;
    line-height: 1.25;
  }

  .waybill-editor input,
  .waybill-editor select {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 0 11px;
    border-radius: 12px;
    font-size: 16px;
  }

  .waybill-editor textarea {
    min-height: 76px;
    padding: 10px 11px;
    border-radius: 12px;
    font-size: 16px;
  }

  .waybill-editor input[readonly] {
    background: #f3f6f4;
    color: #52615f;
  }

  .waybill-trailers {
    gap: 12px;
  }

  .waybill-trailers > div {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    border: 1px solid #e1e8e4;
    border-radius: 14px;
    background: #f8faf9;
  }

  .waybill-trailers > div strong,
  .waybill-trailers > div select {
    grid-column: 1 / -1;
  }
}

@media (max-width: 370px) {
  .mobile-tab {
    font-size: 9px;
  }

  .mobile-tab > svg {
    width: 21px;
    height: 21px;
  }

  .content {
    padding-left: 11px;
    padding-right: 11px;
  }
}

/* Polished desktop experience */
@media (min-width: 901px) {
  :root {
    --radius: 14px;
    --shadow: 0 10px 32px rgba(20, 46, 44, 0.07);
  }

  body {
    background:
      radial-gradient(circle at 84% 3%, rgba(17, 100, 102, 0.06), transparent 28rem),
      #f3f6f4;
  }

  .login-screen {
    min-height: 100dvh;
    padding: 32px;
    background:
      radial-gradient(circle at 18% 18%, rgba(217, 164, 65, 0.2), transparent 30rem),
      linear-gradient(145deg, #0d2a2a 0%, #142323 55%, #081616 100%);
  }

  .login-card {
    width: min(480px, 100%);
    gap: 18px;
    padding: 34px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 26px;
    box-shadow: 0 32px 90px rgba(0, 0, 0, 0.34);
  }

  .login-card .brand {
    gap: 16px;
    margin-bottom: 8px;
  }

  .login-card .brand-logo {
    width: 106px;
    height: 82px;
    flex-basis: 106px;
  }

  .login-card .brand h1 {
    font-size: 29px;
    letter-spacing: -0.035em;
  }

  .login-card .brand p {
    margin-top: 5px;
    font-size: 14px;
  }

  .login-card label {
    gap: 8px;
    font-size: 14px;
  }

  .login-card input {
    min-height: 52px;
    padding: 0 15px;
    border-radius: 13px;
    background: #f9fbfa;
    font-size: 16px;
  }

  .login-card .primary-button {
    min-height: 52px;
    border-radius: 13px;
    font-size: 16px;
    box-shadow: 0 10px 24px rgba(17, 100, 102, 0.22);
  }

  .app-shell {
    grid-template-columns: 268px minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px 20px;
    gap: 30px;
    overflow-y: auto;
    background: linear-gradient(180deg, #142727 0%, #101d1d 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
  }

  .sidebar .brand {
    gap: 10px;
    padding: 0 5px;
  }

  .sidebar .brand-logo {
    width: 68px;
    height: 54px;
    flex-basis: 68px;
  }

  .sidebar .brand h1 {
    font-size: 19px;
    letter-spacing: -0.025em;
  }

  .sidebar .brand p {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.35;
  }

  .nav {
    gap: 7px;
  }

  .nav-item {
    position: relative;
    min-height: 48px;
    padding: 0 15px;
    border-color: transparent;
    border-radius: 12px;
    color: #cbd8d5;
    font-size: 14px;
    font-weight: 650;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
  }

  .nav-item:hover {
    transform: translateX(2px);
  }

  .nav-item.active,
  .nav-item:hover {
    border-color: rgba(75, 159, 155, 0.22);
    background: rgba(66, 131, 129, 0.2);
    color: #fff;
  }

  .nav-item.active::after {
    content: "";
    position: absolute;
    top: 12px;
    bottom: 12px;
    left: 5px;
    width: 3px;
    border-radius: 99px;
    background: #d9a441;
  }

  .role-panel {
    gap: 10px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.035);
  }

  .role-panel select,
  .logout-button {
    min-height: 44px;
    border-radius: 11px;
  }

  .content {
    max-width: 1580px;
    margin: 0 auto;
    padding: 34px clamp(26px, 3vw, 52px) 48px;
  }

  .topbar {
    margin-bottom: 28px;
  }

  .topbar .eyebrow {
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 650;
  }

  .topbar h2 {
    font-size: clamp(34px, 3vw, 42px);
    line-height: 1.05;
    letter-spacing: -0.045em;
  }

  .primary-button,
  .ghost-button,
  .mini-form button {
    min-height: 46px;
    padding: 0 18px;
    border-radius: 12px;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  }

  .primary-button:hover,
  .ghost-button:hover,
  .mini-form button:hover {
    transform: translateY(-1px);
  }

  .primary-button:hover {
    box-shadow: 0 9px 20px rgba(17, 100, 102, 0.2);
  }

  .toolbar {
    gap: 12px;
    margin-bottom: 18px;
    padding: 12px;
    border: 1px solid #dde5e1;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 28px rgba(20, 46, 44, 0.055);
  }

  .toolbar input,
  .toolbar select,
  #calendarDate {
    min-height: 46px;
    border-radius: 12px;
    background: #f8faf9;
  }

  .toolbar input:focus,
  .toolbar select:focus,
  .form-grid input:focus,
  .form-grid select:focus,
  .form-grid textarea:focus,
  .mini-form input:focus,
  .mini-form select:focus,
  .waybill-editor input:focus,
  .waybill-editor textarea:focus {
    border-color: #298587;
    outline: 3px solid rgba(17, 100, 102, 0.1);
  }

  .orders-table-wrap {
    border-color: #dde5e1;
    border-radius: 20px;
    box-shadow: 0 14px 38px rgba(20, 46, 44, 0.07);
  }

  .orders-table thead {
    background: #f6f9f7;
  }

  .orders-table th {
    padding-top: 15px;
    padding-bottom: 15px;
    color: #71807d;
    font-size: 11px;
    letter-spacing: 0.055em;
  }

  .orders-table td {
    padding-top: 17px;
    padding-bottom: 17px;
  }

  .orders-table tbody tr:last-child td {
    border-bottom: 0;
  }

  .orders-table tbody tr:hover {
    background: #f0f7f4;
  }

  .status-select,
  .status-pill {
    min-height: 38px;
    padding: 0 13px;
    font-weight: 700;
  }

  .segmented {
    padding: 4px;
    border-radius: 13px;
    background: #eef3f0;
  }

  .segmented button {
    min-height: 38px;
    padding: 0 15px;
    border: 0;
    border-radius: 9px;
  }

  .form-panel,
  .form-grid {
    max-width: 1100px;
  }

  .form-grid {
    gap: 18px;
    padding: 26px;
    border-color: #dde5e1;
    border-radius: 22px;
  }

  .form-grid label {
    gap: 8px;
    font-size: 14px;
  }

  .form-grid input,
  .form-grid select,
  .form-grid textarea {
    min-height: 48px;
    padding-left: 14px;
    padding-right: 14px;
    border-radius: 12px;
    background: #fbfcfb;
  }

  .form-actions {
    justify-content: flex-end;
    padding-top: 4px;
  }

  .calendar-list {
    gap: 16px;
  }

  .driver-day,
  .calendar-day {
    gap: 13px;
    padding: 20px;
    border-color: #dde5e1;
    border-radius: 18px;
  }

  .waybill-toolbar {
    gap: 16px;
    margin-bottom: 18px;
    padding: 16px 18px;
    border: 1px solid #dde5e1;
    border-radius: 18px;
    box-shadow: var(--shadow);
  }

  .waybill-summary {
    max-width: 980px;
  }

  .waybill-card {
    padding: 22px;
    border-color: #dde5e1;
    border-radius: 20px;
    box-shadow: var(--shadow);
  }

  .waybill-section {
    padding: 22px;
    border-color: #dde5e1;
    border-radius: 20px;
    box-shadow: 0 8px 26px rgba(20, 46, 44, 0.045);
  }

  .directory-grid {
    gap: 18px;
  }

  .directory-block {
    align-content: start;
    padding: 22px;
    border-color: #dde5e1;
    border-radius: 20px;
  }

  .directory-block h3 {
    font-size: 20px;
  }

  .mini-form {
    gap: 10px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e5ebe8;
  }

  .mini-form input,
  .mini-form select,
  .dir-edit-form input,
  .dir-edit-form select,
  .dir-edit-form textarea {
    min-height: 46px;
    border-radius: 11px;
    background: #fbfcfb;
  }

  .dir-item {
    min-height: 54px;
    margin-top: 6px;
    padding: 12px 13px;
    border-color: #e2e9e5;
    border-radius: 13px;
    background: #fbfcfb;
  }

  .details-modal,
  .confirm-modal {
    border-radius: 22px;
  }
}

@media print {
  .mobile-tabbar,
  .mobile-more-backdrop {
    display: none !important;
  }

  html,
  body {
    width: 297mm !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  .app-shell,
  .content,
  #waybillView,
  #waybillPrint {
    display: block !important;
    width: 297mm !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  .print-page {
    display: block !important;
    width: 297mm !important;
    height: 209mm !important;
    min-height: 0 !important;
    max-height: 209mm !important;
    margin: 0 !important;
    padding: 4mm 5mm !important;
    overflow: hidden !important;
    break-inside: avoid-page !important;
    page-break-inside: avoid !important;
    break-after: auto !important;
    page-break-after: auto !important;
  }

  .print-page:not(:last-child) {
    break-after: page !important;
    page-break-after: always !important;
  }
}

/* Shared motion: transform/opacity keep transitions off the layout path. */
@media screen and (prefers-reduced-motion: no-preference) {
  .view.active {
    animation: mobile-view-enter 280ms cubic-bezier(.2,.8,.2,1) both;
  }

  .login-card {
    animation: mobile-view-enter 420ms cubic-bezier(.2,.8,.2,1) both;
  }

  .modal-backdrop:not([hidden]),
  .mobile-more-backdrop:not([hidden]) {
    animation: mobile-backdrop-enter 180ms ease-out both;
  }

  .modal-backdrop:not([hidden]) > .details-modal,
  .modal-backdrop:not([hidden]) > .confirm-modal,
  .mobile-more-backdrop:not([hidden]) > .mobile-more-sheet {
    animation: mobile-panel-enter 320ms cubic-bezier(.16,1,.3,1) both;
  }

  button, .order-card, .mobile-tab > svg, .mobile-create-icon {
    transition: transform 160ms cubic-bezier(.2,.8,.2,1), background-color 160ms ease, box-shadow 160ms ease;
  }

  button:not(:disabled):active { transform: scale(.96); }
  .order-card:active { transform: scale(.985); }
  .mobile-tab.active > svg { transform: translateY(-2px); }
  .mobile-tab-create:active .mobile-create-icon { transform: rotate(90deg); }
}

@keyframes mobile-view-enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes mobile-backdrop-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes mobile-panel-enter {
  from { opacity: 0; transform: translateY(32px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Authentication has its own transition, separate from tab navigation. */
.login-card[aria-busy="true"] .primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.login-card[aria-busy="true"]:not(.login-success) .primary-button::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}
@media screen and (prefers-reduced-motion: no-preference) {
  .login-card[aria-busy="true"] .primary-button::before {
    animation: login-spinner 700ms linear infinite;
  }
  .login-card.login-success {
    pointer-events: none;
    animation: login-departure 360ms cubic-bezier(.4,0,.2,1) both;
  }
  .login-arrival .sidebar {
    animation: login-header-arrival 520ms cubic-bezier(.16,1,.3,1) both;
  }
  .login-arrival .topbar {
    animation: mobile-view-enter 550ms 80ms cubic-bezier(.16,1,.3,1) both;
  }
  .login-arrival .view.active {
    animation: mobile-view-enter 600ms 150ms cubic-bezier(.16,1,.3,1) both;
  }
  .login-arrival .mobile-tabbar {
    animation: login-navigation-arrival 600ms 230ms cubic-bezier(.16,1,.3,1) backwards;
  }
}
@keyframes login-spinner { to { transform: rotate(360deg); } }
@keyframes login-departure {
  0% { opacity: 1; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.025); }
  100% { opacity: 0; transform: translateY(-24px) scale(.96); }
}
@keyframes login-header-arrival {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes login-navigation-arrival {
  from { opacity: 0; translate: 0 32px; }
  to { opacity: 1; translate: 0 0; }
}

/* Keep the form title and close action outside the input area. */
#newOrderView .form-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(18, 60, 57, .06);
}
.order-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(120deg, #edf7f5, #fafcfb);
}
.order-form-eyebrow {
  color: #397a75;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
}
.order-form-header h3 {
  margin: 5px 0 0;
  color: #193b39;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 750;
}
.order-form-header .close-button {
  position: static;
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 12px;
  border: 1px solid #d7e6e2;
  border-radius: 14px;
  background: rgba(255,255,255,.9);
  color: #54716d;
}
.order-form-header .close-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
#newOrderView .form-panel .form-grid {
  padding: 20px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

#orderDetailsModal .details-modal {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
#orderDetailsModal .order-form-header {
  flex: 0 0 auto;
  border-radius: inherit;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.order-form-header > div {
  min-width: 0;
}
.order-form-header h3 {
  overflow-wrap: anywhere;
}
#detailsDate {
  font-size: 12px;
  letter-spacing: .02em;
}
#orderDetailsContent {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: #afc7c0 transparent;
  scrollbar-gutter: stable;
  margin: 4px 6px 8px 0;
  padding: 20px;
}
#orderDetailsContent::-webkit-scrollbar { width: 6px; }
#orderDetailsContent::-webkit-scrollbar-track { background: transparent; }
#orderDetailsContent::-webkit-scrollbar-thumb {
  background: #afc7c0;
  border-radius: 6px;
}
#orderDetailsContent::-webkit-scrollbar-thumb:hover { background: #739f92; }
#orderDetailsContent::-webkit-scrollbar-button { display: none; }
@media (max-width: 900px) {
  #orderDetailsContent {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}

.details-actions {
  display: grid;
  gap: 16px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.details-actions button {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  font-size: 14px;
}
.details-actions .details-edit-button {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  box-shadow: 0 5px 14px rgba(17, 100, 102, .16);
  font-weight: 700;
}
.details-edit-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.details-delete-button {
  border: 0;
  background: transparent;
  color: #96615e;
  font-weight: 500;
}
.details-delete-button:hover { background: #fff5f4; }
.details-delete-confirm {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid #efd3ce;
  border-radius: 18px;
  background: #fff8f6;
}
.details-delete-confirm strong { color: #803a34; }
.details-delete-confirm p {
  margin: 0 0 4px;
  font-size: 13px;
  line-height: 1.5;
  color: #805f5a;
}

/* Shared phone / desktop sign-in scene, drawn as lightweight vector artwork. */
.login-loader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  background: rgba(233, 242, 238, .96);
  backdrop-filter: blur(12px);
}
.login-loader-card {
  width: min(100%, 460px);
  padding: 32px 28px;
  border: 1px solid rgba(255,255,255,.95);
  border-radius: 32px;
  background: #fcfdf9;
  box-shadow: 0 24px 80px #193e3814;
  text-align: center;
  outline: none;
}
.login-loader-brand {
  color: #466c62;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .1em;
}
.login-loader-brand > span { padding: 0 6px; color: #b4c6bc; }
.truck-scene {
  position: relative;
  height: 190px;
  margin: 24px 0 28px;
  overflow: hidden;
  border-radius: 24px;
  background: linear-gradient(#e4f1e8, #f4f6df);
  isolation: isolate;
}
.truck-sun {
  position: absolute;
  width: 56px;
  height: 56px;
  right: 36px;
  top: 20px;
  border-radius: 50%;
  background: #f1d28a;
  box-shadow: 0 0 0 12px #f1d28a25;
}
.truck-hills {
  position: absolute;
  width: 160%;
  height: 100px;
  left: -30%;
  bottom: 26px;
  border-radius: 50% 65% 0 0;
  background: #bcd8bf;
  rotate: -8deg;
}
.truck-hills::after {
  content: "";
  position: absolute;
  width: 80%;
  height: 90px;
  left: 40%;
  top: 15px;
  border-radius: 70% 80% 0 0;
  background: #a3c8b1;
  rotate: 18deg;
}
.truck-road {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 33px;
  background: #78978a;
  border-top: 5px solid #dce7cc;
}
.truck-road::after {
  content: "";
  position: absolute;
  top: 13px;
  left: -60px;
  width: calc(100% + 120px);
  height: 3px;
  background: repeating-linear-gradient(90deg, #eff1d5 0 28px, transparent 28px 60px);
}
.login-truck {
  position: absolute;
  width: 90%;
  max-width: 310px;
  height: auto;
  bottom: 23px;
  left: 50%;
  translate: -50% 0;
}
.truck-wheel-mark { transform-origin: 64px 118px; }
.login-loader-card h2 {
  margin: 0;
  font-size: clamp(21px, 4.9vw, 27px);
  line-height: 1.2;
  color: #193e38;
  letter-spacing: -.035em;
}
.login-loader-card p {
  margin: 12px auto 24px;
  max-width: 280px;
  min-height: 42px;
  color: #718079;
  font-size: 14px;
  line-height: 1.5;
}
.login-loader-track {
  height: 4px;
  width: 130px;
  margin: 0 auto 24px;
  overflow: hidden;
  border-radius: 8px;
  background: #e0eae1;
}
.login-loader-track > span {
  display: block;
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: #24756a;
}
.login-loader-caption {
  font-size: 9px;
  letter-spacing: .12em;
  color: #829589;
}
@media screen and (prefers-reduced-motion: no-preference) {
  .login-loader:not([hidden]) { animation: mobile-backdrop-enter 180ms ease-out both; }
  .login-loader:not([hidden]) .login-loader-card { animation: mobile-panel-enter 350ms cubic-bezier(.16,1,.3,1) both; }
  .login-loader:not([hidden]) .truck-body { animation: truck-bounce 600ms ease-in-out infinite alternate; }
  .login-loader:not([hidden]) .truck-wheel-mark { animation: login-spinner 650ms linear infinite; }
  .login-loader:not([hidden]) .truck-road::after { animation: truck-road-travel 650ms linear infinite; }
  .login-loader:not([hidden]) .login-loader-track > span { animation: truck-loading 1400ms ease-in-out infinite alternate; }
  .login-loader.is-leaving:not([hidden]) { animation: truck-loader-leave 240ms ease-in both; }
}
@keyframes truck-bounce { to { transform: translateY(-1.5px); } }
@keyframes truck-road-travel { to { transform: translateX(-60px); } }
@keyframes truck-loading { from { transform: translateX(-30%); } to { transform: translateX(155%); } }
@keyframes truck-loader-leave { to { opacity: 0; } }
@media (max-width: 380px) {
  .login-loader { padding-left: 14px; padding-right: 14px; }
  .login-loader-card { padding: 26px 18px; }
}

/* Keep native controls consistent across Safari, Chrome and app WebViews. */
@media screen and (max-width: 900px) {
  input:not([type="hidden"]):not(.waybill-native-date),
  select,
  textarea {
    font-size: 16px;
    scroll-margin-block: 100px 190px;
  }

  input[type="date"]:not(.waybill-native-date),
  input[type="time"],
  input[type="datetime-local"] {
    display: block;
    width: 100%;
    height: 52px;
    line-height: normal;
  }

  select:not([multiple]):not([size]) {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m5 8 5 5 5-5' fill='none' stroke='%2352615f' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: 20px 20px;
    background-position: right 12px center;
    background-repeat: no-repeat;
  }

  .segmented {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .segmented button {
    min-width: 0;
    min-height: 44px;
    color: var(--muted);
  }

  .calendar-weekday {
    font-weight: 600;
    text-transform: none;
    line-height: 1.4;
  }

  .trip > div,
  .driver-day h3,
  .calendar-day h3,
  .dir-item,
  .details-grid {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .trip .row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .trip .row-actions button {
    min-height: 44px;
    white-space: normal;
  }

  .waybill-date-field {
    min-width: 0;
  }

  .waybill-date-field button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .waybill-toolbar {
    border: 1px solid var(--line);
    border-radius: 16px;
  }

  .waybill-grid label,
  .waybill-task-row label,
  .waybill-sequence-row label,
  .waybill-downtime-row label {
    font-size: 12px;
    line-height: 1.4;
  }
}

@media screen and (max-width: 480px) {
  .waybill-editor label:has(input[type="date"]),
  .waybill-editor label:has(input[type="time"]),
  .waybill-editor label:has(input[type="datetime-local"]) {
    grid-column: 1 / -1;
  }
}

/* The visible date is independent of the native iOS date-field rendering.
   The transparent native input still receives touch and keyboard interaction. */
#calendarView .calendar-navigation {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.calendar-navigation svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
#calendarView .calendar-navigation button {
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  border-radius: 10px;
}
.calendar-step { display: grid; place-items: center; }
.calendar-date-control {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  min-height: 46px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}
.calendar-date-control:focus-within { outline: 2px solid #116466; outline-offset: 2px; }
#calendarView .calendar-date-control #calendarDate {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
#calendarDate::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  cursor: pointer;
}
@media screen and (min-width: 901px) {
  #calendarView .calendar-navigation { flex: 1; min-width: 350px; }
}
@media screen and (max-width: 900px) {
  #calendarView .calendar-navigation { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  #calendarToday { grid-column: 1 / -1; justify-self: center; }
  #calendarView .toolbar { gap: 8px; }
  #calendarView .calendar-weekday { font-size: 13px; }
  #calendarView .driver-day,
  #calendarView .calendar-day { padding: 12px; border-radius: 14px; box-shadow: none; gap: 8px; }
  #calendarView .driver-day h3,
  #calendarView .calendar-day h3 { margin: 0; font-size: 17px; }
  #calendarView .trip { gap: 6px; padding-top: 10px; font-size: 14px; line-height: 1.4; }
  #calendarView .trip .status-pill { justify-self: start; padding: 4px 9px; font-size: 13px; }
  #calendarView .trip .row-actions { margin: 0; padding-top: 2px; gap: 8px; }
  #calendarView .trip .row-actions button { min-height: 44px; padding: 6px 10px; font-size: 14px; border-radius: 9px; }
  .topbar h2 { font-size: clamp(24px, 6.5vw, 30px); line-height: 1.15; }
}

/* Compact daily orders for dispatchers and administrators in both mobile WebViews. */
@media screen and (max-width: 900px) {
  #todayView .dispatch-card-compact {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 8px;
    padding: 12px;
    border-radius: 14px;
    box-shadow: none;
    align-content: start;
  }

  #todayView .dispatch-card-compact .card-line { display: contents; }
  #todayView .dispatch-card-compact .card-line > strong {
    grid-column: 1;
    grid-row: 1;
    align-self: end;
    font-size: 16px;
    line-height: 1.25;
    letter-spacing: normal;
  }
  #todayView .dispatch-card-compact .dispatch-vehicle {
    grid-column: 1;
    grid-row: 2;
    font-size: 12px;
    line-height: 1.35;
  }
  #todayView .dispatch-card-compact .card-line :is(.status-select, .status-pill) {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: start;
    min-height: 44px;
    max-width: 132px;
    padding-inline: 9px;
    font-size: 12px;
  }
  #todayView .dispatch-card-compact > :is(.dispatch-destination, .dispatch-cargo, .comment-preview, .dispatch-details, .row-actions) {
    grid-column: 1 / -1;
    min-width: 0;
  }
  #todayView .dispatch-card-compact .dispatch-destination {
    gap: 2px;
    margin-top: 4px;
    padding-top: 0;
    border-top: 0;
    font-size: 13px;
    line-height: 1.35;
  }
  #todayView .dispatch-card-compact .dispatch-caption { display: none; }
  #todayView .dispatch-card-compact .dispatch-destination > strong { font-size: 15px; }
  #todayView .dispatch-card-compact .dispatch-cargo {
    gap: 8px;
    padding: 6px 8px;
    margin-top: 2px;
    border-radius: 6px;
  }
  #todayView .dispatch-card-compact .dispatch-cargo > strong { font-size: 18px; }
  #todayView .dispatch-card-compact .dispatch-details {
    min-height: 44px;
    padding-block: 4px;
    font-size: 14px;
  }
  #todayView .dispatch-card-compact .row-actions {
    gap: 6px;
    margin-top: 0;
    padding-top: 6px;
  }
  #todayView .dispatch-card-compact .row-actions button {
    min-height: 44px;
    min-width: 0;
    padding: 6px 10px;
    border-radius: 9px;
    font-size: 13px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #todayView .dispatch-card-compact .card-line .status-select {
    max-width: 180px;
    padding-right: 34px;
    font-size: 16px;
  }
}

@media screen and (max-width: 380px) {
  #todayView .dispatch-card-compact .card-line .status-select {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-self: start;
  }
}

/* Compact visible status with a full-sized native touch target. */
#todayView .order-card .card-line > .card-status-control { padding: 0; background: transparent; border: 0; border-radius: 0; position: relative; display: inline-flex; align-items: center; justify-content: flex-end; flex: 0 0 auto; min-height: 44px; width: max-content; max-width: 100%; }
.card-status-label { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 4px 8px; border: 0; border-radius: 7px; font-size: 12px; font-weight: 600; line-height: 18px; white-space: nowrap; pointer-events: none; }
.card-status-label svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.7; flex: none; }
#todayView .order-card .card-line .card-status-control > .status-select { position: absolute; inset: 0; width: 100%; height: 100%; min-width: 0; max-width: none; min-height: 44px; margin: 0; padding: 0; opacity: 0; font-size: 16px; cursor: pointer; }
.card-status-control:focus-within .card-status-label { outline: 2px solid #116466; outline-offset: 2px; }
@media screen and (max-width: 900px) {
  #todayView .dispatch-card-compact .card-line > .card-status-control { grid-column: 2; grid-row: 1 / span 2; align-self: start; justify-self: end; margin-top: -6px; }
}

.card-line .card-status-label.status-unviewed { color: #76520b; }
.card-line .card-status-label.status-viewed { color: #315d77; }
.card-line .card-status-label.status-transit { color: #0e5e60; }
.card-line .card-status-label.status-done { color: #236243; }
.card-line .card-status-label.status-canceled { color: #983b3b; }

/* Trip completion: shared touch controls for cards, table and details. */
.trip-progress { margin: 12px 0; min-width: 0; text-align: left; }
.trip-progress-label { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--text, #1c2928); font-variant-numeric: tabular-nums; }
.trip-progress progress { display: block; width: 100%; height: 7px; margin: 8px 0 12px; border: 0; border-radius: 8px; overflow: hidden; background: #e2e8e7; accent-color: var(--primary); }
.trip-progress progress::-webkit-progress-bar { background: #e2e8e7; }
.trip-progress progress::-webkit-progress-value { background: var(--primary); }
.trip-progress progress::-moz-progress-bar { background: var(--primary); }
.trip-controls { display: flex; align-items: end; gap: 8px; }
.trip-controls button { min-height: 48px; min-width: 48px; padding: 10px 12px; white-space: nowrap; touch-action: manipulation; }
.trip-controls button:disabled { opacity: .45; cursor: default; }
.trip-count-label { display: grid; gap: 4px; flex: 1; min-width: 64px; font-size: 12px; }
.trip-count-label input { width: 100%; min-width: 0; height: 48px; padding: 8px; font-size: 16px; text-align: center; font-variant-numeric: tabular-nums; }
#todayOrders .trip-progress { min-width: 240px; }
.trip .trip-progress { margin: 4px 0 8px; }
