:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --yellow: #ca8a04;
  --yellow-bg: #fef9c3;
  --orange: #ea580c;
  --orange-bg: #ffedd5;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --purple: #7c3aed;
  --purple-bg: #ede9fe;
  --primary: #0f172a;
  --primary-hover: #1e293b;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.12);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

.top-bar {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.top-bar > * { pointer-events: auto; }

.city-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.city-btn .chevron { opacity: 0.5; }

.top-bar__right { display: flex; gap: 8px; align-items: center; }

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.talon-btn {
  width: auto;
  padding: 0 14px;
  border-radius: 999px;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
  border-color: var(--green-bg);
  background: var(--green-bg);
}

.map-wrap {
  position: relative;
  height: 55vh;
  min-height: 320px;
  max-height: 520px;
}

#map { width: 100%; height: 100%; background: #e8eef4; z-index: 1; }

.map-status {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}

.pulse {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.legend {
  position: absolute;
  bottom: 16px;
  left: 12px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot--green { background: var(--green); }
.dot--red { background: var(--red); }

.map-controls {
  position: absolute;
  right: 12px;
  bottom: 16px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.map-ctrl {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.station-marker {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  cursor: pointer;
}

.station-marker--ok { background: var(--green); }
.station-marker--low { background: var(--yellow); }
.station-marker--queue { background: var(--orange); }
.station-marker--empty { background: var(--red); }
.station-marker--limit { background: var(--purple); }

.safety-card {
  position: absolute;
  top: 60px;
  right: 12px;
  z-index: 500;
  width: min(280px, calc(100vw - 80px));
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.safety-card.hidden { display: none; }
.safety-card__close { position: absolute; top: 8px; right: 8px; border: none; background: none; cursor: pointer; }
.safety-card__title { font-size: 15px; font-weight: 700; margin-bottom: 8px; color: var(--green); }
.safety-card__list { list-style: none; margin-bottom: 8px; font-size: 12px; color: var(--text-secondary); }
.safety-card__text { font-size: 11px; color: var(--text-secondary); margin-bottom: 8px; }
.safety-card__link { font-size: 12px; color: var(--green); text-decoration: none; font-weight: 600; }

.bottom-panel {
  flex: 1;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  margin-top: -16px;
  position: relative;
  z-index: 100;
  padding: 16px 16px 24px;
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
}

.bottom-panel__city { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.bottom-panel__actions { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.chip--green { background: var(--green-bg); border-color: #bbf7d0; color: var(--green); }
.chip--heart { color: #e11d48; }

.fuel-filters { display: flex; align-items: center; gap: 8px; margin: 16px 0 6px; flex-wrap: wrap; }
.fuel-filters__label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.fuel-filters__btns { display: flex; gap: 6px; flex-wrap: wrap; }

.fuel-btn {
  min-width: 36px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.fuel-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.fuel-note { font-size: 11px; color: var(--text-secondary); margin-bottom: 16px; }

.stations-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.stations-header h3 { font-size: 16px; font-weight: 700; }
.text-btn { border: none; background: none; color: var(--green); font-size: 13px; font-weight: 600; cursor: pointer; }

.stations-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }

.station-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.station-item__status { width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.station-item__status--ok { background: var(--green); }
.station-item__status--low { background: var(--yellow); }
.station-item__status--queue { background: var(--orange); }
.station-item__status--empty { background: var(--red); }
.station-item__status--limit { background: var(--purple); }

.station-item__name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.station-item__meta { font-size: 12px; color: var(--text-secondary); }
.station-item__dist { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

.badge--ok { background: var(--green-bg); color: var(--green); }
.badge--low { background: var(--yellow-bg); color: var(--yellow); }
.badge--queue { background: var(--orange-bg); color: var(--orange); }
.badge--empty { background: var(--red-bg); color: var(--red); }
.badge--limit { background: var(--purple-bg); color: var(--purple); }

.station-item__badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-right: 4px;
}

.seo-content { padding: 24px 16px; background: var(--bg); }
.seo-content h1 { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.seo-toggle { width: 100%; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; text-align: left; }
.seo-body p { font-size: 14px; color: var(--text-secondary); margin: 12px 0; }
.seo-body h2 { font-size: 16px; font-weight: 700; margin: 20px 0 12px; }

.faq { display: flex; flex-direction: column; gap: 8px; }
.faq__item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.faq__item summary { padding: 12px 14px; font-size: 14px; font-weight: 600; cursor: pointer; list-style: none; }
.faq__item summary::-webkit-details-marker { display: none; }
.faq__item p { padding: 0 14px 12px; font-size: 13px; color: var(--text-secondary); }

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  font-size: 11px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn--ghost { background: transparent; color: var(--text-secondary); }
.btn--full { width: 100%; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}

.modal-overlay[hidden] { display: none !important; }
.modal-overlay--sheet { align-items: flex-end; padding: 0; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal--sheet { max-width: 100%; border-radius: 20px 20px 0 0; }

.modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  cursor: pointer;
}

.modal__logo { font-size: 28px; font-weight: 800; text-align: center; margin-bottom: 16px; }
.modal__logo span { color: var(--green); }
.modal__title { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.modal__subtitle { font-size: 14px; color: var(--text-secondary); text-align: center; margin-bottom: 24px; }
.modal__skip { display: block; width: 100%; margin-top: 16px; padding: 10px; border: none; background: none; color: var(--text-secondary); font-size: 13px; cursor: pointer; text-decoration: underline; }
.modal__footnote { font-size: 12px; color: var(--text-secondary); text-align: center; margin-top: 12px; }

.input-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }

.phone-input-wrap {
  display: flex;
  align-items: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.phone-input-wrap:focus-within { border-color: var(--primary); }
.phone-prefix { padding: 12px 0 12px 14px; font-size: 16px; font-weight: 600; color: var(--text-secondary); }
.phone-input { flex: 1; border: none; padding: 12px 14px 12px 4px; font-size: 16px; outline: none; background: transparent; }

.code-input {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 12px;
  outline: none;
  margin-bottom: 8px;
}

.card-view-code { margin-bottom: 8px; }
.card-code-inputs {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.card-code-digit {
  width: 44px;
  height: 52px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  outline: none;
}
.card-code-digit:focus { border-color: var(--primary); }

.input-hint { font-size: 12px; color: var(--text-secondary); margin-bottom: 16px; min-height: 18px; }
.input-hint--error { color: var(--red); }

.talon-card__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.talon-card__label { font-size: 13px; color: var(--text-secondary); }
.talon-card__status { padding: 4px 10px; background: var(--green-bg); color: var(--green); border-radius: 999px; font-size: 12px; font-weight: 700; }
.talon-card__number { font-size: 32px; font-weight: 800; letter-spacing: 2px; font-family: "Courier New", monospace; margin-bottom: 16px; }
.talon-card__qr { display: flex; justify-content: center; margin-bottom: 20px; }
.talon-card__details { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.talon-detail { display: flex; flex-direction: column; gap: 4px; padding: 10px; background: var(--bg); border-radius: var(--radius-sm); }
.talon-detail span { font-size: 11px; color: var(--text-secondary); }
.talon-detail strong { font-size: 14px; }
.talon-card__note { font-size: 12px; color: var(--text-secondary); }

.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.status-btn { padding: 14px 10px; border: 2px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer; }
.status-btn.selected { border-width: 2px; }
.status-btn--green.selected { border-color: var(--green); background: var(--green-bg); }
.status-btn--yellow.selected { border-color: var(--yellow); background: var(--yellow-bg); }
.status-btn--orange.selected { border-color: var(--orange); background: var(--orange-bg); }
.status-btn--red.selected { border-color: var(--red); background: var(--red-bg); }
.status-btn--purple.selected { border-color: var(--purple); background: var(--purple-bg); }

.station-detail h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; padding-right: 32px; }
.station-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  padding: 12px 20px;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow);
}

.toast[hidden] { display: none !important; }

.share-card { display: none; }

@media (min-width: 768px) {
  .bottom-panel, .seo-content { max-width: 720px; margin-left: auto; margin-right: auto; width: 100%; }
  .share-card {
    display: flex;
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 420px;
  }
}

@media (max-width: 767px) {
  .safety-card { display: none; }
}
