/* ═══════════════════════════════════════════════════════════════
   SolarBizz — Premium Dark UI
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Editorial-light: white surfaces, ink text, solar-orange accent */
  --bg:           #ffffff;
  --surface:      #ffffff;
  --surface-2:    #f6f6f5;
  --surface-3:    #ededec;
  --border:       rgba(23,20,15,0.12);
  --border-2:     rgba(23,20,15,0.22);

  --accent:       #ff5a23;
  --accent-dark:  #ff4a1c;
  --accent-glow:  rgba(255,74,28,0.20);
  --purple:       #f6a94a;   /* secondary (amber) — gradients read orange→amber */
  --green:        #15a06a;
  --amber:        #c2820a;
  --red:          #d64545;
  --blue:         #2a6fd6;

  --text-1:       #17140f;
  --text-2:       #544e44;
  --text-3:       #8b8275;

  --sidebar-w:    420px;
  --radius:       12px;
  --radius-sm:    8px;
  --radius-lg:    16px;
  --transition:   0.2s ease;

  --ff-body:      'Inter', 'Noto Sans Thai', system-ui, sans-serif;
  --ff-disp:      'Inter', 'Noto Sans Thai', system-ui, sans-serif;
  --ff-mono:      'Inter', 'Noto Sans Thai', system-ui, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--ff-body);
  background: var(--bg);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  max-width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
  z-index: 10;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }

/* ── Sidebar Header ───────────────────────────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(255,90,35,0.12) 0%, rgba(246,169,74,0.08) 100%);
  flex-shrink: 0;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: transparent;
}
.logo-icon svg { width: 34px; height: 34px; }

.logo-title {
  display: block;
  font-family: var(--ff-disp);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.4px;
}

.logo-sub {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
}

/* ── User bar + quota (sidebar) ───────────────────────────────── */
.user-bar {
  margin: 0 14px 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.ub-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ub-id { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; }
.ub-id i { color: var(--accent); }
.ub-email { font-weight: 600; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ub-plan {
  flex-shrink: 0; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 1px 7px; border-radius: 99px; background: var(--accent); color: #fff;
}
.ub-logout {
  flex-shrink: 0; width: 26px; height: 26px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-3); cursor: pointer; transition: var(--transition);
}
.ub-logout:hover { color: var(--red); border-color: var(--red); }
.ub-quota { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.q-row { display: grid; grid-template-columns: 44px 1fr 48px; align-items: center; gap: 7px; font-size: 10px; color: var(--text-2); }
.q-label { color: var(--text-3); }
.q-bar { height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.q-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.q-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.q-row.q-low .q-num { color: var(--red); font-weight: 700; }
.q-row.q-low .q-bar > span { background: var(--red); }
.q-unlim { font-size: 11px; color: var(--green); font-weight: 600; }

/* ── Login gate ───────────────────────────────────────────────── */
.login-gate {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(23, 20, 15, 0.55); backdrop-filter: blur(4px);
}
.login-gate-card {
  width: min(380px, 92vw); background: var(--surface); color: var(--text-1);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(23,20,15,0.25); padding: 30px;
}
.lg-brand { display: flex; align-items: center; gap: 10px; font-size: 1.3rem; font-weight: 800; color: var(--text-1); }
.lg-brand svg { width: 32px; height: 32px; color: var(--accent); }
.lg-brand b { color: var(--accent); }
.lg-sub { color: var(--text-3); font-size: 13px; margin: 6px 0 18px; }
.lg-field { display: block; margin-bottom: 14px; }
.lg-field > span { display: block; font-size: 11px; color: var(--text-3); margin-bottom: 5px; }
.lg-field input {
  width: 100%; padding: 11px 13px; font-size: 14px; font-family: inherit;
  color: var(--text-1); background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
}
.lg-field input:focus { outline: none; border-color: var(--accent); }
.login-gate-card .btn-primary { width: 100%; justify-content: center; margin-top: 6px; }
.lg-hint { font-size: 11px; color: var(--text-3); text-align: center; margin-top: 16px; }

/* ── Buttons ──────────────────────────────────────────────────── */
.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: var(--transition);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text-1); border-color: var(--border-2); }

.icon-btn-sm {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: var(--transition);
  flex-shrink: 0;
}
.icon-btn-sm:hover { color: var(--text-1); background: var(--surface-3); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  width: 100%;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-dark), var(--purple));
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 6px 20px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-3);
  border: 1px solid var(--border);
  margin-top: 6px;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text-2); border-color: var(--border-2); }

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16,185,129,0.25);
}
.btn-success:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-sm { padding: 7px 12px; font-size: 12px; width: auto; }

/* ── Status Bar ───────────────────────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
  flex-shrink: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.idle { background: var(--text-3); }
.status-dot.active { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 1.5s ease-in-out infinite; }
.status-dot.success { background: var(--green); }
.status-dot.error { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  margin: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  overflow: hidden;
  flex-shrink: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  transition: background var(--transition);
  user-select: none;
}
.card-header:hover { background: var(--surface-3); }

.card-header-simple {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 16px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}

.chevron { font-size: 11px; color: var(--text-3); transition: transform var(--transition); }
.card.collapsed .chevron { transform: rotate(-90deg); }
.card.collapsed .card-body { display: none; }

.card-body {
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.icon-accent { color: var(--accent); margin-right: 4px; }

/* ── Inputs ───────────────────────────────────────────────────── */
.input-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 0 10px 0 12px;
  transition: border-color var(--transition);
}
.input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.input-field {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-1);
  font-family: inherit;
  font-size: 13px;
  padding: 10px 0;
}
.input-field::placeholder { color: var(--text-3); }

/* Standalone input */
.card-body .input-field:not(.input-group .input-field) {
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card-body .input-field:not(.input-group .input-field):focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: -4px;
}

.hint-text {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.6;
}
.hint-text strong { color: var(--accent); }

/* ── Polygon Info ─────────────────────────────────────────────── */
.polygon-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255,90,35,0.08);
  border: 1px solid rgba(255,90,35,0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--accent);
}

/* ── Progress Card ────────────────────────────────────────────── */
.progress-card {
  margin: 0 14px 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,90,35,0.25);
  background: rgba(255,90,35,0.06);
  flex-shrink: 0;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
}

.progress-count { color: var(--accent); font-size: 12px; }

.progress-bar-wrap {
  height: 4px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-dark), var(--purple));
  border-radius: 99px;
  transition: width 0.4s ease;
}

.progress-steps { display: flex; flex-direction: column; gap: 6px; }

.step {
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.step.waiting { color: var(--text-3); }
.step.done { color: var(--green); }
.step i { width: 14px; text-align: center; }

/* ── Results Section ──────────────────────────────────────────── */
/* Middle column: sits between the controls sidebar and the map */
.results-section {
  width: 360px;
  min-width: 360px;
  max-width: 360px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 14px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 5;
}

.results-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 2px 0 12px;
  flex-shrink: 0;
}

.results-title {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.results-actions { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.results-actions .btn { width: 100%; flex: none; }

.results-close {
  margin-left: auto;
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.results-close:hover { background: var(--surface-3); color: var(--text-1); }

.autosave-status {
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.autosave-status.asx-unsaved { color: var(--amber); cursor: pointer; }
.autosave-status.asx-saving  { color: var(--text-3); }
.autosave-status.asx-saved   { color: var(--green); }
.autosave-status.asx-error   { color: var(--red); cursor: pointer; }

.results-reopen {
  position: absolute;
  top: 16px; left: 16px;
  z-index: 500;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px;
  background: var(--accent-dark);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.results-reopen:hover { filter: brightness(1.05); }

/* Narrow screens: overlay the results column instead of squeezing the map */
@media (max-width: 1180px) {
  .results-section {
    position: absolute;
    top: 0; left: var(--sidebar-w);
    box-shadow: 8px 0 28px rgba(23,20,15,0.14);
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--accent-dark);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.stats-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.stat-chip {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
}
.stat-chip i { font-size: 10px; color: var(--accent); }

/* ── Results Table ────────────────────────────────────────────── */
.table-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
.table-wrap::-webkit-scrollbar { width: 4px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.results-table thead th {
  padding: 9px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.results-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  cursor: pointer;
}
.results-table tbody tr:last-child { border-bottom: none; }
.results-table tbody tr:hover { background: rgba(255,90,35,0.06); }

.results-table tbody td {
  padding: 9px 10px;
  vertical-align: top;
  color: var(--text-1);
}

.cell-name {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-1);
  margin-bottom: 2px;
  line-height: 1.3;
}

.cell-addr {
  font-size: 10px;
  color: var(--text-3);
  line-height: 1.4;
}

.cell-type {
  display: inline-block;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text-3);
  margin-top: 3px;
}

/* ── Lead CRM (status + inline editor) ─────────────────────────── */
.lead-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.status-chip {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 99px;
  color: #fff;
  background: var(--c, #8b8275);
}

.lead-edit-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  transition: var(--transition);
}
.lead-edit-toggle:hover { color: var(--accent); border-color: var(--accent); }

.edit-row > td { background: var(--surface-2); padding: 0; }
.lead-editor { padding: 12px; border-top: 2px solid var(--accent); }
.le-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.lead-editor label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 10px; font-weight: 600; color: var(--text-3);
}
.le-notes { margin-top: 8px; }
.lead-editor input,
.lead-editor select,
.lead-editor textarea {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-1);
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
}
.lead-editor input:focus,
.lead-editor select:focus,
.lead-editor textarea:focus { outline: none; border-color: var(--accent); }
.lead-editor textarea { resize: vertical; }

.contact-line {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
  font-size: 11px;
  color: var(--text-2);
}
.contact-line:last-child { margin-bottom: 0; }

.contact-line i { width: 12px; text-align: center; font-size: 10px; color: var(--accent); flex-shrink: 0; }

.contact-link {
  color: var(--blue);
  text-decoration: none;
  word-break: break-all;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}
.contact-link:hover { text-decoration: underline; }

.email-text { color: var(--green); }

.loading-dot {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text-3);
  font-size: 10px;
}
.loading-dot::after {
  content: '•••';
  animation: ldots 1.2s steps(3, end) infinite;
}
@keyframes ldots {
  0%  { content: '•'; }
  33% { content: '••'; }
  66% { content: '•••'; }
}

.rating-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--amber);
  white-space: nowrap;
}

.row-num {
  font-size: 10px;
  color: var(--text-3);
  text-align: center;
  font-weight: 600;
}

/* ── Map ──────────────────────────────────────────────────────── */
.map-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
}

/* Override Leaflet draw styles */
.leaflet-draw-toolbar a {
  background-color: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-2) !important;
}
.leaflet-draw-toolbar a:hover {
  background-color: var(--surface-2) !important;
  color: var(--accent) !important;
}
.leaflet-bar a, .leaflet-bar a:hover {
  background-color: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-1) !important;
}

/* ── Map Legend ───────────────────────────────────────────────── */
.map-legend {
  position: absolute;
  top: 14px;        /* top-right — below nothing conflicts here */
  right: 60px;      /* offset left of the Leaflet draw toolbar */
  background: rgba(13, 20, 36, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 12px 14px;
  z-index: 999;
  min-width: 160px;
}

.legend-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-2);
  margin-bottom: 5px;
}
.legend-item:last-child { margin-bottom: 0; }

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

/* ── Map Hint ─────────────────────────────────────────────────── */
.map-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(13, 20, 36, 0.88);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,90,35,0.3);
  border-radius: var(--radius-lg);
  padding: 20px 28px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-2);
  max-width: 340px;
  text-align: center;
  pointer-events: none;
  z-index: 900;
  box-shadow: 0 10px 30px rgba(23,20,15,0.10);
  transition: opacity 0.4s ease;
}

.map-hint i {
  font-size: 28px;
  color: var(--accent);
  flex-shrink: 0;
  animation: float 2s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.map-hint strong { color: var(--accent); }
.map-hint.hidden { opacity: 0; }

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: calc(var(--sidebar-w) + 50%);
  transform: translateX(-50%) translateY(80px);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 99px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
  z-index: 9999;
  box-shadow: 0 10px 30px rgba(23,20,15,0.10);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.35s ease;
  opacity: 0;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success #toast-icon { color: var(--green); }
.toast.error   #toast-icon { color: var(--red); }
.toast.info    #toast-icon { color: var(--accent); }

/* ── Result Marker Popup ──────────────────────────────────────── */
.leaflet-popup-content-wrapper {
  background: var(--surface-2) !important;
  border: 1px solid var(--border-2) !important;
  border-radius: var(--radius) !important;
  color: var(--text-1) !important;
  box-shadow: 0 10px 30px rgba(23,20,15,0.10) !important;
}
.leaflet-popup-tip {
  background: var(--surface-2) !important;
}
.leaflet-popup-content {
  margin: 12px 14px !important;
  font-family: var(--ff-body) !important;
  font-size: 12px !important;
}
.popup-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 4px;
}
.popup-addr { font-size: 11px; color: var(--text-3); margin-bottom: 6px; }
.popup-row { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 11px; margin-bottom: 3px; }
.popup-row i { color: var(--accent); width: 12px; text-align: center; }

/* ── Map Type Switcher ────────────────────────────────────────────── */
.map-type-control {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 50px;           /* sit above the zoom control */
  background: rgba(6, 11, 20, 0.88);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 8px 8px;
  min-width: 148px;
  box-shadow: 0 10px 28px rgba(23,20,15,0.12);
}

.mtype-section-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-3);
  padding: 4px 4px 2px;
  margin-top: 2px;
}
.mtype-section-label.google-section {
  color: rgba(66,133,244,0.7);
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
}

.map-type-btn {
  display: block;
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  white-space: nowrap;
}
.map-type-btn:hover {
  background: var(--surface-3);
  color: var(--text-1);
  border-color: var(--border-2);
}
.map-type-btn.active {
  background: var(--accent-dark);
  border-color: rgba(255,90,35,0.5);
  color: #fff;
  font-weight: 600;
}
.map-type-btn.google-btn.active {
  background: linear-gradient(135deg, #1a73e8, #34a853);
  border-color: rgba(26,115,232,0.5);
}

/* ── Locate Control ───────────────────────────────────────────────── */
.locate-control {
  margin-bottom: 10px;
}

.locate-btn {
  width: 38px;
  height: 38px;
  background: rgba(6, 11, 20, 0.88);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  box-shadow: 0 4px 14px rgba(23,20,15,0.10);
}
.locate-btn:hover {
  background: var(--surface-3);
  color: var(--accent);
  border-color: var(--accent);
  transform: scale(1.05);
}
.locate-btn.locating {
  color: var(--amber);
  border-color: var(--amber);
  animation: pulse-border 1.2s ease-in-out infinite;
}
.locate-btn.located {
  color: var(--green);
  border-color: var(--green);
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251,191,36,0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(251,191,36,0); }
}

/* ── Location Marker (pulsing dot) ────────────────────────────────── */
.location-dot {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border: 2.5px solid #fff;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px var(--accent);
  z-index: 2;
}

.location-pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: location-pulse 2s ease-out infinite;
  z-index: 1;
}

@keyframes location-pulse {
  0%   { transform: translate(-50%,-50%) scale(0.3); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(2.5); opacity: 0; }
}

/* ── Scrollbar Styling ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--surface-3); }

/* ── Google Maps Setup Error Modal ─────────────────────────────────── */
.gmaps-error-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}

.gmaps-error-box {
  background: var(--surface);
  border: 1px solid rgba(251,191,36,0.3);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  max-width: 420px;
  width: 90%;
  position: relative;
  box-shadow: 0 20px 50px rgba(23,20,15,0.16), 0 0 0 1px var(--border);
  animation: slideUp 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.gmaps-error-icon {
  font-size: 32px;
  color: var(--amber);
  margin-bottom: 12px;
}

.gmaps-error-box h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 8px;
}

.gmaps-error-box p {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.gmaps-error-box ol {
  padding-left: 18px;
  margin-bottom: 16px;
}

.gmaps-error-box li {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 8px;
  line-height: 1.6;
}

.gmaps-error-box li strong {
  color: var(--text-1);
  display: block;
}

.gmaps-error-box li span {
  color: var(--text-3);
  font-size: 11px;
}

.gmaps-error-box code {
  background: var(--surface-3);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--ff-mono);
  font-size: 11px;
}

.gmaps-error-steps {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.step-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--amber);
  margin-bottom: 8px;
}

.step-item {
  font-size: 12px;
  color: var(--text-2);
  padding: 3px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.step-item a {
  color: var(--blue);
  text-decoration: none;
}
.step-item a:hover { text-decoration: underline; }

.step-item strong { color: var(--text-1); }

.gmaps-error-actions {
  display: flex;
  gap: 8px;
}

.gmaps-error-actions .btn { width: auto; flex: 1; }

.gmaps-error-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all var(--transition);
}
.gmaps-error-close:hover { color: var(--text-1); background: var(--surface-3); }

/* ── Solar Potential Badges ─────────────────────────────────────────── */
.btn-solar {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.btn-solar:hover {
  background: linear-gradient(135deg, #d97706, #dc2626);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(245,158,11,0.35);
}

.solar-badge-block {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.solar-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 5px;
}
.solar-badge.grade-a {
  background: rgba(239,68,68,0.15);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.3);
}
.solar-badge.grade-b {
  background: rgba(245,158,11,0.15);
  color: #f59e0b;
  border: 1px solid rgba(245,158,11,0.3);
}
.solar-badge.grade-c {
  background: rgba(107,114,128,0.15);
  color: #9ca3af;
  border: 1px solid rgba(107,114,128,0.2);
}
.solar-badge.grade-none {
  background: rgba(107,114,128,0.1);
  color: var(--text-3);
  border: 1px solid var(--border);
  font-weight: 500;
}

.solar-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.solar-details span {
  font-size: 10px;
  color: var(--text-3);
  background: var(--surface-3);
  padding: 2px 7px;
  border-radius: 10px;
}

/* ── Saved Groups & Modal UI ────────────────────────────────────────── */
.groups-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.group-item {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all var(--transition);
}
.group-item:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
  background: rgba(23,20,15,0.03);
}

.group-info-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.group-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  word-break: break-word;
}

.group-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-3);
  margin-top: 2px;
}

.group-badge {
  background: var(--accent-dark);
  color: #fff;
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 700;
}

.group-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 6px;
}

.group-btn-load {
  background: rgba(255,90,35,0.1);
  color: var(--accent);
  border: 1px solid rgba(255,90,35,0.2);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  transition: all var(--transition);
}
.group-btn-load:hover {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.group-btn-delete {
  background: transparent;
  color: var(--text-3);
  border: 1px solid transparent;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition);
}
.group-btn-delete:hover {
  background: rgba(239,68,68,0.1);
  color: var(--red);
  border-color: rgba(239,68,68,0.2);
}

/* Modal Overlay & Box */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(5px);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 24px 60px rgba(23,20,15,0.18), 0 0 0 1px var(--border);
  animation: slideUp 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

