/* ── Detail panel ──────────────────────────────── */
/* ── Shared side-panel geometry (all slide-in panels) ── */
.side-panel {
  position: fixed;
  top: 0; right: 0;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 1000;
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.has-overlay-panel #theme-toggle,
body.has-overlay-panel #layers-btn,
body.has-overlay-panel #layers-panel,
body.has-overlay-panel #pwa-install-btn,
body.has-overlay-panel #pwa-install-tooltip {
  z-index: 50;
}
#detail-panel.open, #cc-panel.open, #town-panel.open, #school-detail-panel.open { transform: translateX(0); }
#detail-panel  { width: 480px; }
#town-panel    { width: 480px; }
#cc-panel      { width: 380px; }

/* ── Shared panel header ── */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}
#detail-header {
  position: relative;
  color: var(--text);
  padding: 8px 14px 7px;
  background:
    radial-gradient(120px 80px at calc(100% - 54px) -12px, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    linear-gradient(135deg, color-mix(in srgb, var(--surface-2) 90%, white 10%) 0%, var(--surface-2) 58%, color-mix(in srgb, var(--surface-2) 86%, var(--accent) 14%) 100%);
  overflow: hidden;
  isolation: isolate;
  display: block;
}
#detail-header::before {
  content: "";
  position: absolute;
  inset: 8px auto 8px 0;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 75%, white 25%) 0%, color-mix(in srgb, var(--accent) 45%, transparent) 100%);
  opacity: .9;
  pointer-events: none;
}

/* ── Shared panel close button ── */
.panel-close-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 0;
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.panel-close-btn:hover { color: var(--text); }
#detail-close {
  position: absolute;
  top: 7px;
  right: 10px;
  z-index: 1;
  margin-top: 0;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(8,15,30,.08);
  backdrop-filter: blur(6px);
}

/* ── Childcare centre panel ── */
#cc-panel-name { font-size: 15px; font-weight: 700; line-height: 1.4; flex: 1; min-width: 0; }
#cc-panel-body { flex: 1; overflow-y: auto; padding: 12px 16px; }

/* ── Town detail panel ── */
#town-header > div { flex: 1; min-width: 0; }
#town-panel-name { font-size: 18px; font-weight: 700; line-height: 1.35; }
#town-panel-meta { margin-top: 4px; font-size: 13px; color: var(--text-dim); }
#town-panel-body {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
#town-summary-chips { padding: 12px 16px 0; }
#town-charts-section { padding: 0 16px 4px; }
#town-top-blocks-section { padding: 0 0 16px; }
#town-top-blocks-section .panel-section-label { padding: 0 8px; }
#town-blocks-table {
  padding: 0 6px;
  overflow-x: auto;
}
.town-blocks-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 100%;
  table-layout: auto;
  font-size: 13px;
  color: var(--text);
  border-radius: 10px;
  box-shadow: 0 0 0 1px var(--border);
  background: var(--surface-1);
  overflow: hidden;
}
.town-blocks-table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: .035em;
  text-align: left;
  padding: 10px 10px 9px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.town-blocks-table thead th + th { border-left: 1px solid var(--border); }
.town-blocks-table thead th:nth-last-child(-n + 2) { text-align: right; }
.town-blocks-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
  line-height: 1.4;
  vertical-align: middle;
  background-clip: padding-box;
}
.town-blocks-table td + td { border-left: 1px solid var(--border-soft); }
.town-blocks-table tbody tr:nth-child(even) td { background-color: var(--surface-1); }
.town-blocks-table tbody tr:hover td { background-color: var(--surface-2) !important; }
.town-blocks-table td:nth-child(3),
.town-blocks-table td:nth-child(4) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.town-blocks-table td:nth-child(4) {
  font-weight: 800;
  color: var(--text);
}
.town-blocks-table td:nth-child(2) {
  width: 100%;
}
:root[data-theme="light"] .town-blocks-table tbody tr:nth-child(even) td { background-color: rgba(15,22,38,.04); }
.data-source {
  font-size: 11px; font-weight: 400; color: var(--text-dim);
  letter-spacing: 0; text-transform: none;
}
#town-price-chart { width: 100%; height: 320px; }
#town-flat-chart  { width: 100%; min-height: 160px; }
#town-lease-chart { width: 100%; min-height: 140px; }
/* Trend controls: town pills + flat-type chips */
#town-trend-controls { padding: 6px 16px 4px; }
.trend-town-pills {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 4px;
}
.town-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.03em;
  color: var(--town-color, var(--text));
  border: 1.5px solid var(--town-color, var(--border));
  border-radius: 12px; padding: 2px 8px;
  background: transparent;
}
.town-pill-remove {
  background: none; border: none; padding: 0 0 0 2px;
  color: var(--text-dim); cursor: pointer; font-size: 14px; line-height: 1;
  min-width: 20px; min-height: 20px;
}
.town-pill-remove:hover { color: var(--text); }
.town-add-select {
  font-size: 12px; padding: 3px 6px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface); color: var(--text);
  cursor: pointer; min-height: 28px;
}
.town-summary-note { padding: 0 16px 8px; }
.town-compare-warning { margin: 4px 0 0; font-size: 11px; }
.town-blocks-empty { padding: 0 16px; }
.town-block-row { cursor: pointer; }
.trend-ft-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.trend-rebase-toggle { margin-left: auto; }
.ft-chip {
  font-size: 11px; padding: 2px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-dim); cursor: pointer; min-height: 24px;
  transition: background 0.12s, color 0.12s;
}
.ft-chip--active {
  background: var(--accent, #2196f3); border-color: var(--accent, #2196f3);
  color: #fff;
}
/* Y-o-Y chip */
.yoy-chip {
  font-size: 12px; font-weight: 600; padding: 2px 10px 4px;
  display: inline-block;
}
.yoy-up   { color: var(--green, #2e7d32); }
.yoy-down { color: var(--red,   #c62828); }
/* Comparison top-blocks grid */
.compare-blocks-grid {
  display: flex; flex-direction: column; gap: 16px;
}
.compare-town-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  color: var(--text-dim); text-transform: uppercase; padding: 4px 0 2px;
}
/* Town popup */
.town-popup-content { padding: 2px 0; color: var(--text, #1a1a1a); }
.town-popup-name { font-size: 16px; font-weight: 700; margin-bottom: 3px; }
.town-popup-region { font-size: 12px; color: var(--text-dim, #888); margin-bottom: 6px; }
.town-popup-count { font-size: 13px; margin-bottom: 12px; }
.town-popup-btn { width: 100%; font-size: 13px; background: var(--accent); }
.town-popup-btn:hover:not(:disabled) { background: var(--accent-hov); }

.town-tooltip {
  min-width: 156px;
}
.town-tooltip strong {
  display: block;
  line-height: 1.2;
}

/* flex: 1 + min-width: 0 lets the inner text column claim all available width so
   long MRT names don't wrap mid-word. Without this, the div is only as wide as its
   widest unwrapped child (the block title), leaving ~104px for meta rows. */
#detail-header > div {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-right: 4px;
}
#detail-block-name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  padding-right: 48px;
}
.detail-title-text { min-width: 0; }
.detail-postal {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: 999px;
  padding: 1px 8px;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.55;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
}
.detail-jump-btn {
  min-width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--text-dim);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16);
  cursor: pointer;
}
.detail-jump-btn:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}
#detail-meta {
  margin-top: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.meta-subline {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.35;
  margin-top: 0;
}
.meta-subline strong { color: var(--text); font-weight: 700; }
.meta-mrt {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.35;
}
.meta-stats {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  font-size: 12px;
  margin-top: 0;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.meta-stats::-webkit-scrollbar { display: none; }
/* Flat-type breakdown — child of the units stat above. ↳ drawn via ::before. */
.meta-flat {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  margin-top: 0;
  padding-left: 2px;
}
.meta-flat::before {
  content: '↳';
  color: var(--text);
  font-size: 13px;
  flex-shrink: 0;
  margin-right: 1px;
}
/* Insights tab — cards rendered by detail-insights.ts. */
