*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #0ea5e9;
  --accent-hover: #0284c7;
  --accent-dim: rgba(14,165,233,.1);
  --danger: #e63946;
  --danger-hover: #c1121f;
  --danger-dim: rgba(230,57,70,.08);
  --green: #16a34a;
  --green-dim: rgba(22,163,74,.08);
  --dark: #18181b;
  --header-bg: #334155;
  --mid: #52525b;
  --muted: #71717a;
  --bg: #f4f4f5;
  --surface: #ffffff;
  --border: #e4e4e7;
  --border-subtle: #f0f0f1;
  --radius: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,.09);
  --shadow-sm: 0 1px 4px rgba(0,0,0,.07);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--dark);
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: var(--header-bg);
  padding: 11px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

header h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .5px;
  color: #fff;
}

header h1 span { color: var(--accent); }

/* ── Filter bar ── */
#filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 9px 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

#filter-bar label {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

#filter-bar select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: .88rem;
  background: var(--surface);
  color: var(--dark);
  cursor: pointer;
}

#filter-bar select:focus { outline: 2px solid var(--accent); border-color: transparent; }

#listing-count {
  margin-left: auto;
  font-size: .82rem;
  color: var(--muted);
}

/* ── Main layout ── */
#main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Map ── */
#map {
  flex: 1;
  z-index: 0;
}

/* ── Sidebar ── */
#sidebar {
  width: 340px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

#sidebar-header {
  padding: 13px 16px 11px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: .78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
}

#sidebar-footer {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}

#add-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

#add-btn:hover { background: var(--accent-hover); }

#site-footer {
  margin-top: 10px;
  font-size: .72rem;
  color: var(--muted);
  text-align: center;
}

#dealer-list { flex: 1; }

.dealer-card {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background .12s;
  border-left: 3px solid transparent;
}

.dealer-card:hover { background: #fafafa; }
.dealer-card.active {
  background: var(--accent-dim);
  border-left-color: var(--accent);
}

.dealer-card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.dealer-name {
  font-weight: 700;
  font-size: .95rem;
  flex: 1;
}

.badge {
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  flex-shrink: 0;
}

.badge-premium { background: #fef9c3; color: #854d0e; }
.badge-standard { background: #f4f4f5; color: var(--muted); }
.badge-expiring { background: rgba(230,57,70,.1); color: var(--danger); border: 1px solid rgba(230,57,70,.2); }

.dealer-vehicle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.dealer-vehicle {
  font-size: .82rem;
  font-weight: 600;
  color: var(--accent);
}

.confirm-count {
  font-size: .73rem;
  color: var(--green);
  font-weight: 600;
}

.dealer-address {
  font-size: .8rem;
  color: var(--mid);
  margin-bottom: 2px;
}

.dealer-meta {
  font-size: .78rem;
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dealer-meta a { color: var(--accent); text-decoration: none; }

.reconfirm-note {
  font-size: .76rem;
  color: var(--danger);
  font-weight: 600;
  margin-top: 4px;
}

.listing-age { color: #bbb; }
.listing-age .age-confirmed { color: var(--green); font-weight: 600; }

.flag-btn {
  display: block;
  background: none;
  border: none;
  padding: 6px 0 0;
  font-size: .75rem;
  color: #ccc;
  cursor: pointer;
  text-align: left;
}

.flag-btn:hover { color: var(--danger); }
.flag-btn:disabled { color: #ddd; cursor: default; }

/* ── Empty state ── */
#empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  display: none;
}

#empty-state p { margin-bottom: 12px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 460px;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-wide { max-width: 700px; }

.modal-body {
  overflow-y: auto;
}

/* two-column layout inside the wide submit form */
.submit-form-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}


.modal-header {
  background: var(--header-bg);
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 { font-size: 1rem; color: #fff; }

.modal-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.6);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  transition: color .12s;
}

.modal-close:hover { color: #fff; }

.modal-body { padding: 20px; }

.form-group { margin-bottom: 15px; }

.form-group label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.form-group select,
.form-group input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: .95rem;
  background: var(--surface);
  color: var(--dark);
}

.form-group select:focus,
.form-group input:focus { outline: 2px solid var(--accent); border-color: transparent; }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 11px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: #e4e4e7; color: #a1a1aa; cursor: not-allowed; }

.msg { margin-top: 12px; font-size: .88rem; padding: 10px 12px; border-radius: var(--radius); }
.msg-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.msg-error   { background: #fff1f2; color: #9f1239; border: 1px solid #fecdd3; }

/* ── Layer switcher ── */
.leaflet-control-layers {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm) !important;
}
.leaflet-control-layers-toggle { background-size: 20px !important; }
.leaflet-control-layers-expanded {
  padding: 8px 12px !important;
  font-size: .82rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ── Dealer search ── */
.dealer-search-wrap { position: relative; }

.dealer-suggestions {
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 20;
  max-height: 220px;
  overflow-y: auto;
}

.dealer-suggestions.hidden { display: none; }

.suggestion-item {
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: #fafafa; }
.suggestion-name { font-weight: 600; font-size: .88rem; }
.suggestion-meta { font-size: .76rem; color: var(--muted); }

.dealer-selected-label {
  font-size: .76rem;
  color: var(--muted);
  margin-top: 5px;
  font-style: italic;
}

/* ── Leaflet popup tweaks ── */
.leaflet-popup-content-wrapper { border-radius: var(--radius) !important; box-shadow: var(--shadow) !important; }
.popup-name { font-weight: 700; font-size: .95rem; margin-bottom: 4px; }
.popup-address { font-size: .82rem; color: var(--mid); margin-bottom: 2px; }

.popup-model-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-top: 1px solid var(--border-subtle);
  gap: 8px;
}

.popup-model-name { font-size: .88rem; }

.popup-model-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.flag-icon-btn {
  cursor: pointer;
  font-size: .9rem;
  opacity: .3;
  transition: opacity .15s;
  background: none;
  border: none;
  padding: 2px;
  line-height: 1;
}

.flag-icon-btn:hover { opacity: .9; }

.popup-confirm-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: .75rem;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  transition: background .12s;
}

.popup-confirm-btn:hover { background: var(--accent-hover); }

/* ── Comments ── */
.listing-comment {
  font-size: .78rem;
  color: var(--muted);
  font-style: italic;
  margin: 3px 0 2px;
  line-height: 1.4;
}

.comment-author {
  font-style: normal;
  font-weight: 600;
  color: var(--mid);
}

/* ── Forms ── */
.form-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: .9rem;
  font-family: inherit;
  resize: vertical;
  min-height: 58px;
  background: var(--surface);
  color: var(--dark);
}

.form-textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* ── Map legend ── */
.map-legend {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 8px 12px;
  font-size: .78rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--mid);
  display: flex;
  flex-direction: column;
  gap: 5px;
  pointer-events: none;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid #fff;
  flex-shrink: 0;
  display: inline-block;
}

/* ── Ideas header button ── */
.ideas-header-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.7);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: .95rem;
  cursor: pointer;
  transition: all .15s;
  line-height: 1.5;
}
.ideas-header-btn:hover { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.4); }

/* ── Ideas modal ── */
.ideas-modal { max-width: 560px !important; }

.ideas-body {
  padding: 0 !important;
  max-height: 80dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.ideas-list { flex: 1; }

.idea-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.idea-card:last-child { border-bottom: none; }

.vote-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 42px;
  flex-shrink: 0;
  transition: all .15s;
  line-height: 1;
}
.vote-btn:hover:not(:disabled) { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.vote-btn.voted { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); cursor: default; }
.vote-btn:disabled { cursor: default; }
.vote-count { font-size: .9rem; }

.idea-content { flex: 1; min-width: 0; }
.idea-title { font-weight: 700; font-size: .92rem; margin-bottom: 3px; }
.idea-desc { font-size: .8rem; color: var(--mid); margin-bottom: 6px; line-height: 1.4; }

.idea-status {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}
.status-open     { background: var(--accent-dim); color: var(--accent); }
.status-planned  { background: #fef9c3; color: #854d0e; }
.status-done     { background: var(--green-dim); color: var(--green); }

.ideas-empty { padding: 24px 16px; color: var(--muted); font-size: .88rem; text-align: center; }

.ideas-submit-section {
  border-top: 2px solid var(--border);
  padding: 16px;
  background: var(--bg);
}
.ideas-submit-section h3 {
  font-size: .82rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 12px;
}

/* ── Custom location / pin-drop ── */
.custom-location-toggle {
  display: inline-block;
  margin-top: 6px;
  font-size: .78rem;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.custom-location-toggle:hover { color: var(--accent-hover); }

.custom-location-wrap { display: none; }
.custom-location-wrap.visible { display: block; }

/* "Pick on map" button inside the form */
.pin-pick-btn {
  width: 100%;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
  transition: background .15s;
  text-align: center;
}
.pin-pick-btn:hover { background: rgba(14,165,233,.18); }

.pin-drop-hint {
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: 10px;
}
.pin-drop-hint.placed { color: var(--green); font-weight: 600; }

/* ── Full-screen pin-drop overlay ── */
.pin-map-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
}
.pin-map-overlay.hidden { display: none; }

#pin-full-map {
  flex: 1;
  cursor: crosshair;
}

.pin-map-toolbar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pin-map-toolbar > span {
  flex: 1;
  font-size: .88rem;
  color: var(--mid);
  min-width: 0;
}

.pin-map-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.pin-cancel-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: .9rem;
  cursor: pointer;
  color: var(--mid);
  transition: background .12s;
}
.pin-cancel-btn:hover { background: var(--bg); }

.pin-map-actions .btn-primary { width: auto; padding: 9px 18px; }

/* ── Responsive ── */
@media (max-width: 700px) {
  #main { flex-direction: column; }
  #map { height: 50dvh; flex: none; }
  #sidebar { width: 100%; flex: 1; border-left: none; border-top: 1px solid var(--border); }

  .modal-wide { max-width: 100%; }
  .submit-form-bottom { grid-template-columns: 1fr; gap: 0; }

  .map-legend { padding: 5px 8px; font-size: .68rem; gap: 3px; }
  .legend-dot { width: 8px; height: 8px; }
}
