/* Apollo — Market Intelligence Styles */

:root {
  --navy: #1a2744;
  --navy-light: #2d3e5f;
  --teal: #2a9d8f;
  --teal-light: #3dbdad;
  --gold: #c9a84c;
  --gold-light: #e0c97a;
  --bg: #f5f5f0;
  --white: #ffffff;
  --text: #333333;
  --ok: #2d8a4e;
  --warn: #c9752c;
  --error: #c94c4c;
  --border: #ddd;
  --input-bg: #fafafa;
  --grey-dark: #6b7280;
  --grey-mid: #c0c5cc;
  --grey-light: #f3f4f6;
  /* For text rendered below 14 px on white — needs a darker grey to clear
     WCAG AA's 4.5:1 bar even though pa11y rounds to integers. 5.5:1 vs #fff. */
  --muted-strong: #5b626d;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ─── Loading ──────────────────────────────────────────────────────── */

.app-loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100vh; gap: 1rem;
  color: var(--navy);
}
.app-loading .spinner {
  width: 40px; height: 40px; border: 3px solid var(--border);
  border-top-color: var(--gold); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Layout ───────────────────────────────────────────────────────── */

.apollo-container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

/* ─── Header ───────────────────────────────────────────────────────── */

.apollo-header {
  background: var(--navy);
  color: var(--white);
  padding: 1rem 2rem;
  border-radius: 8px 8px 0 0;
  display: flex; align-items: center; justify-content: space-between;
}
.apollo-header h1 {
  font-size: 1.4rem; font-weight: 600;
  display: flex; align-items: center; gap: 0.5rem;
}
.apollo-header .subtitle {
  font-size: 0.85rem; color: var(--gold); font-style: italic;
}

/* ─── Navigation Tabs ──────────────────────────────────────────────── */

.apollo-nav {
  display: flex; background: var(--navy-light);
  border-radius: 0 0 8px 8px;
  padding: 0 1rem;
}
.apollo-nav button {
  background: none; border: none; color: var(--grey-mid);
  padding: 0.7rem 1.2rem; font-size: 0.9rem; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.apollo-nav button:hover { color: var(--white); }
.apollo-nav button.active {
  color: var(--gold); border-bottom-color: var(--gold);
}

/* ─── Filter Bar ───────────────────────────────────────────────────── */

.filter-bar {
  display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end;
  padding: 1rem; background: var(--white);
  border: 1px solid var(--border); border-radius: 6px;
  margin: 1rem 0;
}
.filter-group { display: flex; flex-direction: column; gap: 0.2rem; }
.filter-group label {
  font-size: 0.75rem; color: var(--grey-dark); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.filter-group select,
.filter-group input {
  padding: 0.4rem 0.6rem; border: 1px solid var(--border);
  border-radius: 4px; font-size: 0.85rem; background: var(--input-bg);
}
.filter-group select { min-width: 140px; }
.filter-group input[type="date"] { min-width: 130px; }
.filter-bar .btn-reset {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  padding: 0.4rem 0.8rem; font-size: 0.85rem; cursor: pointer;
  color: var(--grey-dark);
}
.filter-bar .btn-reset:hover { background: var(--grey-light); }

/* ─── KPI Cards ────────────────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}
.kpi-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 6px; padding: 1rem;
}
.kpi-card .kpi-label {
  font-size: 0.75rem; color: var(--grey-dark); text-transform: uppercase;
  letter-spacing: 0.04em; margin-bottom: 0.3rem;
}
.kpi-card .kpi-value {
  font-size: 1.6rem; font-weight: 700; color: var(--navy);
  line-height: 1.2;
}
.kpi-card .kpi-change {
  font-size: 0.8rem; margin-top: 0.2rem;
}
.kpi-change.positive { color: var(--ok); }
.kpi-change.negative { color: var(--error); }
.kpi-change.neutral { color: var(--grey-dark); }

/* ─── Chart Panels ─────────────────────────────────────────────────── */

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.chart-panel {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 6px; padding: 1rem;
}
.chart-panel h3 {
  font-size: 0.9rem; color: var(--navy); margin-bottom: 0.6rem;
  font-weight: 600;
}
.chart-panel canvas { width: 100% !important; max-height: 300px; }
.chart-panel.full-width { grid-column: 1 / -1; }

/* ─── Result Table ─────────────────────────────────────────────────── */

.result-table-wrap {
  overflow-x: auto; background: var(--white);
  border: 1px solid var(--border); border-radius: 6px;
}
.result-table {
  width: 100%; border-collapse: collapse; font-size: 0.85rem;
}
.result-table thead th {
  background: var(--grey-light); color: var(--navy);
  padding: 0.6rem 0.8rem; text-align: left; font-weight: 600;
  border-bottom: 2px solid var(--border); cursor: pointer;
  white-space: nowrap; user-select: none;
}
.result-table thead th:hover { background: #e5e7eb; }
.result-table thead th .sort-arrow { margin-left: 0.3rem; font-size: 0.7rem; }
.result-table tbody td {
  padding: 0.5rem 0.8rem; border-bottom: 1px solid var(--border);
}
.result-table tbody tr:hover { background: #fefce8; }
.result-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ─── Column-visibility gear (desktop-first: all columns on by default) ─── */

.result-table-controls {
  position: relative;
  display: flex; justify-content: flex-end;
  margin: 0 0 0.5rem 0;
}
.col-gear-btn {
  background: var(--white); color: var(--navy);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 0.35rem 0.75rem; font-size: 0.8rem; font-weight: 600;
  cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; gap: 0.3rem;
}
.col-gear-btn:hover { background: var(--grey-light); }
.col-gear-btn:focus-visible {
  outline: 2px solid var(--navy); outline-offset: 2px;
}
.col-gear-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 20;
  min-width: 220px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.35rem 0;
  box-shadow: 0 8px 24px rgba(11, 62, 156, 0.12);
  display: flex; flex-direction: column;
}
.col-gear-item {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.4rem 0.75rem; cursor: pointer;
  font-size: 0.82rem; color: var(--navy);
  user-select: none;
}
.col-gear-item:hover { background: var(--grey-light); }
.col-gear-item input[type="checkbox"] { margin: 0; }
.col-gear-item.disabled {
  /* Was #9ca3af — 3.4:1 on #ffffff fails WCAG AA. Bumped to #6b7280 (4.6:1). */
  color: #6b7280; cursor: not-allowed;
}
.col-gear-item.disabled:hover { background: transparent; }
.col-gear-all {
  margin: 0.25rem 0.5rem 0.4rem;
  background: var(--navy); color: var(--white);
  border: 1px solid var(--navy); border-radius: 4px;
  padding: 0.35rem 0.6rem; font-size: 0.75rem; font-weight: 600;
  cursor: pointer; text-align: center;
}
.col-gear-all:hover { background: #08306f; border-color: #08306f; }
.col-gear-all:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}

/* ─── Pagination ───────────────────────────────────────────────────── */

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0.8rem; font-size: 0.85rem; color: var(--grey-dark);
}
.pagination button {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.3rem 0.8rem; cursor: pointer;
}
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination button:hover:not(:disabled) { background: var(--grey-light); }

/* ─── Stats Summary ────────────────────────────────────────────────── */

.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem; padding: 0.8rem;
  background: #f0faf8; border: 1px solid #a7f3d0;
  border-radius: 6px; margin-bottom: 1rem;
}
.stats-summary .stat-item { text-align: center; }
.stats-summary .stat-label {
  font-size: 0.7rem; color: var(--grey-dark); text-transform: uppercase;
}
.stats-summary .stat-value {
  font-size: 1.1rem; font-weight: 600; color: var(--navy);
}

/* ─── Export Panel ─────────────────────────────────────────────────── */

.export-panel {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 6px; padding: 1.5rem;
}
.export-panel h3 { color: var(--navy); margin-bottom: 0.8rem; }
.export-panel p { color: var(--grey-dark); margin-bottom: 1rem; font-size: 0.9rem; }

.btn-primary {
  background: var(--navy); color: var(--white); border: none;
  border-radius: 4px; padding: 0.6rem 1.2rem; font-size: 0.9rem;
  cursor: pointer; font-weight: 500;
}
.btn-primary:hover { background: var(--navy-light); }
.btn-secondary {
  background: var(--white); color: var(--navy); border: 1px solid var(--navy);
  border-radius: 4px; padding: 0.6rem 1.2rem; font-size: 0.9rem;
  cursor: pointer; font-weight: 500;
}
.btn-secondary:hover { background: var(--grey-light); }

/* ─── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .apollo-container { padding: 0.8rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .apollo-header { flex-direction: column; gap: 0.3rem; }
}

/* ─── Compare View (Map) ──────────────────────────────────────────── */

.compare-panel {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
  min-height: 600px;
}
.compare-sidebar {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 6px; padding: 1rem; overflow-y: auto;
  max-height: 700px;
}
.compare-map {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 6px; overflow: hidden; min-height: 600px;
}
.compare-map .leaflet-container { height: 100%; min-height: 600px; width: 100%; }
/* Leaflet's auto-rendered attribution links sit inside a paragraph block;
   axe flags link-in-text-block when only colour distinguishes them. */
.leaflet-control-attribution a { text-decoration: underline; }

.target-card {
  background: var(--navy); color: var(--white); padding: 0.8rem;
  border-radius: 6px; margin-bottom: 0.8rem;
}
.target-card .label { font-size: 0.7rem; color: var(--gold); text-transform: uppercase; }
.target-card .value { font-size: 0.95rem; font-weight: 600; }

.similar-item {
  border-bottom: 1px solid var(--border); padding: 0.6rem 0;
  cursor: pointer; transition: background 0.15s;
}
.similar-item:hover { background: var(--grey-light); }
.similar-item .top {
  display: flex; justify-content: space-between; font-size: 0.85rem;
}
.similar-item .score-badge {
  background: var(--teal); color: var(--white);
  padding: 0.1rem 0.4rem; border-radius: 10px; font-size: 0.7rem;
}
.similar-item .meta {
  font-size: 0.75rem; color: var(--grey-dark); margin-top: 0.2rem;
}

@media (max-width: 1024px) {
  .compare-panel { grid-template-columns: 1fr; }
}

/* Score breakdown (inside .similar-item when expanded) */
.score-breakdown {
  margin-top: 0.5rem; padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}
.score-bar {
  display: grid; grid-template-columns: 80px 1fr 40px;
  gap: 0.4rem; align-items: center;
  font-size: 0.7rem; margin-bottom: 0.25rem;
}
.score-bar-label { color: var(--grey-dark); }
.score-bar-track {
  background: var(--grey-light); border-radius: 8px; height: 6px; overflow: hidden;
}
.score-bar-fill {
  background: linear-gradient(90deg, var(--teal) 0%, var(--gold) 50%, var(--error) 100%);
  height: 100%;
}
.score-bar-val { text-align: right; font-variant-numeric: tabular-nums; }

/* Confidence banner (Compare sidebar) — RICS/EMF confidence tiering */
.confidence-banner {
  padding: 0.55rem 0.8rem; border-radius: 6px; margin-bottom: 0.8rem;
  font-size: 0.8rem; border: 1px solid transparent; line-height: 1.4;
}
.confidence-oracledark {
  background: #fef2f2; color: var(--error); border-color: #fecaca;
  font-weight: 600;
}
.confidence-low {
  background: #fff7ed; color: var(--warn); border-color: #fed7aa;
}
.confidence-medium {
  background: #f0faf8; color: var(--navy); border-color: #a7f3d0;
}
.confidence-high {
  background: #ecfdf5; color: var(--ok); border-color: #a7f3d0;
}

/* Provenance footer — RICS/IVS-aligned evidence source display */
.provenance-footer {
  margin-top: 1.2rem; padding: 0.6rem 0.8rem;
  font-size: 0.72rem; color: var(--grey-dark);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
}
.provenance-version {
  font-family: ui-monospace, Consolas, monospace;
  /* Was opacity: 0.75 — failed WCAG AA color-contrast on light backgrounds. */
  color: #4b5563;
}

/* Data freshness badge (header) */
.freshness-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.05rem 0.4rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  vertical-align: middle;
}
.freshness-fresh      { background: var(--ok);       color: var(--white); }
.freshness-acceptable { background: var(--gold);     color: var(--navy);  }
.freshness-stale      { background: var(--error);    color: var(--white); }
.freshness-unknown    { background: var(--grey-mid); color: var(--white); }

/* Methodology disclosure — button in header */
.methodology-link {
  background: none;
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  margin-bottom: 0.3rem;
  font-family: inherit;
}
.methodology-link:hover {
  background: var(--gold);
  color: var(--navy);
}

/* Modal (generic — first use: methodology) */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-dialog {
  background: var(--white);
  border-radius: 8px;
  padding: 1.5rem 2rem;
  max-width: 720px; width: 100%;
  max-height: 85vh; overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem; padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--gold);
}
.modal-header h2 {
  color: var(--navy); font-size: 1.3rem; margin: 0;
}
.modal-close {
  background: none; border: none;
  font-size: 1.8rem; cursor: pointer;
  color: var(--grey-dark);
  line-height: 1; padding: 0;
  width: 2rem; height: 2rem;
}
.modal-close:hover { color: var(--navy); }
.modal-body h3 {
  color: var(--navy); margin: 1rem 0 0.4rem;
  font-size: 1rem;
}
.modal-body ul {
  margin: 0 0 0.5rem 1.5rem;
  font-size: 0.85rem; line-height: 1.6;
}
.modal-body code {
  background: var(--grey-light);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-family: ui-monospace, Consolas, monospace;
}
.modal-body a {
  color: var(--teal); text-decoration: none;
}
.modal-body a:hover { text-decoration: underline; }

/* Publish status pill (Export view — after Publish action) */
.publish-status {
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  border: 1px solid transparent;
}
.publish-ok {
  background: #ecfdf5;
  color: var(--ok);
  border-color: #a7f3d0;
}
.publish-error {
  background: #fef2f2;
  color: var(--error);
  border-color: #fecaca;
}

/* Antiparochi panel (Phase 5) */
.antiparochi-panel { padding: 0; }
.panel-title {
  color: var(--navy);
  font-size: 1.2rem;
  margin-bottom: 0.3rem;
}
.panel-subtitle {
  color: var(--grey-dark);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}
.antiparochi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1rem;
}
.antiparochi-benchmark, .antiparochi-pairs {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
}
.antiparochi-benchmark h3, .antiparochi-pairs h3 {
  color: var(--navy);
  font-size: 1rem;
  margin-bottom: 0.4rem;
}
.small-muted {
  color: var(--grey-dark);
  font-size: 0.8rem;
  margin-bottom: 0.6rem;
  line-height: 1.5;
}
/* T10: was .oracle-silent — neutral empty-state for the Antiparochi
   panel. The mythological framing ("the oracle is silent") was rewritten
   in copy as "Insufficient sample…" so the visual treatment follows
   suit: muted-grey rather than fef2f2-red, no italics. */
.antiparochi-empty {
  background: #f6f7f9;
  border-left: 3px solid #94a3b8;
  padding: 0.7rem 0.9rem;
  border-radius: 4px;
  font-size: 0.88rem;
  color: #4b5563;
  line-height: 1.45;
}
@media (max-width: 1024px) {
  .antiparochi-grid { grid-template-columns: 1fr; }
}

/* Antiparochi district-benchmark hint in Compare sidebar */
.antiparochi-hint {
  padding: 0.5rem 0.8rem;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  font-size: 0.8rem;
  margin-bottom: 0.6rem;
  color: var(--warn);
}
.antiparochi-hint b { color: var(--navy); }
.antiparochi-hint .small-muted { color: var(--grey-dark); }

/* ─── SearchCascade / SearchableSelect (mirrored from Athena) ────── */

.searchable-select { position: relative; width: 100%; }
.ss-input {
  padding: 8px 30px 8px 10px; border-radius: 5px; border: 1px solid var(--border);
  font-size: 0.88rem; background: var(--input-bg); width: 100%;
}
.ss-input:focus {
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(42,157,143,0.15);
}
.ss-input:disabled { opacity: 0.5; cursor: not-allowed; background: #f0f0f0; }
.ss-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  cursor: pointer; color: #999; font-size: 16px; line-height: 1;
  padding: 2px 4px; border-radius: 3px;
}
.ss-clear:hover { color: #333; background: #eee; }
.ss-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  max-height: 240px; overflow-y: auto;
  background: var(--white); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 5px 5px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.ss-option {
  padding: 6px 10px; font-size: 0.85rem; cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}
.ss-option:hover { background: #f0f8f7; }
.ss-option.ss-selected { background: #e8f5f3; font-weight: 500; }
.ss-more { padding: 6px 10px; font-size: 0.78rem; color: #999; text-align: center; font-style: italic; }
.ss-no-match { padding: 10px; font-size: 0.85rem; color: #999; text-align: center; }

.search-cascade {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.sc-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.7rem;
  align-items: end;
}
.sc-row-secondary {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.9rem;
}
.sc-field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.sc-field-sm { max-width: 150px; }
.sc-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--grey-dark);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sc-source {
  display: flex; gap: 0.8rem; align-items: center;
  padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 5px; background: var(--input-bg);
  font-size: 0.85rem;
}
.sc-checklabel { display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; user-select: none; }
.sc-checklabel input[type=checkbox] { cursor: pointer; }

@media (max-width: 960px) {
  .sc-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .sc-row { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Chip bar (per-chart tick filters) ──────────────────────────── */

.chip-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.25rem 0 0.6rem;
  align-items: center;
}
.chip-bar-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--grey-dark);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.2rem;
}
.chip {
  padding: 3px 10px;
  font-size: 0.76rem;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--grey-dark);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: all 0.12s;
}
.chip:hover { border-color: var(--teal); color: var(--navy); }
.chip.chip-active {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--white);
  font-weight: 600;
}

/* ─── Search map ─────────────────────────────────────────────────── */

.search-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 1rem;
  align-items: start;
}
.search-layout-list { min-width: 0; }  /* prevents table from forcing grid blow-out */
@media (max-width: 1100px) {
  .search-layout { grid-template-columns: 1fr; }
}

/* Stacked variant — used when a subject is pinpointed so the top-15 table
 * can use the full desktop width without clipping columns. Map sits below
 * at a taller fixed height so tri-colour context reads clearly. */
.search-layout.search-layout--stacked {
  grid-template-columns: 1fr;
}
.search-layout.search-layout--stacked .search-map-panel {
  position: static;
}
.search-layout.search-layout--stacked .search-map {
  height: 520px;
}

/* Empty state — shown when the 25 km ring yields zero ranked rows. */
.search-empty-state {
  background: var(--white);
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 2rem;
  text-align: center;
  color: var(--grey-dark);
}
.search-empty-title {
  font-size: 1rem; font-weight: 600; color: var(--navy);
  margin-bottom: 0.4rem;
}
.search-empty-body { font-size: 0.875rem; }

/* Stats header — explicit scope label above the metric tiles. */
.stats-summary-wrap { margin-bottom: 1rem; }
.stats-summary-header {
  font-size: 0.8rem; color: var(--grey-dark);
  padding: 0.4rem 0.8rem 0.3rem;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.stats-summary-header b {
  color: var(--navy); font-weight: 600; text-transform: none;
  letter-spacing: 0;
}
.stats-summary-wrap .stats-summary { margin-bottom: 0; }
.search-map-panel {
  position: sticky; top: 1rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem;
}
.search-map-panel h3 {
  font-size: 0.85rem; margin-bottom: 0.4rem; color: var(--navy);
}
.search-map {
  width: 100%;
  height: 420px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.search-map-meta {
  font-size: 0.75rem;
  color: var(--grey-dark);
  margin-top: 0.3rem;
}
.search-map-meta .legend-dot {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 2px; margin-right: 4px; vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.15);
}

/* ─── Range chart (custom canvas overlay for min/max/mean/median) ─ */
.range-chart-wrap { position: relative; height: 320px; }

/* ─── Subject card (pinned at top of search results) ─────────────── */
.subject-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(90deg, #eaf2ff 0%, #f5f9ff 100%);
  border: 1px solid #c3d6f7;
  border-left: 4px solid #2563eb;
  border-radius: 6px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.8rem;
}
.subject-card-badge {
  background: #2563eb;
  color: #fff;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}
.subject-card-main { flex: 1; min-width: 0; }
.subject-card-title {
  font-weight: 600;
  color: #0b3e9c;
  font-size: 0.95rem;
}
.subject-card-meta {
  font-size: 0.8rem;
  color: var(--grey-dark);
  margin-top: 0.2rem;
}
.subject-card-info {
  font-size: 0.8rem;
  color: #0b3e9c;
  font-weight: 500;
  white-space: nowrap;
}

/* DLS enrichment status chip on the subject card */
.dls-chip {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.45rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-radius: 10px;
  vertical-align: middle;
  cursor: default;
}
.dls-chip-loading {
  background: #fff4cc;
  color: #8a6d00;
  border: 1px solid #ffe08a;
  animation: dlsPulse 1.4s ease-in-out infinite;
}
.dls-chip-ok {
  background: #d4f5df;
  color: #146c2c;
  border: 1px solid #86d49f;
}
.dls-chip-miss {
  background: #fde4e4;
  color: #8a2020;
  border: 1px solid #f0a6a6;
}
@keyframes dlsPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ─── Weight sliders ──────────────────────────────────────────────── */
.weight-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.8rem;
}
.weight-panel-toggle {
  background: transparent;
  border: none;
  color: var(--navy);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.2rem 0;
  font-weight: 500;
}
.weight-panel-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.6rem 1rem;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--grey-light);
}
.weight-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}
.weight-row label {
  width: 60px;
  color: var(--grey-dark);
  text-transform: capitalize;
}
.weight-row input[type="range"] { flex: 1; }
.weight-row-val {
  width: 36px;
  text-align: right;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.btn-link {
  background: transparent;
  border: none;
  color: #2563eb;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.2rem 0.4rem;
}
.btn-link:hover { text-decoration: underline; }

/* ─── Relevance bar (in result table) ─────────────────────────────── */
.rel-bar {
  position: relative;
  width: 58px;
  height: 14px;
  background: #eef0f3;
  border-radius: 3px;
  overflow: hidden;
}
.rel-bar-fill {
  height: 100%;
  transition: width 120ms ease;
}
.rel-bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #222;
  font-weight: 600;
  text-shadow: 0 0 2px rgba(255,255,255,0.7);
}

/* ─── + Combined button in result rows ───────────────────────────── */
.btn-combined, .btn-combined-on {
  font-size: 0.8rem;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--navy);
  min-width: 24px;
}
.btn-combined:hover { background: #f5f9ff; border-color: #2563eb; color: #2563eb; }
.btn-combined-on {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
tr.row-in-combined td { background: #f5f9ff; }

/* ─── Combined floating pill ─────────────────────────────────────── */
.combined-pill-wrap {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1000;
}
.combined-pill-wrap.is-hidden {
  /* Keep the pill mounted (so its ref survives across open/close cycles
     and focus can be returned to it when the drawer closes) but make it
     visually and interactively absent while the drawer is open. */
  visibility: hidden;
  pointer-events: none;
}
.combined-pill {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.3);
}
.combined-pill:hover { background: #1d4ed8; }
.combined-pill:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

/* ─── Comparison-tray first-time coachmark (T8) ──────────────── */
.combined-pill-coachmark {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 0.5rem;
  background: #1a2744;
  color: #ffffff;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  font-size: 0.78rem;
  line-height: 1.4;
  max-width: 260px;
  box-shadow: 0 6px 16px rgba(15, 26, 48, 0.22);
  z-index: 1001;
}
.combined-pill-coachmark::after {
  /* downward-pointing arrow toward the pill */
  content: "";
  position: absolute;
  right: 1.5rem;
  bottom: -6px;
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #1a2744;
}
.combined-pill-coachmark kbd {
  background: rgba(255,255,255,0.15);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.72rem;
}
.combined-pill-coachmark-x {
  position: absolute;
  top: 4px;
  right: 6px;
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.8);
  font-size: 0.95rem;
  cursor: pointer;
  line-height: 1;
}
.combined-pill-coachmark-x:hover { color: #ffffff; }

.combined-pill-icon { margin-right: 0.35rem; }
.combined-pill-count { margin-left: 0.35rem; opacity: 0.92; }

/* ─── Combined slide-out drawer ──────────────────────────────────── */
.combined-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
  z-index: 1000;
  animation: combinedBackdropFade 180ms ease-out;
}
@keyframes combinedBackdropFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.combined-drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 380px;
  max-width: 92vw;
  background: var(--white);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0,0,0,0.1);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  animation: combinedSlideIn 180ms ease-out;
  outline: none;
}
.combined-drawer:focus-visible {
  box-shadow: -8px 0 32px rgba(0,0,0,0.1), inset 0 0 0 2px #93c5fd;
}
@keyframes combinedSlideIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.combined-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--grey-light);
  background: linear-gradient(90deg, #eaf2ff 0%, #f5f9ff 100%);
}
.combined-drawer-head h3 {
  font-size: 1rem;
  color: #0b3e9c;
  margin: 0;
}
.combined-drawer-actions { display: flex; gap: 0.3rem; }

.combined-summary {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--grey-light);
  background: var(--grey-light);
}
.combined-summary-headline {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--navy);
}
.combined-summary-tag {
  font-size: 0.65rem;
  font-weight: 500;
  color: #2563eb;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-left: 0.4rem;
  vertical-align: middle;
}
.combined-summary-alt {
  font-size: 0.8rem;
  color: var(--grey-dark);
  margin-top: 0.2rem;
}

.combined-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}
.combined-row {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 0.5rem;
  background: var(--white);
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.combined-row:hover,
.combined-row:focus-within {
  background: #f5f9ff;
  border-color: #bfdbfe;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.08);
}
.combined-row.is-custom {
  border-left: 3px solid #2563eb;
  padding-left: calc(0.7rem - 2px);
}
.combined-row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.combined-row-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--navy);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.combined-row-remove {
  background: transparent;
  border: none;
  color: var(--grey-dark);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.3rem;
}
.combined-row-remove:hover { color: var(--error); }
.combined-row-meta {
  font-size: 0.75rem;
  color: var(--grey-dark);
  margin-top: 0.25rem;
}
.combined-row-weight {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
}
.combined-row-weight label {
  width: 95px;
  color: var(--grey-dark);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.combined-row-weight input[type="range"] { flex: 1; }
.combined-row-weight input[type="range"]:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
  border-radius: 3px;
}
.combined-row-weight-badge {
  font-size: 0.6rem;
  font-weight: 600;
  color: #2563eb;
  background: #dbeafe;
  padding: 0.05rem 0.3rem;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: help;
}
.combined-row-weight-reset {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--grey-dark);
  border-radius: 3px;
  padding: 0 0.35rem;
  font-size: 0.9rem;
  line-height: 1.4;
  cursor: pointer;
  flex: 0 0 auto;
}
.combined-row-weight-reset:hover {
  background: #f5f9ff;
  border-color: #bfdbfe;
  color: #2563eb;
}
.combined-row-weight-reset:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
}

.combined-row-remove:focus-visible {
  outline: 2px solid #fca5a5;
  outline-offset: 1px;
  border-radius: 3px;
}

/* Drawer footer (keyboard hint) */
.combined-drawer-foot {
  padding: 0.45rem 1rem;
  border-top: 1px solid var(--grey-light);
  background: #fafafa;
}
.combined-drawer-hint {
  font-size: 0.68rem;
  color: var(--grey-dark);
  letter-spacing: 0.02em;
}
.combined-drawer-close:focus-visible,
.combined-drawer-head .btn-link:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
  border-radius: 2px;
}

/* ─── Map popup "+ Combined" button ─────────────────────────────── */
.popup-combined-btn {
  margin-top: 0.3rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 3px;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
}
.popup-combined-btn[data-combined="1"] {
  background: #16a34a;
}

/* ─── Conflict badge (Phase 5 Task 6) ────────────────────────────── */
/* Surfaces a known legal-conflict warning next to a rule citation. */
.apollo-conflict-badge {
  display: inline-block;
  background: #fef3c7;          /* amber-100 */
  color: #92400e;               /* amber-800 — WCAG AA on amber-100 */
  border: 1px solid #fcd34d;    /* amber-300 */
  border-radius: 3px;
  padding: 0.15rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.01em;
  cursor: help;
  vertical-align: baseline;
  white-space: nowrap;
}
.apollo-conflict-badge.inline {
  font-size: 0.65rem;
  padding: 0.05rem 0.35rem;
  margin-left: 0.35rem;
}
.apollo-conflict-badge:focus-visible {
  outline: 2px solid #f59e0b;
  outline-offset: 1px;
}

/* ─── OlympusShell.Footer (design system §1.4 — Data as-of) ──────── */
/* Minimal styles for the data-versions footer. The wider OlympusShell
 * migration (in progress on main) supplies richer styles for the inner
 * spans (.o-footer-asof, .o-footer-version, etc.). When that lands these
 * declarations stay compatible. */
.o-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 16px;
  font-size: 12px;
  color: #4b5563;
  background: #fbfaf6;
  border-top: 1px solid #d8d3c4;
  z-index: 50;
  font-variant-numeric: tabular-nums;
}
.o-footer-asof strong { color: #1a2744; font-weight: 600; }
.o-footer-sep { opacity: 0.5; }
.o-footer-version { color: #4b5563; }
.o-footer-spacer { flex: 1; }
.o-footer-action {
  background: transparent;
  border: 1px solid #d8d3c4;
  border-radius: 3px;
  padding: 0.15rem 0.5rem;
  font-size: 11px;
  color: #1a2744;
  cursor: pointer;
}
.o-footer-action:hover { background: #f3efe2; }

