:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e6e8ec;
  --border-strong: #d3d7dd;
  --text: #111827;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --accent: #d62828;
  --accent-hover: #b91c1c;
  --accent-soft: #fef2f2;
  --accent-ring: rgba(214, 40, 40, 0.16);
  --ok: #16a34a;
  --ok-soft: #ecfdf3;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 10px 32px rgba(17, 24, 39, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── Шапка ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
}

/* ── Контейнер ─────────────────────────────────────────── */
.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 44px 20px 72px;
}

/* ── Hero (красная полоса с машинкой) ─────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
  padding: 40px 36px;
  border-radius: var(--radius);
  background: linear-gradient(120deg, #8f1a1a, #d62828 52%, #ef4444);
  color: #fff;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.hero .tagline {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.hero .sub {
  margin: 0;
  max-width: 560px;
  font-size: 15.5px;
  line-height: 1.6;
  color: #ffe8e8;
}

/* Дорожка машинки под кнопкой — индикатор загрузки. */
.car-track {
  position: relative;
  width: 100%;
  height: 76px;
  margin-top: 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px dashed var(--border-strong);
  overflow: hidden;
}

#car {
  position: absolute;
  bottom: 4px;
  left: 0;
  width: 130px;
  height: auto;
  pointer-events: none;
  will-change: transform;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.2));
}

#car svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ── Карточка-панель ───────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

section.panel { padding: 28px; }

/* ── Форма ─────────────────────────────────────────────── */
.form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px 20px;
}

.field { display: flex; flex-direction: column; min-width: 0; }
.field-full { grid-column: 1 / -1; }

.field > label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="month"],
.field select {
  width: 100%;
  padding: 11px 13px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
  background: #fafbfc;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  appearance: none;
}

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.note {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.45;
}

/* ── Расширенные настройки (сворачиваемый блок) ────────── */
.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

.btn-link:hover { color: var(--accent-hover); }

.btn-link .chev { transition: transform 0.15s; }
.btn-link[aria-expanded="true"] .chev { transform: rotate(90deg); }

.advanced {
  grid-column: 1 / -1;
  padding: 18px;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.advanced-note {
  margin: 0 0 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.per-day-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.per-day-row {
  display: grid;
  grid-template-columns: 40px 1fr 110px;
  gap: 9px;
  align-items: center;
}

.pd-day {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.pd-home,
.pd-cap {
  width: 100%;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}

.pd-home:focus,
.pd-cap:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.pd-cap { text-align: center; }

/* Лимит точек в день — ровная сетка */
.capacity-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.cap-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.cap-name {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
}

.cap-item input {
  text-align: center;
  padding: 10px 6px;
}

/* ── Зоны загрузки ─────────────────────────────────────── */
.dropzones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 128px;
  padding: 20px;
  text-align: center;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  background: #fafbfc;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.dropzone:hover { border-color: var(--accent); color: var(--text); }

.dropzone.filled {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.dz-icon { color: var(--text-faint); transition: color 0.15s; }
.dropzone:hover .dz-icon,
.dropzone.filled .dz-icon { color: var(--accent); }

.dz-title { font-size: 14px; font-weight: 600; color: var(--text); }
.dz-label { font-size: 12.5px; color: var(--text-muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone.filled .dz-label { color: var(--accent); }

/* ── Кнопка + прогресс ─────────────────────────────────── */
.cta { align-items: flex-start; }

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 26px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
}

.primary:hover:not(:disabled) { background: var(--accent-hover); }
.primary:active:not(:disabled) { transform: translateY(1px); }
.primary:disabled { opacity: 0.4; cursor: not-allowed; }

.progress {
  width: 100%;
  height: 5px;
  margin-top: 14px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.25s ease;
}

.progress.active { opacity: 1; }

.stage {
  margin: 12px 0 0;
  min-height: 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
}

.hint {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Статус ────────────────────────────────────────────── */
.status {
  margin: 20px 0;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: #eef2f7;
  font-size: 14.5px;
  color: var(--text);
}

.status.error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* ── Результат ─────────────────────────────────────────── */
.result { margin-top: 20px; }

.result-head { display: flex; align-items: center; gap: 10px; }

.result-badge {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok);
}

.done { margin: 0; font-size: 19px; font-weight: 700; }

.result-meta { margin: 12px 0 16px; font-size: 14.5px; color: var(--text-muted); }

/* ── Карта ─────────────────────────────────────────────── */
#map-section { margin-top: 20px; }

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.map-toolbar h2 { margin: 0; font-size: 17px; }

.day-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.day-filter select {
  padding: 8px 32px 8px 11px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: #fafbfc;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

.day-filter select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.day-filter optgroup { font-style: normal; font-weight: 600; color: var(--text-muted); }

#map { height: 440px; border-radius: var(--radius-sm); overflow: hidden; }

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 14px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(17, 24, 39, 0.08);
}

/* ── Подсказка на карте ────────────────────────────────── */
.leaflet-tooltip.point-tooltip {
  padding: 7px 9px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: 0 4px 14px rgba(17, 24, 39, 0.12);
  color: var(--text);
}
.leaflet-tooltip.point-tooltip::before { display: none; }
.point-tooltip .pt-code {
  display: block;
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
}
.point-tooltip .pt-addr {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.point-tooltip .pt-meta {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.point-tooltip .pt-meta b {
  color: var(--text);
  font-weight: 600;
}

.hidden { display: none !important; }

/* ── Модальное окно подтверждения ──────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(2px);
}

.modal {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 24px 60px rgba(17, 24, 39, 0.25);
}

.modal-title {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 700;
}

.modal-text {
  margin: 0 0 20px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-secondary {
  padding: 11px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover { background: #f3f4f6; }

/* ── Адаптив ───────────────────────────────────────────── */
@media (max-width: 680px) {
  .container { padding: 28px 16px 56px; }
  .hero { padding: 28px 22px; }
  .hero h1 { font-size: 25px; }
  .form { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .dropzones { grid-template-columns: 1fr; }
  section.panel { padding: 22px; }
  #map { height: 300px; }
  .capacity-grid { grid-template-columns: repeat(3, 1fr); }
  .per-day-row { grid-template-columns: 36px 1fr 82px; gap: 7px; }
  .car-track { height: 64px; }
  #car { width: 100px; }
}

/* ── Подвал ─────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 20px 16px 30px;
  color: #9ca3af;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.site-footer .footer-handle {
  color: #d62828;
  font-weight: 600;
  text-decoration: none;
}
.site-footer .footer-handle:hover {
  text-decoration: underline;
}

/* ── Подсказки адресов (автодополнение DaData) ─────────────── */
.address-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 3px;
  z-index: 1000;
  background: #fff;
  border: 1px solid #d62828;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  max-height: 240px;
  overflow-y: auto;
}
.address-suggest-item {
  padding: 9px 12px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  line-height: 1.35;
}
.address-suggest-item + .address-suggest-item {
  border-top: 1px solid #f0f0f0;
}
.address-suggest-item:hover,
.address-suggest-item:focus {
  background: #fbeaea;
}
