:root {
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --gray: #94a3b8;
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --header-h: 52px;
  --city-bar-h: 44px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100dvh;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid #334155;
  height: var(--header-h);
  flex-shrink: 0;
  z-index: 1000;
}

header h1 {
  font-size: 16px;
  white-space: nowrap;
}

header a {
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.fuel-filter {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}

.fuel-filter::-webkit-scrollbar { display: none; }

.fuel-btn {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.fuel-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.locate-btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: var(--surface);
  border: 1px solid #334155;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

.city-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 12px;
  background: var(--surface);
  border-bottom: 1px solid #334155;
  height: var(--city-bar-h);
  flex-shrink: 0;
  z-index: 1000;
}

#city-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

#city-input::placeholder {
  color: var(--muted);
}

.city-go-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.city-go-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.favorites-btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}

.favorite-toggle-btn {
  margin-top: 12px;
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.favorite-toggle-btn.active {
  border-color: #eab308;
  background: rgba(234, 179, 8, 0.12);
  color: #fde047;
}

.favorites-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.favorites-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.favorite-card {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  border: 1px solid transparent;
}

.favorite-card:hover {
  border-color: #334155;
}

.favorite-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.favorite-card h4 {
  font-size: 14px;
  font-weight: 600;
}

.favorite-card .meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.favorite-remove {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.favorite-remove:hover {
  color: var(--red);
}

#favorites-panel {
  width: 360px;
  max-width: 100%;
  background: var(--surface);
  border-left: 1px solid #334155;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1002;
}

#favorites-panel.open {
  display: flex;
}

#main {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

#leaflet-map {
  flex: 1;
  height: calc(100dvh - var(--header-h) - var(--city-bar-h));
}

#panel {
  width: 360px;
  max-width: 100%;
  background: var(--surface);
  border-left: 1px solid #334155;
  overflow-y: auto;
  display: none;
  flex-direction: column;
}

#panel.open {
  display: flex;
}

.panel-header {
  padding: 16px;
  border-bottom: 1px solid #334155;
  position: relative;
}

.panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}

.panel-header h2 {
  font-size: 18px;
  padding-right: 28px;
}

.panel-header .brand {
  color: var(--muted);
  font-size: 13px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 8px;
}

.status-badge.available { background: rgba(34,197,94,0.2); color: var(--green); }
.status-badge.limit { background: rgba(234,179,8,0.2); color: var(--yellow); }
.status-badge.empty { background: rgba(239,68,68,0.2); color: var(--red); }
.status-badge.unknown { background: rgba(148,163,184,0.2); color: var(--gray); }

.panel-section {
  padding: 16px;
  border-bottom: 1px solid #334155;
}

.panel-section h3 {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--muted);
}

.report-form label {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--muted);
}

.report-form select,
.report-form input,
.report-form textarea {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 12px;
}

.status-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.status-btn {
  padding: 10px 4px;
  border-radius: 8px;
  border: 2px solid #334155;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
}

.station-marker-icon {
  background: transparent !important;
  border: none !important;
}

.map-legend {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  background: rgba(30, 41, 59, 0.92);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.map-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.map-legend-dot.available { background: var(--green); }
.map-legend-dot.limit { background: var(--yellow); }
.map-legend-dot.empty { background: var(--red); }
.map-legend-dot.unknown {
  background: transparent;
  border: 2px solid var(--gray);
}

.status-btn.selected.available { border-color: var(--green); background: rgba(34,197,94,0.15); }
.status-btn.selected.limit { border-color: var(--yellow); background: rgba(234,179,8,0.15); }
.status-btn.selected.empty { border-color: var(--red); background: rgba(239,68,68,0.15); }

.status-btn:not(.selected) {
  opacity: 0.7;
}

.status-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.station-delivery {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  font-size: 13px;
}

.station-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.station-warning {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(234, 179, 8, 0.12);
  color: #fde047;
  font-size: 12px;
}

.fuel-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.fuel-chip {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.fuel-chip.missing {
  background: rgba(148, 163, 184, 0.1);
  color: var(--muted);
  border-color: #334155;
}

.local-reports-title {
  margin-top: 16px !important;
}

.ext-report-card {
  background: var(--bg);
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 8px;
}

.ext-report-card .top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.ext-report-card .detail {
  color: var(--muted);
  margin-top: 6px;
  font-size: 12px;
}

.ext-report-card .badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.mini-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.submit-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--green);
  color: #052e16;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}

.reports-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.report-card {
  background: var(--bg);
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
}

.report-card .meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.confirm-btn {
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #334155;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
}

.confirm-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.delivery-note {
  color: var(--accent);
  margin-top: 4px;
}

#loading {
  position: absolute;
  top: calc(var(--header-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 1000;
  display: none;
}

#loading.show { display: block; }

#loading.error {
  cursor: pointer;
  background: rgba(127, 29, 29, 0.92);
  border: 1px solid #ef4444;
}

.error-outage-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.error-outage-modal[hidden] {
  display: none;
}

.error-outage-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
}

.error-outage-card {
  position: relative;
  width: min(100%, 380px);
  background: var(--surface);
  border: 1px solid #334155;
  border-radius: 14px;
  padding: 22px 20px 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.error-outage-card h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.error-outage-card p {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.45;
}

.error-outage-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.error-outage-form input[type="email"] {
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.error-outage-submit {
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.error-outage-status {
  font-size: 13px;
  color: var(--muted);
}

.error-outage-status[data-state="success"] { color: var(--green); }
.error-outage-status[data-state="error"] { color: var(--red); }

.error-outage-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.leaflet-popup-content {
  font-family: inherit;
  font-size: 13px;
  margin: 10px 14px;
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: rgba(59, 130, 246, 0.3);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: rgba(59, 130, 246, 0.8);
  color: white;
}

.subscribe-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 900;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.subscribe-bar-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.subscribe-bar-label {
  font-size: 13px;
  color: #e2e8f0;
  flex: 1 1 140px;
}

.subscribe-bar-form input[type="email"] {
  flex: 1 1 120px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #f1f5f9;
  font-size: 14px;
}

.subscribe-bar-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: #3b82f6;
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}

.subscribe-dismiss {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.subscribe-bar-status {
  margin-top: 6px;
  font-size: 12px;
  color: #94a3b8;
}

.subscribe-bar-status[data-state="success"] { color: #22c55e; }
.subscribe-bar-status[data-state="error"] { color: #ef4444; }

.map-contact {
  position: absolute;
  right: 12px;
  bottom: 56px;
  z-index: 800;
  font-size: 10px;
  color: #64748b;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  opacity: 0.45;
}

.map-contact:hover {
  opacity: 0.85;
  color: #94a3b8;
}

.copy-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  z-index: 10000;
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.96);
  border: 1px solid #334155;
  color: #f1f5f9;
  font-size: 14px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}

.copy-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.subscribe-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 768px) {
  #main { flex-direction: column; }

  #panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 55dvh;
    border-left: none;
    border-top: 1px solid #334155;
    border-radius: 16px 16px 0 0;
    z-index: 1001;
  }

  #favorites-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 70dvh;
    border-left: none;
    border-top: 1px solid #334155;
    border-radius: 16px 16px 0 0;
  }

  #leaflet-map {
    height: calc(100dvh - var(--header-h) - var(--city-bar-h));
  }

  .subscribe-bar {
    bottom: 8px;
    left: 8px;
    right: 8px;
  }
}
