/* viewer-v3 — Purple Cow ISP palette
 *
 * Single source of truth for visual design.
 * Adjust the :root variables below to retheme the entire app.
 * The Settings panel (settings-panel.js) writes --font-scale and --theme at
 * runtime, persisted in localStorage.
 *
 * Font sizing strategy: html font-size = 13px * --font-scale, so every rem-
 * based size in the file scales automatically with the slider. Pixel-valued
 * font-sizes are static-by-design (e.g., dense data tables) — convert to rem
 * if scaling is desired.
 */

:root {
  /* === FONT SCALE — adjusted by Settings panel ============================= */
  --font-scale: 1;
  --font-base: 13px;

  /* === BACKGROUND TOKENS =================================================== */
  --bg-deep:        #0a0a1a;   /* page bg, deepest layer */
  --bg-panel:       #0f0f23;   /* sidebar, dropdowns */
  --bg-card:        #1a1a2e;   /* cards on top of panels */
  --bg-control:     #1e1e3a;   /* buttons, inputs, controls */
  --border-default: #1e1e3a;
  --border-strong:  #2d2d5a;

  /* === BRAND / ACCENT ====================================================== */
  --accent:         #7c3aed;   /* primary action / focus */
  --accent-bright:  #c084fc;   /* hover / active labels */

  /* === TEXT ================================================================ */
  --text-primary:   #e2e8f0;
  --text-secondary: #cbd5e1;
  --text-muted:     #94a3b8;
  --text-subtle:    #64748b;
  --text-disabled:  #4a5568;

  /* === STATUS / SEMANTIC =================================================== */
  --status-green:   #4ade80;
  --status-yellow:  #facc15;
  --status-orange:  #fb923c;
  --status-red:     #f87171;
  --status-amber:   #fbbf24;
  --status-blue:    #38bdf8;

  /* === STATE BG (deep variants for badges) ================================= */
  --bg-green:       #14532d;
  --bg-yellow:      #422006;
  --bg-orange:      #4a1a04;
  --bg-red:         #4a1010;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: -apple-system, 'Segoe UI', BlinkMacSystemFont, sans-serif;
  font-size: calc(var(--font-base) * var(--font-scale));
  overflow: hidden;
}
body {
  display: flex;
  flex-direction: column;
}

/* === TOPBAR ============================================================== */

#topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: #0f0f23;
  border-bottom: 1px solid #1e1e3a;
  height: 46px;
}

.brand {
  font-weight: 700;
  color: #c084fc;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
}

#search-wrap {
  flex: 1;
  position: relative;
  max-width: 720px;
  display: flex;
  gap: 6px;
}

.provider-select {
  background: #1e1e3a;
  border: 1px solid #2d2d5a;
  color: #e2e8f0;
  border-radius: 6px;
  padding: 0 0.5rem;
  font: inherit;
  font-size: 0.75rem;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}
.provider-select:focus { border-color: #7c3aed; }

#search-input {
  width: 100%;
  padding: 0.45rem 0.75rem;
  background: #1e1e3a;
  border: 1px solid #2d2d5a;
  color: #e2e8f0;
  border-radius: 6px;
  font: inherit;
  font-size: 0.8125rem;
  outline: none;
  transition: border-color 0.15s;
}
#search-input:focus              { border-color: #7c3aed; }
#search-input::placeholder       { color: #4a5568; }

.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #0f0f23;
  border: 1px solid #1e1e3a;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  margin-top: 6px;
  z-index: 100;
  display: none;
  max-height: 360px;
  overflow-y: auto;
}
.dropdown.open { display: block; }

.typeahead-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.6rem;
  padding: 0.4rem 0.75rem;
  border: none;
  background: transparent;
  color: #e2e8f0;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
  align-items: center;
  border-bottom: 1px solid #1e1e3a;
}
.typeahead-item .dot { width: 0.5rem; height: 0.5rem; border-radius: 999px; flex-shrink: 0; }
.typeahead-item:last-child       { border-bottom: none; }
.typeahead-item:hover            { background: #1e1e3a; }
.typeahead-item .place           { color: #94a3b8; }
.typeahead-item .sim             { color: #7c3aed; font-family: ui-monospace, monospace; font-size: 0.6875rem; }

/* Unit sub-search (#298) — opens after picking an address with units. */
.dropdown[data-mode="unit"] {
  padding: 0.4rem;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.unit-subsearch-head {
  display: flex; justify-content: space-between; align-items: center;
}
.unit-subsearch-title {
  font-size: 0.75rem; font-weight: 600; color: var(--accent-bright, #c084fc);
}
.unit-subsearch-close {
  background: transparent; border: 1px dashed #2d2d5a; color: #94a3b8;
  border-radius: 3px; padding: 1px 6px; font-size: 0.65rem; cursor: pointer;
  font-family: inherit;
}
.unit-subsearch-close:hover { border-color: #7c3aed; color: #c084fc; }
.unit-subsearch-input-wrap { display: flex; }
.unit-subsearch-input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  background: #1e1e3a;
  border: 1px solid #7c3aed;
  color: #e2e8f0;
  border-radius: 6px;
  font: inherit;
  font-size: 0.8125rem;
  outline: none;
}
.unit-subsearch-input:focus { border-color: #c084fc; box-shadow: 0 0 0 2px rgba(124,58,237,0.2); }
.unit-subsearch-list {
  display: flex; flex-direction: column; gap: 0.15rem;
  max-height: 300px; overflow-y: auto;
}
.unit-subsearch-section {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: #64748b; padding: 0.3rem 0.4rem 0.1rem;
}
.unit-subsearch-row {
  display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap;
  padding: 0.4rem 0.5rem;
  background: #1a1a2e;
  border: 1px solid #1e1e3a;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: #e2e8f0;
  font-size: 0.8125rem;
}
.unit-subsearch-row:hover    { border-color: #7c3aed; background: #1e1e3a; }
.unit-subsearch-row.canonical { border-left: 3px solid #4ade80; }
.unit-subsearch-row.candidate { border-left: 3px solid #fbbf24; }
.unit-subsearch-label { font-weight: 600; }
.unit-subsearch-tag {
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.05rem 0.4rem; border-radius: 8px;
}
.tag-canonical { background: #14532d; color: #86efac; }
.tag-candidate { background: #422006; color: #fbbf24; }
.unit-subsearch-sub {
  flex-basis: 100%;
  font-size: 0.65rem; color: #94a3b8;
}
.unit-subsearch-empty { padding: 0.6rem 0.4rem; text-align: center; }

.status {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  color: #64748b;
  white-space: nowrap;
}
.status.ok  { color: #4ade80; }
.status.err { color: #f87171; }

/* Topbar icon buttons (settings, future help, etc.) */
.topbar-icon-btn {
  background: var(--bg-control);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: 6px;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.1s, color 0.1s;
}
.topbar-icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
}

/* === SETTINGS MODAL ====================================================== */

.settings-modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.settings-modal[hidden] { display: none; }

.settings-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 1.25rem 1.4rem;
  width: min(480px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 1rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border-default);
  padding-bottom: 0.6rem;
}
.settings-title {
  font-size: 1rem; font-weight: 700; color: var(--accent-bright);
}
.settings-close {
  background: transparent; border: none; color: var(--text-muted);
  font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0 0.4rem;
  font-family: inherit;
}
.settings-close:hover { color: var(--accent-bright); }

.settings-section {
  display: flex; flex-direction: column; gap: 0.4rem;
}
.settings-section-label {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-subtle); font-weight: 600;
}
.settings-section-hint {
  font-size: 0.7rem; color: var(--text-subtle); font-style: italic;
}

.settings-presets {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.4rem;
}
.settings-preset {
  background: var(--bg-control);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 0.5rem 0.4rem;
  display: flex; flex-direction: column; gap: 0.15rem; align-items: center;
  cursor: pointer; font-family: inherit;
  color: var(--text-secondary);
  transition: border-color 0.1s, background 0.1s;
}
.settings-preset:hover  { border-color: var(--accent); }
.settings-preset.active {
  border-color: var(--accent-bright);
  background: var(--bg-card);
  color: var(--text-primary);
}
.preset-label { font-size: 0.75rem; font-weight: 600; }
.preset-value {
  font-size: 0.625rem; color: var(--text-muted); font-family: ui-monospace, monospace;
}
.settings-preset.active .preset-value { color: var(--accent-bright); }

.settings-slider-wrap {
  display: flex; align-items: center; gap: 0.6rem; margin-top: 0.4rem;
}
.settings-slider {
  flex: 1; accent-color: var(--accent);
}
.settings-slider-readout {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--accent-bright);
  min-width: 56px; text-align: right;
}

.settings-theme-row { display: flex; }
.settings-select {
  width: 100%;
  background: var(--bg-control);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-family: inherit;
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
}
.settings-select:focus { border-color: var(--accent); }

.settings-reset {
  border-top: 1px solid var(--border-default);
  padding-top: 0.6rem;
  display: flex; justify-content: flex-end;
}
.settings-reset-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}
.settings-reset-btn:hover {
  border-color: var(--status-red);
  color: var(--status-red);
}

/* === LAYOUT ============================================================== */

#layout {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  overflow: hidden;
}

#sidebar {
  background: #0f0f23;
  border-right: 1px solid #1e1e3a;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid #1e1e3a;
  background: #0a0a1a;
}
.sidebar-header h1 {
  font-size: 14px;
  font-weight: 700;
  color: #c084fc;
  letter-spacing: 0.5px;
}
.sidebar-header p {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid #1e1e3a;
  background: #0a0a1a;
}
.sidebar-tab {
  flex: 1;
  padding: 0.5rem 0;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #64748b;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: color 0.1s, border-color 0.1s;
}
.sidebar-tab:hover  { color: #c084fc; }
.sidebar-tab.active { color: #c084fc; border-bottom-color: #7c3aed; }

.tab-pane[hidden] { display: none; }

/* === CURATOR REVIEW QUEUE (R6) ========================================== */

.queues-wrap { padding: 12px 12px 0; flex: 1; overflow-y: auto; }

.curator-queue { display: flex; flex-direction: column; gap: 0.55rem; }

.cq-header {
  display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem;
}
.cq-title { color: #e2e8f0; font-weight: 700; font-size: 0.85rem; }
.cq-actor { display: flex; align-items: center; gap: 0.4rem; font-size: 0.7rem; }
.cq-actor-name  { color: #c084fc; }
.cq-actor-empty { color: #f87171; }
.cq-actor-change, .cq-actor-set {
  background: transparent; border: 1px dashed #2d2d5a; color: #94a3b8;
  border-radius: 3px; padding: 1px 6px; font-size: 0.65rem; cursor: pointer;
  font-family: inherit;
}
.cq-actor-change:hover, .cq-actor-set:hover { border-color: #7c3aed; color: #c084fc; }

.cq-tabs { display: flex; gap: 6px; }
.cq-tab {
  padding: 4px 10px; border-radius: 4px; border: 1px solid #1e1e3a;
  background: #1e1e3a; color: #94a3b8; font-size: 11px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.cq-tab:hover  { border-color: #7c3aed; }
.cq-tab.active { background: #7c3aed; border-color: #c084fc; color: white; }

.cq-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.cq-select { display: flex; flex-direction: column; gap: 2px; }
.cq-select-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b;
}
.cq-select select, .cq-search, .cq-num {
  background: #1e1e3a; border: 1px solid #2d2d5a; color: #e2e8f0;
  border-radius: 4px; padding: 0.25rem 0.4rem; font-family: inherit;
  font-size: 0.75rem; outline: none; min-width: 100px;
}
.cq-num { width: 80px; }
.cq-search { min-width: 160px; }
.cq-select select:focus, .cq-search:focus, .cq-num:focus { border-color: #7c3aed; }

.cq-result-head {
  color: #64748b; font-size: 0.6875rem;
  font-family: ui-monospace, monospace;
}

.cq-body { display: flex; flex-direction: column; gap: 0.45rem; }
.cq-list { display: flex; flex-direction: column; gap: 0.2rem; }

.cq-card {
  background: #1a1a2e;
  border: 1px solid #1e1e3a;
  border-radius: 4px;
  padding: 0.5rem 0.6rem;
  font-size: 0.75rem;
  transition: border-color 0.1s, background 0.1s;
}
.cq-card.clickable        { cursor: pointer; }
.cq-card.clickable:hover  { border-color: #7c3aed; background: #1e1e3a; }
.cq-card.open             { border-color: #c084fc; background: #1e1e3a; }

.cq-card-head {
  display: flex; align-items: center; gap: 0.4rem;
  margin-bottom: 0.25rem; flex-wrap: wrap;
}
.cq-card-key {
  font-size: 0.65rem; background: #0a0a1a; padding: 0.1rem 0.4rem;
  border-radius: 3px; color: #c084fc; word-break: break-all;
  font-family: ui-monospace, monospace;
}
.cq-card-history-count {
  font-size: 0.625rem; color: #f59e0b;
  background: #2d2210; padding: 0.05rem 0.3rem; border-radius: 3px;
}
.cq-card-sub { color: #cbd5e1; margin-bottom: 0.25rem; }

.cq-pill {
  display: inline-block; padding: 0.05rem 0.4rem; border-radius: 8px;
  font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.04em;
  font-weight: 600;
}
.pill-gray   { background: #2d2d5a; color: #cbd5e1; }
.pill-yellow { background: #422006; color: #fbbf24; }
.pill-orange { background: #4a1a04; color: #fb923c; }
.pill-green  { background: #14532d; color: #86efac; }
.pill-red    { background: #4a1010; color: #fca5a5; }

.cq-signal-row { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-top: 0.15rem; }
.cq-signal-badge {
  font-size: 0.625rem; padding: 0.05rem 0.4rem; border-radius: 3px;
  font-family: ui-monospace, monospace;
  border: 1px solid transparent;
}
.sig-key   { background: #14532d; color: #86efac; border-color: #16a34a; }
.sig-el    { background: #1e293b; color: #38bdf8; border-color: #0284c7; }
.sig-bell  { background: #2d1b4e; color: #c084fc; border-color: #7c3aed; }
.sig-cp    { background: #422006; color: #fbbf24; border-color: #d97706; }
.sig-sf    { background: #1f2937; color: #34d399; border-color: #059669; }
.sig-prov  { background: #1e1e3a; color: #94a3b8; border-color: #475569; }
.sig-other { background: #0a0a1a; color: #94a3b8; border-color: #1e1e3a; }

.cq-most-likely-hint { margin-top: 0.2rem; font-size: 0.65rem; }

.cq-card-expand:empty { display: none; }
.cq-card-expand {
  margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid #2d2d5a;
  display: flex; flex-direction: column; gap: 0.5rem;
}

.cq-detail-sec       { display: flex; flex-direction: column; gap: 0.2rem; }
.cq-detail-head      {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: #64748b;
}
.cq-canonical-ref    { display: flex; }
.cq-canonical-btn {
  background: #0a0a1a; border: 1px solid #2d2d5a; color: #c084fc;
  border-radius: 3px; padding: 4px 8px; font-family: inherit;
  font-size: 0.7rem; cursor: pointer; text-align: left;
  width: 100%;
}
.cq-canonical-btn:hover { border-color: #7c3aed; background: #1e1e3a; }
.cq-canonical-label { color: #cbd5e1; font-size: 0.7rem; }

.cq-actions {
  display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center;
  padding: 0.4rem; background: #0a0a1a; border-radius: 4px;
}
.cq-btn {
  border-radius: 4px; padding: 5px 12px; font-family: inherit;
  font-size: 0.75rem; font-weight: 600; cursor: pointer;
  border: 1px solid;
}
.cq-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.cq-btn-promote {
  background: #14532d; border-color: #16a34a; color: #86efac;
}
.cq-btn-promote:hover:not(:disabled) { background: #16a34a; color: white; }
.cq-btn-link {
  background: #1e3a5f; border-color: #0284c7; color: #38bdf8;
}
.cq-btn-link:hover:not(:disabled) { background: #0284c7; color: white; }
.cq-btn-reject {
  background: #4a1010; border-color: #b91c1c; color: #fca5a5;
}
.cq-btn-reject:hover:not(:disabled) { background: #b91c1c; color: white; }
.cq-actions-disabled { color: #f59e0b; font-size: 0.7rem; flex-basis: 100%; }

/* Bulk-flick (R8) */
.cq-bulk-panel {
  display: flex; flex-direction: column; gap: 0.4rem;
  padding: 0.6rem; border: 1px dashed #c084fc;
  background: #1e1e3a; border-radius: 6px;
}
.cq-bulk-ctrl { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: end; }
.cq-btn-bulk-flick {
  background: #2d1b4e; border-color: #7c3aed; color: #c084fc;
}
.cq-btn-bulk-flick:hover:not(:disabled) { background: #7c3aed; color: white; }

.cq-empty {
  padding: 1rem; border: 1px dashed #2d2d5a; border-radius: 4px;
  background: #1a1a2e; display: flex; flex-direction: column; gap: 0.3rem;
}

/* Suspected-junk auto-tag (#300 Part 1) */
.cq-junk-filter-row {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.4rem;
  background: #1e1e3a; border: 1px solid #2d2d5a; border-radius: 4px;
  font-size: 0.7rem; color: #cbd5e1; cursor: pointer;
}
.cq-junk-filter-label { user-select: none; }
.cq-junk-badge {
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.05rem 0.4rem; border-radius: 4px;
  background: #4a1010; color: #fca5a5; font-weight: 600;
}
.cq-btn-bulk-reject {
  background: #4a1010; border-color: #b91c1c; color: #fca5a5;
}
.cq-btn-bulk-reject:hover:not(:disabled) { background: #b91c1c; color: white; }

/* Unit highlight pulse (#300 Part 2) — applied after sub-search unit pick. */
@keyframes cq-unit-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(192, 132, 252, 0.55); background-color: rgba(124, 58, 237, 0.18); }
  60%  { box-shadow: 0 0 0 8px rgba(192, 132, 252, 0); background-color: rgba(124, 58, 237, 0.10); }
  100% { box-shadow: 0 0 0 0 rgba(192, 132, 252, 0); background-color: transparent; }
}
.unit-highlight-pulse {
  border-radius: 4px;
  animation: cq-unit-pulse 1.5s ease-out 1;
  outline: 1px solid #c084fc;
  outline-offset: 2px;
}

.cq-history-line {
  display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: baseline;
  font-size: 0.7rem; color: #94a3b8;
  padding: 0.2rem 0; border-bottom: 1px dotted #1e1e3a;
}
.cq-history-line:last-child { border-bottom: none; }
.cq-history-time   { color: #64748b; font-family: ui-monospace, monospace; font-size: 0.625rem; }
.cq-history-action {
  font-weight: 600; padding: 0.05rem 0.35rem; border-radius: 3px;
  font-size: 0.65rem; text-transform: uppercase;
}
.cq-history-action.promoted           { background: #14532d; color: #86efac; }
.cq-history-action.linked             { background: #1e3a5f; color: #38bdf8; }
.cq-history-action.rejected_duplicate,
.cq-history-action.rejected_junk      { background: #4a1010; color: #fca5a5; }
.cq-history-action.unrejected         { background: #422006; color: #fbbf24; }
.cq-history-action.state_change       { background: #2d2d5a; color: #cbd5e1; }
.cq-history-target { color: #c084fc; font-family: ui-monospace, monospace; }
.cq-history-reason { color: #cbd5e1; font-style: italic; }

.cq-pager {
  display: flex; align-items: center; gap: 0.5rem; justify-content: space-between;
  margin-top: 0.4rem; font-size: 0.6875rem;
}
.cq-pager-btn {
  background: #1e1e3a; border: 1px solid #2d2d5a; color: #94a3b8;
  border-radius: 4px; padding: 3px 10px; font-family: inherit;
  font-size: 0.6875rem; cursor: pointer;
}
.cq-pager-btn:hover:not(:disabled) { border-color: #7c3aed; color: #c084fc; }
.cq-pager-btn:disabled             { opacity: 0.4; cursor: default; }

/* === STATS PANEL ========================================================= */

.stats-wrap { padding: 12px; flex: 1; overflow-y: auto; }
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 0.6rem;
}
.stat-box {
  background: #1a1a2e;
  border: 1px solid #1e1e3a;
  border-radius: 4px;
  padding: 0.5rem 0.6rem;
}
.stat-box.orange { border-color: #fb923c; }
.stat-label { font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; }
.stat-value { font-size: 1rem; font-weight: 700; color: #e2e8f0; font-family: ui-monospace, monospace; }
.stat-hint  { font-size: 0.625rem; color: #64748b; margin-top: 2px; }

.stats-dist { margin-top: 0.6rem; }
.stats-dist .subhead { color: #c084fc; font-size: 10px; text-transform: uppercase; margin-bottom: 0.3rem; }
.stats-row {
  display: flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0;
  font-size: 0.75rem; border-top: 1px solid #1e1e3a;
}
.stats-row .k { color: #94a3b8; flex: 1; }
.stats-row .v { color: #e2e8f0; font-family: ui-monospace, monospace; font-variant-numeric: tabular-nums; }

#map { width: 100%; height: 100%; position: relative; background: #0a0a1a; }

/* === STATUS BAR ========================================================== */

#status-bar {
  flex-shrink: 0;
  height: 26px;
  background: #0a0a1a;
  border-top: 1px solid #1e1e3a;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 20px;
  font-size: 11px;
  color: #64748b;
}
#status-bar #status-coords,
#status-bar #status-zoom { font-family: ui-monospace, monospace; font-variant-numeric: tabular-nums; color: #94a3b8; }
.status-fill { flex: 1; }
.status-meta { color: #4a5568; font-family: ui-monospace, monospace; }

/* === LAYER PANEL ========================================================= */

.layer-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  background: rgba(15,15,35,0.95);
  border: 1px solid #1e1e3a;
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  font-size: 0.8125rem;
  /* Fixed width so the panel (and its two tab buttons) is identical on both the
     Layers and Testing tabs — without it the panel shrink-wraps each tab's
     content, making the buttons different widths per view and letting the long
     Testing legend stretch the panel off-screen. 272px comfortably fits the
     Layers toggles on one line and forces the legend to wrap. */
  width: 272px;
  /* Flex column so the tabs pin to the top and the body scrolls. Capped to the
     map viewport (minus the 12px top/bottom anchor gap) so it never runs off
     the bottom of the screen. */
  display: flex;
  flex-direction: column;
  max-height: calc(100% - 24px);
}
/* Collapse toggle: panel shrinks up-and-left into a 38px square at its
   top-left anchor. Toggle lives at the TOP-LEFT in both states so collapse
   and expand happen without moving the mouse. */
.layer-panel-toggle {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #9ca3af;
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}
.layer-panel-toggle:hover { color: #e5e7eb; border-color: #1e1e3a; }

/* Section tabs (Layers / Testing) pinned to the top of the panel. The row is
   padded left to clear the absolutely-positioned collapse toggle. */
.layer-panel-tabs {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
  padding-left: 26px;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #1e1e3a;
}
.layer-panel-tab {
  flex: 1 1 0;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid #1e1e3a;
  background: #14142e;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.layer-panel-tab:hover { border-color: #7c3aed; color: #e5e7eb; }
.layer-panel-tab.active {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
}

/* Scrollable body: the tabs stay fixed, the active pane scrolls if it overflows
   the panel's capped max-height. min-height:0 lets the flex child shrink so the
   overflow actually scrolls instead of pushing the panel off-screen. */
.layer-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.layer-panel-body::-webkit-scrollbar { width: 8px; }
.layer-panel-body::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 4px; }
.layer-panel-body::-webkit-scrollbar-thumb:hover { background: #3a3a5a; }
.layer-tab-pane[hidden] { display: none; }
.layer-tab-pane > .layer-panel-title:first-child { margin-top: 0; }

.layer-panel.collapsed {
  width: 38px;
  height: 38px;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
}
.layer-panel.collapsed > *:not(.layer-panel-toggle) { display: none; }
.layer-panel.collapsed .layer-panel-toggle {
  top: 0;
  left: 0;
  width: 38px;
  height: 38px;
  color: #c084fc;
  border: 0;
  font-size: 1.05rem;
}

.layer-panel-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #7c3aed;
  margin: 0.5rem 0 0.4rem;
}
.layer-panel-title:first-child { margin-top: 0; }

.province-buttons {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.province-buttons button {
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #1e1e3a;
  background: #1e1e3a;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.province-buttons button:hover  { border-color: #7c3aed; }
.province-buttons button.active {
  background: #7c3aed;
  border-color: #c084fc;
  color: white;
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  cursor: pointer;
  user-select: none;
}
.layer-toggle .layer-label { flex: 1; color: #e2e8f0; font-weight: 500; }
.layer-hint { color: #4a5568; font-family: ui-monospace, monospace; font-size: 10px; }

/* iOS-style toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider {
  position: absolute;
  inset: 0;
  background: #1e1e3a;
  border-radius: 9px;
  transition: background 0.15s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: left 0.15s;
}
.switch input:checked + .slider { background: #7c3aed; }
.switch input:checked + .slider::before { left: 16px; }

.filter-group {
  margin-left: 1rem;
  border-left: 1px solid #1e1e3a;
  padding: 0.2rem 0 0.2rem 0.6rem;
  margin-bottom: 0.4rem;
}
.filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.15rem 0;
  cursor: pointer;
  user-select: none;
  font-size: 0.75rem;
}
.filter-row input { accent-color: #7c3aed; cursor: pointer; }
.filter-label { color: #94a3b8; }
.filter-label.muted { color: #4a5568; font-style: italic; font-size: 10px; }
.filter-label.warn { color: #facc15; font-style: normal; }

/* Confidence-tile publish control (C3) */
.tile-publish {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 2px 0 2px;
}
.tile-publish-btn {
  background: #5b6dee; color: #fff; border: none; border-radius: 4px;
  padding: 3px 10px; font-size: 11px; font-weight: 600; cursor: pointer;
}
.tile-publish-btn:hover:not(:disabled) { background: #6d7df0; }
.tile-publish-btn:disabled { background: #2a2e42; color: #5a6178; cursor: default; }

.layer-legend {
  display: flex;
  align-items: flex-start;   /* top-align so the multi-line Testing legend reads cleanly */
  gap: 0.4rem;
  margin-left: 1rem;
  margin-bottom: 0.6rem;
  padding-left: 0.6rem;
  border-left: 1px solid #1e1e3a;
  line-height: 1.4;          /* breathing room when the legend text wraps */
}

.dot   { width: 0.5rem; height: 0.5rem; border-radius: 999px; display: inline-block; flex-shrink: 0; }
.dot.green  { background: #4ade80; }
.dot.yellow { background: #facc15; }
.dot.red    { background: #f87171; }
.dot.gray   { background: #888; }
.dot.orange { background: #fb923c; }

.line  { width: 1rem; height: 0.2rem; border-radius: 1px; display: inline-block; }
.line.green   { background: #4ade80; }
.line.yellow  { background: #facc15; }
.line.red     { background: #f87171; }
.line.gray    { background: #6b7280; }

/* === CHECK-ADDRESS RESULT ================================================ */

.check-result-wrap:empty { display: none; }
.check-result-wrap { padding: 12px 16px; border-bottom: 1px solid #1e1e3a; }

.check-result { padding: 0.7rem; background: #1e1e3a; border-radius: 6px; }

.check-result .resolved-line { font-weight: 600; margin-bottom: 0.4rem; font-size: 0.9rem; color: #e2e8f0; }
.check-result .check-status  { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.check-result .service-text  { font-weight: 500; }
.check-result .muted { color: #94a3b8; font-size: 0.75rem; }
.check-result .note {
  font-size: 0.75rem;
  color: #facc15;
  margin-top: 0.4rem;
  padding: 0.3rem 0.5rem;
  background: rgba(250,204,21,0.08);
  border-radius: 4px;
  border-left: 2px solid #facc15;
}
.check-result .providers {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  font-size: 0.75rem;
}
.check-result .providers li {
  display: flex;
  justify-content: space-between;
  padding: 0.2rem 0;
  border-top: 1px solid #2d2d5a;
}
.check-result .providers .pname    { color: #94a3b8; }
.check-result .providers .pstatus  { font-weight: 500; }
.providers .pstatus.serviceable     { color: #4ade80; }
.providers .pstatus.conditional     { color: #facc15; }
.providers .pstatus.not_serviceable { color: #f87171; }

.check-result.confidence-needs_unit { border-left: 3px solid #facc15; }
.check-result.confidence-low        { border-left: 3px solid #c084fc; }
.check-result.confidence-unresolved { border-left: 3px solid #4a5568; }

/* === DETAIL PANEL ======================================================== */

.detail-wrap { padding: 12px 16px; flex: 1; overflow-y: auto; font-size: 0.8125rem; }
.detail-wrap .empty { color: #4a5568; font-style: italic; }

.detail h3 { margin: 0 0 0.25rem; font-size: 1rem; color: #e2e8f0; }
.detail .muted { color: #94a3b8; font-size: 0.8125rem; margin-bottom: 0.6rem; }

.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0; }
.badge {
  font-size: 0.6875rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  font-family: ui-monospace, monospace;
}
.badge.b-serviceable     { background: #166534; color: #4ade80; }
.badge.b-conditional     { background: #713f12; color: #facc15; }
.badge.b-not_serviceable { background: #7f1d1d; color: #f87171; }
.badge.b-unknown         { background: #1e293b; color: #94a3b8; }
.badge.b-seg-green       { background: #166534; color: #4ade80; }
.badge.b-seg-yellow      { background: #713f12; color: #facc15; }
.badge.b-seg-red         { background: #7f1d1d; color: #f87171; }
.badge.b-seg-unknown     { background: #1e293b; color: #94a3b8; }
.badge.b-info            { background: #4c1d95; color: #c084fc; }
.badge.b-candidate       { background: #312e81; color: #a5b4fc; border: 1px dashed #6366f1; }
.badge.b-el-confirmed    { background: #14532d; color: #86efac; }
.badge.b-no_row          { background: #1e293b; color: #94a3b8; }
/* Pattern-J resolver badges (#269 J2). Compound = both direct and derived
   agree on serviceable; derived = inferred from a rule (e.g. SF accept). */
.badge.b-ironclad        { background: #064e3b; color: #6ee7b7; border: 1px solid #10b981; }
.badge.b-derived         { background: #312e81; color: #a5b4fc; border: 1px dashed #6366f1; }

/* "via SF accept ⇒ EL batch" provenance line under a status badge. */
.via-line {
  font-size: 0.7rem;
  letter-spacing: 0.01em;
  margin-top: 0.15rem;
  margin-bottom: 0.25rem;
}

/* Suggested Equivalences (#267 D3) — curator-facing assertion cards. */
.equiv-card {
  border: 1px solid #312e81;
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  margin: 0.4rem 0;
  background: #15152b;
}
.equiv-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}
.equiv-source {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  color: #cbd5e1;
}
.equiv-unit {
  font-weight: 600;
  color: #e2e8f0;
}
.equiv-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.equiv-btn {
  font-size: 0.75rem;
  padding: 0.3rem 0.55rem;
  border-radius: 4px;
  border: 1px solid #475569;
  background: #1e293b;
  color: #e2e8f0;
  cursor: pointer;
  font-family: inherit;
}
.equiv-btn:hover         { background: #334155; }
.equiv-btn.confirm       { border-color: #22c55e; color: #4ade80; }
.equiv-btn.confirm:hover { background: #14532d; }
.equiv-btn.distinct      { border-color: #ef4444; color: #f87171; }
.equiv-btn.distinct:hover { background: #7f1d1d; }
.equiv-btn.retract       { font-size: 0.7rem; padding: 0.15rem 0.4rem; margin-left: 0.4rem; }
.equiv-select {
  font-size: 0.75rem;
  padding: 0.25rem 0.4rem;
}
.equiv-confirmed {
  font-size: 0.78rem;
  color: #cbd5e1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

/* Address alias variant: dashed border to differentiate from unit candidates. */
.equiv-card.alias-card {
  border-style: dashed;
}

/* "also known as" line beneath the canonical street in the Identity hero. */
.aka-line {
  font-size: 0.78rem;
  margin-top: 0.15rem;
  margin-bottom: 0.4rem;
  letter-spacing: 0.01em;
}

/* "Best available" line — multi-provider blender hint when the selected
   provider isn't the strongest answer (#246). */
.best-available {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
}

/* Audit trail drawer (#267 D8) — quiet styling so retracted history doesn't
   compete visually with active suggestions. */
.history-drawer {
  margin-top: 0.6rem;
  border-top: 1px dashed #334155;
  padding-top: 0.4rem;
}
.history-summary {
  font-size: 0.72rem;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
}
.history-summary:hover { color: #cbd5e1; }
.history-body {
  margin-top: 0.4rem;
  padding-left: 0.6rem;
  border-left: 2px solid #1e293b;
}
.history-group {
  margin-top: 0.5rem;
  padding-bottom: 0.4rem;
}
.history-pair {
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  color: #94a3b8;
  margin-bottom: 0.2rem;
}
.history-entry {
  font-size: 0.72rem;
  margin: 0.15rem 0;
  padding-left: 0.4rem;
}
.history-entry.active     { color: #cbd5e1; border-left: 2px solid #4ade80; }
.history-entry.retracted  { color: #94a3b8; border-left: 2px solid #f87171; opacity: 0.85; }

/* Provider scoping (#268): primary block highlights the selected provider in
   the Serviceability section; secondary blocks surface the others quietly. */
.provider-block.primary {
  border-left: 3px solid #7c3aed;
  padding-left: 0.5rem;
  margin: 0.3rem 0 0.5rem;
}
.provider-block.secondary {
  opacity: 0.78;
  margin: 0.3rem 0;
}
.provider-block .subhead {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.section.provider-others summary {
  color: #94a3b8;
}

/* Candidate unit cards — surfaced from unit_candidates when no canonical
   units are linked to the address (fallback for the "64 Rankin shows yellow,
   no units" bug). Visually distinct from promoted units via the dashed border. */
.candidate-card {
  border: 1px dashed #4c1d95;
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  margin: 0.4rem 0;
  background: #15152b;
}
.candidate-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}
.candidate-name {
  font-weight: 600;
  color: #e2e8f0;
  margin-right: 0.35rem;
}
.section > summary .badge { margin-left: 0.5rem; vertical-align: middle; }

.section {
  margin-top: 0.4rem;
  border: 1px solid #1e1e3a;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  background: #1a1a2e;
}
.section > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #7c3aed;
  outline: none;
  list-style: none;
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 0.4rem;
  color: #4a5568;
  font-size: 0.625rem;
  transition: transform 0.1s;
}
.section[open] > summary::before { transform: rotate(90deg); }

.section-body {
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid #1e1e3a;
}

.subhead {
  color: #c084fc;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0.5rem 0 0.2rem;
  font-weight: 600;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.2rem 0;
  font-size: 0.75rem;
  font-family: ui-monospace, monospace;
}
.kv-row .k { color: #94a3b8; }
.kv-row .v { color: #e2e8f0; text-align: right; word-break: break-all; max-width: 200px; }

.leaf {
  font-size: 0.75rem;
  font-family: ui-monospace, monospace;
  color: #cbd5e1;
  padding: 0.15rem 0 0.15rem 0.6rem;
  border-left: 2px solid #1e1e3a;
  margin: 0.1rem 0;
}
.leaf.clickable {
  background: transparent;
  border: none;
  border-left: 2px solid #1e1e3a;
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: #cbd5e1;
  font: inherit;
  padding: 0.2rem 0 0.2rem 0.6rem;
  transition: border-left-color 0.1s, color 0.1s;
}
.leaf.clickable:hover {
  border-left-color: #7c3aed;
  color: #c084fc;
}

.section pre,
.pre-small {
  font-family: ui-monospace, monospace;
  font-size: 0.6875rem;
  background: #0a0a1a;
  padding: 0.5rem;
  overflow-x: auto;
  color: #94a3b8;
  max-height: 360px;
  margin: 0.4rem 0;
  border-radius: 4px;
  border: 1px solid #1e1e3a;
}

.err { color: #f87171; font-size: 0.8125rem; }

/* === MVT POPUP =========================================================== */

.mvt-popup { font-family: inherit; color: #1f2937; min-width: 200px; }
.mvt-popup-head    { font-weight: 700; font-size: 0.875rem; margin-bottom: 0.15rem; color: #1f2937; }
.mvt-popup-sub     { font-size: 0.8125rem; color: #4b5563; margin-bottom: 0.3rem; }
.mvt-popup-reason  { font-size: 0.75rem; color: #4b5563; margin-bottom: 0.3rem; }
.mvt-popup-key {
  display: block;
  font-size: 0.6875rem;
  background: #f3f4f6;
  padding: 0.25rem 0.4rem;
  border-radius: 3px;
  word-break: break-all;
  font-family: ui-monospace, monospace;
}

/* === DATA BROWSER (top-level Data view) ================================== */

/* Map ⇄ Data is a TOP-LEVEL view switch (topbar), not a sidebar tab: in
   data-mode the map column collapses, the sidebar spans the viewport, and
   everything sidebar-ish (header, tab strip, panes, check card) hides so the
   grid owns the screen. */
#data-panel { display: none; }
body.data-mode #layout { grid-template-columns: 1fr 0; }
body.data-mode #map    { display: none; }
body.data-mode #sidebar {
  overflow: hidden;          /* the grid scrolls internally, not the sidebar */
}
body.data-mode .sidebar-header,
body.data-mode .sidebar-tabs,
body.data-mode .check-result-wrap,
body.data-mode .tab-pane { display: none; }
body.data-mode #data-panel { display: flex; flex: 1; min-height: 0; }

/* Topbar view switcher */
.view-switch {
  display: inline-flex;
  gap: 2px;
  margin-left: 14px;
  background: rgba(15,15,35,0.95);
  border: 1px solid #1e1e3a;
  border-radius: 8px;
  padding: 2px;
}
.view-btn {
  background: transparent;
  color: #9ca3af;
  border: 0;
  padding: 4px 14px;
  border-radius: 6px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.view-btn:hover:not(.active) { color: #e5e7eb; }
.view-btn.active { background: #7c3aed; color: #fff; }

.data-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  padding: 10px 12px 12px;
  gap: 0.6rem;
  overflow: hidden;
}

.db-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  gap: 0.6rem;
}

/* Picker row */
.db-picker {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.db-pick-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  font-weight: 600;
}
.db-table-search {
  background: var(--bg-control);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font: inherit;
  font-size: 0.8125rem;
  outline: none;
  width: 180px;
  transition: border-color 0.15s;
}
.db-table-search:focus      { border-color: var(--accent); }
.db-table-search::placeholder { color: var(--text-disabled); }

.db-table-select {
  background: var(--bg-control);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.8125rem;
  font-family: ui-monospace, monospace;
  outline: none;
  cursor: pointer;
  min-width: 280px;
  max-width: 440px;
}
.db-table-select:focus { border-color: var(--accent); }

.db-rowcount {
  font-family: ui-monospace, monospace;
  font-size: 0.7rem;
  color: var(--accent-bright);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 0.25rem 0.55rem;
  white-space: nowrap;
}

.db-empty {
  color: var(--text-subtle);
  font-style: italic;
  font-size: 0.8125rem;
  padding: 1rem 0;
}
.db-empty.db-err { color: var(--status-red); font-style: normal; }

.db-grid {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-panel);
}

/* Filter bar (Feature A): builder row + chips strip ---------------------- */
.db-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}
.db-filter-builder {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.db-filter-col,
.db-filter-op {
  background: var(--bg-control);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
  font: inherit;
  font-size: 0.75rem;
  font-family: ui-monospace, monospace;
  outline: none;
  cursor: pointer;
}
.db-filter-col { min-width: 150px; max-width: 240px; }
.db-filter-op  { min-width: 96px; }
.db-filter-col:focus,
.db-filter-op:focus { border-color: var(--accent); }

.db-filter-val {
  background: var(--bg-control);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  font: inherit;
  font-size: 0.75rem;
  outline: none;
  width: 160px;
  transition: border-color 0.15s;
}
.db-filter-val:focus { border-color: var(--accent); }
.db-filter-val::placeholder { color: var(--text-disabled); }
.db-filter-val:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.db-filter-val-error {
  border-color: var(--status-red) !important;
}

.db-filter-add {
  background: var(--accent);
  border: 1px solid var(--accent-bright);
  color: #fff;
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.db-filter-add:hover { background: var(--accent-bright); }

.db-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 0;
}
.db-filter-chips:empty { display: none; }
.db-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(124, 58, 237, 0.16);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 0.15rem 0.25rem 0.15rem 0.6rem;
  font-size: 0.7rem;
}
.db-filter-chip-text {
  font-family: ui-monospace, monospace;
  color: var(--accent-bright);
  white-space: nowrap;
}
.db-filter-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.db-filter-chip-x:hover { background: var(--accent); color: #fff; }

/* "View on map" action column (Feature B) -------------------------------- */
.db-mapaction-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--bg-control);
  color: var(--accent-bright);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background 0.12s, border-color 0.12s;
}
.db-mapaction-btn:hover {
  background: var(--accent);
  border-color: var(--accent-bright);
  color: #fff;
}
.db-mapaction-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.tabulator-row .tabulator-cell.db-mapaction-cell {
  padding: 0.15rem;
  overflow: visible;
}

/* Null + placeholder cell markers */
.db-null        { color: var(--text-disabled); }
.db-placeholder {
  color: var(--accent-bright);
  font-family: ui-monospace, monospace;
  font-size: 0.7rem;
  background: rgba(124, 58, 237, 0.12);
  padding: 0 0.3rem;
  border-radius: 3px;
}

/* Global entity search (task #332) --------------------------------------- */
/* Lives at the right of the picker row; visually distinct from the table
   picker via an accent ring + leading glyph. Owns an absolutely-positioned
   grouped results dropdown. */
.db-global-search {
  position: relative;
  margin-left: auto;          /* push to the right edge of the picker row */
  display: flex;
  align-items: center;
}
.db-global-search-icon {
  position: absolute;
  left: 0.55rem;
  color: var(--accent-bright);
  font-size: 0.95rem;
  pointer-events: none;
  line-height: 1;
}
.db-global-search-input {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 0.35rem 0.6rem 0.35rem 1.7rem;   /* room for the glyph */
  font: inherit;
  font-size: 0.8125rem;
  outline: none;
  width: 230px;
  transition: border-color 0.15s, box-shadow 0.15s, width 0.15s;
}
.db-global-search-input:focus {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.25);
  width: 280px;
}
.db-global-search-input::placeholder { color: var(--text-muted); }

.db-global-search-drop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 360px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: none;
  padding: 0.25rem;
}
.db-global-search-drop.open { display: block; }

.db-gs-status {
  padding: 0.5rem 0.6rem;
  color: var(--text-subtle);
  font-style: italic;
  font-size: 0.8rem;
}
.db-gs-error { color: var(--status-red); font-style: normal; }

.db-gs-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem 0.2rem;
  position: sticky;
  top: 0;
  background: var(--bg-panel);
}
.db-gs-group-title {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent-bright);
  font-weight: 700;
}
.db-gs-group-count {
  font-family: ui-monospace, monospace;
  font-size: 0.62rem;
  color: var(--text-subtle);
  background: var(--bg-card);
  border-radius: 8px;
  padding: 0.05rem 0.4rem;
}

.db-gs-row {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 5px;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-primary);
}
.db-gs-row:hover { background: var(--bg-control); }
.db-gs-row-primary {
  font-size: 0.8rem;
  color: var(--text-primary);
}
.db-gs-row-secondary {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* === TABULATOR DARK THEME (Purple Cow) =================================== */
/* Full theme override — no Tabulator stylesheet is imported, so these rules
   are the complete look. Matches the viewer palette: deep navy bg, purple
   accents, monospace data, thin borders. */

.tabulator {
  background: var(--bg-panel);
  border: none;
  font-family: -apple-system, 'Segoe UI', BlinkMacSystemFont, sans-serif;
  font-size: 0.75rem;
  color: var(--text-primary);
}
.tabulator,
.tabulator * { box-sizing: border-box; }

/* Header */
.tabulator .tabulator-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-weight: 600;
}
.tabulator .tabulator-header .tabulator-col {
  background: var(--bg-card);
  border-right: 1px solid var(--border-default);
}
.tabulator .tabulator-header .tabulator-col .tabulator-col-content {
  padding: 0.4rem 0.55rem;
}
.tabulator .tabulator-header .tabulator-col .tabulator-col-title {
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  text-transform: none;
  font-family: ui-monospace, monospace;
}
.tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover {
  background: var(--bg-control);
}
.tabulator .tabulator-header .tabulator-col .tabulator-col-sorter .tabulator-arrow {
  border-bottom-color: var(--text-subtle);
}
.tabulator .tabulator-header .tabulator-col[aria-sort="ascending"] .tabulator-col-sorter .tabulator-arrow {
  border-bottom-color: var(--accent-bright);
}
.tabulator .tabulator-header .tabulator-col[aria-sort="descending"] .tabulator-col-sorter .tabulator-arrow {
  border-top-color: var(--accent-bright);
  border-bottom-color: transparent;
}

/* Header filter inputs */
.tabulator .tabulator-header .tabulator-header-filter input {
  background: var(--bg-control);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
  font: inherit;
  font-size: 0.7rem;
  outline: none;
}
.tabulator .tabulator-header .tabulator-header-filter input:focus {
  border-color: var(--accent);
}
.tabulator .tabulator-header .tabulator-header-filter input::placeholder {
  color: var(--text-disabled);
}

/* Body rows */
.tabulator .tabulator-tableholder {
  background: var(--bg-panel);
}
.tabulator-row {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-default);
  min-height: 28px;
}
.tabulator-row.tabulator-row-even { background: #0c0c1f; }
.tabulator-row:hover {
  background: var(--bg-control) !important;
}
.tabulator-row .tabulator-cell {
  border-right: 1px solid var(--border-default);
  padding: 0.3rem 0.55rem;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.tabulator-row .tabulator-cell:last-child { border-right: none; }

.tabulator .tabulator-placeholder {
  background: var(--bg-panel);
}
.tabulator .tabulator-placeholder .tabulator-placeholder-contents {
  color: var(--text-subtle);
  font-style: italic;
  font-size: 0.8rem;
}

/* Footer / pagination */
.tabulator .tabulator-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 0.25rem 0.4rem;
}
.tabulator .tabulator-footer .tabulator-page-counter,
.tabulator .tabulator-footer .tabulator-paginator label {
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
  font-size: 0.68rem;
}
.tabulator .tabulator-footer .tabulator-page,
.tabulator .tabulator-footer .tabulator-paginator select {
  background: var(--bg-control);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  margin: 0 0.1rem;
}
.tabulator .tabulator-footer .tabulator-page:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent-bright);
  color: #fff;
}
.tabulator .tabulator-footer .tabulator-page.active {
  background: var(--accent);
  border-color: var(--accent-bright);
  color: #fff;
}
.tabulator .tabulator-footer .tabulator-page:disabled { opacity: 0.4; }
.tabulator .tabulator-footer .tabulator-paginator select:focus { border-color: var(--accent); }

/* Loader overlay */
.tabulator .tabulator-loader {
  background: rgba(10, 10, 26, 0.6);
}
.tabulator .tabulator-loader .tabulator-loader-msg {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--accent-bright);
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
}

/* Column resize handle */
.tabulator .tabulator-col-resize-handle { opacity: 0; }

/* === CURATOR BLOCK (C4) — confidence overrides in the detail panel ======= */

.curator-block {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px dashed #2d2d5a;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.curator-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  color: #c084fc;
}
.curator-subhead {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  font-weight: 600;
  margin-top: 0.3rem;
}

/* Simple band buttons + reason */
.curator-simple { display: flex; flex-direction: column; gap: 0.4rem; }
.curator-reason {
  background: #1e1e3a; border: 1px solid #2d2d5a; color: #e2e8f0;
  border-radius: 4px; padding: 0.35rem 0.5rem; font-family: inherit;
  font-size: 0.75rem; outline: none;
}
.curator-reason:focus { border-color: #7c3aed; }
.curator-reason::placeholder { color: #4a5568; }

.curator-bands { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.curator-band {
  flex: 1 1 auto;
  border-radius: 4px; padding: 0.35rem 0.6rem; font-family: inherit;
  font-size: 0.72rem; font-weight: 700; cursor: pointer;
  border: 1px solid; letter-spacing: 0.03em;
}
.cb-green  { background: #14532d; border-color: #16a34a; color: #86efac; }
.cb-green:hover  { background: #16a34a; color: #fff; }
.cb-yellow { background: #422006; border-color: #d97706; color: #fbbf24; }
.cb-yellow:hover { background: #d97706; color: #fff; }
.cb-red    { background: #4a1010; border-color: #b91c1c; color: #fca5a5; }
.cb-red:hover    { background: #b91c1c; color: #fff; }
/* Do-not-serve — distinct from the bands: heavier, dashed, full-width. */
.cb-dns {
  flex-basis: 100%;
  background: #2a0a0a; border: 1px dashed #ef4444; color: #f87171;
  text-transform: uppercase;
}
.cb-dns:hover { background: #7f1d1d; color: #fff; border-style: solid; }

.curator-reprobe {
  align-self: flex-start;
  background: #1e293b; border: 1px solid #0284c7; color: #38bdf8;
  border-radius: 4px; padding: 0.3rem 0.6rem; font-family: inherit;
  font-size: 0.72rem; font-weight: 600; cursor: pointer;
}
.curator-reprobe:hover { background: #0284c7; color: #fff; }

/* Advanced expander */
.curator-advanced {
  border: 1px solid #1e1e3a; border-radius: 6px;
  background: #15152b; padding: 0.4rem 0.5rem;
}
.curator-advanced > summary {
  cursor: pointer; font-size: 0.72rem; font-weight: 600; color: #94a3b8;
  list-style: none; outline: none;
}
.curator-advanced > summary::-webkit-details-marker { display: none; }
.curator-advanced > summary::before {
  content: '▸'; margin-right: 0.35rem; color: #4a5568; font-size: 0.6rem;
}
.curator-advanced[open] > summary::before { content: '▾'; }
.curator-adv-form {
  display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.5rem;
}
.curator-adv-field { display: flex; flex-direction: column; gap: 0.15rem; }
.curator-adv-label {
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b;
}
.curator-adv-select, .curator-adv-input {
  background: #1e1e3a; border: 1px solid #2d2d5a; color: #e2e8f0;
  border-radius: 4px; padding: 0.3rem 0.45rem; font-family: inherit;
  font-size: 0.72rem; outline: none;
}
.curator-adv-select:focus, .curator-adv-input:focus { border-color: #7c3aed; }
.curator-adv-input::placeholder { color: #4a5568; }
.curator-adv-value {
  display: flex; flex-direction: column; gap: 0.4rem;
  padding: 0.4rem; border: 1px solid #1e1e3a; border-radius: 4px; background: #0f0f23;
}
.curator-adv-hint { font-size: 0.68rem; color: #94a3b8; }
.curator-adv-hint.identity { color: #fbbf24; }
.curator-adv-submit {
  align-self: flex-start;
  background: #2d1b4e; border: 1px solid #7c3aed; color: #c084fc;
  border-radius: 4px; padding: 0.35rem 0.7rem; font-family: inherit;
  font-size: 0.72rem; font-weight: 600; cursor: pointer;
}
.curator-adv-submit:hover { background: #7c3aed; color: #fff; }

/* Active overrides list */
.curator-overrides { display: flex; flex-direction: column; gap: 0.3rem; }
.curator-override-list { display: flex; flex-direction: column; gap: 0.35rem; }
.curator-override-row {
  display: flex; flex-direction: column; gap: 0.25rem;
  border: 1px solid #312e81; border-left: 3px solid #7c3aed;
  border-radius: 4px; background: #15152b; padding: 0.4rem 0.5rem;
}
.curator-override-head { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.curator-override-meta { display: flex; flex-direction: column; gap: 0.1rem; }
.curator-override-val {
  font-family: ui-monospace, monospace; font-size: 0.7rem; color: #cbd5e1;
  word-break: break-all;
}
.curator-override-meta .muted { font-size: 0.7rem; color: #94a3b8; }
.curator-retract {
  align-self: flex-start;
  background: #1e293b; border: 1px solid #b91c1c; color: #fca5a5;
  border-radius: 4px; padding: 0.2rem 0.55rem; font-family: inherit;
  font-size: 0.68rem; cursor: pointer;
}
.curator-retract:hover { background: #b91c1c; color: #fff; }

/* Toast */
.curator-toast {
  position: fixed; bottom: 18px; left: 50%; transform: translate(-50%, 14px);
  z-index: 400; max-width: 420px;
  padding: 0.5rem 0.9rem; border-radius: 6px;
  font-size: 0.78rem; font-weight: 500;
  background: #1a1a2e; color: #e2e8f0;
  border: 1px solid #2d2d5a;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  opacity: 0; transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.curator-toast.show { opacity: 1; transform: translate(-50%, 0); }
.curator-toast-ok  { border-color: #16a34a; color: #86efac; }
.curator-toast-err { border-color: #b91c1c; color: #fca5a5; }
.curator-toast-info { border-color: #7c3aed; color: #c084fc; }

/* ── Add-address (C5) ───────────────────────────────────────────────────── */
.add-address-tools { display: flex; }
.add-address-btn {
  width: 100%;
  background: var(--bg-control);
  border: 1px solid var(--border-strong);
  color: var(--accent-bright);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.78rem; font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.add-address-btn:hover { border-color: var(--accent); }
.add-address-btn.active {
  border-color: var(--accent-bright);
  background: var(--bg-card);
}

/* Floating form panel over the map. */
.add-address-panel {
  position: absolute;
  top: 64px; right: 16px;
  z-index: 420;
  width: 320px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.55);
  padding: 0.9rem;
}
.add-address-form { display: flex; flex-direction: column; gap: 0.55rem; }
.add-head { display: flex; align-items: center; justify-content: space-between; }
.add-title { font-size: 0.92rem; font-weight: 700; color: var(--accent-bright); }
.add-close {
  background: transparent; border: none; color: var(--text-muted);
  font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 0.3rem;
}
.add-close:hover { color: var(--accent-bright); }
.add-hint { font-size: 0.7rem; line-height: 1.35; }
.add-geo-row { display: flex; }
.add-geo-input {
  width: 100%;
  background: var(--bg-control);
  border: 1px solid var(--border-strong);
  color: var(--text, #e2e8f0);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  font-size: 0.78rem;
}
.add-geo-input:focus { outline: none; border-color: var(--accent); }
.add-geo-dropdown { display: flex; flex-direction: column; gap: 1px; }
.add-geo-dropdown:empty { display: none; }
.add-geo-option {
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  color: var(--text-secondary, #cbd5e1);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  font-size: 0.72rem;
  cursor: pointer;
}
.add-geo-option:hover { border-color: var(--accent); background: var(--bg-control); }
.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; }
.add-field { display: flex; flex-direction: column; gap: 0.2rem; }
.add-field-label { font-size: 0.66rem; color: var(--text-muted); font-weight: 600; }
.add-field input, .add-field select {
  background: var(--bg-control);
  border: 1px solid var(--border-strong);
  color: var(--text, #e2e8f0);
  border-radius: 5px;
  padding: 0.3rem 0.45rem;
  font-size: 0.76rem;
}
.add-field input:focus, .add-field select:focus { outline: none; border-color: var(--accent); }
.add-coord-row { display: flex; align-items: baseline; gap: 0.4rem; }
.add-coord { font-size: 0.72rem; font-family: ui-monospace, monospace; color: #86efac; }
.add-actions { display: flex; gap: 0.5rem; margin-top: 0.25rem; }
.add-save {
  flex: 1;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 0.42rem 0.6rem;
  font-size: 0.78rem; font-weight: 600;
  cursor: pointer;
}
.add-save:hover { background: var(--accent-bright); border-color: var(--accent-bright); }
.add-cancel {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.42rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
}
.add-cancel:hover { color: var(--text-secondary); border-color: var(--accent); }

/* === CONFLICT QUEUE (C4.7) =============================================== */

.cq-conflict-hint {
  font-size: 0.7rem; color: #94a3b8; flex-basis: 100%;
  padding: 0.4rem 0.5rem; border: 1px dashed #d97706; border-radius: 6px;
  background: rgba(217,119,6,0.06);
}
.cq-conflict-card { border-left: 3px solid #d97706; }
.cq-conflict-civic {
  flex: 1; color: #e2e8f0; font-weight: 600; font-size: 0.75rem; word-break: break-word;
}
.cq-conflict-flag {
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 700; padding: 0.05rem 0.4rem; border-radius: 4px;
  background: #422006; color: #fbbf24;
}
.cq-conflict-laws {
  display: flex; flex-direction: column; gap: 0.2rem; margin: 0.3rem 0;
}
.cq-conflict-law {
  display: flex; gap: 0.4rem; align-items: baseline; flex-wrap: wrap;
  font-size: 0.7rem; padding: 0.15rem 0;
  border-left: 2px solid #2d2d5a; padding-left: 0.5rem;
}
.cq-conflict-source {
  font-family: ui-monospace, monospace; font-size: 0.65rem;
  background: #0a0a1a; color: #38bdf8; padding: 0.05rem 0.35rem; border-radius: 3px;
}
.cq-conflict-label { color: #cbd5e1; }
.cq-conflict-actions { display: flex; gap: 0.4rem; margin-top: 0.3rem; }

/* === SCROLLBARS ========================================================== */

::-webkit-scrollbar          { width: 6px; height: 6px; }
::-webkit-scrollbar-track    { background: transparent; }
::-webkit-scrollbar-thumb    { background: #2d2d5a; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #7c3aed; }

/* === API PANEL (top-level API view — admin-only) ========================= */
/* Mirrors the data-mode pattern: api-mode hides the map + sidebar chrome and
   shows #api-panel full-screen below the topbar. */

#api-panel { display: none; }

body.api-mode #layout { grid-template-columns: 1fr 0; }
body.api-mode #map    { display: none; }
body.api-mode #sidebar { overflow: hidden; }
body.api-mode .sidebar-header,
body.api-mode .sidebar-tabs,
body.api-mode .check-result-wrap,
body.api-mode .tab-pane { display: none; }
body.api-mode #data-panel { display: none; }
body.api-mode #api-panel {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  flex-direction: column;
}

/* Inner wrapper — constrained, centered, scrollable. */
.api-wrap-inner {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Section card */
.api-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.api-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-bright);
  margin: 0;
}

.api-section-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

/* Tester block (label + controls) */
.api-tester-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.api-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.api-label-hint {
  font-family: ui-monospace, monospace;
  font-size: 0.68rem;
  color: var(--text-subtle);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* Input row */
.api-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.api-input {
  background: var(--bg-control);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-size: 0.8125rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.api-input:focus         { border-color: var(--accent); }
.api-input::placeholder  { color: var(--text-disabled); }

.api-input-grow  { flex: 1; width: auto; }
.api-input-coord { flex: 1; width: auto; }

.api-run-btn {
  background: var(--accent);
  border: 1px solid var(--accent-bright);
  color: #fff;
  border-radius: 6px;
  padding: 0.45rem 1rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.api-run-btn:hover { background: var(--accent-bright); }

/* Autofill wrap + dropdown */
.api-autofill-wrap {
  position: relative;
}

.api-drop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 50;
  max-height: 280px;
  overflow-y: auto;
}
.api-drop[hidden] { display: none; }

.api-drop-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-default);
  color: var(--text-primary);
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}
.api-drop-item:last-child  { border-bottom: none; }
.api-drop-item:hover,
.api-drop-item.active      { background: var(--bg-control); color: var(--accent-bright); }

/* Result block */
.api-result-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.api-result-wrap[hidden] { display: none; }

.api-result-summary {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.6rem;
  border-radius: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
}
.api-result-summary.summary-ok   { color: var(--status-green); border-color: #16a34a; background: var(--bg-green); }
.api-result-summary.summary-err  { color: var(--status-red);   border-color: #b91c1c; background: var(--bg-red); }
.api-result-summary.summary-warn { color: var(--status-yellow); border-color: #d97706; background: var(--bg-yellow); }

.api-result-pre {
  font-family: ui-monospace, monospace;
  font-size: 0.6875rem;
  background: var(--bg-deep);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 0.75rem 0.9rem;
  overflow-x: auto;
  color: var(--text-muted);
  max-height: 420px;
  overflow-y: auto;
  white-space: pre;
  margin: 0;
}

/* Divider between tester sub-sections */
.api-divider {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: 0;
}

/* Swagger UI section — give the container room and reset Swagger's own styles */
.api-section-swagger {
  /* Let Swagger grow naturally; the section card provides the outer chrome. */
  min-height: 400px;
}

#api-swagger-ui {
  /* Swagger UI injects its own stylesheet; we just give it the right container.
     A few targeted overrides below keep it readable in the dark theme. */
  margin-top: 0.25rem;
}

/* Swagger UI dark-theme nudges */
#api-swagger-ui .swagger-ui,
#api-swagger-ui .swagger-ui .info .title,
#api-swagger-ui .swagger-ui .info p,
#api-swagger-ui .swagger-ui .info li,
#api-swagger-ui .swagger-ui .opblock-tag,
#api-swagger-ui .swagger-ui .opblock-summary-description {
  color: var(--text-primary) !important;
}
#api-swagger-ui .swagger-ui .wrapper,
#api-swagger-ui .swagger-ui section.models {
  background: transparent !important;
}
#api-swagger-ui .swagger-ui .opblock {
  background: var(--bg-card) !important;
  border-color: var(--border-strong) !important;
}
#api-swagger-ui .swagger-ui .opblock .opblock-summary {
  background: var(--bg-control) !important;
}
#api-swagger-ui .swagger-ui input[type=text],
#api-swagger-ui .swagger-ui textarea,
#api-swagger-ui .swagger-ui select {
  background: var(--bg-control) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-strong) !important;
}
#api-swagger-ui .swagger-ui .btn {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent-bright) !important;
}
#api-swagger-ui .swagger-ui table tbody tr td,
#api-swagger-ui .swagger-ui table thead tr th {
  color: var(--text-secondary) !important;
  background: var(--bg-panel) !important;
  border-color: var(--border-default) !important;
}
/* Swagger's last light surfaces: the top info block + the white Servers box. */
#api-swagger-ui .swagger-ui .information-container,
#api-swagger-ui .swagger-ui .info {
  background: transparent !important;
  box-shadow: none !important;
}
#api-swagger-ui .swagger-ui .scheme-container {
  background: var(--bg-control) !important;
  box-shadow: none !important;
  border: 1px solid var(--border-default) !important;
  border-radius: 8px;
}
#api-swagger-ui .swagger-ui .info a,
#api-swagger-ui .swagger-ui .info .base-url,
#api-swagger-ui .swagger-ui .servers > label,
#api-swagger-ui .swagger-ui .opblock-summary-path,
#api-swagger-ui .swagger-ui .opblock-summary-path__deprecated,
#api-swagger-ui .swagger-ui .response-col_status,
#api-swagger-ui .swagger-ui label {
  color: var(--text-secondary) !important;
}

/* === HARVEST PANEL (top-level Harvest view — admin-only) ================== */
/* Live EL serviceability harvest dashboard. Layout mirrors the api-mode swap
   (hide map + sidebar chrome, show #harvest-panel full-screen below the
   topbar); the inner styling recreates infra/el-reprobe/scale-dashboard.html on
   the viewer's dark theme. */

#harvest-panel { display: none; }

body.harvest-mode #layout { grid-template-columns: 1fr 0; }
body.harvest-mode #map    { display: none; }
body.harvest-mode #sidebar { overflow: hidden; }
body.harvest-mode .sidebar-header,
body.harvest-mode .sidebar-tabs,
body.harvest-mode .check-result-wrap,
body.harvest-mode .tab-pane { display: none; }
body.harvest-mode #data-panel { display: none; }
body.harvest-mode #api-panel { display: none; }
body.harvest-mode #harvest-panel {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
}

.harvest-wrap-inner {
  width: 100%;
  height: 100%;
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-height: 0;
}

.harvest-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.85rem 1rem;
}

/* Header: status line + progress bar + controls */
.harvest-head { flex: 0 0 auto; display: flex; flex-direction: column; gap: 0.7rem; }

.harvest-status-row {
  display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap;
  font-size: 0.78rem; color: var(--text-muted);
}
.harvest-status-text { font-weight: 600; color: var(--text-secondary); }
.harvest-meta b { color: var(--accent-bright); }

.harvest-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #ff4444; display: inline-block; flex: 0 0 auto;
}
.harvest-dot.on { background: #00ff88; animation: harvest-pulse 2s infinite; }
.harvest-dot.paused { background: #ffaa00; }
.harvest-dot.done { background: var(--text-muted); }
@keyframes harvest-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.harvest-progress-wrap { display: flex; align-items: center; gap: 0.75rem; }
.harvest-progress-track {
  flex: 1; height: 14px; border-radius: 7px;
  background: var(--bg-control, #0a0a1a);
  border: 1px solid var(--border-strong);
  overflow: hidden;
}
.harvest-progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  transition: width 0.4s ease;
}
.harvest-progress-label {
  flex: 0 0 auto; font-family: ui-monospace, monospace;
  font-size: 0.75rem; color: var(--text-secondary); min-width: 200px; text-align: right;
}

.harvest-controls { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
.harvest-ctl {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-muted);
}
.harvest-num {
  width: 64px; background: var(--bg-control, #0a0a1a);
  border: 1px solid var(--border-strong); color: var(--text-primary);
  padding: 0.3rem 0.5rem; border-radius: 5px; font: inherit;
  font-size: 0.85rem; text-align: center; outline: none;
}
.harvest-num:focus { border-color: var(--accent); }
.harvest-btn {
  background: var(--bg-control, #1a1a2e); border: 1px solid var(--border-strong);
  color: var(--text-secondary); padding: 0.35rem 0.85rem; border-radius: 5px;
  cursor: pointer; font: inherit; font-size: 0.78rem;
}
.harvest-btn:hover { border-color: var(--accent); color: var(--accent-bright); }

/* Two-column body */
.harvest-cols {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem;
}
.harvest-col { display: flex; flex-direction: column; min-height: 0; gap: 0.65rem; }
.harvest-af { border-color: #2a4866; }
.harvest-cs { border-color: #2a6648; }

.harvest-col-title { font-size: 0.9rem; font-weight: 700; margin: 0; }
.harvest-af .harvest-col-title { color: #44aaff; }
.harvest-cs .harvest-col-title { color: #00ff88; }
.harvest-col-sub { font-family: ui-monospace, monospace; font-size: 0.7rem; color: var(--text-subtle); font-weight: 400; }

.harvest-stats { flex: 0 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.45rem; }
.harvest-stat {
  background: var(--bg-control, #151515); border: 1px solid var(--border-strong);
  border-radius: 5px; padding: 0.5rem 0.4rem; text-align: center;
}
.harvest-stat-v { font-size: 1.15rem; font-weight: 700; line-height: 1.1; }
.harvest-stat-l { font-size: 0.6rem; color: var(--text-muted); margin-top: 0.2rem; text-transform: uppercase; letter-spacing: 0.02em; }
.harvest-af .harvest-stat-v { color: #44aaff; }
.harvest-cs .harvest-stat-v { color: #00ff88; }
.harvest-stat-v.harvest-lat { color: #ff66cc; }
.harvest-stat-v.harvest-dim { color: var(--text-secondary); }

.harvest-substats { flex: 0 0 auto; display: flex; gap: 0.8rem; font-size: 0.72rem; color: var(--text-muted); flex-wrap: wrap; }
.harvest-substats b { color: var(--text-secondary); }
.harvest-substats b.hv-g { color: #00ff88; }
.harvest-substats b.hv-y { color: #ffaa00; }
.harvest-substats b.hv-r { color: #ff4444; }
.harvest-substats b.hv-f { color: #cc66ff; }
.harvest-substats b.hv-muted { color: var(--text-subtle); }

/* Results log table */
.harvest-log {
  flex: 1 1 auto; min-height: 80px; overflow-y: auto;
  background: var(--bg-control, #0c0c0c); border: 1px solid var(--border-strong);
  border-radius: 5px;
}
.harvest-table { width: 100%; border-collapse: collapse; font-size: 0.72rem; font-family: ui-monospace, monospace; }
.harvest-table th {
  background: var(--bg-panel); color: var(--text-muted); padding: 0.25rem 0.45rem;
  text-align: left; border-bottom: 1px solid var(--border-strong);
  position: sticky; top: 0;
}
.harvest-table td {
  padding: 0.2rem 0.45rem; border-bottom: 1px solid rgba(45, 45, 90, 0.4);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;
}
.harvest-table .hv-svc { color: #00ff88; }
.harvest-table .hv-cond { color: #ffaa00; }
.harvest-table .hv-notsvc { color: #ff4444; }
.harvest-table .hv-fiber { color: #cc66ff; font-weight: 700; }
.harvest-table .hv-muted { color: var(--text-subtle); }
.harvest-table .hv-ok { color: var(--text-secondary); }
