:root {
  --bg: #eef3f8;
  --surface: rgba(255, 255, 255, 0.95);
  --surface-soft: rgba(248, 251, 254, 0.98);
  --surface-strong: rgba(242, 247, 252, 0.98);
  --line: #d8e2ed;
  --line-strong: #c4d1de;
  --text: #17324f;
  --muted: #6d829b;
  --primary: #1870db;
  --primary-deep: #104d9b;
  --primary-soft: #eaf2fd;
  --shadow: 0 18px 40px rgba(16, 39, 68, 0.12);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Manrope", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

.route-map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.topbar,
.sidebar,
.results-panel {
  position: absolute;
  z-index: 10;
}

.topbar,
.panel,
.results-panel {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.topbar {
  top: 12px;
  left: 12px;
  right: 12px;
  height: 60px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
}

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

.brand-logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
}

.brand-text {
  display: grid;
  gap: 4px;
}

.topbar-brand strong {
  font-size: 1.24rem;
  line-height: 1;
  letter-spacing: -0.04em;
}

.panel-kicker {
  display: inline-flex;
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-metrics {
  display: flex;
  gap: 8px;
  align-items: center;
}

.metric-pill {
  min-width: 82px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  display: grid;
  gap: 2px;
}

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

.metric-pill strong {
  font-size: 0.8rem;
}

.user-pill {
  min-width: 146px;
}

.auth-trigger {
  cursor: pointer;
  text-align: left;
}

.sidebar {
  top: 84px;
  left: 12px;
  width: 370px;
  bottom: 12px;
}

.panel {
  border-radius: 22px;
  padding: 14px;
}

.planner-panel {
  height: 100%;
  overflow: auto;
}

.planner-group {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-strong);
}

.results-panel {
  top: 84px;
  right: 12px;
  width: 302px;
  bottom: 12px;
  border-radius: 22px;
  padding: 12px;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 10px;
}

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

.panel-head h2,
.section-title h3 {
  margin: 4px 0 0;
  font-size: 1rem;
  letter-spacing: -0.03em;
}

.section-title-inline {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.section-title-inline p {
  margin: 0;
}

.panel-form,
.stops-section,
.saved-routes,
.ordered-stops {
  display: grid;
  gap: 10px;
}

.stops-container {
  display: grid;
  gap: 8px;
}

.auth-modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(14, 29, 46, 0.2);
  display: grid;
  place-items: start end;
  padding: 84px 14px 14px;
}

.auth-modal-card {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
  padding: 12px;
  backdrop-filter: blur(14px);
}

.field,
.check-field {
  display: grid;
  gap: 5px;
}

.field.compact-field input {
  background: rgba(255, 255, 255, 0.75);
}

.field span,
.check-field span,
.section-title p,
.status-banner,
.saved-route-item span,
.ordered-stop-address,
.ordered-stop-meta,
.empty-state {
  font-size: 0.75rem;
  color: var(--muted);
}

input,
select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(26, 115, 232, 0.55);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

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

.check-field {
  align-content: end;
  justify-items: start;
}

.check-field input {
  width: 16px;
  height: 16px;
  margin: 0;
}

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

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

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

.export-actions {
  margin-top: -2px;
}

.primary-button,
.secondary-button,
.ghost-button,
.inline-button,
.remove-button {
  height: 34px;
  border-radius: 11px;
  padding: 0 12px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
}

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

.secondary-button,
.inline-button {
  background: var(--primary-soft);
  color: var(--primary-deep);
}

.ghost-button,
.remove-button {
  background: var(--surface-soft);
  color: var(--muted);
  border-color: var(--line);
}

.stop-card,
.saved-route-item,
.summary-card,
.status-banner {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  border-radius: 16px;
}

.stop-card,
.saved-route-item {
  padding: 10px;
}

.origin-top {
  margin-bottom: 4px;
}

.stop-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stop-top,
.saved-route-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

.stop-index {
  font-size: 0.73rem;
  font-weight: 800;
  color: var(--primary-deep);
}

.stop-name-toggle {
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  color: var(--primary-deep);
  background: transparent;
  border-color: transparent;
}

.stop-name-field {
  margin-top: -2px;
}

.stop-card .remove-button {
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.7rem;
}

.stop-card .input-action {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.stop-card .stop-address {
  height: 38px;
  border-radius: 999px;
  padding: 0 14px;
}

.planner-group .input-action input {
  height: 38px;
  border-radius: 999px;
  padding: 0 14px;
}

.planner-group .input-action .inline-button {
  height: 30px;
  border-radius: 999px;
  padding: 0 10px;
}

.stop-card .stop-geocode-button {
  height: 30px;
  border-radius: 999px;
  padding: 0 10px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.suggestions {
  display: grid;
  gap: 6px;
}

.suggestion-item {
  text-align: left;
  display: grid;
  gap: 2px;
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 11px;
  padding: 9px 10px;
  cursor: pointer;
}

.suggestion-item strong {
  font-size: 0.82rem;
}

.suggestion-item span {
  font-size: 0.73rem;
  color: var(--muted);
}

.status-banner {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  line-height: 1.45;
}

.loading-progress {
  height: 7px;
  border-radius: 999px;
  background: rgba(196, 209, 222, 0.45);
  overflow: hidden;
  border: 1px solid rgba(196, 209, 222, 0.55);
}

.loading-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1870db 0%, #4ea1ff 100%);
  transition: width 180ms ease;
}

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

.summary-card {
  padding: 11px 10px;
}

.summary-card span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
}

.summary-card strong {
  display: block;
  margin-top: 4px;
  font-size: 0.92rem;
}

.ordered-stops,
.saved-routes {
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: auto;
}

.ordered-stop {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 14px;
}

.ordered-stop-badge {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 0.78rem;
  font-weight: 800;
}

.map-marker {
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 16px rgba(17, 41, 74, 0.18);
}

.map-marker span {
  transform: rotate(45deg);
  font-size: 0.76rem;
  font-weight: 800;
}

.map-marker-origin {
  background: #0d4fa8;
}

.map-marker-stop {
  background: var(--primary);
}

.ordered-stop-title {
  display: block;
  font-size: 0.85rem;
}

.history-section {
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid rgba(196, 209, 222, 0.65);
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .topbar {
    position: relative;
    inset: auto;
    margin: 10px;
  }

  .route-map {
    position: fixed;
    inset: 0;
  }

  .sidebar,
  .results-panel,
  .auth-modal {
    position: relative;
    inset: auto;
    width: auto;
    margin: 0 10px 10px;
  }

  .results-panel {
    top: auto;
    right: auto;
    bottom: auto;
    max-height: none;
  }

  .auth-modal {
    background: transparent;
    padding: 0;
  }

  .auth-modal-card {
    width: auto;
  }
}

@media (max-width: 760px) {
  .topbar {
    height: auto;
    padding: 10px;
    align-items: start;
    flex-direction: column;
    gap: 10px;
  }

  .topbar-metrics {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-row,
  .truck-grid,
  .results-summary {
    grid-template-columns: 1fr;
  }
}
