.delivery-app {
  --delivery-green: #008b47;
  --delivery-green-dark: #065f3b;
  --delivery-green-soft: #eaf7ef;
  --delivery-ink: #153127;
  --delivery-muted: #61756c;
  --delivery-line: #d8e6dd;
  position: relative;
  display: grid;
  gap: 18px;
  color: var(--delivery-ink);
}

.delivery-app button,
.delivery-app input,
.delivery-app select,
.delivery-app textarea {
  letter-spacing: 0;
}

.delivery-loading {
  position: fixed;
  z-index: 900;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(245, 249, 247, .72);
  backdrop-filter: blur(2px);
}

.delivery-loading[hidden] { display: none; }

.delivery-loading span {
  border: 1px solid var(--delivery-line);
  border-radius: 8px;
  background: #fff;
  padding: 14px 18px;
  color: var(--delivery-green-dark);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(21, 49, 39, .12);
}

.delivery-header,
.delivery-section-head,
.delivery-map-head,
.delivery-driver-route {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
}

.delivery-header {
  padding: 2px 2px 0;
}

.delivery-header h2 {
  margin: 3px 0 4px;
  color: var(--delivery-ink);
  font-size: clamp(25px, 3vw, 36px);
  line-height: 1.08;
}

.delivery-header p,
.delivery-section-head p,
.delivery-driver-route p {
  margin: 0;
  color: var(--delivery-muted);
  font-size: 13px;
  line-height: 1.55;
}

.delivery-eyebrow {
  margin: 0 !important;
  color: var(--delivery-green) !important;
  font-size: 10px !important;
  font-weight: 900 !important;
  letter-spacing: .08em !important;
  text-transform: uppercase;
}

.delivery-header-actions,
.delivery-dispatch-actions,
.delivery-route-summary,
.delivery-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.delivery-button,
.delivery-icon-button,
.delivery-row-actions button {
  min-height: 40px;
  border: 1px solid var(--delivery-line);
  border-radius: 8px;
  background: #fff;
  color: var(--delivery-ink);
  font-size: 12px;
  font-weight: 850;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.delivery-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
}

.delivery-button:hover,
.delivery-row-actions button:hover {
  border-color: #91c7a7;
  background: #f4fbf7;
}

.delivery-button.primary,
.delivery-row-actions button.primary {
  border-color: var(--delivery-green);
  background: var(--delivery-green);
  color: #fff;
}

.delivery-button.primary:hover,
.delivery-row-actions button.primary:hover {
  border-color: var(--delivery-green-dark);
  background: var(--delivery-green-dark);
}

.delivery-button.large { min-height: 48px; padding-inline: 20px; }
.delivery-icon-button { display: grid; width: 42px; padding: 0; place-items: center; }
.delivery-icon-button:hover { background: var(--delivery-green-soft); color: var(--delivery-green-dark); }

.delivery-controls {
  display: grid;
  grid-template-columns: 190px minmax(260px, 1fr) 240px;
  gap: 12px;
  border: 1px solid var(--delivery-line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  box-shadow: 0 8px 20px rgba(21, 49, 39, .05);
}

.delivery-controls label,
.delivery-form-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: #52665d;
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.delivery-controls input,
.delivery-controls select,
.delivery-form-grid input,
.delivery-form-grid select,
.delivery-form-grid textarea,
.delivery-dispatch-actions select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--delivery-line);
  border-radius: 7px;
  background: #fff;
  padding: 9px 11px;
  color: var(--delivery-ink);
  font-size: 13px;
  font-weight: 700;
  outline: none;
  text-transform: none;
}

.delivery-controls input:focus,
.delivery-controls select:focus,
.delivery-form-grid input:focus,
.delivery-form-grid select:focus,
.delivery-form-grid textarea:focus {
  border-color: var(--delivery-green);
  box-shadow: 0 0 0 3px rgba(0, 139, 71, .1);
}

.delivery-search > div,
.delivery-field-action,
.delivery-time-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.delivery-search > div {
  border: 1px solid var(--delivery-line);
  border-radius: 7px;
  padding-inline: 11px;
}

.delivery-search > div:focus-within {
  border-color: var(--delivery-green);
  box-shadow: 0 0 0 3px rgba(0, 139, 71, .1);
}

.delivery-search input { border: 0; padding-inline: 0; box-shadow: none !important; }
.delivery-search svg { width: 16px; color: #7a8e84; }

.delivery-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--delivery-line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.delivery-metric {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 88px;
  border-right: 1px solid var(--delivery-line);
  padding: 16px;
}

.delivery-metric:last-child { border-right: 0; }
.delivery-metric > span { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border-radius: 7px; background: var(--delivery-green-soft); color: var(--delivery-green); }
.delivery-metric strong { display: block; font-size: 24px; line-height: 1; }
.delivery-metric small { display: block; margin-top: 7px; color: var(--delivery-muted); font-size: 11px; font-weight: 750; }
.delivery-metric.metric-4 > span { background: #fff4e5; color: #b26c00; }

.delivery-dispatch-band,
.delivery-map-band,
.delivery-list-band,
.delivery-driver-route {
  border: 1px solid var(--delivery-line);
  border-radius: 8px;
  background: #fff;
}

.delivery-dispatch-band,
.delivery-driver-route { padding: 18px; }
.delivery-section-head h3,
.delivery-map-head h3,
.delivery-driver-route h3 { margin: 3px 0 5px; color: var(--delivery-ink); font-size: 18px; }
.delivery-section-head.compact { align-items: center; }
.delivery-dispatch-actions { justify-content: flex-end; }
.delivery-dispatch-actions select { width: 220px; }

.delivery-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  border-radius: 7px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 750;
}

.delivery-notice.warning { background: #fff6e8; color: #8b5a0a; }

.delivery-map-band { overflow: hidden; }
.delivery-map-head { align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--delivery-line); }
.delivery-route-summary { color: var(--delivery-muted); font-size: 11px; font-weight: 800; }
.delivery-route-summary span { display: inline-flex; align-items: center; gap: 5px; border-left: 1px solid var(--delivery-line); padding-left: 10px; }
.delivery-route-summary span:first-child { border-left: 0; padding-left: 0; }
.delivery-route-summary svg { width: 14px; color: var(--delivery-green); }

.delivery-map {
  width: 100%;
  height: 390px;
  background: #edf4f0;
}

.delivery-map-placeholder {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #71867b;
  font-size: 13px;
  font-weight: 750;
}

.delivery-map-placeholder svg { width: 28px; height: 28px; }
.leaflet-container { font-family: inherit; }

.delivery-live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #b9dfc8;
  border-radius: 999px;
  background: var(--delivery-green-soft);
  padding: 9px 13px;
  color: var(--delivery-green-dark);
  font-size: 11px;
  font-weight: 850;
}

.delivery-live-indicator i { width: 8px; height: 8px; border-radius: 50%; background: #00a65a; box-shadow: 0 0 0 4px rgba(0, 166, 90, .14); }

.delivery-list-band { overflow: hidden; }
.delivery-list-band > .delivery-section-head { padding: 17px 18px; border-bottom: 1px solid var(--delivery-line); }
.delivery-sync { display: inline-flex; align-items: center; gap: 6px; color: #6b7f75; font-size: 10px; font-weight: 800; }
.delivery-sync svg { width: 14px; }

.delivery-table-head,
.delivery-row {
  display: grid;
  grid-template-columns: 36px minmax(170px, .72fr) minmax(260px, 1.45fr) minmax(160px, .72fr) minmax(130px, .58fr) minmax(170px, .75fr);
  gap: 12px;
  align-items: center;
}

.delivery-table-head {
  min-height: 42px;
  border-bottom: 1px solid var(--delivery-line);
  background: #f5f9f6;
  padding: 8px 14px;
  color: #708278;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.delivery-row {
  min-height: 104px;
  border-bottom: 1px solid var(--delivery-line);
  padding: 13px 14px;
  transition: background .16s ease;
}

.delivery-row:last-child { border-bottom: 0; }
.delivery-row:hover { background: #fbfdfc; }
.delivery-row.is-current { box-shadow: inset 4px 0 0 var(--delivery-green); background: #f7fcf9; }
.delivery-check { display: grid; place-items: center; }
.delivery-check input,
.delivery-table-head input { width: 16px; height: 16px; accent-color: var(--delivery-green); }

.delivery-sequence { display: flex; align-items: center; gap: 10px; min-width: 0; }
.delivery-sequence > span { display: grid; width: 30px; height: 30px; flex: 0 0 30px; place-items: center; border-radius: 50%; background: var(--delivery-green-soft); color: var(--delivery-green-dark); font-size: 11px; font-weight: 900; }
.delivery-row strong { display: block; color: var(--delivery-ink); font-size: 12px; }
.delivery-row small,
.delivery-row span { color: var(--delivery-muted); font-size: 10px; line-height: 1.45; }
.delivery-customer,
.delivery-driver { min-width: 0; }
.delivery-customer > span,
.delivery-customer > small,
.delivery-driver > span,
.delivery-sequence small { display: block; margin-top: 4px; }
.delivery-customer em { display: inline-flex; align-items: center; gap: 5px; margin-top: 5px; color: #a56500; font-size: 10px; font-style: normal; font-weight: 800; }
.delivery-customer em svg { width: 13px; }

.delivery-status {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 9px;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
}

.delivery-status.neutral { background: #eef2f0; color: #66776f; }
.delivery-status.ready { background: #e8f7ee; color: #05713f; }
.delivery-status.assigned { background: #edf5ee; color: #426a55; }
.delivery-status.route { background: #dcf5e7; color: #006b3c; }
.delivery-status.arrived { background: #d8f3e2; color: #005d34; box-shadow: inset 0 0 0 1px #9cd0b1; }
.delivery-status.delivered { background: #dff7e8; color: #006338; }
.delivery-status.issue { background: #fff0e0; color: #9b5700; }

.delivery-row-actions { justify-content: flex-start; }
.delivery-row-actions button { display: inline-flex; min-height: 34px; align-items: center; gap: 5px; padding: 7px 9px; font-size: 10px; }
.delivery-row-actions svg { width: 14px; }

.delivery-empty,
.delivery-empty-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--delivery-muted);
}

.delivery-empty { min-height: 420px; flex-direction: column; text-align: center; }
.delivery-empty h2 { margin: 0; color: var(--delivery-ink); }
.delivery-empty p { margin: 0 0 10px; }
.delivery-empty-inline { min-height: 110px; }
.delivery-empty-inline > svg { width: 28px; height: 28px; color: #8da197; }
.delivery-empty-inline strong,
.delivery-empty-inline span { display: block; }
.delivery-empty-inline span { margin-top: 3px; font-size: 11px; }

.delivery-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 36px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--delivery-ink);
  box-shadow: 0 28px 80px rgba(7, 38, 25, .25);
}

.delivery-dialog.small { width: min(520px, calc(100vw - 28px)); }
.delivery-dialog::backdrop { background: rgba(12, 30, 23, .52); backdrop-filter: blur(3px); }
.delivery-dialog form { display: flex; max-height: calc(100vh - 36px); flex-direction: column; }
.delivery-dialog header,
.delivery-dialog footer { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px; }
.delivery-dialog header { border-bottom: 1px solid var(--delivery-line); }
.delivery-dialog footer { justify-content: flex-end; border-top: 1px solid var(--delivery-line); background: #f8fbf9; }
.delivery-dialog header h3 { margin: 3px 0 4px; font-size: 21px; }
.delivery-dialog header p:not(.delivery-eyebrow) { margin: 0; color: var(--delivery-muted); font-size: 12px; }
.delivery-dialog header > button { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border: 1px solid var(--delivery-line); border-radius: 7px; background: #fff; color: #61756c; }
.delivery-dialog header > button:hover { background: var(--delivery-green-soft); color: var(--delivery-green-dark); }

.delivery-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  overflow-y: auto;
  padding: 20px;
}

.delivery-form-grid .wide { grid-column: 1 / -1; }
.delivery-form-grid textarea { resize: vertical; }
.delivery-form-grid label small { color: var(--delivery-muted); font-size: 10px; font-weight: 650; text-transform: none; }
.delivery-field-action input { flex: 1; }
.delivery-field-action button { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; border: 1px solid var(--delivery-line); border-radius: 7px; background: var(--delivery-green-soft); color: var(--delivery-green-dark); }
.delivery-time-range input { min-width: 0; }
.delivery-template-note { display: flex; align-items: flex-start; gap: 9px; border-radius: 7px; background: var(--delivery-green-soft); padding: 11px 12px; color: #315f49; font-size: 11px; font-weight: 750; line-height: 1.45; }
.delivery-template-note svg { flex: 0 0 16px; width: 16px; }
.delivery-form-feedback { min-height: 20px; margin: -4px 20px 8px; color: #a05a00; font-size: 11px; font-weight: 750; }

.delivery-timeline { max-height: 60vh; overflow-y: auto; padding: 12px 20px 20px; }
.delivery-timeline article { display: grid; grid-template-columns: 32px 1fr; gap: 12px; position: relative; padding: 10px 0; }
.delivery-timeline article::after { content: ""; position: absolute; top: 38px; bottom: -10px; left: 15px; width: 1px; background: var(--delivery-line); }
.delivery-timeline article:last-child::after { display: none; }
.delivery-timeline article > span { display: grid; z-index: 1; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: var(--delivery-green-soft); color: var(--delivery-green); }
.delivery-timeline article svg { width: 15px; }
.delivery-timeline p { margin: 4px 0; color: var(--delivery-muted); font-size: 11px; }
.delivery-timeline small { color: #84958d; font-size: 10px; }
.delivery-dialog-loading { min-height: 240px; display: grid; place-items: center; color: var(--delivery-muted); font-weight: 750; }

.delivery-toast {
  position: fixed;
  z-index: 1200;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 32px));
  border: 1px solid #9bd0af;
  border-radius: 8px;
  background: #f2fbf5;
  padding: 13px 16px;
  color: #155d38;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 16px 42px rgba(12, 55, 36, .18);
}

.delivery-toast.error { border-color: #f0b6b0; background: #fff2f0; color: #9a342b; }
.delivery-toast.warning { border-color: #e7c78e; background: #fff8ea; color: #8b5a0a; }
.delivery-toast[hidden] { display: none; }

@media (max-width: 1500px) {
  .delivery-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .delivery-metric { border-bottom: 1px solid var(--delivery-line); }
  .delivery-table-head { display: none; }
  .delivery-row { grid-template-columns: 36px minmax(150px, .7fr) minmax(220px, 1.3fr) minmax(140px, .7fr); }
  .delivery-row > div:nth-last-child(2), .delivery-row > div:last-child { grid-column: auto; }
}

@media (max-width: 760px) {
  .delivery-app { gap: 12px; }
  .delivery-header,
  .delivery-section-head,
  .delivery-map-head,
  .delivery-driver-route { flex-direction: column; align-items: stretch; }
  .delivery-header-actions,
  .delivery-dispatch-actions { justify-content: stretch; }
  .delivery-header-actions .delivery-button,
  .delivery-dispatch-actions > * { flex: 1; }
  .delivery-controls { grid-template-columns: 1fr; }
  .delivery-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .delivery-metric { min-height: 76px; padding: 12px; }
  .delivery-metric strong { font-size: 21px; }
  .delivery-map { height: 310px; }
  .delivery-route-summary { align-items: flex-start; }
  .delivery-route-summary span { border-left: 0; padding-left: 0; }
  .delivery-row { grid-template-columns: 28px 1fr; gap: 9px; padding: 14px 12px; }
  .delivery-row > div { grid-column: 2; }
  .delivery-row > .delivery-check { grid-column: 1; grid-row: 1 / span 5; align-self: start; padding-top: 7px; }
  .delivery-sequence { grid-row: 1; }
  .delivery-customer { grid-row: 2; }
  .delivery-driver { grid-row: 3; }
  .delivery-row-actions { grid-row: 5; }
  .delivery-row-actions button { flex: 1; justify-content: center; }
  .delivery-form-grid { grid-template-columns: 1fr; }
  .delivery-form-grid .wide { grid-column: auto; }
  .delivery-dialog footer { flex-direction: column-reverse; }
  .delivery-dialog footer .delivery-button { width: 100%; }
  .delivery-live-indicator { align-self: flex-start; }
}
