:root {
  color-scheme: light;
  --ink: #152024;
  --muted: #66757b;
  --line: #dbe4e5;
  --soft: #f5f8f7;
  --paper: #ffffff;
  --teal: #0f6b73;
  --teal-dark: #0b5158;
  --coral: #df6a4f;
  --gold: #d8a83f;
  --blue: #3f72af;
  --done: #2f8f62;
  --shadow: 0 18px 48px rgba(24, 40, 45, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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

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

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "workspace route"
    "controls route";
  min-height: 100dvh;
}

.workspace {
  grid-area: workspace;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 92px;
  padding: 22px 28px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.12;
}

h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

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

.route-summary span {
  min-height: 36px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 800;
}

.map-band {
  position: relative;
  min-height: 430px;
  flex: 1 1 auto;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.map-tools {
  position: absolute;
  right: 16px;
  top: 16px;
  z-index: 500;
  display: flex;
  gap: 8px;
}

.control-grid {
  grid-area: controls;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
  background: #edf3f1;
  border-top: 1px solid var(--line);
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 22px rgba(21, 32, 36, 0.06);
}

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

.panel p,
.settings-copy p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

label {
  display: grid;
  gap: 7px;
  color: #415157;
  font-size: 13px;
  font-weight: 800;
}

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

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 107, 115, 0.14);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.primary-button,
.ghost-button,
.icon-button,
.tab {
  border: 0;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.primary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
}

.primary-button {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 10px 20px rgba(15, 107, 115, 0.2);
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--teal-dark);
}

.ghost-button {
  border: 1px solid #c9d5d7;
  background: #fff;
  color: var(--ink);
}

.ghost-button:hover,
.ghost-button:focus-visible {
  background: var(--soft);
}

.compact {
  min-height: 40px;
  padding: 9px 12px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--ink);
  border: 1px solid rgba(21, 32, 36, 0.12);
  box-shadow: 0 10px 28px rgba(21, 32, 36, 0.12);
}

.icon-button:hover,
.icon-button:focus-visible {
  transform: translateY(-1px);
}

[data-icon] {
  width: 19px;
  height: 19px;
  display: inline-block;
  background: currentColor;
  mask-size: contain;
  mask-position: center;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
}

[data-icon="target"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3Cpath d='M12 2v3M12 19v3M2 12h3M19 12h3'/%3E%3C/svg%3E");
}

[data-icon="scan"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 7V5a2 2 0 0 1 2-2h2M17 3h2a2 2 0 0 1 2 2v2M21 17v2a2 2 0 0 1-2 2h-2M7 21H5a2 2 0 0 1-2-2v-2'/%3E%3Cpath d='M7 12h10'/%3E%3C/svg%3E");
}

[data-icon="route"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='6' cy='19' r='3'/%3E%3Ccircle cx='18' cy='5' r='3'/%3E%3Cpath d='M12 19h4a4 4 0 0 0 0-8H8a4 4 0 0 1 0-8h4'/%3E%3C/svg%3E");
}

[data-icon="sparkles"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m12 3 1.8 4.2L18 9l-4.2 1.8L12 15l-1.8-4.2L6 9l4.2-1.8L12 3Z'/%3E%3Cpath d='m5 14 1 2 2 1-2 1-1 2-1-2-2-1 2-1 1-2ZM19 14l.8 1.7 1.7.8-1.7.8L19 19l-.8-1.7-1.7-.8 1.7-.8L19 14Z'/%3E%3C/svg%3E");
}

[data-icon="upload"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 3v12'/%3E%3Cpath d='m7 8 5-5 5 5'/%3E%3Cpath d='M5 15v4h14v-4'/%3E%3C/svg%3E");
}

[data-icon="download"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 3v12'/%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3Cpath d='M5 19h14'/%3E%3C/svg%3E");
}

[data-icon="refresh"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 12a8 8 0 1 1-2.3-5.7'/%3E%3Cpath d='M20 4v5h-5'/%3E%3C/svg%3E");
}

[data-icon="navigation"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m12 2 7 20-7-4-7 4 7-20Z'/%3E%3C/svg%3E");
}

[data-icon="plus"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
}

[data-icon="check"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m5 12 4 4L19 6'/%3E%3C/svg%3E");
}

[data-icon="phone"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.4 19.4 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1.9.3 1.7.6 2.5a2 2 0 0 1-.4 2.1L8 9.6a16 16 0 0 0 6.4 6.4l1.3-1.3a2 2 0 0 1 2.1-.4c.8.3 1.6.5 2.5.6a2 2 0 0 1 1.7 2Z'/%3E%3C/svg%3E");
}

[data-icon="trash"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 6h18'/%3E%3Cpath d='M8 6V4h8v2'/%3E%3Cpath d='M19 6 18 20H6L5 6'/%3E%3C/svg%3E");
}

[data-icon="key"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='7.5' cy='14.5' r='4.5'/%3E%3Cpath d='M11 11 21 1M16 6l2 2M14 8l2 2'/%3E%3C/svg%3E");
}

[data-icon="pin"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 10c0 5-8 12-8 12S4 15 4 10a8 8 0 1 1 16 0Z'/%3E%3Ccircle cx='12' cy='10' r='3'/%3E%3C/svg%3E");
}

.address-tools {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.inline-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.inline-status.success {
  color: var(--done);
  font-weight: 800;
}

.inline-status.error {
  color: var(--coral);
  font-weight: 800;
}

.file-drop {
  min-height: 138px;
  border: 1px dashed #a8bbbf;
  border-radius: 8px;
  padding: 18px;
  display: grid;
  place-items: center;
  text-align: center;
  background: #f8fbfa;
  cursor: pointer;
}

.file-drop input {
  display: none;
}

.file-drop [data-icon] {
  width: 28px;
  height: 28px;
  color: var(--teal);
}

.file-drop small {
  color: var(--muted);
  font-weight: 600;
  line-height: 1.35;
}

.route-panel {
  grid-area: route;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 44px rgba(21, 32, 36, 0.08);
  overflow: hidden;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfa;
}

.tab {
  min-height: 40px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.tab.active {
  background: var(--ink);
  color: #fff;
}

.drawer-view {
  display: none;
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 16px;
}

.drawer-view.active {
  display: block;
}

.driver-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.route-list,
.raw-order-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.stop-card {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stop-card.done {
  background: #f3faf6;
  border-color: rgba(47, 143, 98, 0.34);
}

.stop-index {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: #fff;
  font-weight: 950;
}

.stop-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.status-pill {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 999px;
  background: #eef4f3;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.stop-card.done .status-pill {
  background: rgba(47, 143, 98, 0.12);
  color: var(--done);
}

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

.stop-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.stop-actions .icon-button {
  width: 40px;
  height: 40px;
  box-shadow: none;
}

.done-button {
  color: var(--done);
}

.call-button {
  color: var(--blue);
}

.nav-button {
  color: var(--teal);
}

.delete-button {
  color: var(--coral);
}

.order-form {
  display: grid;
  gap: 12px;
}

.settings-copy,
.api-box {
  display: grid;
  gap: 12px;
}

.api-box {
  margin-top: 18px;
}

.leaflet-control-attribution {
  font-size: 10px;
}

.number-marker {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  background: var(--coral);
  color: #fff;
  font-size: 13px;
  font-weight: 950;
  box-shadow: 0 8px 20px rgba(21, 32, 36, 0.24);
}

.number-marker.depot {
  background: var(--teal);
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "workspace"
      "route"
      "controls";
  }

  .route-panel {
    height: auto;
    min-height: 48dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .drawer-view {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 16px;
    min-height: 82px;
    align-items: flex-start;
  }

  h1 {
    font-size: 23px;
  }

  .map-band {
    min-height: 48dvh;
  }

  .control-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .panel {
    padding: 14px;
  }

  .field-row {
    grid-template-columns: 1fr 1fr;
  }

  .route-summary {
    flex-direction: column;
    gap: 6px;
  }

  .route-summary span {
    min-height: 32px;
    padding: 7px 10px;
    font-size: 13px;
  }

  .drawer-view {
    padding: 14px;
  }
}

@media (max-width: 440px) {
  .topbar {
    gap: 10px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .address-tools {
    grid-template-columns: 1fr;
  }

  .address-tools .ghost-button {
    width: 100%;
  }

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

  .driver-head .primary-button {
    width: 100%;
  }

  .stop-card {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .stop-index {
    width: 32px;
    height: 32px;
  }
}
