/* ── Stat cards ── */
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 14px 18px;
}
.stat-card[title] { cursor: help; }
.stat-card--link { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.stat-card--link:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.stat-card--link:hover .lbl { color: var(--accent); }
.ov-stats-hint { font-size: var(--fs-xs); color: var(--text-faint); font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: 4px; }
.stat-card .val { font-size: var(--fs-stat); font-weight: var(--fw-bold); color: var(--accent); font-family: monospace; line-height: 1; }
.stat-card .lbl { font-size: var(--fs-sm); color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }

/* ── Tables ── */
.tbl-wrap { overflow: auto; flex: 1; }
.tbl-toolbar { padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex-shrink: 0; }
.tbl-count { font-size: var(--fs-sm); color: var(--text-muted); margin-left: auto; font-family: monospace; }
.search-input {
  background: var(--surface3); border: 1px solid var(--border); color: var(--text-primary);
  font-family: var(--font); font-size: var(--fs-base); padding: 4px 12px;
  border-radius: 50px; outline: none; width: 200px; transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--dim); }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-base); }
thead th {
  position: sticky; top: 0; background: var(--surface2);
  border-bottom: 2px solid var(--border); padding: 8px 12px;
  font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .5px;
  color: var(--accent); font-weight: var(--fw-bold); white-space: nowrap; z-index: 10;
}
tbody td { padding: 7px 12px; border-bottom: 1px solid rgba(65,67,69,0.35); vertical-align: middle; }
tbody tr:hover td { background: rgba(104,204,209,0.04); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text-primary); }

/* ── Badges ── */
.badge-wd { background: #0a2a18; color: var(--accent); border: 1px solid rgba(0,255,65,0.3); font-size: var(--fs-xs); padding: 1px 6px; border-radius: 50px; font-family: monospace; white-space: nowrap; }
.badge-miss { background: #2a0a0a; color: #ff4444; border: 1px solid rgba(255,68,68,0.3); font-size: var(--fs-xs); padding: 1px 6px; border-radius: 50px; }

/* Company sector badges */
.badge-sector { font-size: var(--fs-xs); padding: 1px 7px; border-radius: 50px; font-weight: var(--fw-semi); }
.badge-Defence { background: #1a1a3a; color: var(--c-defence); }
.badge-Mining  { background: #2a1800; color: var(--c-mining);  }
.badge-Tech    { background: #001a2a; color: var(--c-tech);    }
.badge-Startup { background: #0a2a0a; color: var(--c-startup); }
.badge-Comm    { background: #1a0a2a; color: #b87aff; }

/* Investor / entity type badges */
.badge-type { font-size: var(--fs-xs); padding: 1px 7px; border-radius: 50px; font-weight: var(--fw-semi); white-space: nowrap; }
.badge-type--fund               { background: rgba(0,255,65,0.1);   color: var(--c-fund); border: 1px solid rgba(0,255,65,0.25); }
.badge-type--government_agency  { background: rgba(255,184,0,0.1);  color: var(--c-govt); border: 1px solid rgba(255,184,0,0.25); }
.badge-type--bank               { background: rgba(204,136,255,0.1);color: var(--c-bank); border: 1px solid rgba(204,136,255,0.25); }
.badge-type--institution        { background: rgba(0,204,238,0.1);  color: var(--c-inst); border: 1px solid rgba(0,204,238,0.25); }
.badge-type--company            { background: rgba(255,255,255,0.05); color: var(--grey-light); border: 1px solid rgba(255,255,255,0.12); }

/* Dual-role badge (manufacturer that also invests) */
.badge-dual { background: rgba(255,136,68,0.1); color: var(--c-dual); border: 1px solid rgba(255,136,68,0.3); font-size: var(--fs-xs); padding: 1px 6px; border-radius: 50px; font-weight: var(--fw-semi); white-space: nowrap; }

/* Type dot (inline color indicator) */
.type-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
/* Investor types → squares */
.type-dot--fund              { background: var(--c-fund); border-radius: 0; }
.type-dot--government_agency { background: var(--c-govt); border-radius: 0; }
.type-dot--bank              { background: var(--c-bank); border-radius: 0; }
.type-dot--institution       { background: var(--c-inst); border-radius: 0; }
/* Company sectors → circles */
.type-dot--Defence           { background: var(--c-defence); }
.type-dot--Mining            { background: var(--c-mining);  }
.type-dot--Tech              { background: var(--c-tech);    }
.type-dot--Startup           { background: var(--c-startup); }

.badge-lead   { background: rgba(0,255,65,0.12); color: var(--accent); border: 1px solid rgba(0,255,65,0.25); font-size: var(--fs-xs); padding: 1px 6px; border-radius: 50px; font-weight: var(--fw-bold); }
.badge-follow { background: rgba(255,255,255,0.05); color: var(--text-muted); font-size: var(--fs-xs); padding: 1px 6px; border-radius: 50px; }
.badge-val-review { color: #ffaa44; font-size: var(--fs-sm); }
.badge-val-flag   { color: #ff4444; font-size: var(--fs-sm); }

/* ── Legend bottom bar ── */
#legend {
  position: fixed; bottom: 0; right: 0; z-index: 450;
  background: var(--surface); border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  display: flex; align-items: center;
  height: var(--legend-h);
  padding: 0 14px;
  font-family: var(--font); font-size: var(--fs-base);
  width: fit-content;
}
#legend-body {
  display: flex; align-items: center; gap: 0;
}
.lg-label {
  font-size: var(--fs-sm); color: var(--text-primary); text-transform: uppercase;
  letter-spacing: .8px; font-weight: var(--fw-bold); margin-right: 0; white-space: nowrap;
}
.lg-group-label {
  font-size: var(--fs-sm); color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: .8px; font-weight: var(--fw-bold); margin-right: 8px; white-space: nowrap;
}
.lg-item {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--text-secondary); white-space: nowrap; margin-right: 14px; font-size: var(--fs-sm); text-transform: uppercase;
}
.lg-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.lg-square { border-radius: 0; }
.lg-star { font-size: var(--fs-base); line-height: 1; flex-shrink: 0; }
.lg-sep { width: 1px; height: 16px; background: var(--border); margin: 0 14px; flex-shrink: 0; }

/* ── Sector filter buttons ── */
.sf-btn {
  padding: 3px 12px; font-size: var(--fs-sm); font-family: var(--font); font-weight: var(--fw-bold);
  letter-spacing: .3px; border: 1px solid var(--border); border-radius: 50px;
  background: transparent; color: var(--dim); cursor: pointer; transition: all .12s;
}
.sf-btn:hover { border-color: var(--grey-mid); color: var(--text-primary); }
.sf-btn.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* ── Tooltip ── */
#tip {
  position: fixed; background: var(--tooltip-bg); border: 1px solid var(--border);
  padding: 10px 14px; font-size: var(--fs-body); pointer-events: none;
  display: none; z-index: 600; border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,.25); max-width: 280px; line-height: var(--lh-body);
}
#tip .tn { color: var(--accent); font-weight: var(--fw-bold); margin-bottom: 2px; }
#tip .ti { color: var(--dim); }
#tip .th { color: var(--text-tertiary); font-size: var(--fs-sm); margin-top: 2px; }

/* ── Sidebar — common font scale (single control point) ── */
.sidebar { font-size: var(--scale-sidebar); }

/* ── Shared panel primitives (slide-in + inline panels) ── */
.sl-title {
  font-size: var(--sl-title-fs); font-weight: var(--fw-bold);
  text-transform: uppercase; letter-spacing: .3px; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.sl-close {
  background: none; border: none; color: var(--dim); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 0; flex-shrink: 0;
}
.sl-close:hover { color: var(--text-primary); }
.sl-section-lbl {
  font-size: var(--sl-section-lbl-fs); font-weight: var(--fw-bold);
  text-transform: uppercase; letter-spacing: .8px; color: var(--accent);
  margin: 12px 0 6px;
}
.sl-row {
  display: flex; gap: 8px; align-items: baseline; padding: .3rem 0;
  border-bottom: 1px solid rgba(65,67,69,0.3);
}
.sl-row:last-child { border-bottom: none; }
.sl-row-lbl {
  font-size: var(--sl-row-lbl-fs); font-weight: var(--fw-bold);
  text-transform: uppercase; letter-spacing: .4px; color: var(--dim);
  min-width: 90px; white-space: nowrap; flex-shrink: 0;
}
.sl-row-val { font-size: var(--sl-row-val-fs); color: var(--text-primary); word-break: break-word; }

/* ── Matrix detail panel ── */
#mx-detail { width: var(--sl-w-inline); flex-shrink: 0; background: var(--sl-inline-bg); border-right: 1px solid var(--border); overflow-y: hidden; display: none; flex-direction: column; }
#mx-detail.open { display: flex; }
#mx-detail-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: var(--sl-header-pad); background: var(--sl-header-bg);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#mx-detail-body { flex: 1; overflow-y: auto; padding: var(--sl-body-pad); }

/* ── Detail panel body content (matrix + graph shared) ── */
.gv-context   { margin: 10px 0 4px; font-size: var(--sl-desc-fs); color: var(--text-secondary); line-height: var(--lh-body); border-left: 2px solid var(--border); padding-left: 8px; }
.dp-inv-meta  { margin-top: 10px; font-size: var(--sl-row-val-fs); color: var(--text-muted); }
.dp-co-meta   { margin-top: 8px; font-size: var(--sl-row-lbl-fs); color: var(--text-muted); }
.dp-funding   { font-size: var(--sl-row-lbl-fs); color: var(--text-muted); margin-top: 2px; }
.dp-funding span { color: var(--text-tertiary); }
.dp-desc      { font-size: var(--sl-desc-fs); color: var(--text-secondary); margin-top: 8px; line-height: var(--lh-body); border-left: 2px solid var(--border); padding-left: 8px; }
.dp-links     { margin-top: 8px; display: flex; gap: 10px; }
.dp-link      { color: var(--dim); font-size: var(--sl-row-lbl-fs); }
.dp-co-count  { font-size: var(--fs-xs); color: var(--text-faint); }
.es-list li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gv-entity-link {
  background: none; border: none; padding: 0;
  color: var(--text-secondary); font-size: inherit; font-family: inherit;
  cursor: pointer; text-align: left;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gv-entity-link:hover { color: var(--accent); text-decoration: underline; }

/* ── Entity detail sidebar ── */
.entity-sidebar {
  position: fixed;
  top: calc(var(--nav-h) + var(--tab-h) + var(--subtab-h));
  left: 0; right: 0; bottom: 0;
  z-index: var(--sl-z); pointer-events: none;
}
.entity-sidebar.open { pointer-events: all; }
.entity-sidebar-overlay {
  position: absolute; inset: 0; background: var(--sl-overlay-bg); opacity: 0;
  transition: var(--sl-overlay-t);
}
.entity-sidebar.open .entity-sidebar-overlay { opacity: 1; }
.entity-sidebar-panel {
  position: absolute; top: 0; left: 0; bottom: 0; width: var(--sl-w-inline); max-width: 95vw;
  background: var(--sl-panel-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transform: translateX(-100%); transition: var(--sl-panel-t); overflow: hidden;
}
.entity-sidebar.open .entity-sidebar-panel { transform: translateX(0); }
.entity-sidebar-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: var(--sl-header-pad); background: var(--sl-header-bg); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.entity-sidebar-body { padding: var(--sl-body-pad); overflow-y: auto; flex: 1; }

/* Content blocks */
.es-header-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 1rem; flex-wrap: wrap; }
.es-id { font-family: monospace; font-size: .65em; color: var(--text-faint); }
.es-block { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid rgba(65,67,69,0.3); }
.es-block:last-child { border-bottom: none; }
.es-row { display: flex; gap: 8px; align-items: baseline; padding: .3rem 0; }
.es-lbl { font-size: var(--sl-row-lbl-fs); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: .4px; color: var(--dim); min-width: 90px; white-space: nowrap; }
.es-val { font-size: var(--sl-row-val-fs); color: var(--text-primary); word-break: break-word; }
.es-lbl-solo { font-size: var(--sl-row-lbl-fs); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: .4px; color: var(--dim); margin-bottom: 6px; }
.es-desc { font-size: var(--sl-desc-fs); color: var(--text-secondary); line-height: var(--lh-body); }
.es-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.es-tag { font-size: var(--sl-row-lbl-fs); background: rgba(255,255,255,0.05); border: 1px solid var(--border); border-radius: 50px; padding: 2px 9px; color: var(--dim); }
.es-list { list-style: none; padding: 0; margin: 0; }
.es-nav-btn {
  display: inline-block; margin: 3px 4px 3px 0;
  padding: 3px 12px; font-size: var(--fs-sm); font-family: var(--font);
  background: transparent; border: 1px solid var(--border); border-radius: 50px;
  color: var(--dim); cursor: pointer; transition: all .1s; white-space: nowrap;
}
.es-nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.es-list li { padding: 5px 0; border-bottom: 1px solid rgba(65,67,69,0.3); font-size: var(--sl-row-val-fs); color: var(--text-secondary); display: flex; align-items: center; justify-content: flex-start; gap: 6px; flex-wrap: wrap; }
.es-list li .badge-lead { margin-left: auto; }
.es-list li:last-child { border-bottom: none; }

/* ── Shared panel section wrapper ── */
.sl-panel-section { margin-bottom: 16px; }

/* ── Wikidata block in entity sidebar ── */
.es-wd-block {
  background: rgba(104,204,209,0.04);
  border: 1px solid rgba(104,204,209,0.15);
  border-radius: 6px;
  padding: .75rem .9rem !important;
  margin-bottom: 1rem !important;
}
.es-wd-block:last-child { border-bottom: none; }
.es-wd-header {
  font-size: .65em; font-weight: var(--fw-bold); text-transform: uppercase;
  letter-spacing: .6px; color: rgba(104,204,209,0.7);
  margin-bottom: .55rem; display: flex; align-items: center; gap: 6px;
}
.es-wd-header::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  background: rgba(104,204,209,0.6); border-radius: 50%; flex-shrink: 0;
}
.es-wd-desc { margin-bottom: .5rem; }
.es-na { font-size: .8em; color: var(--text-muted); font-style: italic; }
.es-wd-updated { font-size: .65em; color: var(--text-faint); margin-top: .55rem; font-family: monospace; }

/* ── Crunchbase block in entity sidebar ── */
:root { --cb-accent: #f4a147; }
.es-cb-block {
  background: rgba(244,161,71,0.04);
  border: 1px solid rgba(244,161,71,0.18);
  border-radius: 6px;
  padding: .75rem .9rem !important;
  margin-bottom: 1rem !important;
}
.es-cb-block:last-child { border-bottom: none; }
.es-cb-header {
  font-size: .65em; font-weight: var(--fw-bold); text-transform: uppercase;
  letter-spacing: .6px; color: rgba(244,161,71,0.75);
  margin-bottom: .55rem; display: flex; align-items: center; gap: 6px;
}
.es-cb-header::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  background: rgba(244,161,71,0.65); border-radius: 50%; flex-shrink: 0;
}
.es-cb-desc { margin-bottom: .5rem; }
.es-cb-updated { font-size: .65em; color: var(--text-faint); margin-top: .55rem; font-family: monospace; }

/* Clickable table rows / cells */
#co-tbody tr, #inv-tbody tr, #rel-tbody tr { cursor: pointer; }
.es-click-cell { cursor: pointer; }
.es-click-cell:hover { color: var(--accent) !important; text-decoration: underline; }

/* ── Search highlight ── */
tr.sel-row td { background: rgba(104,204,209,0.13) !important; }
td.sel-col { background: rgba(104,204,209,0.05) !important; }
th.sel-col .col-inner { color: var(--text-primary) !important; }

/* ── Toolbar extras ── */
.sf-label    { font-size: var(--fs-sm); color: var(--grey-dark); text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
.wd-cov-row  { font-size: var(--fs-sm); display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.tbl-wrap--lg { max-height: 340px; overflow-y: auto; margin-top: 8px; }
#wd-cov-pct  { color: var(--accent); font-family: var(--font); }
#q-missing   { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#mx-toolbar  { gap: 8px; }

/* ── Glossary tooltips ── */
.gl-term {
  cursor: help;
  border-bottom: 3px dashed rgba(0,255,65,0.4);
  position: relative;
  display: inline;
}
.gl-term::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-family: var(--font);
  font-weight: var(--fw-normal);
  line-height: var(--lh-snug);
  padding: 6px 10px;
  border-radius: 4px;
  width: max-content;
  max-width: 240px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
  white-space: normal;
  text-transform: none;
  letter-spacing: 0;
}
.gl-term:hover::after { opacity: 1; }

/* ── Glossary tab entries ── */
.gl-entry {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.gl-entry-term {
  font-family: var(--font);
  font-size: var(--fs-sm);
  color: var(--accent);
}
.gl-entry-def {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: var(--lh-body);
}

/* ── Data files tab ── */
.a-data-file {
  margin-top: 20px;
}
.a-data-link {
  font-family: var(--font);
  font-size: var(--fs-sm);
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(0,255,65,0.3);
  padding-bottom: 1px;
}
.a-data-link:hover { border-bottom-color: var(--accent); color: var(--accent); }
.a-data-desc {
  margin-top: 6px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: var(--lh-body);
}
.a-data-meta {
  margin: 8px 0 0 0; padding-left: 18px;
  list-style: disc; color: var(--text-secondary); font-size: var(--fs-sm);
  line-height: var(--lh-body);
}
.a-data-meta li { margin-bottom: 4px; }
.a-data-meta li strong { color: var(--text-primary); }
.a-ext-link { color: var(--accent); text-decoration: none; }
.a-ext-link:hover { text-decoration: underline; }

/* ── Light theme overrides ── */
[data-theme="light"] .badge-wd      { background: #d8f0e4; }
[data-theme="light"] .badge-miss    { background: #fde8e8; color: var(--error); border-color: rgba(204,34,0,0.3); }
[data-theme="light"] .badge-Defence { background: #ddf0e8; }
[data-theme="light"] .badge-Mining  { background: #f0edd8; }
[data-theme="light"] .badge-Tech    { background: #d8ece0; }
[data-theme="light"] .badge-Startup { background: #d8eee0; }
[data-theme="light"] .badge-Comm    { background: #ede8f8; color: #6600aa; }
[data-theme="light"] .badge-type--fund              { background: rgba(204,34,0,0.07);   }
[data-theme="light"] .badge-type--government_agency { background: rgba(153,0,0,0.07);    }
[data-theme="light"] .badge-type--bank              { background: rgba(119,0,0,0.07);    }
[data-theme="light"] .badge-type--institution       { background: rgba(170,34,85,0.07);  }
[data-theme="light"] .badge-type--company           { background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.12); }
[data-theme="light"] .badge-dual  { background: rgba(122,88,0,0.08); border-color: rgba(122,88,0,0.3); }
[data-theme="light"] .badge-lead  { background: rgba(0,102,34,0.09); border-color: rgba(0,102,34,0.25); }
[data-theme="light"] .badge-follow { background: rgba(0,0,0,0.05); }
[data-theme="light"] .badge-val-review { color: var(--warn); }
[data-theme="light"] .badge-val-flag   { color: var(--error); }
[data-theme="light"] .es-tag { background: rgba(0,0,0,0.05); }
[data-theme="light"] .es-wd-block    { background: rgba(0,80,40,0.04); border-color: rgba(0,80,40,0.15); }
[data-theme="light"] .es-wd-header   { color: rgba(0,80,40,0.75); }
[data-theme="light"] .es-wd-header::before { background: rgba(0,80,40,0.65); }
[data-theme="light"] .gl-term { border-bottom-color: rgba(0,102,34,0.4); }
[data-theme="light"] .a-data-link { border-bottom-color: rgba(0,102,34,0.3); }
