:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-muted: #eef3f8;
  --border: #d8e1ea;
  --text: #17202a;
  --muted: #5f6f80;
  --accent: #0f766e;
  --accent-dark: #0b5d56;
  --danger: #b42318;
  --warning: #b7791f;
  --ok: #257a48;
  --shadow: 0 18px 45px rgba(21, 32, 43, 0.10);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  background: #15202a;
  color: #f8fafc;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand-block {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f8fafc;
  color: #15202a;
  font-weight: 800;
}

.brand-block strong {
  display: block;
  font-size: 1rem;
}

.brand-block small,
.sync-panel span {
  color: #b9c5d1;
}

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

.nav-item,
.secondary-action,
.primary-action,
.mini-action {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
}

.nav-item {
  background: transparent;
  color: #d8e1ea;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.sync-panel {
  margin-top: auto;
}

.sync-panel,
.snapshot-panel {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 8px;
}

.snapshot-panel {
  margin-top: 0;
}

.snapshot-panel input {
  background: #ffffff;
  border-color: transparent;
}

.snapshot-panel small {
  color: #b9c5d1;
  font-size: 0.78rem;
}

.workspace {
  padding: 28px;
  display: grid;
  gap: 22px;
  align-content: start;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.1rem;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.select-label,
.route-form label,
.delivery-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  min-height: 40px;
  padding: 8px 10px;
}

textarea {
  min-height: 74px;
  resize: vertical;
}

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

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric strong {
  display: block;
  font-size: 1.7rem;
  line-height: 1;
}

.metric strong.money-value {
  font-size: 1.04rem;
  line-height: 1.15;
  white-space: nowrap;
}

.metric span {
  color: var(--muted);
  font-size: 0.86rem;
}

.hidden {
  display: none !important;
}

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

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

.delivery-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 12px;
}

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

.delivery-card,
.driver-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.delivery-card header,
.driver-card header {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.delivery-card h3,
.driver-card h3 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.muted,
.delivery-card p,
.driver-card p {
  color: var(--muted);
}

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

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
}

.tag.warn {
  background: #fff7e6;
  color: var(--warning);
}

.tag.danger {
  background: #ffebe8;
  color: var(--danger);
}

.tag.ok {
  background: #e8f6ee;
  color: var(--ok);
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

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

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

.secondary-action,
.mini-action {
  background: var(--surface-muted);
  color: var(--text);
}

.mini-action {
  min-height: 34px;
  justify-self: start;
}

.route-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
}

.route-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 10px;
  box-shadow: var(--shadow);
}

.route-summary {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 8px;
  box-shadow: var(--shadow);
}

.route-summary strong {
  font-size: 1rem;
}

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

.summary-item {
  background: var(--surface-muted);
  border-radius: 8px;
  padding: 10px;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.summary-item b {
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.route-stops {
  margin: 12px 0 0;
  padding-left: 22px;
  display: grid;
  gap: 8px;
}

.route-stops li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.map-panel {
  min-height: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.map-canvas {
  position: relative;
  min-height: 560px;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.10) 1px, transparent 1px),
    linear-gradient(rgba(15, 118, 110, 0.10) 1px, transparent 1px),
    #eef5f7;
  background-size: 42px 42px;
}

.map-canvas.google-map-live {
  background: #dbe7ed;
}

.map-setup {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 28px;
  text-align: center;
  background:
    linear-gradient(rgba(255, 255, 255, 0.70), rgba(255, 255, 255, 0.78)),
    linear-gradient(90deg, rgba(15, 118, 110, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(15, 118, 110, 0.12) 1px, transparent 1px),
    #e6f0f3;
  background-size: auto, 42px 42px, 42px 42px, auto;
}

.map-setup-label {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: #e8f6ee;
  color: var(--ok);
  font-size: 0.78rem;
  font-weight: 800;
}

.map-setup strong {
  max-width: 520px;
  font-size: clamp(1.2rem, 2vw, 1.6rem);
}

.map-setup p {
  max-width: 560px;
  color: var(--muted);
  margin-bottom: 0;
}

.map-setup small {
  color: var(--muted);
  font-weight: 800;
}

.map-action {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--accent);
  color: #ffffff;
  text-decoration: none;
}

.map-action:hover {
  background: var(--accent-dark);
}

.map-pin {
  position: absolute;
  min-width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #ffffff;
  font-weight: 900;
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.25);
}

.map-pin.store {
  background: #15202a;
}

.route-line-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.driver-list {
  display: grid;
  gap: 12px;
  max-width: 760px;
}

.driver-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  background: #15202a;
  color: #ffffff;
  padding: 13px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-weight: 700;
}

@media (max-width: 1020px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .metrics-grid,
  .delivery-list,
  .route-layout {
    grid-template-columns: 1fr;
  }

  .map-panel,
  .map-canvas {
    min-height: 420px;
  }
}

@media (max-width: 700px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .section-heading {
    display: grid;
  }

  .toolbar,
  .form-grid {
    grid-template-columns: 1fr;
    display: grid;
  }
}
