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

:root {
  --bg:         #08101a;
  --surface:    #0d1520;
  --surface-2:  #111c2b;
  --surface-3:  #162130;
  --border:     #1e2d3d;
  --accent:     #1a6bfa;
  --accent-dim: rgba(26, 107, 250, 0.15);
  --text:       #dce6f0;
  --muted:      #7a90a8;
  --faint:      #4a5f72;
  --green:      #22c55e;
  --green-dim:  rgba(34, 197, 94, 0.12);
  --amber:      #f59e0b;
  --amber-dim:  rgba(245, 158, 11, 0.12);
  --purple:     #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.12);
  --red:        #ef4444;
  --red-dim:    rgba(239, 68, 68, 0.12);
  --radius:     10px;
  --shadow:     0 1px 4px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.25);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  min-height: 100vh;
}

/* ── Filter bar ── */
.filter-bar {
  position: sticky;
  top: 52px;
  z-index: 90;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.filter-bar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.filter-bar-inner::-webkit-scrollbar { display: none; }

.filter-bar-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 0.25rem;
}

/* Environment tabs */
.env-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 3px;
  flex-shrink: 0;
}
.env-tab {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.85rem;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  transition: all 0.15s;
  white-space: nowrap;
}
.env-tab:hover { color: var(--text); }
.env-tab.active {
  background: var(--accent);
  color: #fff;
}

/* Filter trigger button */
.filter-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.filter-trigger:hover {
  border-color: rgba(26, 107, 250, 0.45);
  color: var(--text);
}
.filter-trigger.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.filter-icon { flex-shrink: 0; opacity: 0.8; }

.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--accent);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: 99px;
  line-height: 1;
}
/* Author display rule overrides UA [hidden]{display:none} — must be explicit */
.filter-badge[hidden] { display: none; }

/* Active filter chips (inline in filter bar) */
.active-chips {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.active-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  background: rgba(26, 107, 250, 0.12);
  border: 1px solid rgba(26, 107, 250, 0.3);
  border-radius: 5px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s;
  font-family: inherit;
}
.active-chip:hover {
  background: rgba(26, 107, 250, 0.2);
  border-color: rgba(26, 107, 250, 0.5);
}

.entity-count {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Filter backdrop ── */
.filter-backdrop {
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgba(0, 0, 0, 0.45);
}
.filter-backdrop[hidden] { display: none; }

/* ── Filter sheet ── */
.filter-sheet[hidden] { display: none; }

.filter-sheet {
  position: fixed;
  z-index: 150;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Desktop: right-anchored popover */
@media (min-width: 768px) {
  .filter-sheet {
    top: 106px;
    right: max(calc((100vw - 1100px) / 2), 1.5rem);
    width: 288px;
    max-height: calc(100dvh - 126px);
    border-radius: 10px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.25);
    animation: popover-in 0.15s ease-out;
  }
  @keyframes popover-in {
    from { transform: translateY(-6px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }
  .filter-sheet-handle { display: none; }
}

/* Mobile: bottom sheet */
@media (max-width: 767px) {
  .filter-sheet {
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 82dvh;
    border-radius: 12px 12px 0 0;
    border-bottom: none;
    animation: sheet-up 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .filter-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 99px;
    margin: 0.75rem auto 0;
    flex-shrink: 0;
  }
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* Filter sheet internals */
.filter-sheet-hd {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.filter-sheet-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.filter-sheet-clear {
  margin-left: auto;
  padding: 0.2rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--faint);
  font-size: 0.7rem;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.filter-sheet-clear:hover { color: var(--red); border-color: rgba(239, 68, 68, 0.4); }
.filter-sheet-close {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.filter-sheet-close:hover { color: var(--text); border-color: rgba(26, 107, 250, 0.35); }

.filter-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0 0.5rem;
}

/* Filter sections */
.fsec {
  padding: 1rem 1.125rem;
  border-bottom: 1px solid var(--border);
}
.fsec--last { border-bottom: none; }
.fsec-title {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--faint);
  margin-bottom: 0.75rem;
}

/* Geo chips */
.geo-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.geo-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.42rem 0.9rem;
  min-height: 36px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.geo-chip:hover { color: var(--text); border-color: rgba(110, 209, 232, 0.35); }
.geo-chip.active {
  background: rgba(110, 209, 232, 0.1);
  border-color: rgba(110, 209, 232, 0.55);
  color: rgba(110, 209, 232, 0.95);
  font-weight: 600;
}

/* Type pills */
.type-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.type-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.42rem 0.9rem;
  min-height: 36px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s;
}
.type-pill:hover { color: var(--text); border-color: rgba(26, 107, 250, 0.4); }
.type-pill.active {
  background: var(--accent-dim);
  border-color: rgba(26, 107, 250, 0.5);
  color: var(--accent);
  font-weight: 600;
}

/* Sort options — 2-col grid on mobile for compactness */
.sort-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}
.sort-option {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.5rem;
  min-height: 40px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: all 0.12s;
}
.sort-option:hover { color: var(--text); border-color: rgba(26, 107, 250, 0.3); }
.sort-option.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: rgba(26, 107, 250, 0.4);
  font-weight: 600;
}

/* Desktop: sort as single column list */
@media (min-width: 768px) {
  .sort-options { grid-template-columns: 1fr; gap: 0.1rem; }
  .sort-option {
    justify-content: flex-start;
    min-height: auto;
    padding: 0.42rem 0.6rem;
    background: transparent;
    border-color: transparent;
    border-radius: 5px;
    font-size: 0.8rem;
  }
  .sort-option:hover { background: var(--surface-2); border-color: transparent; }
  .sort-option.active {
    background: var(--accent-dim);
    border-color: rgba(26, 107, 250, 0.25);
  }
  .sort-option.active::before {
    content: '●';
    font-size: 0.45rem;
    margin-right: 0.45rem;
    flex-shrink: 0;
    opacity: 0.7;
  }
}

/* ── Main content ── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 2rem 5rem;
}

/* ── Entity grid ── */
#entities-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.875rem;
}

/* ── Entity card ── */
.entity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}
.entity-card:hover {
  border-color: rgba(26, 107, 250, 0.4);
  background: var(--surface-2);
  box-shadow: 0 0 0 1px rgba(26, 107, 250, 0.15), var(--shadow);
}
.entity-card.active {
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: 0 0 0 2px rgba(26, 107, 250, 0.2), var(--shadow);
}
.entity-card-main { flex: 1; min-width: 0; }
.entity-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.4rem;
}
.entity-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.entity-env {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Card stats (right side) */
.entity-card-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  flex-shrink: 0;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.stat-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.stat .stat-label {
  font-size: 0.68rem;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat:first-child .stat-value {
  font-size: 1.15rem;
  color: var(--accent);
}

/* ── Badges ── */
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  line-height: 1.4;
}
/* ── Entity type badge colours — canonical 7-type taxonomy ── */
.badge-type.badge-company    { background: var(--accent-dim);      color: var(--accent);  border: 1px solid rgba(26,107,250,0.3); }
.badge-type.badge-country    { background: rgba(6,182,212,0.12);   color: #06b6d4;        border: 1px solid rgba(6,182,212,0.3); }
.badge-type.badge-person     { background: var(--green-dim);       color: var(--green);   border: 1px solid rgba(34,197,94,0.3); }
.badge-type.badge-topic      { background: var(--amber-dim);       color: var(--amber);   border: 1px solid rgba(245,158,11,0.3); }
.badge-type.badge-sector     { background: rgba(249,115,22,0.12);  color: #f97316;        border: 1px solid rgba(249,115,22,0.3); }
.badge-type.badge-regulator  { background: rgba(244,63,94,0.12);   color: #f43f5e;        border: 1px solid rgba(244,63,94,0.3); }
.badge-type.badge-asset_class{ background: rgba(139,92,246,0.12);  color: #8b5cf6;        border: 1px solid rgba(139,92,246,0.3); }
/* Legacy — kept so any stale 'other' rows still render without breaking */
.badge-type.badge-other      { background: var(--purple-dim);      color: var(--purple);  border: 1px solid rgba(167,139,250,0.3); }
.badge-env {
  background: var(--surface-3);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ── Momentum label (card + detail) ── */
.entity-momentum {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.45rem;
  flex-wrap: wrap;
}
.momentum-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}
.momentum-stats {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Label colour variants */
.momentum-heating  { background: var(--amber-dim);  color: var(--amber);  border: 1px solid rgba(245,158,11,0.3); }
.momentum-emerging { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(34,197,94,0.3); }
.momentum-stable   { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(26,107,250,0.3); }
.momentum-cooling  { background: var(--surface-3);  color: var(--muted);  border: 1px solid var(--border); }
.momentum-dormant  { background: var(--surface-3);  color: var(--faint);  border: 1px solid var(--border); }
.momentum-active   { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(26,107,250,0.3); }

/* ── Momentum summary in detail panel ── */
.momentum-detail-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.momentum-detail-box.momentum-detail-heating  { border-left: 3px solid var(--amber); }
.momentum-detail-box.momentum-detail-emerging { border-left: 3px solid var(--green); }
.momentum-detail-box.momentum-detail-stable   { border-left: 3px solid var(--accent); }
.momentum-detail-box.momentum-detail-cooling  { border-left: 3px solid var(--faint); }
.momentum-detail-box.momentum-detail-dormant  { border-left: 3px solid var(--border); }

.momentum-detail-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.momentum-detail-stats {
  font-size: 0.82rem;
  color: var(--muted);
}
.momentum-detail-explanation {
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Detail panel overlay ── */
#entity-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: flex-end;
}
#entity-detail-overlay[hidden] { display: none; }

#entity-detail-panel {
  width: 480px;
  max-width: 100vw;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.5);
  animation: slide-in 0.2s ease-out;
}

@keyframes slide-in {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Detail panel content ── */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 10;
}
.detail-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.detail-badges {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.detail-close {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.detail-close:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: rgba(26,107,250,0.4);
}

.detail-summary {
  margin: 1.25rem 1.5rem;
  font-size: 0.92rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  line-height: 1.55;
  font-style: italic;
}

.detail-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  padding: 0 1.5rem 1.25rem;
}
.detail-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.875rem 1rem;
  text-align: center;
}
.detail-stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.detail-stat:first-child .detail-stat-value { color: var(--accent); font-size: 1.3rem; }
.detail-stat-label {
  font-size: 0.68rem;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-section {
  border-top: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
}
.detail-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  margin-bottom: 0.75rem;
}

/* (geo-filter-bar replaced by filter-sheet — see filter bar section above) */

/* ── Evidence Trail ── */
.evidence-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.evidence-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  transition: border-color 0.15s;
}
.evidence-item:hover {
  border-color: rgba(26, 107, 250, 0.35);
}

.evidence-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Signal type badge — distinct from entity type badges */
.badge-signal-type {
  background: var(--surface-3);
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
}

.evidence-scores {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}
.score-badge,
.confidence-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
}
.score-badge.score-high { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(34,197,94,0.3); }
.score-badge.score-mid  { background: var(--amber-dim);  color: var(--amber);  border: 1px solid rgba(245,158,11,0.3); }
.score-badge.score-low  { background: var(--surface-3);  color: var(--muted);  border: 1px solid var(--border); }
.confidence-badge {
  background: var(--surface-3);
  color: var(--faint);
  border: 1px solid var(--border);
}

.evidence-summary {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.5;
}

.evidence-why {
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.5;
}
.evidence-why-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin-right: 0.4rem;
}

.evidence-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.15rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.evidence-source-name {
  font-size: 0.73rem;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.evidence-source-link {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
  flex: 1;
}
.evidence-source-link:hover {
  text-decoration: underline;
}
.evidence-date {
  font-size: 0.73rem;
  color: var(--faint);
  margin-left: auto;
  white-space: nowrap;
}
.evidence-missing-note {
  font-size: 0.73rem;
  color: var(--faint);
  font-style: italic;
  padding: 0.4rem 0 0.1rem;
  opacity: 0.7;
}

/* Geo chips on evidence cards */
.ev-geo-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.ev-geo-chip {
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  background: rgba(110, 209, 232, 0.07);
  color: rgba(110, 209, 232, 0.75);
  border: 1px solid rgba(110, 209, 232, 0.2);
  white-space: nowrap;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.12s, color 0.12s, opacity 0.12s;
}
.ev-geo-chip:hover {
  background: rgba(110, 209, 232, 0.13);
  color: rgba(110, 209, 232, 1);
}
/* Active geo filter states */
.ev-geo-chip--match {
  background: rgba(110, 209, 232, 0.18);
  color: rgba(110, 209, 232, 1);
  border-color: rgba(110, 209, 232, 0.6);
  box-shadow: 0 0 0 1px rgba(110, 209, 232, 0.2);
}
.ev-geo-chip--fade {
  opacity: 0.3;
  cursor: default;
}
.ev-geo-chip--fade:hover {
  background: rgba(110, 209, 232, 0.07);
  color: rgba(110, 209, 232, 0.75);
  opacity: 0.3;
}

/* Evidence trail geo filter badge in section title */
.evidence-trail-geo-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: rgba(110, 209, 232, 0.12);
  color: rgba(110, 209, 232, 0.9);
  border: 1px solid rgba(110, 209, 232, 0.3);
  margin-left: 0.4rem;
  vertical-align: middle;
  letter-spacing: 0.04em;
}

/* In-card filtered geo context section (L2 — shown when geo filter active) */
.ev-geo-context {
  margin-top: 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: 5px;
  background: rgba(110, 209, 232, 0.04);
  border: 1px solid rgba(110, 209, 232, 0.14);
}
.ev-geo-context-title {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(110, 209, 232, 0.7);
  margin-bottom: 0.4rem;
}
.ev-geo-exp-row,
.ev-geo-rel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.5rem;
  font-size: 0.72rem;
  padding: 0.2rem 0;
  border-top: 1px solid rgba(110, 209, 232, 0.07);
}
.ev-geo-exp-row:first-of-type,
.ev-geo-rel-row:first-of-type {
  border-top: none;
}
.ev-geo-exp-role {
  font-weight: 600;
  color: rgba(110, 209, 232, 0.85);
  white-space: nowrap;
  min-width: 5rem;
}
.ev-geo-exp-geo {
  color: var(--text);
  font-weight: 500;
}
.ev-geo-exp-geo--parent {
  color: var(--muted);
  font-style: italic;
}
.ev-geo-exp-conf {
  font-size: 0.67rem;
  color: var(--muted);
  white-space: nowrap;
}
.ev-geo-exp-evidence {
  color: var(--muted);
  font-size: 0.7rem;
  font-style: italic;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ev-geo-rel-market {
  color: var(--muted);
  font-weight: 500;
}
.ev-geo-rel-market--match {
  color: rgba(110, 209, 232, 0.9);
  font-weight: 700;
}
.ev-geo-rel-arrow {
  color: var(--faint);
  font-size: 0.68rem;
  white-space: nowrap;
}

/* Brief list */
.brief-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.brief-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
}
.brief-date { color: var(--text); }
.brief-signals {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── States ── */
.loading-state,
.error-state,
.empty-state {
  grid-column: 1 / -1;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.error-state { color: var(--red); }
.loading-small,
.empty-small {
  font-size: 0.83rem;
  color: var(--muted);
  padding: 0.4rem 0;
}

/* ── Footer ── */
footer {
  color: var(--faint);
}

/* ── Responsive ── */
@media (max-width: 768px) {

  /* Shell */
  header { padding-left: 1rem; padding-right: 1rem; }
  main   { padding: 0.875rem 0.875rem 5rem; }

  /* Filter bar */
  .filter-bar-inner { padding: 0 1rem; }

  /* Grid */
  #entities-list {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  /* Card — vertical stack */
  .entity-card {
    flex-direction: column;
    gap: 0;
    padding: 0.75rem 1rem;
    overflow: hidden;
  }
  .entity-card-main { width: 100%; }

  .entity-name     { font-size: 0.93rem; margin-bottom: 0.25rem; }
  .entity-meta     { gap: 0.3rem; }
  .entity-momentum { margin-top: 0.35rem; gap: 0.3rem; }
  .momentum-stats  { white-space: normal; font-size: 0.71rem; line-height: 1.4; }

  /* Stats footer — horizontal strip at bottom of card */
  .entity-card-stats {
    flex-direction: row;
    align-items: baseline;
    flex-wrap: wrap;
    flex-shrink: 1;
    column-gap: 0.875rem;
    row-gap: 0.1rem;
    width: 100%;
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
  }

  /* Each stat: label + value side-by-side */
  .stat {
    flex-direction: row;
    align-items: baseline;
    gap: 0.2rem;
  }
  .stat-value                     { font-size: 0.76rem; font-weight: 600; }
  .stat:first-child .stat-value   { font-size: 0.84rem; color: var(--accent); }
  .stat .stat-label               { font-size: 0.63rem; letter-spacing: 0.04em; }

  /* Inspector — full-screen bottom sheet on mobile */
  #entity-detail-overlay { align-items: flex-end; }
  #entity-detail-panel {
    width: 100%;
    height: 92dvh;
    border-left: none;
    border-radius: 12px 12px 0 0;
    animation: sheet-up 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .detail-stats-grid { grid-template-columns: 1fr 1fr; }
  .detail-stats-grid .detail-stat:last-child { grid-column: span 2; }
}

html, body { overflow-x: hidden; }

/* ── Geo filter: detail panel annotations ──────────────────────────────────── */
.stat-filter-note {
  font-size: 0.7em;
  font-weight: 400;
  color: var(--muted);
}
.detail-section-geo {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--accent);
}

/* ── Geo debug overlay (card-level, ?debugGeo=1) ───────────────────────────── */
.geo-debug-overlay {
  margin: 0.5rem -0.5rem -0.5rem;
  padding: 0.5rem 0.625rem;
  border-top: 1px solid var(--border);
  font-size: 0.68rem;
  color: var(--muted);
  background: rgba(0,0,0,0.25);
  border-radius: 0 0 6px 6px;
  pointer-events: none;
}
.geo-debug-full    { border-top-color: var(--green);  }
.geo-debug-partial { border-top-color: var(--amber);  }
.geo-debug-nomatch { border-top-color: var(--red);    }

.geo-debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}
.geo-debug-id { font-size: 0.63rem; color: var(--faint); font-family: monospace; }

.geo-debug-match-type {
  font-size: 0.63rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}
.geo-debug-full    .geo-debug-match-type { background: var(--green-dim);  color: var(--green);  }
.geo-debug-partial .geo-debug-match-type { background: var(--amber-dim);  color: var(--amber);  }
.geo-debug-nomatch .geo-debug-match-type { background: rgba(239,68,68,.12); color: var(--red); }

.geo-debug-tags {
  display: flex; flex-wrap: wrap; gap: 0.2rem;
  margin-bottom: 0.25rem;
}
.geo-debug-tag {
  font-size: 0.6rem;
  padding: 0.05rem 0.3rem;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
}

.geo-debug-reason {
  font-size: 0.63rem;
  color: var(--muted);
  margin: 0.1rem 0;
}
.geo-debug-reason code {
  font-family: monospace;
  color: var(--faint);
  font-size: 0.6rem;
}

.geo-debug-stats {
  margin-top: 0.3rem;
  font-size: 0.6rem;
  color: var(--faint);
}

/* ── Geo debug diagnostics panel (?debugGeo=1, filter active) ─────────────── */
.geo-debug-panel {
  grid-column: 1 / -1;
  padding: 0.625rem 1rem;
  margin-bottom: 0.5rem;
  background: rgba(26,107,250,0.06);
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  font-size: 0.72rem;
  color: var(--muted);
}
.geo-debug-panel-title {
  margin-bottom: 0.4rem;
  font-size: 0.7rem;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.03em;
}
.geo-debug-strict {
  font-weight: 400;
  color: var(--amber);
}
.geo-debug-panel-stats {
  display: flex; flex-wrap: wrap; gap: 1rem;
}
.geo-debug-panel-stats span { color: var(--muted); }
.geo-debug-panel-stats strong { color: var(--text); }
.geo-debug-warn strong { color: var(--red) !important; }
