:root {
  --navy:    #0d2137;
  --blue:    #1467d0;
  --bg:      #eef1f6;
  --surface: #ffffff;
  --border:  #dde3ea;
  --text:    #111827;
  --muted:   #6b7280;
  --radius:  10px;
  --shadow:  0 1px 4px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.04);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  height: 58px;
  background: var(--navy);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  z-index: 100;
}

.brand {
  font-size: 18px;
  font-weight: 800;
  color: white;
  text-decoration: none;
  letter-spacing: -0.4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand em { color: #7dd3fc; font-style: normal; }

.header-search {
  flex: 1;
  max-width: 560px;
  display: flex;
  align-items: center;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
  position: relative;
}
.search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: #9ca3af;
  pointer-events: none;
  flex-shrink: 0;
}
.header-search input {
  flex: 1;
  padding: 0 12px 0 36px;
  height: 38px;
  border: none;
  font-size: 14px;
  color: var(--text);
  outline: none;
  background: transparent;
  min-width: 0;
}
.header-search input::placeholder { color: #9ca3af; }
.header-search button {
  padding: 0 18px;
  height: 38px;
  background: var(--blue);
  color: white;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.header-search button:hover { background: #1256b4; }

.header-nav { margin-left: auto; flex-shrink: 0; }
.header-nav a {
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
}
.header-nav a:hover { color: white; background: rgba(255,255,255,0.1); }

/* ── App body ────────────────────────────────────────────── */
.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Left column ─────────────────────────────────────────── */
.left-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  position: relative;
  min-width: 0;
}

/* ── Tab strip ───────────────────────────────────────────── */
.tab-strip {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  flex-shrink: 0;
  gap: 4px;
}
.tab {
  padding: 13px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); border-bottom-color: var(--blue); font-weight: 600; }

/* ── Areas filter bar ────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  align-items: center;
}
.filter-bar input,
.filter-bar select {
  flex: 1;
  min-width: 80px;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: white;
}
.filter-bar input:focus,
.filter-bar select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(20,103,208,0.08);
}
.filter-bar button {
  padding: 7px 16px;
  background: var(--navy);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.filter-bar button:hover { background: #1a3a5c; }

/* ── Scrollable results ──────────────────────────────────── */
.results-pane {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

/* ── Sort bar ────────────────────────────────────────────── */
.sort-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.result-count { font-size: 13px; color: var(--muted); }
.sort-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.sort-label select {
  padding: 4px 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: white;
  cursor: pointer;
  color: var(--text);
}

/* ── Area cards ──────────────────────────────────────────── */
.area-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 14px 18px;
  margin-bottom: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.area-card:hover {
  border-color: var(--blue);
  box-shadow: 0 3px 16px rgba(20,103,208,0.14);
}
.area-card-left { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.area-code-row { display: flex; align-items: center; gap: 8px; }
.area-code-text { font-size: 22px; font-weight: 800; color: var(--navy); }
.area-location { font-size: 13px; color: var(--muted); }
.area-card-right { text-align: right; flex-shrink: 0; }
.area-charge-count { font-size: 20px; font-weight: 700; color: var(--navy); }
.area-charge-detail { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Property / Charge result cards ──────────────────────── */
.property-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.property-card:hover {
  border-color: var(--blue);
  box-shadow: 0 4px 18px rgba(20,103,208,0.13);
}
.prop-badge {
  position: absolute;
  top: 16px;
  right: 18px;
}
.prop-address {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
  margin-bottom: 6px;
  padding-right: 100px;
}
.prop-postcodes {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}
.postcode-pill {
  background: #dbeafe;
  color: #1d4ed8;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.prop-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
  gap: 8px;
}
.prop-company {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prop-date { font-size: 11px; color: #9ca3af; white-space: nowrap; }

/* ── Status badges ───────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-outstanding { background: #fef3c7; color: #92400e; }
.badge-active      { background: #d1fae5; color: #065f46; }
.badge-dissolved   { background: #fee2e2; color: #991b1b; }

/* ── Rank badges ─────────────────────────────────────────── */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.rank-1     { background: #fbbf24; color: #1a1a1a; }
.rank-2     { background: #d1d5db; color: #1a1a1a; }
.rank-3     { background: #cd7f32; color: white; }
.rank-other { background: #e5e7eb; color: #6b7280; }

/* ── Companies table ─────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
thead th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #f1f5f9; cursor: pointer; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f0f7ff; }
tbody td { padding: 10px 14px; vertical-align: top; font-size: 13px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Sub-search bars ─────────────────────────────────────── */
.sub-search {
  display: flex;
  gap: 8px;
  padding: 4px 0 14px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
}
.sub-search input,
.sub-search select {
  flex: 1;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: white;
  box-shadow: var(--shadow);
}
.sub-search input:focus,
.sub-search select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(20,103,208,0.08);
}
.sub-search button {
  padding: 9px 18px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.sub-search button:hover { background: #1256b4; }

/* ── Search result summary ───────────────────────────────── */
#search-summary {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
  padding: 8px 12px;
  background: white;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ── Empty / loading / error ─────────────────────────────── */
.empty-state { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.loading     { padding: 48px 20px; text-align: center; color: var(--muted); }
.error       { padding: 48px 20px; text-align: center; color: #dc2626; }

/* ── Pagination ──────────────────────────────────────────── */
#pagination, .pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#pagination button, .pagination-bar button {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
#pagination button:hover:not(:disabled),
.pagination-bar button:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
#pagination button:disabled,
.pagination-bar button:disabled { opacity: 0.35; cursor: default; }
#page-info, .pagination-bar span { font-size: 13px; color: var(--muted); }

/* ── Detail overlay ──────────────────────────────────────── */
#detail-panel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  z-index: 20;
  overflow-y: auto;
  padding: 20px;
}
.close-btn {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 7px 16px;
  cursor: pointer;
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  display: inline-block;
}
.close-btn:hover { border-color: var(--navy); color: var(--navy); }

#detail-content h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
#detail-content h3 {
  font-size: 11px;
  font-weight: 700;
  margin: 22px 0 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 24px;
  margin-bottom: 18px;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.detail-meta dt { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 10px; }
.detail-meta dd { font-weight: 600; font-size: 13px; margin-top: 2px; }
.charge-card {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  margin-bottom: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
}
.charge-card:hover { border-color: #93c5fd; }
.charge-card .desc { color: #4a5568; margin-top: 6px; font-size: 12px; line-height: 1.55; font-style: italic; }
.charge-card .pc-tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.pc-tag {
  background: #dbeafe;
  color: #1d4ed8;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.pc-tag:hover { background: var(--navy); color: white; }

/* ── Pulse marker (charge location highlight) ────────────── */
@keyframes pulse-expand {
  0%   { transform: scale(0.3); opacity: 0.9; }
  100% { transform: scale(3.2); opacity: 0;   }
}
.pulse-marker { background: none !important; border: none !important; }
.pulse-ring {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(189, 0, 38, 0.55);
  position: absolute; top: 10px; left: 10px;
  animation: pulse-expand 1.4s ease-out infinite;
}
.pulse-dot {
  width: 12px; height: 12px;
  background: #bd0026;
  border-radius: 50%;
  border: 2.5px solid white;
  box-shadow: 0 0 6px rgba(0,0,0,0.45);
  position: absolute; top: 14px; left: 14px;
}

/* ── House map markers ───────────────────────────────────── */
.house-icon {
  background: none !important;
  border: none !important;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.35));
}
.house-icon:hover { filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)) brightness(1.15); }

/* ── Registered address link ─────────────────────────────── */
.addr-link {
  color: var(--blue);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none;
  border: none;
  font: inherit;
  padding: 0;
}
.addr-link:hover { color: var(--navy); }

.addr-back-btn {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 5px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 14px;
  display: inline-block;
}
.addr-back-btn:hover { border-color: var(--navy); color: var(--navy); }

/* ── Right sidebar ───────────────────────────────────────── */
/* ── Right panel (map + stats) ───────────────────────────── */
.right-sidebar {
  width: 46%;
  min-width: 400px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow: hidden;
  background: var(--bg);
  border-left: 1px solid var(--border);
}

/* ── Compact stats strip ─────────────────────────────────── */
.stats-strip {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}
.stat-item {
  flex: 1;
  padding: 8px 10px;
  border-right: 1px solid var(--border);
  text-align: center;
}
.stat-item:last-child { border-right: none; }
.stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 15px; font-weight: 700; color: var(--navy); margin-top: 2px; }

/* ── Portfolio evaluation ────────────────────────────────── */
.eval-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--blue); color: white;
  border: none; border-radius: 8px; padding: 8px 16px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  margin: 14px 0 10px;
}
.eval-btn:hover { background: #1256b4; }

.portfolio-panel { margin: 4px 0 20px; }

.portfolio-summary {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 6px;
  box-shadow: var(--shadow);
}
.ps-item { background: var(--surface); padding: 10px 12px; text-align: center; }
.ps-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.ps-value { font-size: 16px; font-weight: 700; color: var(--navy); margin-top: 3px; }
.ps-green { color: #16a34a; }
.ps-blue  { color: var(--blue); }
.ps-meta  { font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.ps-note  { font-size: 11px; color: var(--muted); margin-top: 12px; font-style: italic; }

/* ── Forecasts tab ──────────────────────────────────────── */
.forecast-source { margin-bottom: 32px; }
.forecast-source h2 { font-size: 17px; margin-bottom: 4px; }
.forecast-meta { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.forecast-meta a { color: var(--accent, #2563eb); text-decoration: none; }
.forecast-meta a:hover { text-decoration: underline; }
.forecast-table { width: 100%; border-collapse: collapse; font-size: 13px; max-width: 460px; }
.forecast-table th { font-size: 10px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.5px; padding: 6px 10px; border-bottom: 2px solid var(--border); text-align: left; }
.forecast-table td { padding: 7px 10px; border-bottom: 1px solid #f3f4f6; }
.forecast-table .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600;
  border-radius: 4px; }
.forecast-history-title { font-size: 13px; margin: 24px 0 10px; }
.forecast-change { border-left: 3px solid var(--border); padding: 4px 0 4px 12px; margin-bottom: 12px; }
.forecast-change-date { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.forecast-change ul { margin: 0; padding-left: 18px; font-size: 12px; color: var(--muted); }
.forecast-no-changes { font-size: 12px; color: var(--muted); font-style: italic; }

.portfolio-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
.portfolio-table th { font-size: 10px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.5px; padding: 6px 8px; border-bottom: 2px solid var(--border); }
.portfolio-table td { padding: 8px; border-bottom: 1px solid #f3f4f6; vertical-align: top; }
.portfolio-table tr:last-child td { border-bottom: none; }
.portfolio-table tr:hover td { background: #f8fafc; }
.portfolio-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.portfolio-table .charge-no-data td { color: var(--muted); }
.charge-desc { font-size: 12px; color: var(--text); margin-bottom: 4px; }
.txn-postcode { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.txn-row { font-size: 11px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.txn-addr  { font-weight: 600; color: var(--text); }
.txn-price { color: #16a34a; font-weight: 600; }
.txn-date  { color: var(--muted); }
.txn-est   { color: var(--blue); font-style: italic; }
.txn-no-data { font-size: 11px; color: #9ca3af; font-style: italic; margin-top: 2px; }

.portfolio-company-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 6px;
}
.remove-btn {
  margin-left: auto; background: none; border: none;
  color: var(--muted); cursor: pointer; font-size: 14px;
  padding: 2px 6px; border-radius: 4px;
}
.remove-btn:hover { background: #fee2e2; color: #dc2626; }

#portfolio-actions { margin: 6px 0 4px; }

.portfolio-section {
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 10px; overflow: hidden;
}
.portfolio-section summary {
  padding: 10px 14px; background: #f8fafc; cursor: pointer;
  font-size: 13px; list-style: none; display: flex; align-items: center; gap: 8px;
}
.portfolio-section summary:hover { background: #eef1f6; }
.portfolio-section > .portfolio-summary,
.portfolio-section > .portfolio-table,
.portfolio-section > .ps-meta { margin: 10px 14px; }

/* ── Full-height map ─────────────────────────────────────── */
.map-fill {
  flex: 1;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
#map { height: 100%; display: block; }
