:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #18202a;
  --muted: #627084;
  --line: #d9e0e8;
  --blue: #1f6feb;
  --blue-weak: #eaf2ff;
  --green: #14804a;
  --green-weak: #e9f7ef;
  --orange: #a95d00;
  --orange-weak: #fff3df;
  --red: #c93c37;
  --red-weak: #ffeceb;
  --staff: #1769aa;
  --staff-weak: #e8f3fc;
  --admin: #b45309;
  --admin-weak: #fff1df;
  --driver: #0f766e;
  --driver-weak: #e5f7f4;
  --shadow: 0 14px 35px rgba(24, 32, 42, 0.08);
  color-scheme: light;
  font-family: Inter, "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans Thai", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

body {
  overflow-x: hidden;
}

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

button {
  min-height: 38px;
  border: 1px solid var(--blue);
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  filter: brightness(0.96);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

button.danger {
  background: #fff;
  color: var(--red);
  border-color: #e8aaa7;
}

button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.2;
  white-space: normal;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--blue);
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  padding: 0 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.button-link.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.2;
  white-space: normal;
}

.button-link:hover {
  filter: brightness(0.96);
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

textarea {
  padding: 9px 10px;
  line-height: 1.4;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.button-link:focus-visible {
  outline: 3px solid rgba(31, 111, 235, 0.2);
  outline-offset: 1px;
}

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

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
}

h3 {
  font-size: 15px;
  line-height: 1.25;
  margin-bottom: 10px;
}

p,
.subtle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 249, 0.94);
  backdrop-filter: blur(10px);
}

.brand {
  display: block;
  font-size: 20px;
  line-height: 1.2;
}

.brand > span[lang="th"] {
  font-weight: 700;
}

.app-version {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

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

.current-role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 2px solid var(--line);
  border-radius: 7px;
  padding: 4px 9px;
  background: #fff;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.15;
}

.current-role-badge.staff {
  color: var(--staff);
  border-color: var(--staff);
  background: var(--staff-weak);
}

.current-role-badge.admin {
  color: var(--admin);
  border-color: var(--admin);
  background: var(--admin-weak);
}

.current-role-badge.driver {
  color: var(--driver);
  border-color: var(--driver);
  background: var(--driver-weak);
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
}

.status-pill.online {
  color: var(--green);
  border-color: #b9e3c7;
  background: var(--green-weak);
}

.status-pill.offline {
  color: var(--red);
  border-color: #f0b9b6;
  background: var(--red-weak);
}

.shell {
  display: grid;
  grid-template-columns: minmax(370px, 0.9fr) minmax(0, 2fr);
  gap: 14px;
  padding: 14px;
}

.left-column {
  min-width: 0;
}

.main-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-head.compact {
  margin-bottom: 10px;
}

.role-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 7px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.role-tab {
  display: flex;
  min-width: 0;
  min-height: 68px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  border-width: 2px;
  background: #fff;
  padding: 8px 12px;
  text-align: left;
  white-space: normal;
}

.role-tab strong {
  font-size: 16px;
  line-height: 1.15;
}

.role-tab span {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.role-tab[data-role="staff"] {
  color: var(--staff);
  border-color: #9bc7e8;
  background: var(--staff-weak);
}

.role-tab[data-role="admin"] {
  color: var(--admin);
  border-color: #e5b67f;
  background: var(--admin-weak);
}

.role-tab[data-role="driver"] {
  color: var(--driver);
  border-color: #8acdc4;
  background: var(--driver-weak);
}

.role-tab[data-role="staff"].active {
  border-color: var(--staff);
  background: var(--staff);
  color: #fff;
}

.role-tab[data-role="admin"].active {
  border-color: var(--admin);
  background: var(--admin);
  color: #fff;
}

.role-tab[data-role="driver"].active {
  border-color: var(--driver);
  background: var(--driver);
  color: #fff;
}

.role-panel {
  border-top-width: 5px;
}

.staff-role-panel {
  border-top-color: var(--staff);
}

.admin-role-panel {
  border-top-color: var(--admin);
}

.driver-role-panel {
  border-top-color: var(--driver);
}

.mart-bar {
  display: grid;
  grid-template-columns: minmax(240px, 360px) minmax(260px, 1fr);
  gap: 12px;
  align-items: start;
}

.add-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.add-box summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.driver-auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.role-auth-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
  align-items: end;
}

.role-auth-grid .button-row button {
  flex: 1 1 180px;
  min-height: 44px;
  white-space: normal;
}

.admin-credential-section {
  margin: 14px 0;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.credential-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, auto);
  gap: 9px;
  align-items: end;
}

.credential-grid button {
  min-height: 38px;
  white-space: normal;
}

.driver-auth-grid .button-row {
  grid-column: 1 / -1;
}

.driver-auth-grid .button-row button {
  width: 100%;
  white-space: normal;
}

.admin-driver-section h3 {
  margin-bottom: 2px;
}

.permission-recovery {
  margin-top: 14px;
  border: 2px solid var(--red);
  border-radius: 8px;
  padding: 12px;
  background: var(--red-weak);
  color: var(--ink);
}

.permission-recovery strong {
  display: block;
  color: var(--red);
  font-size: 16px;
}

.permission-recovery p {
  margin: 7px 0 10px;
  color: #6a302e;
  font-size: 13px;
}

.driver-location-actions {
  margin-top: 12px;
}

.delivery-form-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

.customer-lookup-section {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.form-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.form-section-title strong,
.optional-section > summary {
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.required-section {
  margin-right: -14px;
  margin-left: -14px;
  padding: 14px;
  border-top: 2px solid #9bc7e8;
  border-bottom: 2px solid #9bc7e8;
  background: var(--staff-weak);
}

.required-count {
  color: var(--staff);
  font-size: 12px;
  font-weight: 900;
}

.required-grid {
  display: grid;
  grid-template-columns: minmax(140px, 0.75fr) minmax(0, 1.65fr);
  gap: 10px;
}

.required-field > span::after {
  content: " *";
  color: var(--red);
}

.required-field input {
  min-height: 46px;
  border-width: 2px;
  border-color: var(--staff);
  font-size: 15px;
  font-weight: 750;
}

.optional-section > summary {
  cursor: pointer;
  color: var(--staff);
}

.optional-grid {
  margin-top: 12px;
}

.delivery-submit-row {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.primary-action {
  min-height: 52px;
  font-size: 17px;
  font-weight: 900;
  white-space: normal;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

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

.field.wide {
  grid-column: span 2;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
  min-width: 0;
}

.button-row.end {
  justify-content: flex-end;
  margin-top: 12px;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(360px, 0.95fr);
  gap: 14px;
  align-items: start;
}

.map-panel {
  position: sticky;
  top: 78px;
}

#map {
  width: 100%;
  height: min(58vh, 560px);
  min-height: 390px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2f5;
  overflow: hidden;
}

.map-fallback {
  display: none;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.map-fallback.active {
  display: block;
}

.route-panel {
  position: sticky;
  top: 78px;
}

.history-filter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-top: 10px;
}

.route-end-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

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

#setRouteEndButton {
  grid-column: 1 / -1;
  min-height: 44px;
  font-weight: 900;
}

.route-end-state {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.route-list,
.search-results,
.admin-list,
.audit-list,
.check-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.route-list {
  margin-top: 12px;
}

.route-summary {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.route-summary.warning {
  color: var(--orange);
  border-color: #edcf98;
  background: var(--orange-weak);
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  background: #fbfcfd;
}

.route-row,
.result-row,
.admin-row,
.audit-row,
.driver-check {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.route-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

.route-row.done {
  border-color: #9fd5b2;
  background: #f2fbf5;
  box-shadow: inset 4px 0 0 var(--green);
}

.route-row.cancelled {
  border-color: #edb9b6;
  background: #fff6f5;
  box-shadow: inset 4px 0 0 var(--red);
}

.route-row.route-excluded {
  border-color: #e4c26f;
  background: #fffbeb;
  box-shadow: inset 4px 0 0 #b7791f;
}

.route-row.done .route-rank {
  background: var(--green-weak);
  color: var(--green);
}

.route-row.cancelled .route-rank {
  background: var(--red-weak);
  color: var(--red);
}

.route-row.route-excluded .route-rank {
  background: #fff0bf;
  color: #8a5800;
}

.route-rank {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--blue-weak);
  color: var(--blue);
  font-weight: 800;
  font-size: 22px;
}

.route-main {
  min-width: 0;
}

.route-title,
.row-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  font-weight: 800;
}

.route-title {
  align-items: flex-start;
  font-size: 18px;
  line-height: 1.3;
}

.row-title span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-title span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.route-meta {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px 10px;
  margin: 12px 0 0;
  font-size: 15px;
  line-height: 1.45;
}

.route-meta dt {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.route-meta dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.route-copy-value {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.route-copy-value > span {
  min-width: 0;
  padding-top: 4px;
  overflow-wrap: anywhere;
}

.copy-button {
  flex: 0 0 78px;
  min-height: 32px;
  padding: 4px 6px;
  border-color: #adc1d5;
  background: #fff;
  color: #29455f;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.15;
  white-space: normal;
}

.route-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

button.wait-active {
  border-color: #9c6500;
  background: #9c6500;
  color: #fff;
}

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

.proof-record,
.proof-editor {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.proof-record > strong {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}

.proof-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.proof-photo-wrap {
  position: relative;
  width: 72px;
  height: 72px;
}

.proof-photo {
  display: block;
  width: 72px;
  height: 72px;
  min-height: 72px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #eef2f5;
}

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

.proof-photo-delete {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 26px;
  min-height: 26px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  box-shadow: 0 2px 7px rgba(24, 32, 42, 0.22);
}

.proof-note {
  margin-top: 7px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.proof-editor textarea {
  min-height: 66px;
}

.proof-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 7px;
}

.proof-upload-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid var(--blue);
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  padding: 0 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.proof-upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 1px;
  opacity: 0;
  pointer-events: none;
}

.proof-upload-button.disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.badge.waiting {
  color: var(--orange);
  border-color: #edcf98;
  background: var(--orange-weak);
}

.badge.delivering {
  color: var(--blue);
  border-color: #b8cef8;
  background: var(--blue-weak);
}

.badge.done {
  color: var(--green);
  border-color: #b9e3c7;
  background: var(--green-weak);
}

.badge.cancelled {
  color: var(--red);
  border-color: #f0b9b6;
  background: var(--red-weak);
}

.badge.route-wait {
  color: #7a4d00;
  border-color: #e4c26f;
  background: #fff0bf;
}

.search-results {
  max-height: 230px;
  overflow: auto;
  margin-top: 8px;
}

.result-row,
.admin-row,
.audit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
}

.row-sub {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.selected-target,
.notice {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

.selected-target:empty,
.notice:empty {
  display: none;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

.unlock-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.edit-box {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.audit-list {
  max-height: 300px;
  overflow: auto;
}

.audit-row {
  grid-template-columns: minmax(0, 1fr);
}

.audit-change {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.driver-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  cursor: pointer;
}

.driver-check input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--blue);
}

.hidden {
  display: none !important;
}

body.proof-viewer-open {
  overflow: hidden;
}

.proof-viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: rgba(14, 18, 24, 0.98);
  color: #fff;
}

.proof-viewer-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto 44px;
  align-items: center;
  gap: 10px;
}

.proof-viewer-bar strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proof-viewer-counter,
.proof-viewer-caption {
  color: #d6dde7;
  font-size: 13px;
}

.proof-viewer-stage {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

.proof-viewer-stage img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
}

.proof-viewer-icon {
  width: 44px;
  min-height: 44px;
  padding: 0;
  border-color: #566273;
  background: #283241;
  color: #fff;
  font-size: 28px;
  line-height: 1;
}

.proof-viewer-bar .proof-viewer-icon {
  justify-self: end;
  font-size: 20px;
}

.proof-viewer-delete {
  min-height: 36px;
  padding: 0 10px;
  border-color: #e16c67;
  background: #b8322e;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.proof-viewer-icon:disabled {
  opacity: 0.28;
}

.proof-viewer-caption {
  min-height: 20px;
  text-align: center;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 28px));
  border-radius: 8px;
  background: #172033;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: 0.18s ease;
  font-size: 14px;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.leaflet-container {
  font: inherit;
}

.pin {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  border: 2px solid #fff;
  box-shadow: 0 6px 16px rgba(24, 32, 42, 0.25);
}

.pin.driver {
  background: var(--blue);
}

.pin.customer {
  background: var(--orange);
}

.pin.mart {
  background: var(--green);
}

.pin.home {
  background: #6b3fa0;
}

.delivery-map-icon {
  border: 0;
  background: transparent;
}

.delivery-map-label {
  display: grid;
  width: 180px;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: 25px 21px;
  filter: drop-shadow(0 3px 5px rgba(24, 32, 42, 0.28));
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.delivery-map-label.selected {
  z-index: 3;
  transform: translateY(-5px) scale(1.04);
  filter: drop-shadow(0 7px 8px rgba(24, 32, 42, 0.42));
}

.delivery-map-order,
.delivery-map-customer,
.delivery-map-route {
  display: flex;
  align-items: center;
  min-width: 0;
  border: 2px solid #fff;
}

.delivery-map-label.done .delivery-map-order,
.delivery-map-label.done .delivery-map-customer {
  background: var(--green);
}

.delivery-map-label.done .delivery-map-route {
  background: var(--green-weak);
  color: #0b5f37;
}

.delivery-map-label.excluded .delivery-map-order,
.delivery-map-label.excluded .delivery-map-customer {
  background: #9c6500;
}

.delivery-map-label.excluded .delivery-map-route {
  background: #fff0bf;
  color: #704600;
}

.driver-map-icon {
  border: 0;
  background: transparent;
}

.driver-map-marker {
  display: flex;
  align-items: center;
  width: 210px;
  height: 56px;
  filter: drop-shadow(0 4px 6px rgba(24, 32, 42, 0.3));
}

.driver-car-motion {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--driver);
}

.driver-car {
  display: block;
  font-size: 27px;
  line-height: 1;
  transform: rotate(var(--heading, 0deg));
  transform-origin: center;
}

.driver-map-marker.moving .driver-car-motion {
  animation: driver-vehicle-motion 0.9s ease-in-out infinite alternate;
}

.driver-map-copy {
  display: flex;
  min-width: 0;
  max-width: 162px;
  min-height: 43px;
  margin-left: -5px;
  border: 2px solid #fff;
  border-radius: 0 7px 7px 0;
  background: var(--driver);
  color: #fff;
  padding: 5px 8px 5px 11px;
  flex-direction: column;
  justify-content: center;
}

.driver-map-copy strong,
.driver-map-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.driver-map-copy strong {
  font-size: 13px;
  line-height: 1.15;
}

.driver-map-copy small {
  margin-top: 3px;
  font-size: 10px;
  line-height: 1.1;
}

@keyframes driver-vehicle-motion {
  from { transform: translate(-2px, 1px); }
  to { transform: translate(3px, -1px); }
}

@media (prefers-reduced-motion: reduce) {
  .driver-map-marker.moving .driver-car-motion {
    animation: none;
  }
}

.delivery-map-order {
  grid-row: 1 / span 2;
  justify-content: center;
  border-radius: 8px 0 0 8px;
  background: var(--admin);
  color: #fff;
  font-size: 17px;
}

.delivery-map-customer {
  overflow: hidden;
  border-radius: 0 8px 0 0;
  background: var(--staff);
  color: #fff;
  padding: 0 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delivery-map-route {
  border-top: 0;
  border-radius: 0 0 8px 0;
  background: #fff;
  color: var(--ink);
  padding: 0 7px;
  font-size: 11px;
  white-space: nowrap;
}

@media (max-width: 1120px) {
  .shell,
  .work-grid {
    grid-template-columns: 1fr;
  }

  .route-panel,
  .map-panel {
    position: static;
  }

  .left-column {
    order: 2;
  }

  .main-column {
    order: 1;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .shell {
    padding: 10px;
  }

  .mart-bar,
  .form-grid,
  .unlock-row,
  .driver-auth-grid,
  .credential-grid {
    grid-template-columns: 1fr;
  }

  .field.wide {
    grid-column: span 1;
  }

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

  .role-tab {
    min-height: 76px;
    padding: 7px;
  }

  .role-tab strong {
    font-size: 14px;
  }

  .role-tab span {
    font-size: 11px;
  }

  .required-grid,
  .delivery-submit-row {
    grid-template-columns: 1fr;
  }

  .delivery-submit-row .primary-action {
    order: -1;
  }

  .route-row {
    grid-template-columns: 50px minmax(0, 1fr);
    gap: 9px;
    padding: 12px 10px;
  }

  .route-rank {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .route-meta {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  #map {
    height: 360px;
    min-height: 320px;
  }

  .result-row,
  .admin-row {
    grid-template-columns: 1fr;
  }

  .proof-viewer {
    gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .proof-viewer-stage {
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    gap: 5px;
  }

  .proof-viewer-bar {
    gap: 6px;
  }

  .proof-viewer-stage .proof-viewer-icon {
    width: 42px;
    min-height: 42px;
  }
}
