/* ── RESET ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang HK", "Noto Sans HK",
               "Microsoft YaHei New", "Microsoft YaHei", "Hiragino Sans GB",
               "Source Han Sans CN", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

/* ── VARIABLES ───────────────────────────────────────── */
:root {
  --primary:        #0057b8;
  --primary-h:      #004494;
  --primary-light:  #dbeafe;
  --green:          #16a34a;
  --green-bg:       #dcfce7;
  --amber:          #d97706;
  --amber-bg:       #fef3c7;
  --red:            #dc2626;
  --red-bg:         #fee2e2;
  --gray:           #6b7280;
  --gray-bg:        #f1f5f9;
  --white:          #ffffff;
  --border:         #e2e8f0;
  --text:           #0f172a;
  --text-muted:     #64748b;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.10);
  --shadow-md:      0 4px 16px rgba(0,0,0,.15);
  --radius:         8px;
  --sidebar-w:      390px;
  --header-h:       62px;
  /* semantic aliases used by dark theme */
  --bg:             #f1f5f9;
  --surface-alt:    #fafbfd;
  --hover:          #f8fafc;
}

/* ── DARK THEME ──────────────────────────────────────── */
html.dark {
  --primary:        #60a5fa;
  --primary-h:      #3b82f6;
  --primary-light:  #1e3a5f;
  --green:          #4ade80;
  --green-bg:       #14532d;
  --amber:          #fbbf24;
  --amber-bg:       #78350f;
  --red:            #f87171;
  --red-bg:         #7f1d1d;
  --gray:           #9ca3af;
  --gray-bg:        #1e293b;
  --white:          #1e293b;
  --border:         #334155;
  --text:           #f1f5f9;
  --text-muted:     #94a3b8;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.4);
  --shadow-md:      0 4px 16px rgba(0,0,0,.5);
  --bg:             #0f172a;
  --surface-alt:    #162032;
  --hover:          #243347;
}
html.dark body    { background: var(--bg); color: var(--text); }
html.dark #header { background: #1e293b; box-shadow: 0 2px 8px rgba(0,0,0,.5); }

/* Cards & lists */
html.dark .cp-card:hover { background: var(--hover); }
html.dark .cp-card.selected { background: var(--primary-light); }

/* Vacancy badge colours */
html.dark .vb-green { background: #14532d; color: #86efac; }
html.dark .vb-amber { background: #78350f; color: #fde68a; }
html.dark .vb-red   { background: #7f1d1d; color: #fca5a5; }
html.dark .vb-gray  { background: #1e293b; color: #94a3b8; }

/* Pills */
html.dark .pill-open        { background: #14532d; color: #86efac; }
html.dark .pill-closed      { background: #7f1d1d; color: #fca5a5; }
html.dark .pill-rate        { background: #14532d; color: #86efac; }
html.dark .pill-ev          { background: #064e3b; color: #6ee7b7; }
html.dark .pill-dis         { background: #1e3a5f; color: #93c5fd; }
html.dark .pill-nature      { background: #1e1b4b; color: #a5b4fc; }
html.dark .pill-ht          { background: #2e1065; color: #d8b4fe; }
html.dark .pill-stale       { background: #78350f; color: #fde68a; }
html.dark .pill-priv        { background: #1f2937; color: #9ca3af; }
html.dark .pill-priv-active { background: #713f12; color: #fde68a; font-weight: 700; }

/* Search & filters */
html.dark .search-row { background: var(--gray-bg); border-color: var(--border); }
html.dark .search-row:focus-within { background: var(--white); }
html.dark .filter-select { background: var(--white); color: var(--text); border-color: var(--border); }
html.dark .filters-wrap  { background: var(--surface-alt); }

/* Stats & street bar */
html.dark .street-stats { background: #1a1040; border-color: #2e1a5e; }

/* Map legend & popups */
html.dark .map-legend { background: rgba(15,23,42,.92); color: var(--text); }
html.dark .leaflet-popup-content-wrapper { background: #1e293b; color: var(--text); }
html.dark .leaflet-popup-tip { background: #1e293b; }
html.dark .popup-sub { color: var(--text-muted); }

/* Detail panel */
html.dark .stale-alert   { background: #451a03; color: #fed7aa; border-left-color: #f59e0b; }
html.dark .ph-note       { color: #93c5fd; }
html.dark .ph-pricing-note { color: #93c5fd; }
html.dark .hours-row.ph-today { background: #1e3a5f; }
html.dark .priv-applicable     { background: #14532d; border-color: #166534; }
html.dark .priv-not-applicable { background: #1e293b; border-color: #334155; }
html.dark .priv-badge-yes { background: #14532d; color: #86efac; }
html.dark .priv-badge-no  { background: #7f1d1d; color: #fca5a5; }
html.dark .remark-pricing { background: #162032; color: var(--text-muted); }
html.dark .dp-section-yt { background: #3f1212; }
html.dark .yt-desc       { color: #fca5a5; }
html.dark .data-source-val { color: var(--text-muted); }

/* Street summary card */
html.dark .street-summary-card { background: #0d2b1a; border-color: #166534; }
html.dark .ss-label       { color: #4ade80; }
html.dark .ss-street-name { color: #86efac; }
html.dark .ss-district    { color: #4ade80; }
html.dark .ss-show-btn    { background: #15803d; }

/* Hamburger menu */
html.dark .hamburger-menu { background: #1e293b; }
html.dark .hm-body        { color: var(--text-muted); }
html.dark .hm-divider     { background: var(--border); }
html.dark .hm-email       { color: var(--primary); }

/* Tooltips */
html.dark .help-tooltip         { background: #0f172a; }
html.dark .help-tooltip::after  { border-top-color: #0f172a; }

/* Mobile section toggles */
html.dark .section-toggle { background: var(--border); color: var(--text-muted); }
html.dark .section-toggle:hover { background: #475569; }

/* ── APP SHELL ───────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── HEADER ──────────────────────────────────────────── */
#header {
  height: var(--header-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  z-index: 1000;
}
.header-left  { display: flex; align-items: center; gap: 12px; }
.logo         { font-size: 30px; line-height: 1; }
.app-title    { font-size: 17px; font-weight: 700; line-height: 1.25; }
.app-tagline  { font-size: 11px; opacity: .8; margin-top: 2px; }
.header-right { display: flex; align-items: center; gap: 14px; }
.refresh-timer{ font-size: 12px; opacity: .85; white-space: nowrap; }

/* ── THEME TOGGLE ────────────────────────────────────── */
.theme-toggle-btn {
  background: rgba(255,255,255,.15); border: none; color: #fff;
  width: 34px; height: 34px; border-radius: 8px;
  font-size: 17px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; flex-shrink: 0;
}
.theme-toggle-btn:hover { background: rgba(255,255,255,.28); }

/* ── ADD TO HOME SCREEN BANNER ───────────────────────── */
.a2hs-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 9998;
  background: #1e293b; color: #f1f5f9;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 -4px 20px rgba(0,0,0,.3);
  animation: slideUp .3s ease;
}
.a2hs-banner.hidden { display: none; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.a2hs-icon { font-size: 28px; flex-shrink: 0; }
.a2hs-text { flex: 1; font-size: 13px; line-height: 1.5; }
.a2hs-text strong { display: block; font-size: 14px; margin-bottom: 2px; }
.a2hs-install-btn {
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius);
  padding: 8px 14px; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: inherit; white-space: nowrap;
  flex-shrink: 0;
}
.a2hs-dismiss-btn {
  background: none; border: none; color: #94a3b8;
  font-size: 20px; cursor: pointer; padding: 0 4px; flex-shrink: 0;
}

/* ── HAMBURGER MENU ───────────────────────────────────── */
.hamburger-wrap { position: relative; }
.hamburger-btn {
  background: rgba(255,255,255,.15); border: none; color: #fff;
  width: 34px; height: 34px; border-radius: 8px;
  font-size: 18px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: background .15s; flex-shrink: 0;
}
.hamburger-btn:hover { background: rgba(255,255,255,.28); }
.hamburger-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 280px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  z-index: 2000;
  overflow: hidden;
}
.hamburger-menu.visible { display: block; }
.hm-section   { padding: 14px 16px; }
.hm-title     { font-size: 11px; font-weight: 700; text-transform: uppercase;
                 letter-spacing: .06em; color: var(--primary); margin-bottom: 5px; }
.hm-body      { font-size: 12px; color: var(--text-muted); line-height: 1.55; margin: 0; }
.hm-email     { font-size: 13px; color: var(--primary); text-decoration: none; font-weight: 600; }
.hm-email:hover { text-decoration: underline; }
.hm-divider   { height: 1px; background: #e2e8f0; margin: 0; }

/* Language Switcher */
.lang-switcher { display: flex; gap: 3px; }
.lang-btn {
  padding: 4px 11px;
  border: 1.5px solid rgba(255,255,255,.45);
  border-radius: 4px;
  background: transparent;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.lang-btn:hover  { background: rgba(255,255,255,.18); }
.lang-btn.active { background: #fff; color: var(--primary); border-color: #fff; }

/* ── MAIN CONTENT ────────────────────────────────────── */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── SIDEBAR ─────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
  transition: flex .3s ease, width .3s ease;
}

/* Search */
.search-wrap {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}
.search-row {
  display: flex;
  align-items: center;
  background: var(--gray-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0 8px;
  gap: 6px;
  transition: border-color .2s;
}
.search-row:focus-within { border-color: var(--primary); background: var(--white); }
.search-icon { font-size: 14px; color: var(--text-muted); }
.search-row input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 0;
  font-size: 13px;
  outline: none;
  color: var(--text);
  min-width: 0;
}
.search-row input::placeholder { color: var(--text-muted); }
#near-me-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background .15s;
  line-height: 1;
}
#near-me-btn:hover   { background: var(--border); }
#near-me-btn.active  { background: var(--primary-light); color: var(--primary); border-radius: 4px; }
#near-me-btn.loading { opacity: .5; cursor: wait; }

/* Filters */
.filters-wrap {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.filter-label {
  font-size: 12px;
  color: var(--text-muted);
  width: 62px;
  flex-shrink: 0;
  font-weight: 500;
}
.filter-select {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--white);
  outline: none;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}
.filter-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.check-label input {
  cursor: pointer;
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
}
.check-label-bm { color: #92400e; font-weight: 600; }

/* Street parking help icon & tooltip */
.help-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
}
.help-icon {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #cbd5e1; color: #475569;
  border: none; cursor: pointer;
  font-size: 10px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 0; font-family: inherit;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.help-icon:hover, .help-icon:focus-visible {
  background: var(--primary); color: #fff; outline: none;
}
.help-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  right: -8px; left: auto;
  width: 260px;
  background: #1e293b; color: #f1f5f9;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px; line-height: 1.55;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  z-index: 999;
  pointer-events: none;
}
.help-tooltip.visible { display: block; }
.help-tooltip p { margin: 0 0 6px; }
.help-tooltip p:last-child { margin-bottom: 0; }
/* Caret — aligned to right side to match right-anchored tooltip */
.help-tooltip::after {
  content: '';
  position: absolute;
  top: 100%; right: 12px; left: auto;
  border: 6px solid transparent;
  border-top-color: #1e293b;
}

/* Street parking stats bar */
.street-stats {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 5px 12px;
  font-size: 11px; color: var(--text-muted);
  background: #f5f3ff;
  border-bottom: 1px solid #e9d5ff;
  flex-shrink: 0;
}
.street-stats.hidden { display: none; }
.ss-dot  { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.ss-num  { font-weight: 700; color: #7c3aed; }
.ss-sep  { color: var(--border); }

/* Stats bar */
.stats-bar {
  display: flex;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
}
.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stat-n {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.stat-n.green { color: var(--green); }
.stat-n.blue  { color: var(--primary); }
.stat-l {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  text-align: center;
}

/* Carpark List */
#carpark-list {
  flex: 1;
  overflow-y: auto;
  background: var(--white);
}

.list-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 180px;
  color: var(--text-muted);
  font-size: 13px;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.no-results {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.7;
}
.no-results .no-icon { font-size: 32px; display: block; margin-bottom: 8px; }

.error-msg {
  margin: 16px;
  padding: 12px;
  background: var(--red-bg);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 13px;
  line-height: 1.5;
}

/* ── CARPARK CARD ────────────────────────────────────── */
.cp-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
  position: relative;
}
.cp-card:hover    { background: var(--hover); }
.cp-card.selected { background: var(--primary-light); }

/* Bookmark star on card */
.card-bm-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: none; border: none;
  font-size: 16px; line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color .15s, background .15s;
  z-index: 1;
}
.card-bm-btn:hover  { background: var(--border); color: var(--text); }
.card-bm-btn.active { color: #f59e0b; }

/* Vacancy badge (left side of card) */
.vac-badge {
  width: 54px;
  height: 54px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
}
.vac-badge .vn { font-size: 20px; line-height: 1; }
.vac-badge .vl { font-size: 9px; margin-top: 2px; }
.vb-green  { background: var(--green-bg); color: #166534; }
.vb-amber  { background: var(--amber-bg); color: #92400e; }
.vb-red    { background: var(--red-bg);   color: #991b1b; }
.vb-gray   { background: var(--gray-bg);  color: #64748b; }

/* Card text */
.cp-info    { flex: 1; min-width: 0; }
.cp-name    {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cp-addr    { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.cp-pills   { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.pill {
  padding: 2px 7px; border-radius: 20px; font-size: 10px; font-weight: 600;
}
.pill-open   { background: #dcfce7; color: #166534; }
.pill-closed { background: var(--red-bg); color: #991b1b; }
.pill-rate   { background: #f0fdf4; color: #166534; }
.pill-ev     { background: #ecfdf5; color: #065f46; }
.pill-dis    { background: #eff6ff; color: #1e40af; }
.pill-nature { background: #e0e7ff; color: #3730a3; }
.pill-ht     { background: #faf5ff; color: #6b21a8; }
.pill-stale      { background: #fef3c7; color: #92400e; }
.pill-priv       { background: #f3f4f6; color: #6b7280; }        /* privileges exist, not today */
.pill-priv-active{ background: #fef9c3; color: #854d0e; font-weight: 700; } /* applicable today */

/* ── MAP ─────────────────────────────────────────────── */
#map { flex: 1; z-index: 1; transition: flex .3s ease, width .3s ease, height .3s ease; }
/* Map collapse — applies at all breakpoints */
#map.collapsed {
  flex: 0 0 0 !important; width: 0 !important; height: 0 !important;
  min-width: 0 !important; min-height: 0 !important; overflow: hidden !important;
}
#sidebar.map-collapsed { flex: 1 !important; width: 100% !important; max-width: none !important; }

/* Map legend */
.map-legend {
  background: rgba(255,255,255,.92);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.8;
  box-shadow: var(--shadow-sm);
}
.legend-row { display: flex; align-items: center; gap: 6px; }
.legend-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
}
.ld-green { background: #16a34a; }
.ld-amber { background: #d97706; }
.ld-red   { background: #dc2626; }
.ld-gray  { background: #94a3b8; }

/* Map marker icons */
.map-marker {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.30);
  cursor: pointer;
  transition: transform .15s;
}
.map-marker:hover     { transform: scale(1.15); }
.mm-available         { background: #16a34a; }
.mm-low               { background: #d97706; }
.mm-full              { background: #dc2626; }
.mm-unknown           { background: #94a3b8; }

/* MarkerCluster override */
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: rgba(0,87,184,.8) !important;
  color: #fff !important;
  font-weight: 700;
}
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: rgba(0,87,184,.15) !important;
}

/* Leaflet popup */
.leaflet-popup-content-wrapper { border-radius: 8px; box-shadow: var(--shadow-md); }
.leaflet-popup-content { margin: 10px 14px; }
.popup-name { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.popup-vac  { font-size: 18px; font-weight: 700; }
.popup-sub  { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* Street parking space popup */
.street-popup   { font-size: 12px; line-height: 1.6; min-width: 160px; }
.sp-type        { font-size: 10px; font-weight: 700; color: #7c3aed; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.sp-id          { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.sp-loc         { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.sp-status      { font-weight: 700; margin-bottom: 2px; }
.sp-vt          { font-size: 11px; color: var(--text-muted); }
.sp-rate        { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.sp-updated     { font-size: 10px; color: #cbd5e1; margin-top: 4px; }
.sp-nav         { display: flex; gap: 4px; margin-top: 8px; }
.sp-nav-btn     {
  flex: 1; text-align: center; padding: 5px 4px;
  border-radius: 5px; font-size: 11px; font-weight: 600;
  text-decoration: none; color: #fff; white-space: nowrap;
  transition: opacity .15s;
}
.sp-nav-btn:hover { opacity: .85; }
.sp-nav-gm { background: var(--primary); }
.sp-nav-wz { background: #33ccff; }
.sp-nav-am { background: #0d9488; }

/* ── DETAIL PANEL ────────────────────────────────────── */
.detail-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 360px;
  background: var(--white);
  z-index: 500;
  box-shadow: -4px 0 20px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.detail-panel.hidden { transform: translateX(102%); }

.dp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--white);
}
.dp-back {
  background: none; border: none; color: var(--primary); cursor: pointer;
  font-size: 13px; font-weight: 700; padding: 4px 0;
  font-family: inherit;
}
.dp-back:hover { text-decoration: underline; }
.dp-close {
  background: var(--gray-bg); border: none; cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 14px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.dp-close:hover { background: var(--border); }
.dp-bm-btn {
  background: none; border: none; cursor: pointer;
  font-size: 20px; line-height: 1;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  transition: color .15s, background .15s;
  margin-left: auto; margin-right: 6px;
}
.dp-bm-btn:hover  { background: var(--border); color: var(--text); }
.dp-bm-btn.active { color: #f59e0b; }

.dp-body { flex: 1; overflow-y: auto; padding: 16px; }

/* Detail content */
.dp-name {
  font-size: 19px; font-weight: 700; color: var(--text); line-height: 1.3;
}
.dp-addr {
  font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.5;
}
.dp-pills { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }

.dp-section { margin-top: 20px; }
.dp-section-title {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 10px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* Vacancy table */
.vac-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.vac-table th, .vac-table td {
  padding: 7px 8px; border: 1px solid var(--border); text-align: center;
}
.vac-table th { background: var(--gray-bg); font-weight: 600; color: var(--text-muted); }
.vac-table td:first-child { text-align: left; font-weight: 500; color: var(--text); }
.vc-green { color: var(--green); font-weight: 700; }
.vc-amber { color: var(--amber); font-weight: 700; }
.vc-red   { color: var(--red);   font-weight: 700; }
.vc-gray  { color: var(--gray); }

/* Pricing rows */
.price-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.price-row:last-child { border-bottom: none; }
.price-lbl { color: var(--text-muted); }
.price-val { font-weight: 600; color: var(--text); }

/* Facility / payment badges */
.badge-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.info-badge {
  padding: 4px 10px; border-radius: 20px; font-size: 12px;
  background: var(--gray-bg); color: var(--text-muted); font-weight: 500;
}
.badge-ev-c  { background: #ecfdf5; color: #065f46; }
.badge-dis-c { background: #eff6ff; color: #1e40af; }

/* Height limit bar */
.height-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; font-size: 13px;
}
.height-val { font-size: 22px; font-weight: 700; color: var(--primary); }
.height-unit { color: var(--text-muted); font-size: 12px; }
.height-remark { font-size: 11px; color: var(--text-muted); }
.height-note { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; white-space: pre-wrap; }

/* Remark-embedded pricing (upstream API data quality workaround) */
.remark-pricing {
  font-family: inherit;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  background: var(--gray-bg);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0;
  border-left: 3px solid var(--primary-light);
}

/* Privilege entries in detail panel */
.priv-entry {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.priv-entry:last-child { margin-bottom: 0; }

.priv-applicable     { border-left: 3px solid #16a34a; }
.priv-not-applicable { border-left: 3px solid #d1d5db; opacity: .7; }

.priv-status { margin-bottom: 5px; }
.priv-badge {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
}
.priv-badge-yes { background: #dcfce7; color: #166534; }
.priv-badge-no  { background: #f3f4f6; color: #6b7280; }

.priv-days {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.priv-desc {
  font-size: 12px; line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}

/* Share section */
.share-row      { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.btn-share      {
  flex: 1; text-align: center; padding: 9px 10px;
  border-radius: var(--radius); font-size: 13px; font-weight: 700;
  text-decoration: none; cursor: pointer; border: none;
  font-family: inherit; transition: opacity .15s; color: #fff;
  white-space: nowrap;
}
.btn-share:hover { opacity: .85; }
.btn-share-wa   { background: #25d366; }
.btn-share-wc   { background: #07c160; }

/* Toast notification */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: #1e293b; color: #f1f5f9;
  padding: 10px 18px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  z-index: 9999; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* EV Charger Details section */
.dp-section-ev  { background: #f0fdf4; border-radius: var(--radius); padding: 12px 14px;
                   border-left: 3px solid #16a34a; }
.ev-summary     { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.ev-total-count { font-weight: 700; color: #166534; font-size: 14px; }
.ev-avail-count { font-size: 12px; color: #16a34a; font-weight: 600; }
.ev-type-list   { margin: 6px 0 8px; border-top: 1px solid #bbf7d0; padding-top: 6px; }
.ev-type-row    { display: flex; justify-content: space-between; align-items: baseline;
                   font-size: 12px; padding: 2px 0; gap: 8px; }
.ev-type-name   { color: var(--text); flex: 1; }
.ev-type-count  { color: #166534; font-weight: 600; white-space: nowrap; }
.ev-meta        { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.ev-source      { opacity: .75; }

html.dark .dp-section-ev  { background: #052e16; border-left-color: #4ade80; }
html.dark .ev-total-count { color: #4ade80; }
html.dark .ev-avail-count { color: #86efac; }
html.dark .ev-type-list   { border-top-color: #166534; }
html.dark .ev-type-count  { color: #4ade80; }

/* YouTube section */
.dp-section-yt  { background: #fef2f2; border-radius: var(--radius); padding: 12px 14px; }
.yt-desc        { font-size: 12px; color: #991b1b; margin: 0 0 8px; line-height: 1.5; }
.btn-yt {
  display: inline-block; padding: 7px 14px;
  background: #dc2626; color: #fff;
  border-radius: var(--radius); font-size: 12px; font-weight: 700;
  text-decoration: none; transition: background .15s;
}
.btn-yt:hover { background: #b91c1c; }

/* Data source */
.data-source-val { font-size: 12px; color: var(--text-muted); margin: 0; line-height: 1.5; }

/* ── Phase 12: History / Sparklines ──────────────────────────────────── */
.history-wrap { display: flex; flex-direction: column; gap: 10px; }
.history-row { background: var(--surface); border-radius: var(--radius); padding: 8px 10px; }
.history-row-meta {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 4px;
}
.history-type-label { font-size: 12px; font-weight: 600; }
.history-latest {
  font-size: 18px; font-weight: 700; color: var(--text);
}
.sparkline-canvas { display: block; width: 100%; height: 64px; }
.history-time-row {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--text-muted); margin-top: 2px;
}
.history-no-data { font-size: 12px; color: var(--text-muted); margin: 0; }
.manual-no-vacancy {
  font-size: 13px; color: var(--text-muted);
  background: var(--surface); border-radius: var(--radius);
  padding: 10px 12px; margin: 0;
}
html.dark .history-row { background: #1e293b; }

/* Directions buttons row */
.dp-directions-row {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px;
}
.dp-directions-row .btn-directions {
  flex: 1 1 0; min-width: 0; margin-top: 0; padding: 10px 8px;
  font-size: 13px;
}
.btn-directions {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; margin-top: 16px; padding: 12px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 700; cursor: pointer;
  text-decoration: none; transition: background .15s;
  font-family: inherit;
}
.btn-directions:hover { background: var(--primary-h); }
.btn-waze { background: #33ccff; }
.btn-waze:hover { background: #22b0e0; }
.btn-amap { background: #0d9488; }
.btn-amap:hover { background: #0b7a70; }

/* Street summary card (search result for a street name) */
.street-summary-card {
  background: #f0fdf4; border: 1px solid #86efac;
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 6px;
}
.ss-header { margin-bottom: 4px; }
.ss-label {
  font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: #16a34a;
}
.ss-street-name { font-size: 14px; font-weight: 700; color: #14532d; line-height: 1.3; }
.ss-district { font-size: 12px; color: #166534; margin-top: 1px; }
.ss-pills { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.ss-show-btn {
  margin-top: 8px; padding: 5px 10px;
  background: #16a34a; color: #fff;
  border: none; border-radius: var(--radius);
  font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: background .15s;
}
.ss-show-btn:hover { background: #15803d; }

/* Stale data alert (detail panel) */
.stale-alert {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12px; color: #92400e;
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  padding: 8px 12px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  line-height: 1.5;
}

/* Public holiday note (hours section) */
.ph-note {
  font-size: 12px; color: #1d4ed8;
  margin-top: 8px; line-height: 1.5;
}

/* Public holiday note (pricing section) */
.ph-pricing-note {
  font-size: 12px; color: #1d4ed8;
  background: #eff6ff;
  border-left: 3px solid #3b82f6;
  padding: 8px 12px;
  border-radius: var(--radius);
  margin-top: 10px;
  line-height: 1.5;
}

/* Hours list */
.hours-row {
  display: flex; justify-content: space-between;
  font-size: 12px; padding: 5px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.hours-row:last-child { border-bottom: none; }
.hours-days { font-weight: 500; color: var(--text); }

/* Highlight the PH row when today is a public holiday */
.hours-row.ph-today {
  background: #eff6ff;
  border-radius: 4px;
  padding: 5px 8px;
  border-bottom: none;
  color: var(--text);
  font-weight: 600;
}
.hours-row.ph-today .hours-days { color: #1d4ed8; }

/* ── SCROLLBARS ──────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── MOBILE ──────────────────────────────────────────── */
/* Mobile collapse toggle buttons — hidden on desktop */
.section-toggle { display: none; }

@media (max-width: 768px) {
  :root { --sidebar-w: 100%; }
  .app-tagline { display: none; }
  .main-content { flex-direction: column-reverse; }
  #map { flex: 1; min-height: 0; overflow: hidden;
         transition: height .3s ease, flex .3s ease, width .3s ease; }
  #sidebar { height: 50vh; width: 100%; border-right: none;
             border-top: 1px solid var(--border);
             transition: height .3s ease; }
  #sidebar.map-collapsed { height: auto; }
  .filters-wrap { transition: max-height .3s ease, opacity .3s ease;
                  max-height: 500px; opacity: 1; overflow: hidden; }
  .filters-wrap.collapsed { max-height: 0; opacity: 0; }
  .detail-panel { width: 100%; top: 0; }
  .refresh-timer { display: none; }

  /* Section toggle buttons */
  .section-toggle {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%; padding: 5px 0;
    background: var(--border); border: none; border-radius: 0;
    font-size: 11px; font-weight: 600; color: var(--text-muted);
    cursor: pointer; letter-spacing: .04em;
    font-family: inherit; transition: background .15s;
  }
  .section-toggle:hover { background: #cbd5e1; }

  /* Map toggle bar sits between sidebar and map (column-reverse order) */
  #map-toggle-bar {
    width: 100%; background: var(--white); flex-shrink: 0;
    border-bottom: 1px solid var(--border);
  }
  #map-toggle-bar .section-toggle { border-bottom: none; }

  /* Filter toggle sits above the filter rows inside sidebar */
  #filter-toggle-btn { border-bottom: 1px solid var(--border); }
}

@media (max-width: 420px) {
  .header-left .logo { display: none; }
  .app-title { font-size: 15px; }
}
