:root {
  --black: #101010;
  --white: #ffffff;
  --orange: #f47b20;
  --orange-dark: #c85c09;
  --ink: #1d1d1f;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f5f6f8;
  --panel: #ffffff;
  --success: #14804a;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--soft);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--white);
  color: var(--ink);
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
  background: radial-gradient(circle at top left, #2b2b2b, var(--black) 46%);
}

.login-panel {
  display: grid;
  gap: 14px;
  width: min(100%, 430px);
  padding: 24px;
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
}

.login-panel h1 {
  font-size: 34px;
}

.login-panel p,
.login-panel label {
  color: var(--muted);
  font-size: 13px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--orange);
  color: var(--black);
  font-weight: 900;
}

.brand-mark.large {
  width: 58px;
  height: 58px;
  font-size: 20px;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: 260px;
  background: var(--black);
  color: var(--white);
  padding: 18px 14px;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  pointer-events: auto;
}

.sidebar-overlay { display: none; position: fixed; inset: 0; border: 0; background: rgba(0, 0, 0, .45); z-index: 39; }
body.sidebar-open { overflow: hidden; }
body.sidebar-open .sidebar-overlay { display: block; }
body.sidebar-open .sidebar { z-index: 42; }
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row input { width: auto; }
.segmented { display: flex; gap: 4px; margin-bottom: 12px; }
.segmented button { flex: 1; }
.segmented button.active { background: var(--black); color: var(--white); }
.notification-center { position: fixed; top: 64px; right: 12px; z-index: 45; width: min(420px, calc(100vw - 24px)); max-height: 70vh; overflow: auto; background: var(--white); border: 1px solid var(--line); padding: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.22); }
.password-field { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; gap: 6px; }
.password-field .password-toggle { min-width: 44px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 5000; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.58); isolation: isolate; }
.app-modal { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--white); border-radius: 8px; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.32); }
.modal-fields { display: grid; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.form-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-message { margin-top: 10px; color: var(--danger); font-weight: 700; }
.evidence-image { display: block; width: 100%; max-height: 60vh; object-fit: contain; margin: 12px 0; background: #111; }
.notification-unread { border-left: 4px solid var(--orange); }
.toast[data-type="success"] { background: var(--success); }
.toast[data-type="warning"] { background: #8a5a00; }
.toast[data-type="error"] { background: var(--danger); }
.map-panel,
.leaflet-container { position: relative; z-index: 1; }
.leaflet-pane,
.leaflet-top,
.leaflet-bottom,
.leaflet-popup { z-index: 2 !important; }
.modal-backdrop .app-modal { position: relative; z-index: 5001; }

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-brand span {
  display: block;
  color: #c8c8c8;
  font-size: 12px;
}

.side-nav {
  display: grid;
  gap: 6px;
  margin-top: 16px;
}

.side-nav button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 12px;
  background: transparent;
  color: #e7e7e7;
  text-align: left;
}

.side-nav button.active,
.side-nav button:hover {
  background: var(--orange);
  color: var(--black);
}

.side-nav .download-nav {
  margin-top: 10px;
  background: var(--orange);
  color: var(--black);
}

.finance-tabs {
  position: sticky;
  top: 74px;
  z-index: 8;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  overflow-x: auto;
}

.finance-tabs button {
  min-width: max-content;
  padding: 0 14px;
}

.system-tabs {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.table-wrap,
.data-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  table-layout: auto;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: var(--black);
  color: var(--white);
  font-size: 13px;
  white-space: nowrap;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table td:last-child {
  width: auto;
}

.data-table td,
.data-table th {
  overflow-wrap: anywhere;
}

.data-table button,
.data-table .small {
  min-height: 36px;
  white-space: nowrap;
}

.table-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 8px;
  width: min(720px, calc(100vw - 64px));
  max-width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
  color: var(--ink);
}

.table-detail-row td {
  padding: 0;
  background: #fff;
}

.table-detail-row .table-detail-grid {
  width: 100%;
  max-width: none;
  border: 0;
  border-radius: 0;
  padding: 14px;
}

.table-detail-grid-wide {
  grid-template-columns: repeat(3, minmax(150px, 1fr));
}

.table-detail-grid div {
  display: grid;
  gap: 2px;
}

.table-detail-grid .wide {
  grid-column: 1 / -1;
}

.table-detail-grid span {
  color: var(--muted);
  font-size: 12px;
}

.table-detail-grid strong {
  overflow-wrap: anywhere;
}

.blocking-loader {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  background: rgba(16, 16, 16, 0.58);
}

.blocking-loader-box {
  display: grid;
  justify-items: center;
  gap: 14px;
  width: min(360px, calc(100vw - 32px));
  padding: 24px;
  border-radius: 8px;
  background: var(--white);
  text-align: center;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid #eeeeee;
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.cp-editor {
  display: grid;
  gap: 10px;
}

.cp-field-list {
  display: grid;
  gap: 8px;
}

.cp-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
}

.nested-doc-list {
  display: grid;
  gap: 8px;
}

.nested-doc-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(100px, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.needs-data-row td {
  background: #fff1f1;
}

.needs-data-row td:first-child {
  border-left: 5px solid var(--danger);
}

.packages-table td,
.compact-driver-table td {
  vertical-align: top;
}

.packages-table th,
.compact-driver-table th {
  min-width: 96px;
}

.packages-table th:first-child,
.compact-driver-table th:first-child {
  min-width: 118px;
}

.packages-table th:nth-child(2),
.packages-table td:nth-child(2) {
  min-width: 116px;
}

.packages-table td:first-child strong {
  display: inline-block;
  min-width: 92px;
}

.packages-table td:nth-child(8),
.packages-table td:nth-child(9),
.compact-driver-table td:nth-child(4),
.compact-driver-table td:nth-child(5),
.compact-driver-table td:nth-child(6),
.compact-driver-table td:nth-child(7) {
  white-space: nowrap;
}

.finance-tab-panel {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.select-row-main {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 10px;
  align-items: center;
  min-width: 0;
}

.select-row-main small {
  grid-column: 2;
}

.main-shell {
  margin-left: 260px;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  font-size: 22px;
}

.badge {
  display: inline-block;
  margin-top: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--orange);
  color: var(--black);
  font-size: 12px;
  font-weight: 800;
}

.session-box {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.install-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(244, 123, 32, 0.5);
  border-radius: 8px;
  background: var(--orange);
  color: var(--black);
  font-weight: 900;
}

.install-btn svg {
  width: 18px;
  height: 18px;
}

main {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 18px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel,
.form-panel,
.item,
.metric,
.detail,
.log-item,
.data-card,
.user-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(16, 16, 16, 0.04);
}

.panel,
.form-panel,
.item,
.metric,
.detail,
.log-item {
  padding: 14px;
}

.primary,
.secondary,
.danger,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
}

.primary {
  background: var(--orange);
  color: var(--black);
}

.secondary,
.icon-btn {
  background: var(--black);
  color: var(--white);
}

.danger {
  background: var(--danger);
  color: var(--white);
}

.icon-btn {
  width: 44px;
  min-width: 44px;
  padding: 0;
}

.small {
  min-height: 38px;
}

.full {
  width: 100%;
}

.mobile-only {
  display: none;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metrics-top {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 14px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.disabled-row {
  opacity: .62;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.metric[data-status="bad"] { border-color: rgba(180, 35, 24, .3); background: #fff4f2; }
.metric[data-status="warn"] { border-color: rgba(244, 123, 32, .35); background: #fff7ed; }
.metric[data-status="ok"] { border-color: rgba(20, 128, 74, .25); background: #effaf3; }

.compact-events {
  padding: 0;
  overflow: hidden;
}

.compact-events summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  font-weight: 800;
}

.compact-events:not([open]) {
  background: #fff;
}

.compact-head,
.compact-log {
  margin: 0 16px 14px;
}
.alert-action { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }

.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.driver-welcome {
  display: grid;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.driver-welcome h2 {
  font-size: 28px;
}

.driver-welcome p {
  color: var(--muted);
}

.driver-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.driver-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.driver-actions button {
  min-height: 64px;
  justify-content: flex-start;
  padding: 0 18px;
  font-size: 16px;
}

.finance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.map-tools {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.map-tools button {
  min-height: 46px;
}

.map-panel {
  min-height: 560px;
  height: min(68vh, 680px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8eef2;
}

.map-side {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  overflow-x: hidden;
  max-height: none;
}

.tf-marker {
  background: transparent;
  border: 0;
}

.tf-marker span {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.tf-marker .route-order {
  display: grid;
  width: 28px;
  height: 28px;
  color: var(--white);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.route-stop {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 38px 38px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.route-stop strong,
.route-stop small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.route-stop small {
  grid-column: 2 / 3;
  color: var(--muted);
}

.route-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--orange);
  color: var(--black);
  font-weight: 900;
}

.bar-list,
.timeline {
  display: grid;
  gap: 9px;
}

.legend-row {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.legend-row span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px #fff;
}

.legend-row small {
  font-weight: 900;
}

.bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 34px;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.bar-row div {
  height: 8px;
  border-radius: 999px;
  background: #eee;
  overflow: hidden;
}

.bar-row i {
  display: block;
  height: 100%;
  background: var(--orange);
}

.chart-bars {
  display: flex;
  align-items: end;
  gap: 10px;
  min-height: 160px;
}

.chart-col {
  position: relative;
  display: grid;
  align-content: start;
  justify-items: center;
  min-width: 42px;
  border-radius: 8px 8px 0 0;
  background: var(--orange);
  color: var(--black);
  font-size: 12px;
  font-weight: 800;
}

.chart-col small {
  position: absolute;
  bottom: -20px;
  color: var(--muted);
}

.timeline div {
  display: grid;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.timeline span,
.empty {
  color: var(--muted);
  font-size: 12px;
}

.scanner {
  width: 100%;
  min-height: 330px;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
}

.scanner.compact {
  display: none;
  min-height: 260px;
  margin: 12px 0;
}

.scan-counter {
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--black);
  color: var(--white);
  font-weight: 800;
}

.scan-feedback {
  margin: 12px 0;
  padding: 16px;
  border-radius: 8px;
  background: #f0f0f0;
  font-weight: 900;
  text-align: center;
}

.scan-feedback.ok {
  background: #dff6e9;
  color: var(--success);
}

.scan-feedback.bad {
  background: #ffe4e0;
  color: var(--danger);
}

.manual-row {
  display: grid;
  grid-template-columns: 1fr 54px;
  gap: 8px;
  margin: 12px 0;
}

.log {
  display: grid;
  gap: 8px;
}

.log-item {
  border-left: 5px solid var(--orange);
}

.filters,
.wide-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.report-filters {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stacked-form {
  grid-template-columns: 1fr;
}

.finance-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #fff1dc;
  color: var(--orange-dark);
}

.helper-text {
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 700;
}

.form-panel label,
.filters label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  color: var(--ink) !important;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.list,
.cards-list,
.user-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.compact-list {
  max-height: 300px;
  overflow-y: auto;
  overflow-x: hidden;
}

.select-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.select-row input {
  min-height: 18px;
}

.item {
  display: grid;
  gap: 10px;
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.delivery-info {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.delivery-info div {
  display: grid;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}

.delivery-info .wide {
  grid-column: 1 / -1;
}

.delivery-info span {
  color: var(--muted);
  font-size: 12px;
}

.delivery-info strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.item-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.no-delivery-detail {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  background: #fff4f2;
  color: var(--ink);
}

.no-delivery-detail span {
  color: var(--muted);
  font-size: 13px;
}

.photo-actions {
  display: grid;
  grid-template-columns: 120px 1fr 1fr;
  gap: 8px;
  align-items: stretch;
}

.photo-thumb {
  display: block;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--white);
}

.photo-thumb img {
  display: block;
  width: 100%;
  height: 86px;
  object-fit: cover;
}

.bad-soft {
  background: #fff4f2;
  color: var(--danger);
}

.danger-zone {
  border-color: rgba(180, 35, 24, 0.35);
  background: #fffafa;
}

.danger-zone p {
  color: var(--danger);
  font-weight: 700;
  margin-bottom: 12px;
}

.state {
  padding: 4px 8px;
  border-radius: 6px;
  background: #f0f0f0;
  font-size: 12px;
  font-weight: 800;
}

.state.ok {
  background: #dff6e9;
  color: var(--success);
}

.state.warn {
  background: #fff1dc;
  color: var(--orange-dark);
}

.state.bad {
  background: #ffe4e0;
  color: var(--danger);
}

.file-box {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.cross-result {
  margin-top: 14px;
}

.cross-card {
  padding: 24px;
  border-radius: 8px;
  text-align: center;
}

.cross-card h2 {
  margin: 12px 0;
  font-size: 36px;
}

.cross-card.ok {
  background: #dff6e9;
  color: var(--success);
}

.cross-card.bad {
  background: #ffe4e0;
  color: var(--danger);
}

.data-card {
  display: grid;
  gap: 4px;
  width: 100%;
  min-width: 0;
  padding: 12px;
  text-align: left;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.data-card span {
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
}

.user-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
}

.user-main {
  display: grid;
  gap: 2px;
  min-height: 40px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.user-main span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.toast {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 7000;
  display: none;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--black);
  color: var(--white);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
  font-weight: 800;
}

.rate-hint {
  border: 0;
  background: transparent;
  padding: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toast.show {
  display: block;
}

.location-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .5);
}

.location-drawer {
  width: min(960px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 28px 70px rgba(0, 0, 0, .35);
}

.location-drawer header,
.location-drawer footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.location-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.location-map {
  min-height: 360px;
  height: 46vh;
}

@media (max-width: 980px) {
  .mobile-only {
    display: inline-flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: none;
    width: min(86vw, 320px);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .main-shell {
    margin-left: 0;
  }

  .metrics-top,
  .metrics,
  .ops-grid,
  .map-tools,
  .map-layout,
  .driver-metrics,
  .driver-actions,
  .finance-grid,
  .filters,
  .report-filters,
  .wide-form,
  .user-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 12px;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .section-actions {
    display: grid;
    grid-template-columns: 1fr 44px;
  }

  main {
    padding: 12px;
  }

  .scanner {
    min-height: 280px;
  }

  .item-actions {
    grid-template-columns: 1fr;
  }

  .delivery-info {
    grid-template-columns: 1fr;
  }

  .photo-actions {
    grid-template-columns: 1fr;
  }

  .map-panel {
    min-height: 360px;
    height: 60vh;
  }

  .map-side {
    max-height: none;
  }

  .compact-list {
    max-height: 45vh;
  }

  .photo-thumb img {
    height: 180px;
  }

  .modal-backdrop {
    align-items: stretch;
    justify-items: stretch;
    padding: 0;
  }

  .app-modal {
    width: 100%;
    max-height: 100dvh;
    min-height: 100dvh;
    border-radius: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    padding: 14px;
  }

  #appModalForm {
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
  }

  .modal-fields {
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 16px;
  }

  .modal-actions {
    position: sticky;
    bottom: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding-top: 10px;
    background: var(--white);
  }

  .form-actions { grid-template-columns: 1fr; }

  .data-table {
    min-width: 720px;
  }

  .packages-table {
    min-width: 920px;
  }

  .table-detail-grid,
  .table-detail-grid-wide {
    grid-template-columns: 1fr;
    width: min(420px, calc(100vw - 48px));
  }

  .location-drawer-backdrop {
    align-items: stretch;
    justify-items: stretch;
    background: var(--white);
    overflow: hidden;
  }

  .location-drawer {
    width: 100%;
    max-height: 100dvh;
    min-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    grid-template-rows: auto auto auto auto auto auto auto;
    align-content: start;
    overflow-y: auto;
    padding: 14px 14px 0;
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .location-fields {
    grid-template-columns: 1fr;
  }

  .location-drawer header {
    position: sticky;
    top: 0;
    z-index: 4;
    padding-bottom: 8px;
    background: var(--white);
  }

  .location-map {
    min-height: 320px;
    height: 42vh;
    margin-bottom: 10px;
  }

  #locationUsePointBtn {
    width: 100%;
    margin: 0 0 10px;
  }

  .location-drawer footer {
    position: sticky;
    bottom: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 10px 0 max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--white);
  }

  .route-stop {
    grid-template-columns: 34px minmax(0, 1fr) 42px 42px;
  }
}
/* UX operativo: paradas seleccionadas legibles en mobile */
.route-stop-card {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.75rem;
  padding: 0.9rem !important;
}

.route-stop-card > strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.route-stop-card > small {
  grid-column: 2;
  display: block;
  min-width: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.route-stop-card > button,
.route-stop-card > .detail {
  grid-column: 2;
  width: 100%;
  min-height: 2.75rem;
  white-space: normal;
}

.route-stop-card .route-number {
  grid-row: span 2;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #f47b20;
  color: #111;
  font-weight: 900;
}

.route-stop-body {
  min-width: 0;
}

.route-stop-body strong,
.route-stop-body span,
.route-stop-body small {
  display: block;
  overflow-wrap: anywhere;
}

.route-stop-actions {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.route-stop-actions .small,
.route-stop-actions .icon-btn {
  min-height: 2.75rem;
  width: 100%;
  white-space: normal;
}

.route-stop > .route-stop-body {
  grid-column: 2;
}

.route-stop > .route-stop-actions {
  grid-column: 1 / -1;
}
