:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-strong: #eef3f4;
  --text: #172126;
  --muted: #65727a;
  --line: #d9e1e3;
  --primary: #236b73;
  --primary-dark: #164b52;
  --accent: #f2b84b;
  --success: #2f7d59;
  --shadow: 0 16px 40px rgba(23, 33, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
  font: inherit;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px 14px 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

h1 {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.1;
}

.route-count {
  min-width: 86px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary-dark);
  font-weight: 700;
  text-align: center;
}

.state-panel {
  min-height: 280px;
  display: grid;
  place-items: center;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
  box-shadow: var(--shadow);
}

.state-panel p {
  max-width: 440px;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.loader {
  width: 34px;
  height: 34px;
  border: 4px solid var(--surface-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.state-panel.is-error .loader {
  display: none;
}

.route-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.route-summary > div {
  min-height: 72px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

.route-summary strong {
  display: block;
  font-size: 1.08rem;
  line-height: 1.3;
}

.view-switch {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 0 14px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(246, 247, 245, 0.94);
  backdrop-filter: blur(10px);
}

.view-switch button {
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.view-switch button.is-active {
  background: var(--primary);
  color: #ffffff;
}

.points-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.point-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.point-body {
  padding: 16px;
}

.point-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.order-badge {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #322205;
  font-weight: 900;
}

.point-title {
  min-width: 0;
}

.point-title h2 {
  margin: 0 0 6px;
  font-size: 1.18rem;
  line-height: 1.25;
}

.status-pill {
  display: inline-flex;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 999px;
  background: #eaf5ef;
  color: var(--success);
  font-size: 0.8rem;
  font-weight: 800;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 14px 0;
}

.info-item {
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-strong);
}

.info-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.info-item p,
.address {
  margin: 0;
  line-height: 1.45;
}

.address {
  color: #2d383d;
  font-weight: 650;
}

.photo-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 14px 0;
}

.photo-frame {
  min-width: 0;
}

.photo-frame span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.photo-frame img,
.empty-photo {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  object-fit: cover;
}

.empty-photo {
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 12px;
  text-align: center;
}

.photo-thumbs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.photo-thumbs img {
  aspect-ratio: 4 / 3;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

.route-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.route-options-label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.78rem;
}

.primary-action,
.secondary-action {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.primary-action {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.route-option {
  min-height: 48px;
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--primary-dark);
}

.map-view {
  display: grid;
  gap: 12px;
}

.map-canvas {
  width: 100%;
  min-height: 360px;
  height: 64vh;
  max-height: 640px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  overflow: hidden;
}

.map-fallback {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  line-height: 1.45;
}

.map-points {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(245px, 82%);
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
}

.map-point-card {
  scroll-snap-align: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.map-point-card strong {
  display: block;
  margin-bottom: 6px;
  line-height: 1.3;
}

.map-point-card p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.35;
}

.leaflet-popup-content {
  margin: 10px 12px;
}

.popup-title {
  margin: 0 0 6px;
  font-weight: 800;
}

.popup-address {
  margin: 0;
  color: #4b5960;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (min-width: 560px) {
  .app-shell {
    padding: 22px 20px 40px;
  }

  .route-summary,
  .info-grid,
  .photo-grid,
  .actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 900px) {
  .points-list {
    grid-template-columns: 1fr 1fr;
  }

  h1 {
    font-size: 2rem;
  }
}
