:root {
  --bg: #f5f5f5;
  --ink: #444a4e;
  --muted: #69757d;
  --line: #dddddd;
  --panel: #ffffff;
  --accent: #59ba20;
  --accent-strong: #4aa217;
  --factory-blue: #1f4968;
  --factory-orange: #f89c1a;
  --success: #1f8a5b;
  --warning: #b87914;
  --danger: #b43b3b;
  --blue: #2d6cdf;
  --green: #228b62;
  --orange: #d77b20;
  --purple: #7a58c2;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.incident-report-button {
  border: 0;
  border-radius: 12px;
  background: #d94c32;
  color: #fff;
  font-weight: 800;
  padding: 11px 16px;
  cursor: pointer;
}

.incident-mobile-button {
  border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 10px;
  background: #d94c32;
  color: #fff;
  font-size: .78rem;
  font-weight: 800;
  line-height: 1;
  padding: 9px 10px;
  white-space: nowrap;
}

.incident-dialog {
  width: min(620px, calc(100vw - 24px));
  border: 0;
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(16, 34, 38, .28);
}

.incident-dialog::backdrop { background: rgba(8, 28, 32, .62); }
.incident-form { display: grid; gap: 14px; padding: 22px; }
.incident-form header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.incident-form h2 { margin: 2px 0 0; }
.incident-form label { display: grid; gap: 7px; font-weight: 700; }
.incident-form input, .incident-form select, .incident-form textarea { width: 100%; }
.incident-two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.incident-location-note { margin: 0; color: var(--muted, #66757a); font-size: .9rem; }

.vehicle-incidents { margin-top: 16px; display: grid; gap: 10px; }
.empty-incidents { color: var(--muted, #66757a); font-size: .9rem; }
.incident-record { border: 1px solid #dbe3e5; border-left: 5px solid #d9a62e; border-radius: 12px; padding: 12px; background: #fff; display: grid; gap: 8px; }
.incident-record.high, .incident-record.critical { border-left-color: #d94c32; }
.incident-record.closed { border-left-color: #2b926e; background: #f7fcfa; }
.incident-record.ignored { border-left-color: #7b8589; background: #f7f8f8; }
.incident-record-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.incident-record p { margin: 0; white-space: pre-wrap; }
.incident-record small { color: var(--muted, #66757a); }
.incident-evidence, .incident-close-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.incident-resolution { padding: 9px 10px; border-radius: 9px; background: #edf3f3; font-size: .9rem; }

@media (max-width: 640px) {
  .incident-two-columns { grid-template-columns: 1fr; }
  .driver-app #driverView > .topbar { align-items: center; }
  .incident-report-button { padding: 10px 12px; }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body.login-required {
  min-height: 100vh;
  background: var(--factory-blue);
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  overflow: hidden;
}

.login-required .app-shell {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: none;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(31, 73, 104, 0.96), rgba(89, 186, 32, 0.78)),
    var(--factory-blue);
}

.login-required .login-screen {
  display: grid;
}

.login-card {
  width: min(420px, 100%);
  padding: 26px;
  display: grid;
  gap: 16px;
  border: 1px solid rgba(89, 186, 32, 0.22);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(31, 73, 104, 0.32);
}

.login-brand {
  margin-bottom: 4px;
}

.login-hero-logo {
  width: min(280px, 100%);
  justify-self: center;
  display: block;
  margin: -2px auto 2px;
  border-radius: 8px;
  object-fit: contain;
}

.login-card label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.login-card input {
  min-height: 44px;
  border: 1px solid #b8c8cf;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 500;
}

.full {
  width: 100%;
}

.login-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.driver-login-band {
  display: none !important;
}

body.driver-session .sidebar {
  display: none;
}

body.driver-session .app-shell {
  grid-template-columns: 1fr;
}

body.driver-session .workspace {
  padding: 0;
}

body.driver-session #driverView > .topbar {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--factory-blue);
  color: #fff;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar .brand {
  align-items: flex-start;
  flex-direction: column;
  gap: 10px;
}

.brand-logo {
  width: 154px;
  max-width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.sidebar-logo {
  width: 164px;
  padding: 7px 8px;
  border-radius: 8px;
  background: #fff;
}

.brand span:last-child,
.sidebar-panel span,
.panel-header span,
.import-band span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.sidebar .brand span:last-child,
.sidebar-panel span {
  color: #d7e3ea;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  padding: 12px;
  border-radius: 8px;
  background: transparent;
  color: #edf6f1;
  text-align: left;
  position: relative;
}

.nav-tab.active,
.nav-tab:hover {
  background: rgba(89, 186, 32, 0.18);
  color: #fff;
  box-shadow: inset 4px 0 0 var(--accent);
}

.nav-tab.document-warning::after,
.nav-tab.document-danger::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 12px;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 2px 7px rgba(15, 23, 42, 0.24);
  transform: translateY(-50%);
}

.nav-tab.document-danger::after {
  background: #dc2626;
}

.sidebar-panel {
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-panel label {
  display: block;
  margin-bottom: 8px;
  color: #dce5ea;
}

.sidebar-panel input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 10px;
  border-radius: 6px;
}

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

.stat-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

button.stat-row {
  min-height: 32px;
  align-items: center;
}

button.stat-row:hover,
button.stat-row.active {
  color: #fff;
}

button.stat-row.active {
  font-weight: 800;
}

button.stat-row.notice {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffe4a8;
}

.workspace {
  padding: 24px;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-logout,
.driver-drawer-logout {
  width: 100%;
  margin-top: auto;
  min-height: 40px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.26);
}

.sidebar-logout:hover,
.driver-drawer-logout:hover {
  background: rgba(255, 255, 255, 0.18);
}

.driver-drawer-logout {
  background: var(--factory-blue);
  color: #fff;
  border-color: var(--factory-blue);
}

.driver-drawer-logout:hover {
  background: #17384f;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--factory-blue);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
}

h1, h2, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  color: var(--factory-blue);
}

h2 {
  font-size: 16px;
  margin-bottom: 2px;
}

.actions {
  display: flex;
  gap: 10px;
}

.primary,
.secondary,
.file-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-strong);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(89, 186, 32, 0.3);
  border-color: var(--accent) !important;
}

.secondary,
.file-button {
  background: #edf2ef;
  color: var(--factory-blue);
}

.file-button input {
  display: none;
}

.import-band {
  margin-bottom: 16px;
  padding: 14px 16px;
  background: #eff8eb;
  border: 1px solid #cfe8c5;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 1500;
}

.import-band > div:first-child {
  flex: 0 0 min(340px, 32%);
}

.compact-band {
  background: #eef3f5;
  border-color: var(--line);
}

.quick-address {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(150px, 0.35fr) auto;
  gap: 10px;
  flex: 1 1 auto;
  width: 100%;
  position: relative;
}

.driver-login {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(120px, 0.8fr) auto auto;
  gap: 10px;
  width: min(760px, 100%);
}

.driver-login input {
  min-height: 40px;
  border: 1px solid #b8c8cf;
  border-radius: 8px;
  padding: 0 12px;
}

.quick-address input,
.quick-address select {
  width: 100%;
  box-sizing: border-box;
  min-height: 40px;
  border: 1px solid #b8c8cf;
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.quick-address-field,
.driver-route-field {
  position: relative;
}

.suggestion-menu {
  position: absolute;
  z-index: 5000;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: none;
  max-height: min(420px, 52vh);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 32px rgba(21, 33, 42, 0.18);
}

.suggestion-menu.visible {
  display: block;
}

.suggestion-item {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  border-bottom: 1px solid #edf1f4;
}

.suggestion-item:hover {
  background: #eef7f8;
}

.suggestion-item small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.planner-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(520px, 1.15fr);
  gap: 16px;
  align-items: start;
}

.map-panel-wide {
  margin-bottom: 16px;
}

.driver-config-panel {
  margin-bottom: 16px;
}

.driver-config-grid {
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.driver-config-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  display: grid;
  gap: 10px;
  background: #f8fafb;
  overflow: hidden;
}

.driver-config-card summary {
  min-height: 54px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-weight: 700;
  background: #fff;
}

.driver-config-card summary span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  object-fit: cover;
  background: var(--factory-blue);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  border: 2px solid #fff;
  box-shadow: 0 3px 10px rgba(31, 73, 104, 0.18);
}

.user-avatar.admin-avatar {
  background: var(--accent);
}

.user-avatar.driver-avatar {
  background: var(--factory-orange);
}

.driver-config-card summary small {
  color: var(--muted);
  font-weight: 500;
}

.driver-config-card label {
  display: grid;
  gap: 6px;
  margin: 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.driver-config-card input[type="text"] {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
}

.driver-config-card input[type="email"],
.driver-config-card input[type="password"],
.driver-config-card input[type="number"],
.driver-config-card input[type="color"],
.driver-config-card input[type="file"],
.driver-config-card select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
}

.driver-config-card input[type="color"] {
  min-height: 42px;
  padding: 4px;
}

.photo-editor {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 0 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.photo-editor label {
  margin: 0;
}

.photo-editor-preview .user-avatar {
  width: 46px;
  height: 46px;
}

.driver-card-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px 12px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed #c9d3da;
  border-radius: 8px;
  color: var(--muted);
  background: #f8fafb;
}

.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 12px;
}

.driver-config-card .account-grid label {
  margin: 0;
}

.security-note {
  margin: 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
}

.panel-header {
  min-height: 66px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.panel-header input,
.topbar select,
.proof-form input,
.proof-form select,
.proof-form textarea,
.dialog-card input,
.dialog-card select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}

.dispatch-list,
.driver-board,
.mobile-stops,
.closure-grid {
  padding: 14px;
}

.dispatch-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 228px);
  overflow: auto;
}

.stop-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 8px;
}

.stop-card.priority-first {
  border-left: 4px solid #228b62;
}

.stop-card.priority-last {
  border-left: 4px solid #7a58c2;
}

.stop-card.duplicated,
.mobile-card.duplicated {
  border-color: rgba(190, 111, 26, 0.5);
  box-shadow: inset 4px 0 0 rgba(190, 111, 26, 0.82);
}

.stop-route-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.stop-route-controls label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stop-route-controls input {
  width: 58px;
  min-height: 28px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.priority-buttons {
  display: inline-flex;
  gap: 5px;
  flex-wrap: wrap;
}

.mini-button.active,
.priority-badge {
  background: #e3f3ea;
  color: #1f734f;
}

.stop-card-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.mini-button {
  min-height: 28px;
  border-radius: 6px;
  padding: 0 9px;
  background: #e9eef2;
  color: var(--ink);
  font-size: 12px;
}

.mini-button.danger {
  background: #fde8e8;
  color: var(--danger);
}

.stop-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stop-card[draggable="true"] {
  cursor: grab;
}

.stop-card:hover {
  border-color: #b5c4cc;
  box-shadow: 0 8px 18px rgba(21, 33, 42, 0.06);
}

.stop-card.dragging {
  opacity: 0.5;
}

.stop-card strong {
  display: block;
}

.stop-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  background: #eef2f5;
  color: var(--muted);
}

.badge.ok { background: #e5f6ef; color: var(--success); }
.badge.warn { background: #fff1d8; color: var(--warning); }
.badge.bad { background: #fde8e8; color: var(--danger); }
.badge.duplicate-badge {
  background: #fff0dc;
  color: #9a560d;
  font-weight: 800;
}

.badge.navigation-badge {
  background: #e6f4ff;
  color: #126580;
  font-weight: 800;
}

.driver-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  overflow-x: auto;
}

.driver-column {
  min-height: 210px;
  border: 1px dashed #c9d3da;
  border-radius: 8px;
  background: #f8fafb;
  padding: 10px;
}

.driver-column.over {
  background: #e8f4f5;
  border-color: var(--accent);
}

.driver-column header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-weight: 700;
}

.driver-column header span:first-child {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.driver-route-summary {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.driver-route-summary strong {
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-detail-button {
  width: 100%;
  min-height: 36px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: #e9eef2;
  color: var(--ink);
  font-weight: 800;
}

.departure-row {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.departure-row input {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
  color: var(--ink);
}

.no-return-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 13px;
}

.no-return-row input {
  width: 16px;
  height: 16px;
}

.route-lifecycle {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(180px, 1.2fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
}

.route-lifecycle.compact {
  grid-template-columns: 1fr 1fr;
  margin: 0;
}

.route-lifecycle.compact span {
  grid-column: 1 / -1;
}

.route-lifecycle span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.route-lifecycle button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.route-vehicle-row {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: left;
}

.route-vehicle-row select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}

.route-vehicle-row small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.route-start-gate .route-vehicle-row {
  text-align: left;
}

.driver-route-lifecycle {
  display: grid;
  gap: 8px;
}

.route-start-gate {
  position: relative;
  z-index: 3;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid #b9e1ef;
  border-radius: 10px;
  background: #ecf9fd;
  text-align: center;
  box-shadow: 0 12px 28px rgba(39, 167, 216, 0.24);
}

.route-restart-gate {
  border-color: #f0c36a;
  background: #fff8e8;
  box-shadow: 0 12px 28px rgba(214, 154, 48, 0.2);
}

.route-start-gate strong {
  font-size: 16px;
}

.route-start-gate span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.route-started-pill {
  padding: 9px 10px;
  border-radius: 999px;
  background: #e9f8ef;
  color: #1d784d;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.phone-frame.route-locked .mobile-stops {
  opacity: 1;
  filter: none;
  pointer-events: auto;
}

.route-finish-footer {
  padding: 10px 0 4px;
}

.danger-route-button {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: #b43b3b;
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.driver-route-archive {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed #c7dde0;
  border-radius: 8px;
  background: #f8fbfb;
}

.driver-route-archive > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.driver-route-archive button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.driver-route-archive button.active {
  border-color: #27a7d8;
  background: #ecf9fd;
  color: #126580;
}

.map-stage {
  height: min(62vh, 620px);
  min-height: 460px;
  margin: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(21, 33, 42, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(21, 33, 42, 0.06) 1px, transparent 1px),
    #eef4f5;
  background-size: 40px 40px;
  position: relative;
  overflow: hidden;
}

.app-version {
  position: fixed;
  right: 12px;
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 1200;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(31, 73, 104, 0.86);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(89, 186, 32, 0.4);
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
}

.map-empty {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  color: var(--muted);
}

.leaflet-container {
  font: inherit;
}

.route-marker {
  position: relative;
  min-width: 28px;
  width: max-content;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0 8px;
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  border: 2px solid #fff;
  box-shadow: 0 5px 16px rgba(21, 33, 42, 0.25);
}

.driver-stop-marker.delivered {
  box-shadow: 0 0 0 3px rgba(34, 139, 98, 0.22), 0 5px 16px rgba(21, 33, 42, 0.25);
}

.driver-stop-marker.failed {
  background: #b43b3b;
}

.marker-corner {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  background: #fff;
  color: #111b22;
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  box-shadow: 0 4px 10px rgba(21, 33, 42, 0.24);
}

.driver-stop-marker.delivered .marker-corner {
  color: #228b62;
}

.driver-stop-marker.failed .marker-corner {
  color: #b43b3b;
}

.marker-special {
  position: absolute;
  left: 50%;
  bottom: -13px;
  transform: translateX(-50%);
  min-width: 24px;
  padding: 2px 5px;
  border-radius: 999px;
  background: #111b22;
  color: #fff;
  border: 2px solid #fff;
  font-size: 9px;
  line-height: 1;
  box-shadow: 0 4px 10px rgba(21, 33, 42, 0.22);
}

.marker-duplicate {
  position: absolute;
  left: -10px;
  top: -8px;
  min-width: 24px;
  padding: 2px 5px;
  border-radius: 999px;
  background: #fff0dc;
  color: #9a560d;
  border: 2px solid #fff;
  font-size: 9px;
  line-height: 1;
  font-weight: 900;
  box-shadow: 0 4px 10px rgba(21, 33, 42, 0.22);
}

.original-stop-marker {
  width: 16px;
  min-width: 16px;
  height: 16px;
  padding: 0;
  background: #fff !important;
  border: 3px solid #7a8992;
  box-shadow: 0 3px 10px rgba(21, 33, 42, 0.18);
  opacity: 0.75;
}

.duplicate-popup {
  display: inline-block;
  margin-top: 4px;
  color: #9a560d;
  font-weight: 800;
}

.location-marker {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(45, 108, 223, 0.22);
  border: 2px solid #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 16px rgba(45, 108, 223, 0.35);
}

.location-marker span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2d6cdf;
}

.driver-car-marker {
  position: relative;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--driver-color);
  box-shadow: 0 7px 18px rgba(31, 73, 104, 0.34);
  overflow: visible;
}

.driver-car-marker.document-warning,
.vehicle-marker.document-warning img {
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.28), 0 7px 18px rgba(31, 73, 104, 0.28);
}

.driver-car-marker.document-danger,
.vehicle-marker.document-danger img {
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.28), 0 7px 18px rgba(31, 73, 104, 0.28);
}

.driver-car-marker img {
  width: 25px;
  height: 25px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}

.driver-car-marker .driver-marker-photo {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: none;
}

.vehicle-marker {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  position: relative;
}

.document-alert-dot {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 13px;
  height: 13px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.24);
  z-index: 3;
}

.document-danger .document-alert-dot {
  background: #dc2626;
}

.vehicle-marker img {
  width: 36px;
  height: 36px;
  display: block;
  filter: drop-shadow(0 7px 12px rgba(15, 23, 42, 0.24));
}

.vehicle-marker.offline img {
  filter: grayscale(1) opacity(0.72) drop-shadow(0 7px 12px rgba(15, 23, 42, 0.18));
}

.vehicle-marker span {
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: absolute;
  left: 50%;
  bottom: -14px;
  transform: translateX(-50%);
  padding: 1px 5px;
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  background: var(--vehicle-color, rgba(17, 27, 34, 0.88));
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.3;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.18);
}

.vehicle-marker.offline {
  opacity: 0.78;
}

.google-html-marker {
  position: absolute;
  width: 86px;
  height: 66px;
  border: 0;
  padding: 0;
  background: transparent;
  transform: translate(-50%, -50%);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.google-html-marker .driver-car-marker,
.google-html-marker .vehicle-marker {
  pointer-events: none;
}

.route-popup strong {
  display: block;
  margin-bottom: 4px;
}

.route-popup {
  min-width: 220px;
}

.route-popup-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.navigation-meta {
  display: grid;
  gap: 3px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
}

.navigation-meta.adjusted {
  border-color: rgba(18, 101, 128, 0.35);
  background: #edf8fc;
}

.navigation-meta strong {
  margin: 0;
  font-size: 12px;
}

.navigation-meta span,
.navigation-meta small {
  color: var(--muted);
}

.navigation-meta summary {
  cursor: pointer;
  color: var(--factory-blue);
  font-weight: 800;
}

.vehicle-popup-image {
  width: 100%;
  max-width: 220px;
  height: 118px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f7faf9;
}

.vehicle-popup-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
}

.map-assignment-controls {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #edf1f4;
  display: grid;
  gap: 6px;
  min-width: 210px;
}

.map-assignment-controls strong,
.map-assignment-controls small {
  display: block;
}

.map-assignment-controls small,
.map-assignment-empty {
  color: var(--muted);
  font-size: 12px;
}

.map-assignment-select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 6px 8px;
}

.map-assignment-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.map-assignment-actions button,
.map-popup-action {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  background: #eef7f8;
  color: var(--factory-blue);
  font-weight: 800;
}

.map-popup-action {
  margin-top: 8px;
}

.route-popup .badges {
  margin: 7px 0;
}

.route-popup-pending {
  margin-top: 8px;
  padding: 8px;
  border-radius: 8px;
  background: #fff8e1;
  color: #8a6400;
  font-weight: 800;
}

.route-popup-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 8px;
}

.route-popup-details div {
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbfc;
}

.route-popup-details .wide {
  grid-column: 1 / -1;
}

.route-popup-details span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.route-popup-details strong {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.route-popup-photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.route-popup-photo-link {
  display: block;
  width: 74px;
  height: 74px;
  padding: 0 !important;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #eef2f5;
}

.route-popup-photo-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.route-popup-review {
  margin-top: 8px;
  padding: 7px;
  border-radius: 7px;
  background: #ecf9fd;
  color: #126580;
  font-weight: 900;
}

.map-pin {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(21, 33, 42, 0.22);
}

.map-pin.start-pin {
  background: #111b22;
}

.map-pin span {
  transform: rotate(45deg);
}

.legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 14px 14px;
}

.route-summary {
  display: grid;
  gap: 8px;
  padding: 0 14px 14px;
}

.route-summary-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 10px 0 2px;
}

.route-summary-card {
  position: relative;
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.route-summary-card[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 1000;
  left: 12px;
  bottom: calc(100% + 8px);
  min-width: 220px;
  max-width: 320px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #111b22;
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-line;
  box-shadow: 0 14px 32px rgba(21, 33, 42, 0.22);
}

.route-summary-card strong,
.route-summary-card span {
  display: block;
}

.route-summary-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.legend-item {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.vehicle-dot {
  background: #1b6d74;
  border-radius: 3px;
}

.context-menu {
  position: fixed;
  z-index: 10000;
  display: none;
  width: 250px;
  max-height: calc(100vh - 24px);
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(21, 33, 42, 0.22);
  overflow: hidden;
}

.context-menu.visible {
  display: grid;
  gap: 8px;
}

.context-menu-title {
  padding: 6px 8px 8px;
  border-bottom: 1px solid #edf1f4;
}

.context-menu-title strong,
.context-menu-title span,
.context-menu-section > span {
  display: block;
}

.context-menu-title span,
.context-menu-section > span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.context-menu-section {
  display: grid;
  gap: 4px;
}

.context-menu-assignment {
  max-height: min(42vh, 320px);
  overflow-y: auto;
  padding-right: 3px;
}

.context-menu-section button {
  min-height: 34px;
  padding: 0 8px;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.context-menu-section button:hover,
.context-menu-section button.selected {
  background: #eef7f8;
}

.context-menu-section button.selected {
  font-weight: 700;
}

.context-menu-section button.danger {
  color: var(--danger);
}

.context-menu-section button.danger:hover {
  background: #fde8e8;
}

.driver-layout {
  display: block;
}

.driver-side {
  display: grid;
  gap: 18px;
}

.evidence-panel {
  display: none;
}

.evidence-panel.visible {
  display: block;
}

.driver-map-panel {
  position: relative;
  min-height: min(760px, calc(100vh - 190px));
  overflow: hidden;
}

.driver-menu-toggle {
  position: static;
  z-index: 760;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: none;
  place-items: center;
  background: var(--factory-blue);
  color: #fff;
  font-size: 22px;
  box-shadow: 0 10px 26px rgba(31, 73, 104, 0.3);
}

.driver-drawer {
  position: absolute;
  z-index: 920;
  top: 0;
  right: 0;
  width: min(340px, 86vw);
  height: 100%;
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr auto;
  align-content: stretch;
  gap: 16px;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 42px rgba(31, 73, 104, 0.22);
  transform: translateX(105%);
  transition: transform 180ms ease;
}

.driver-drawer.visible {
  transform: translateX(0);
}

.driver-drawer-backdrop {
  position: absolute;
  z-index: 910;
  inset: 0;
  display: none;
  background: rgba(17, 27, 34, 0.26);
}

.driver-drawer-backdrop.visible {
  display: block;
}

.driver-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.driver-drawer label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.driver-drawer-actions {
  align-self: end;
  display: grid;
  gap: 10px;
}

.driver-drawer input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  color: var(--ink);
}

.driver-route-stats {
  display: grid;
  gap: 8px;
}

.route-stat-grid {
  display: grid;
  gap: 8px;
}

.route-stat-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.route-stat-button {
  min-height: 44px;
  padding: 9px 10px;
  border-radius: 8px;
  display: grid;
  gap: 2px;
  background: #f2f6f8;
  color: var(--ink);
  border: 1px solid var(--line);
  text-align: left;
}

.route-stat-button span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.route-stat-button strong {
  font-size: 18px;
  line-height: 1;
}

.route-stat-button.active,
.route-stat-button:hover {
  border-color: var(--factory-blue);
  box-shadow: 0 0 0 2px rgba(31, 73, 104, 0.09);
}

.driver-column .route-stat-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0 0 10px;
}

.driver-column .route-stat-button {
  min-height: 50px;
  padding: 8px;
}

.route-archive-card {
  display: grid;
  width: 100%;
  gap: 4px;
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
}

.route-archive-card.active {
  border-color: #27a7d8;
  box-shadow: 0 0 0 2px rgba(39, 167, 216, 0.16);
}

.route-archive-card > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.route-archive-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

body.driver-session .driver-map-panel {
  min-height: 100svh;
  border-radius: 0;
}

body.driver-session .driver-menu-toggle {
  display: grid;
}

body.driver-session .evidence-panel.visible {
  position: fixed;
  z-index: 980;
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  max-height: min(86svh, 720px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

body.driver-session .evidence-panel input,
body.driver-session .evidence-panel select,
body.driver-session .evidence-panel textarea,
body.driver-session .driver-route-tools input {
  font-size: 16px;
}

.driver-map-panel > .panel-header {
  position: absolute;
  z-index: 600;
  top: 12px;
  left: 12px;
  right: 12px;
  width: min(420px, calc(100% - 24px));
  min-height: auto;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 24px rgba(21, 33, 42, 0.14);
}

.driver-map {
  height: min(760px, calc(100vh - 190px));
  min-height: 560px;
  margin: 0;
  border: 0;
  border-radius: 8px;
  background: #eef4f5;
}

body.driver-session .driver-map {
  height: 100svh;
  min-height: 100svh;
  border-radius: 0;
}

.selected-stop {
  position: absolute;
  z-index: 620;
  top: 92px;
  left: 12px;
  width: min(420px, calc(100% - 24px));
  padding: 0;
  display: grid;
  gap: 10px;
}

.selected-stop-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: #fff;
}

.nav-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
}

.mobile-card.selected {
  border-color: #27a7d8;
  box-shadow: 0 0 0 2px rgba(39, 167, 216, 0.2);
}

.phone-frame {
  position: absolute;
  z-index: 650;
  left: 12px;
  right: 12px;
  bottom: 12px;
  border-radius: 18px;
  background: rgba(16, 25, 32, 0.92);
  padding: 12px;
  box-shadow: 0 16px 40px rgba(21, 33, 42, 0.28);
  backdrop-filter: blur(10px);
}

body.driver-session .phone-frame {
  bottom: max(12px, env(safe-area-inset-bottom));
  max-height: 46svh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.phone-header {
  color: #fff;
  padding: 10px 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.phone-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.phone-header > div:not(.phone-header-actions) {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.phone-header span,
.phone-header small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.driver-route-tools {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  gap: 8px;
  margin-bottom: 8px;
}

.sync-state-button {
  width: 42px;
  min-width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  font-weight: 800;
}

.phone-header .sync-state-button {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.sync-state-button.syncing {
  animation: sync-spin 900ms linear infinite;
}

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

.driver-route-field {
  min-width: 0;
}

.driver-route-tools input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #3b4d58;
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

.driver-route-tools .primary,
.driver-route-tools .secondary {
  min-height: 40px;
  padding: 0 10px;
  white-space: nowrap;
}

.danger-action {
  color: var(--danger);
}

.link-button.danger-action {
  color: var(--danger);
  background: #fde8e8;
  border: 1px solid #f2b8b8;
  font-weight: 800;
}

.link-button.danger-action:hover {
  background: #fbd4d4;
}

.driver-route-eta {
  color: #dce5ea;
  font-size: 12px;
  padding: 0 8px 4px;
}

.driver-live-status {
  color: #dce5ea;
  font-size: 11px;
  font-weight: 800;
  padding: 0 8px 10px;
}

.driver-live-status.active {
  color: #9df0c3;
}

.driver-live-status.stale {
  color: #ffd28a;
}

.driver-title-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.driver-title-inline .user-avatar {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.mobile-stops {
  background: transparent;
  border-radius: 14px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: visible;
  scroll-snap-type: none;
  padding-bottom: 2px;
}

.mobile-card {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.mobile-card .priority-badge {
  font-weight: 800;
}

.mobile-priority-buttons {
  width: 100%;
}

.mobile-priority-buttons .mini-button {
  flex: 1 1 0;
}

.mobile-card.closed {
  opacity: 0.58;
  background: #f4f6f7;
}

.mobile-card.completed {
  border-color: rgba(34, 139, 98, 0.32);
}

.mobile-card.failed {
  border-color: rgba(180, 59, 59, 0.32);
}

.mobile-card.closed.selected {
  opacity: 0.78;
}

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

.mobile-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #f2f6f7;
  font-weight: 800;
}

.mobile-navigation-buttons {
  display: flex;
  gap: 8px;
}

.mobile-navigation-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.app-icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  text-decoration: none;
  line-height: 1;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.app-icon-button.google {
  background: #fff;
}

.app-icon-button.waze {
  background: #eafbff;
}

.app-icon-button img {
  width: 25px;
  height: 25px;
  display: block;
}

.link-button {
  text-decoration: none;
  color: var(--ink);
  background: #e9eef2;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  font-size: 13px;
}

.proof-form {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.proof-form label,
.dialog-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.photo-preview-grid {
  display: none;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.photo-preview-grid.visible {
  display: grid;
}

.photo-preview-item {
  position: relative;
  margin: 0;
}

.photo-preview-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: block;
}

.photo-preview-item figcaption {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(17, 27, 34, 0.78);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.full {
  width: 100%;
}

.closure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  padding: 0;
}

.closure-search-panel {
  margin-bottom: 16px;
  padding: 14px;
}

.closure-search-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) minmax(160px, 0.7fr) minmax(140px, 0.55fr) minmax(140px, 0.55fr);
  gap: 12px;
  align-items: end;
}

.closure-search-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.closure-search-grid input,
.closure-search-grid select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
}

.vehicles-panel {
  display: grid;
  gap: 12px;
}

.vehicles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.vehicle-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.vehicle-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.vehicle-card-title {
  min-width: 0;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.vehicle-card-image {
  width: 76px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #eef4f5;
  object-fit: cover;
}

.vehicle-card-image.placeholder {
  display: grid;
  place-items: center;
  color: #55727a;
  font-size: 18px;
  font-weight: 900;
}

.vehicle-card header strong,
.vehicle-card header span {
  display: block;
}

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

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

.vehicle-live-grid div,
.vehicle-detail-grid div {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbfc;
}

.vehicle-live-grid span,
.vehicle-detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.vehicle-live-grid strong,
.vehicle-detail-grid strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.vehicle-documents {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid #c7dde0;
  border-left: 4px solid #1b6d74;
  border-radius: 8px;
  background: #f8fbfb;
}

.vehicle-documents.empty {
  color: var(--muted);
  border-left-color: #a9b8be;
}

.vehicle-documents.warning {
  border-color: #f4d08a;
  border-left-color: #f59e0b;
  background: #fff8ea;
}

.vehicle-documents.danger {
  border-color: #f3b5b5;
  border-left-color: #dc2626;
  background: #fff1f1;
}

.vehicle-documents > strong {
  font-size: 13px;
}

.vehicle-document-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content max-content;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.vehicle-document-row span,
.vehicle-document-row strong {
  overflow-wrap: anywhere;
}

.vehicle-document-row strong {
  color: var(--muted);
  font-size: 11px;
}

.vehicle-document-row.danger strong {
  color: #b91c1c;
}

.vehicle-document-row.warning strong {
  color: #92400e;
}

.vehicle-document-row a {
  color: #14555b;
  font-weight: 900;
}

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

.vehicle-edit-grid .wide {
  grid-column: 1 / -1;
}

.vehicle-edit-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.vehicle-edit-grid input,
.vehicle-edit-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  color: var(--ink);
  background: #fff;
}

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

.vehicle-save-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.vehicle-power-button {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 12px;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.vehicle-power-button.cut {
  background: var(--danger);
}

.vehicle-power-button.restore {
  background: var(--success);
}

.vehicle-power-status {
  color: var(--factory-blue);
  font-size: 12px;
  font-weight: 900;
}

.link-as-button {
  display: inline-grid;
  place-items: center;
  min-height: 38px;
  text-decoration: none;
}

.vehicle-details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 900;
}

.closure-custom-range {
  display: none !important;
}

.closure-custom-range.visible {
  display: grid !important;
}

.closure-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.history-separator {
  grid-column: 1 / -1;
  padding: 8px 2px 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.history-card {
  border-color: #c7dde0;
  background: #f8fbfb;
}

.route-history-card {
  background: #fff;
  border: 1px solid #c7dde0;
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.route-history-stops {
  display: grid;
  gap: 7px;
}

.route-history-stops div {
  display: grid;
  grid-template-columns: minmax(72px, 0.7fr) minmax(92px, 0.7fr) minmax(0, 1.6fr);
  gap: 8px;
  align-items: start;
  padding: 8px;
  border-radius: 7px;
  background: #f8fbfc;
  color: var(--ink);
}

.route-history-stops span,
.route-history-stops strong {
  font-size: 12px;
}

.route-history-stops small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.driver-route-history-menu {
  display: grid;
  gap: 8px;
}

.driver-route-history-menu > strong {
  color: var(--ink);
  font-size: 13px;
}

.driver-history-empty {
  padding: 9px;
  border-radius: 8px;
  background: #f4f6f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.driver-history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.driver-history-item summary {
  padding: 9px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.driver-history-item .route-history-card {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.approval-card {
  border-color: #f0c36a;
  background: #fffaf0;
}

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

.closure-photo {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: 8px;
  background: #eef2f5;
}

.closure-photo-link {
  position: relative;
  display: block;
  min-height: 150px;
  border-radius: 8px;
  overflow: hidden;
  background: #eef2f5;
  color: var(--accent);
  text-decoration: none;
}

.closure-photo-link span {
  position: absolute;
  inset: auto 8px 8px 8px;
  padding: 7px 9px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  opacity: 0;
}

.closure-photo-link:hover span,
.closure-photo-link.missing span {
  opacity: 1;
}

.closure-photo-link.missing .closure-photo {
  display: none;
}

.closure-photo-link.missing {
  display: grid;
  place-items: center;
}

.closure-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}

dialog {
  border: 0;
  border-radius: 10px;
  padding: 0;
  width: min(520px, calc(100vw - 32px));
}

dialog::backdrop {
  background: rgba(8, 15, 20, 0.5);
}

.dialog-card {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.photo-crop-card {
  width: min(420px, calc(100vw - 28px));
}

.navigation-adjust-card {
  width: min(820px, calc(100vw - 24px));
}

.navigation-adjust-card textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  resize: vertical;
  font: inherit;
}

.navigation-adjust-summary {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 8px;
}

.navigation-adjust-summary div {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
}

.navigation-adjust-summary span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.navigation-adjust-summary strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.navigation-adjust-map {
  height: min(56vh, 440px);
  min-height: 300px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #eef4f5;
}

#routeDriverDialog {
  width: min(720px, calc(100vw - 28px));
}

.route-detail-card {
  max-height: min(86vh, 760px);
  overflow: auto;
}

.route-detail-card header h2 {
  margin: 0;
}

.route-detail-card header span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.route-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.route-detail-checkbox {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.route-detail-checkbox input {
  width: 18px;
  height: 18px;
}

.route-detail-card .route-vehicle-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
}

.route-detail-card .route-stat-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.route-detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.route-detail-stops {
  display: grid;
  gap: 8px;
  max-height: min(46vh, 430px);
  overflow: auto;
  padding-right: 3px;
}

.route-detail-stop,
.route-detail-empty {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.route-detail-stop {
  cursor: grab;
}

.route-detail-stop.dragging {
  opacity: 0.55;
}

.route-detail-stop.drop-before {
  border-color: #27a7d8;
  box-shadow: 0 -3px 0 #27a7d8;
}

.route-detail-stop-main {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.route-detail-stop-number {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--factory-blue);
  color: #fff !important;
  font-weight: 900;
}

.route-detail-stop span,
.route-detail-empty {
  color: var(--muted);
}

.route-detail-stop-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.route-detail-stop-controls label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.route-detail-stop-controls input {
  width: 58px;
  min-height: 28px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.photo-crop-preview {
  width: 220px;
  height: 220px;
  margin: 0 auto;
  border-radius: 50%;
  border: 4px solid #fff;
  outline: 1px solid var(--line);
  background-color: #eef2f5;
  background-repeat: no-repeat;
  box-shadow: 0 10px 28px rgba(21, 33, 42, 0.16);
}

.photo-crop-card input[type="range"] {
  width: 100%;
}

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

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #e9eef2;
}

@media (max-width: 1180px) {
  .planner-grid {
    grid-template-columns: 1fr;
  }

  .closure-search-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dispatch-list {
    max-height: none;
  }
}

@media (max-width: 780px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: auto;
    padding: 12px;
  }

  .workspace {
    height: auto;
    overflow: visible;
  }

  body.driver-session .app-shell,
  body.driver-session .workspace {
    height: 100svh;
    min-height: 100svh;
    overflow: hidden;
  }

  .brand,
  .sidebar-panel {
    display: none;
  }

  .sidebar-logout {
    display: none;
  }

  .nav-tabs {
    grid-template-columns: repeat(4, 1fr);
  }

  .nav-tab {
    text-align: center;
  }

  .workspace {
    padding: 14px;
  }

  .topbar,
  .import-band,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .closure-search-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 22px;
  }

  .actions,
  .quick-address,
  .driver-login,
  .driver-route-tools,
  .mobile-actions {
    grid-template-columns: 1fr;
    display: grid;
  }

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

  .photo-editor [data-action="edit-photo"] {
    grid-column: 1 / -1;
  }

  .driver-board,
  .driver-layout,
  .nav-buttons {
    grid-template-columns: 1fr;
  }

  .route-lifecycle {
    grid-template-columns: 1fr;
  }

  .route-detail-grid,
  .route-detail-card .route-stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .navigation-adjust-summary {
    grid-template-columns: 1fr;
  }

  .vehicle-document-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .phone-frame {
    border-radius: 14px;
    padding: 10px;
  }

  body.driver-session .driver-map-panel > .panel-header {
    top: 10px;
    left: 10px;
    right: 76px;
    width: auto;
    padding: 10px;
  }

  body.driver-session .driver-map-panel > .panel-header h2 {
    font-size: 17px;
    margin-bottom: 2px;
  }

  body.driver-session .driver-map-panel > .panel-header span {
    display: none;
  }

  body.driver-session .selected-stop {
    top: 72px;
    left: 10px;
    right: 10px;
    width: auto;
  }

  body.driver-session .selected-stop-card {
    padding: 10px;
  }

  body.driver-session .phone-frame {
    left: 10px;
    right: 10px;
    padding: 10px;
    max-height: 46svh;
  }

  body.driver-session .phone-header {
    padding: 2px 4px 8px;
  }

  body.driver-session .driver-route-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  body.driver-session .driver-route-field {
    grid-column: 1 / -1;
  }

  body.driver-session .driver-route-tools input {
    min-height: 38px;
  }

  body.driver-session .driver-route-tools .primary,
  body.driver-session .driver-route-tools .secondary {
    min-height: 36px;
    padding: 0 8px;
    font-size: 14px;
  }

  body.driver-session .driver-route-eta {
    padding: 0 4px 7px;
  }

  body.driver-session .mobile-card {
    padding: 10px;
    gap: 6px;
  }

  body.driver-session .mobile-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.driver-session .mobile-navigation {
    padding: 8px;
  }

  body.driver-session .app-icon-button {
    width: 34px;
    height: 34px;
    border-radius: 9px;
  }
}
