/* ABOUTME: Shared CSS for the internal tools app — CRM and viz pages.
   ABOUTME: Extends Pico CSS with app-specific components: toolbars, badges, cards, viz layouts. */

:root {
  --pico-font-size: 14px;

  --gtm-bg: #ffffff;
  --gtm-surface: #f8f9fa;
  --gtm-border: #dee2e6;
  --gtm-text: #212529;
  --gtm-text-muted: #6c757d;
  --gtm-text-mono: #495057;

  --gtm-success: #198754;
  --gtm-warning: #e65100;
  --gtm-danger: #dc3545;
  --gtm-info: #0d6efd;

  --gtm-overlay-a: rgba(0, 140, 255, 0.5);
  --gtm-overlay-b: rgba(220, 53, 69, 0.5);

  /* Lo-Fi Industrial palette — used by Project Index hub and primary CTAs.
     Safety orange is reserved strictly for primary actions (assign facet,
     new project) so it stays meaningful. */
  --ind-paper: #f5f3ee;
  --ind-paper-alt: #ecebe5;
  --ind-ink: #1a1a1a;
  --ind-ink-soft: #404040;
  --ind-rule: #1a1a1a;
  --ind-orange: #ff6a00;
  --ind-orange-hover: #e55f00;
  --ind-yellow: #f6c945;
  --ind-green: #2e7d32;
  --ind-red: #c0392b;
  --ind-gray: #b8b5ac;
}

/* ── Lo-Fi shared primitives ────────────────────────────
   Square borders, no radius, ink-on-paper. Reused across
   all pages — Project Index/Detail keep their own inline
   copies for now; CRM pages rely on these. */
.btn-primary {
  background: var(--ind-orange); color: #fff;
  border: 2px solid var(--ind-ink); border-radius: 0;
  padding: 6px 14px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  cursor: pointer; box-shadow: 3px 3px 0 var(--ind-ink);
  transition: transform .05s ease, box-shadow .05s ease;
  margin: 0;
}
.btn-primary:hover { background: var(--ind-orange-hover); }
.btn-primary:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ind-ink); }
.btn-primary[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary.btn-sm { padding: 4px 10px; font-size: 11px; box-shadow: 2px 2px 0 var(--ind-ink); }
.btn-primary.btn-sm:active { box-shadow: 1px 1px 0 var(--ind-ink); }

.btn-outline {
  background: #fff; color: var(--ind-ink);
  border: 2px solid var(--ind-ink); border-radius: 0;
  padding: 6px 14px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  cursor: pointer; margin: 0; width: auto;
}
.btn-primary { width: auto; }
.btn-outline:hover { background: var(--ind-ink); color: #fff; }
.btn-outline.btn-sm { padding: 4px 10px; font-size: 11px; }

.lf-link {
  background: none; border: none; padding: 0;
  color: var(--ind-ink-soft); text-decoration: underline;
  cursor: pointer; font-size: 12px;
}
.lf-link:hover { color: var(--ind-ink); }

/* Lo-Fi data table — sticky uppercase header, ink underlines, hover tint. */
.lf-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  background: #fff; border: 2px solid var(--ind-ink);
}
.lf-table th {
  text-align: left; padding: 6px 10px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ind-ink); font-weight: 800;
  border-bottom: 2px solid var(--ind-ink);
  background: var(--ind-paper-alt);
  position: sticky; top: 0;
}
.lf-table td {
  padding: 5px 10px; border-bottom: 1px solid #e8e8e8;
  vertical-align: middle;
}
.lf-table tbody tr:hover td { background: #fffaf2; }
.lf-table tbody tr.selected td { background: #fff3e0; }
.lf-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.lf-table .pct-cell { color: var(--ind-ink-soft); font-size: 12px; }
.lf-table-wrap {
  border: 2px solid var(--ind-ink); overflow: auto;
  /* Fills remaining vertical space when an ancestor is a flex column at
     100vh; otherwise falls back to a sensible viewport-relative cap. */
  flex: 1 1 0; min-height: 240px;
  max-height: calc(100vh - 280px);
}
.lf-table-wrap .lf-table { border: none; }

/* Lo-Fi toolbar / filter bar (search + selects + button). */
.lf-toolbar {
  display: flex; gap: 10px; align-items: end; flex-wrap: wrap;
  margin: 14px 0;
}
.lf-toolbar input[type="search"], .lf-toolbar input[type="text"] {
  flex: 1; min-width: 220px; padding: 7px 12px; font-size: 14px;
  border: 2px solid var(--ind-ink); border-radius: 0;
  background: #fff; margin: 0;
}
.lf-field { display: flex; flex-direction: column; gap: 2px; margin: 0; }
.lf-field span {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ind-ink-soft);
}
.lf-field select, .lf-field input {
  padding: 6px 8px; font-size: 13px; border: 2px solid var(--ind-ink);
  border-radius: 0; background: #fff; margin: 0;
}
/* Pico defaults form buttons to width:100%; force inline so .lf-toolbar
   can sit Filter/Clear next to the search + selects on one row. */
.lf-toolbar button, .lf-toolbar a[role="button"] { width: auto; flex-shrink: 0; }

/* Lo-Fi page header (h1 + subtitle + actions). */
.lf-page-header { margin-bottom: 12px; }
.lf-page-header-row { display: flex; align-items: center; gap: 12px; }
.lf-page-header h1 {
  font-size: 22px; margin: 0; font-weight: 800;
  letter-spacing: -0.01em; color: var(--ind-ink);
}
.lf-page-header .subtitle { font-size: 13px; color: var(--ind-ink-soft); }
.lf-page-header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Lo-Fi stat strip — replaces the rounded .stats-row look. */
.lf-stat-row {
  display: flex; gap: 0; flex-wrap: wrap;
  border: 2px solid var(--ind-ink); background: #fff;
  margin-bottom: 14px;
}
.lf-stat {
  flex: 1 1 0; min-width: 120px;
  padding: 10px 14px;
  border-right: 1px solid var(--ind-ink);
  text-align: left;
}
.lf-stat:last-child { border-right: none; }
.lf-stat .label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ind-ink-soft); font-weight: 700; margin-bottom: 2px;
}
.lf-stat .num { font-size: 22px; font-weight: 800; color: var(--ind-ink); }
.lf-stat .sub { font-size: 11px; color: var(--ind-ink-soft); margin-top: 2px; }

/* Lo-Fi square tag (replaces rounded .tag for new pages). */
.lf-tag {
  display: inline-block; padding: 1px 6px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--ind-paper-alt); color: var(--ind-ink-soft);
  border: 1px solid var(--ind-gray);
  margin-right: 3px;
}

/* Page wrapper for CRM pages that should size to viewport (so an
   internal table-wrap can flex to fill). Pages opt in by overriding
   main_wrapper to render `<main class="lf-page">` instead of using
   Pico's <main class="container-fluid">. */
.lf-page {
  padding: 24px; background: var(--ind-paper);
  height: 100vh; box-sizing: border-box;
  display: flex; flex-direction: column; gap: 12px;
  overflow: hidden;
}
.lf-page > .lf-page-header,
.lf-page > .lf-tab-nav,
.lf-page > .lf-toolbar,
.lf-page > .lf-stat-row { flex-shrink: 0; margin: 0; }
.lf-page > .lf-tab-content {
  flex: 1 1 0; min-height: 0; padding: 0;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--ind-paper);
}
.lf-page > .lf-tab-content > * { flex-shrink: 0; }
.lf-page > .lf-tab-content > .lf-table-wrap,
.lf-page > .lf-tab-content > .kanban-board { flex: 1 1 0; min-height: 0; }

/* Tab nav (Table | Kanban toggle on /leads). Same pattern as project detail. */
.lf-tab-nav {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--ind-ink);
  margin: 16px 0 0;
}
.lf-tab-link {
  padding: 8px 16px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ind-ink-soft); text-decoration: none;
  border: 2px solid transparent; border-bottom: none;
  margin-bottom: -2px; background: transparent;
}
.lf-tab-link:hover { color: var(--ind-ink); }
.lf-tab-link.active {
  color: var(--ind-ink); background: var(--ind-paper);
  border-color: var(--ind-ink); border-bottom-color: var(--ind-paper);
}
.lf-tab-content {
  background: var(--ind-paper); padding: 16px 0; min-height: 200px;
}

/* ── App shell (sidebar layout) ─────────────────────── */
.app-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}
.app-main {
  flex: 1 1 auto;
  min-width: 0;          /* allow children to shrink (prevents overflow on tables/canvases) */
}

/* ── Sidebar (Lo-Fi: paper-alt bg, 2px ink right border) ──── */
.sidebar {
  flex: 0 0 220px;
  width: 220px;
  background: var(--ind-paper-alt);
  border-right: 2px solid var(--ind-ink);
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 0 1rem 0.75rem;
  border-bottom: 2px solid var(--ind-ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ind-ink);
}
.sidebar-brand strong { font-weight: 800; }
.sidebar-nav { flex: 1 1 auto; padding: 0.5rem 0; }
.sidebar-group { margin-bottom: 1rem; }
.sidebar-group-label {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ind-ink-soft);
}
.sidebar-group ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar-group li { margin: 0; }
.sidebar-group a {
  display: block;
  padding: 0.45rem 1rem;
  font-size: 13px;
  color: var(--ind-ink);
  text-decoration: none;
  border-left: 3px solid transparent;
}
.sidebar-group a:hover { background: rgba(26, 26, 26, 0.06); }
.sidebar-group a[aria-current="page"] {
  font-weight: 800;
  background: var(--ind-ink);
  color: var(--ind-paper);
  border-left-color: var(--ind-orange);
}
.sidebar-footer {
  border-top: 2px solid var(--ind-ink);
  padding: 0.75rem 1rem;
}
/* Lo-Fi outline button for the Refresh action. */
.sidebar-refresh {
  width: 100%;
  margin: 0;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fff;
  color: var(--ind-ink);
  border: 2px solid var(--ind-ink);
  border-radius: 0;
  cursor: pointer;
}
.sidebar-refresh:hover { background: var(--ind-ink); color: var(--ind-paper); }

/* Narrow viewports: collapse sidebar to a top bar so canvas tools (DI, Stitch)
   keep their full width. */
@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 2px solid var(--ind-ink);
    padding: 0.5rem 0;
  }
  .sidebar-nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; padding: 0.25rem 1rem; }
  .sidebar-group { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0; }
  .sidebar-group-label { padding: 0; }
  .sidebar-group ul { display: flex; gap: 0.5rem; }
  .sidebar-group a { padding: 0.2rem 0.4rem; border-left: none; border-bottom: 2px solid transparent; }
  .sidebar-group a[aria-current="page"] { border-left: none; border-bottom-color: var(--ind-orange); }
  .sidebar-footer { display: none; }
}

/* ── Tables ─────────────────────────────────────────── */
table { font-size: 13px; }
th, td { padding: 0.4rem 0.6rem; white-space: nowrap; }
td.wrap { white-space: normal; max-width: 300px; }

/* ── Badges (Lo-Fi square, color-mixed tints from --ind-* tokens) ──
   Used on lead status, eval results, etc. Square corners + 1px border. */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 0;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  border: 1px solid currentColor;
}
.badge-success, .badge-active {
  color: var(--ind-green);
  background: color-mix(in srgb, var(--ind-green) 12%, white);
}
.badge-info, .badge-prospect {
  color: var(--ind-ink);
  background: color-mix(in srgb, var(--ind-yellow) 30%, white);
  border-color: var(--ind-ink-soft);
}
.badge-warning, .badge-converted {
  color: var(--ind-orange);
  background: color-mix(in srgb, var(--ind-orange) 12%, white);
}
.badge-danger, .badge-lost {
  color: var(--ind-red);
  background: color-mix(in srgb, var(--ind-red) 12%, white);
}
.badge-churned, .badge-muted {
  color: var(--ind-ink-soft);
  background: var(--ind-paper-alt);
  border-color: var(--ind-gray);
}

/* ── Tags ───────────────────────────────────────────── */
.tag {
  display: inline-block; padding: 1px 6px; border-radius: 0;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--ind-paper-alt); color: var(--ind-ink-soft);
  border: 1px solid var(--ind-gray);
  margin-right: 3px;
}

/* ── Stats (legacy class — kept for now; new pages use .lf-stat-row) ── */
.stat { text-align: center; }
.stat .num { font-size: 2rem; font-weight: 700; }
.stat .label { font-size: 0.8rem; color: var(--ind-ink-soft); }
.stats-row { display: flex; gap: 2rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.pct { color: var(--ind-ink-soft); font-size: 11px; }

/* ── Filters (legacy — new pages use .lf-toolbar) ───── */
.filters { display: flex; gap: 0.5rem; align-items: end; margin-bottom: 1rem; flex-wrap: wrap; }
.filters input, .filters select { margin-bottom: 0; }

/* ── Icon button (square outlined, ink-on-paper) ────── */
.btn-sm { padding: 0.2rem 0.6rem; font-size: 12px; }
.icon-btn {
  background: transparent; border: 2px solid var(--ind-ink);
  border-radius: 0; color: var(--ind-ink);
  font-size: 14px; line-height: 1;
  padding: 3px 7px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  margin: 0 2px;
}
.icon-btn:hover { background: var(--ind-ink); color: var(--ind-paper); }

/* ── Email list ─────────────────────────────────────── */
.email-row { display: flex; align-items: center; gap: 0.3rem; margin-bottom: 0.3rem; }
.email-row input { margin-bottom: 0; flex: 1; }
.email-row .icon-btn { font-size: 16px; }

/* ── Multi-check groups ─────────────────────────────── */
.multi-check { display: flex; gap: 1rem; flex-wrap: wrap; padding: 0.3rem 0; }
.multi-check label { display: flex; align-items: center; gap: 0.3rem; font-size: 13px; margin-bottom: 0; cursor: pointer; }
.multi-check input[type="checkbox"] { margin: 0; }

/* ── Dialogs (Lo-Fi: square, 2px ink border, no Pico radius) ──── */
dialog {
  border-radius: 0; max-width: 640px; width: 90vw;
  border: 2px solid var(--ind-ink);
  background: var(--ind-paper);
  box-shadow: 6px 6px 0 var(--ind-ink);
  padding: 0;
}
dialog::backdrop { background: rgba(0,0,0,0.4); }
dialog article {
  background: var(--ind-paper); border-radius: 0;
  box-shadow: none; border: none; padding: 16px 20px;
}
dialog header {
  margin: -16px -20px 12px; padding: 10px 20px;
  border-bottom: 2px solid var(--ind-ink);
  background: var(--ind-paper-alt);
  display: flex; align-items: center; justify-content: space-between;
}
dialog header h3 {
  font-size: 14px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.06em; margin: 0; color: var(--ind-ink);
}
dialog footer {
  margin: 14px -20px -16px; padding: 10px 20px;
  border-top: 2px solid var(--ind-ink);
  background: var(--ind-paper-alt);
  display: flex; gap: 8px; justify-content: flex-end;
}
dialog .grid { gap: 0.5rem; }
dialog label { font-size: 12px; }
/* Pico's <dialog> close button: re-position so it doesn't get clipped by our new header. */
dialog header button[rel="prev"] { margin: 0; }

/* ── View-lead modal ────────────────────────────────── */
#view-lead .grid { margin-bottom: 0.8rem; }
#view-lead small.pct { display: block; margin-bottom: 0.15rem; }

/* ── Call log ───────────────────────────────────────── */
.call-body { font-size: 13px; line-height: 1.5; }
.call-body h2 { font-size: 1.1rem; margin: 0.8rem 0 0.3rem; }
.call-body h3 { font-size: 1rem; margin: 0.6rem 0 0.2rem; }
.call-body ul, .call-body ol { margin: 0.3rem 0; padding-left: 1.2rem; }
.call-body li { margin-bottom: 0.15rem; }
.call-body p { margin-bottom: 0.4rem; }

/* ── Kanban (Lo-Fi: square, ink borders, paper-alt headers) ──── */
.kanban-board {
  display: flex; gap: 14px; overflow-x: auto; padding-bottom: 1rem;
  align-items: flex-start;
  /* Falls back to a tall block if not nested inside a flex parent
     (.lf-page > .lf-tab-content makes it flex: 1 1 0 instead). */
  height: calc(100vh - 220px);
}
.lf-page .kanban-board { height: auto; }
.kanban-col {
  min-width: 280px; max-width: 320px;
  background: #fff;
  border: 2px solid var(--ind-ink); border-radius: 0;
  flex-shrink: 0; max-height: 100%; overflow-y: auto;
}
.kanban-col-header {
  padding: 8px 12px; border-bottom: 2px solid var(--ind-ink);
  background: var(--ind-paper-alt);
  display: flex; justify-content: space-between; align-items: center;
}
.kanban-col-header strong {
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--ind-ink);
}
.kanban-col-header .pct {
  font-size: 11px; font-weight: 700;
  color: var(--ind-ink); background: #fff;
  border: 1px solid var(--ind-ink); padding: 0 6px;
}
.kanban-card {
  display: block; padding: 8px 12px;
  border-bottom: 1px solid #e8e8e8;
  text-decoration: none; color: var(--ind-ink);
}
.kanban-card:hover { background: #fffaf2; }
.kanban-card:last-child { border-bottom: none; }
.kanban-card-name { font-weight: 700; font-size: 13px; color: var(--ind-ink); }
.kanban-card-company { font-size: 12px; color: var(--ind-ink-soft); margin-top: 1px; }
.kanban-card-meta { margin-top: 5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kanban-lost {
  border-top: 2px solid var(--ind-ink);
  background: var(--ind-paper-alt);
}
.kanban-lost summary {
  padding: 8px 12px; cursor: pointer;
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ind-red); list-style: none;
}
.kanban-lost summary::after { content: ' \25b8'; font-size: 11px; }
.kanban-lost[open] summary::after { content: ' \25be'; }
.kanban-lost .kanban-card { opacity: 0.6; }
.preview-star { color: var(--ind-yellow); margin-left: 2px; }
.preview-star.future { color: var(--ind-orange); }

/* ── Document panels (campaign detail) — Lo-Fi square ──── */
.md-content { font-size: 14px; line-height: 1.6; }
.md-content table { font-size: 13px; }
.doc-panels { display: flex; gap: 12px; align-items: stretch; margin-bottom: 1.5rem; }
.doc-panel {
  flex: 1 1 0; min-width: 0; width: 0;
  border: 2px solid var(--ind-ink); border-radius: 0;
  background: #fff;
  max-height: 70vh; display: flex; flex-direction: column;
}
.doc-panel-header {
  padding: 8px 14px; border-bottom: 2px solid var(--ind-ink);
  font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ind-ink); background: var(--ind-paper-alt);
  flex-shrink: 0; display: flex; align-items: center; gap: 0.5rem;
}
.doc-panel-body { padding: 14px; overflow-y: auto; flex: 1 1 auto; }
.doc-panel-body .md-content { font-size: 13px; line-height: 1.5; }
.doc-panel-empty {
  padding: 2rem 1rem; text-align: center;
  color: var(--ind-ink-soft); font-size: 13px;
}
.md-content h1 { font-size: 1.4rem; }
.md-content h2 { font-size: 1.2rem; }
.md-content h3 { font-size: 1.05rem; }
.md-content h4 { font-size: 0.95rem; }
.md-content pre {
  font-size: 12px; background: var(--ind-paper-alt);
  padding: 1rem; border-radius: 0;
  border: 1px solid var(--ind-gray);
}
.md-content blockquote {
  border-left: 3px solid var(--ind-ink); padding-left: 1rem;
  color: var(--ind-ink-soft);
}

/* ── Viz: stitch index page ─────────────────────────── */
.stitch-index-header { margin-bottom: 1rem; }
.stitch-index-header h1 { margin-bottom: 0.25rem; }
.stitch-index-header .muted { font-size: 0.9rem; margin: 0; }
.stitch-index-footer { text-align: center; margin: 2rem 0 1rem; }
.stitch-project-card {
  border: 1px solid var(--gtm-border, #d8d8e0);
  border-radius: 8px;
  margin-bottom: 1.25rem;
  padding: 0;
  background: var(--gtm-card-bg, #fff);
  overflow: hidden;
}
.stitch-project-header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0.6rem 1rem; border-bottom: 1px solid var(--gtm-border, #d8d8e0);
  background: rgba(0,0,0,0.02);
}
.stitch-project-header h2 { margin: 0; font-size: 1.1rem; font-family: var(--gtm-mono, monospace); }
.stitch-sg-table { width: 100%; margin: 0; border-collapse: collapse; font-size: 0.9rem; }
.stitch-sg-table thead th {
  text-align: left; padding: 0.4rem 0.7rem; border-bottom: 1px solid var(--gtm-border, #d8d8e0);
  font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--gtm-muted, #666); background: rgba(0,0,0,0.01);
}
.stitch-sg-table tbody tr { border-bottom: 1px solid rgba(0,0,0,0.04); }
.stitch-sg-table tbody tr:last-child { border-bottom: none; }
.stitch-sg-table td { padding: 0.45rem 0.7rem; vertical-align: middle; }
.stitch-sg-table td.num, .stitch-sg-table th.num { text-align: center; white-space: nowrap; }
.stitch-sg-table td.actions a { font-size: 0.85rem; }
.stitch-sg-table td.actions .sep-dot { color: var(--gtm-muted, #aaa); margin: 0 0.2rem; }
.gt-incomplete { color: #b08a1a; font-weight: 600; }
.fp-flag { color: #c0392b; font-weight: 600; }
.score-cell { font-feature-settings: 'tnum'; padding: 0.4rem 0.5rem !important; }
.score-cell .small { display: block; font-size: 0.7rem; opacity: 0.8; }

/* ── Index table column groupings: project / edges / gt ─────── */
.stitch-sg-grouped colgroup.cg-edges  col { background: rgba(0, 180, 90, 0.04); }
.stitch-sg-grouped colgroup.cg-gt     col { background: rgba(0, 110, 220, 0.04); }
.stitch-sg-grouped colgroup.cg-edges + colgroup.cg-gt col:first-child,
.stitch-sg-grouped colgroup.cg-project + colgroup.cg-edges col:first-child {
  border-left: 2px solid var(--gtm-border, #d8d8e0);
}
.stitch-sg-grouped .header-groups th {
  text-align: center; padding: 0.35rem 0.5rem;
  background: rgba(0,0,0,0.04);
  border-bottom: 1px solid var(--gtm-border, #d8d8e0);
  font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--gtm-muted, #555);
}
.stitch-sg-grouped .group-label-project { background: rgba(0,0,0,0.025); }
.stitch-sg-grouped .group-label-edges   { background: rgba(0, 180, 90, 0.10); color: #0d5a26; border-left: 2px solid var(--gtm-border, #d8d8e0); }
.stitch-sg-grouped .group-label-gt      { background: rgba(0, 110, 220, 0.10); color: #143a72; border-left: 2px solid var(--gtm-border, #d8d8e0); }
.score-good { background: rgba(0, 200, 80, 0.12); color: #1f7a3a; }
.score-warn { background: rgba(230, 170, 30, 0.16); color: #8a6a10; }
.score-bad  { background: rgba(220, 60, 60, 0.14); color: #b3221c; }
.score-na   { color: var(--gtm-muted, #aaa); }
.variant-actions {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.82rem; margin-right: 0.5rem;
}
.variant-actions:not(:last-child)::after {
  content: '|'; color: var(--gtm-muted, #ccc); margin-left: 0.5rem;
}
.variant-actions .variant-name {
  font-family: var(--gtm-mono, monospace); font-weight: 600;
  color: var(--gtm-muted, #666); font-size: 0.78rem;
}

/* ── Viz: edges side-by-side compare ────────────────── */
.edges-canvas { position: absolute; left: 0; top: 0; }
.edges-canvas img { display: block; max-width: none; max-height: none; width: auto; height: auto; }
.edges-svg { position: absolute; left: 0; top: 0; pointer-events: none; }
.edges-svg .edges-handle { pointer-events: auto; }
.edges-legend {
  display: flex; gap: 1.5rem; padding: 0.5rem 1rem; font-size: 0.85rem;
  background: rgba(0,0,0,0.02); border-bottom: 1px solid var(--gtm-border, #ddd);
}
.edges-legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.edges-swatch { display: inline-block; width: 16px; height: 16px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.2); }
.swatch-bbox { background: white; border: 2px dashed #e11d48; }
.swatch-alg  { background: rgba(0,170,255,0.15); border: 2px solid #0099ff; }
.swatch-gt   { background: rgba(245,180,40,0.4); border: 2px solid #b07b00; }
.swatch-edit { background: rgba(0,180,90,0.3); border: 2px solid #147a3a; }

.variant-pill {
  display: inline-block; padding: 0.15rem 0.5rem; margin: 0 0.1rem;
  font-family: var(--gtm-mono, monospace); font-size: 0.85rem; font-weight: 600;
  background: rgba(0,0,0,0.05); border: 1px solid rgba(0,0,0,0.15);
  border-radius: 4px; cursor: pointer; color: var(--gtm-muted, #666);
  transition: background .1s, color .1s;
}
.variant-pill:hover { background: rgba(0,0,0,0.1); }
.variant-pill.active {
  background: var(--gtm-info, #0066cc);
  color: white;
  border-color: var(--gtm-info, #0066cc);
}

/* ── Viz: toolbar breadcrumb + variant dropdown ─────── */
.toolbar-back {
  font-size: 0.85rem; text-decoration: none; color: var(--gtm-link, #2266cc);
  padding: 0.2rem 0.4rem;
}
.toolbar-back:hover { text-decoration: underline; }
.breadcrumb-segment {
  font-family: var(--gtm-mono, monospace); font-size: 0.85rem;
  color: var(--gtm-text, #333);
}
.breadcrumb-sep { color: var(--gtm-muted, #aaa); margin: 0 0.2rem; }
.toolbar-variant {
  display: flex; align-items: center; gap: 0.3rem;
  font-size: 0.8rem; color: var(--gtm-muted, #555); margin: 0;
}
.toolbar-variant select {
  padding: 0.1rem 0.3rem; font-size: 0.85rem; height: auto;
  margin: 0; min-width: 60px;
}

/* ── Viz: full-viewport app container ───────────────── */
.viz-app {
  background: var(--gtm-bg); overflow: hidden;
  height: calc(100vh - 50px); display: flex; flex-direction: column;
}
.viz-scroll-app {
  background: var(--gtm-bg);
  min-height: calc(100vh - 50px);
}

/* ── Viz: toolbar ───────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px; background: var(--gtm-surface);
  border-bottom: 1px solid var(--gtm-border);
  flex-shrink: 0; font-size: 13px;
}
.toolbar a { color: var(--pico-primary); text-decoration: none; font-weight: 600; }
.toolbar a:hover { text-decoration: underline; }
.toolbar button {
  background: var(--gtm-bg); color: var(--gtm-text);
  border: 1px solid var(--gtm-border); padding: 3px 10px;
  border-radius: 4px; cursor: pointer; font-size: 12px; transition: background .15s;
}
.toolbar button:hover { background: var(--gtm-surface); }
.toolbar button.active { background: var(--pico-primary-background); color: #fff; border-color: var(--pico-primary-background); }
.toolbar select {
  background: var(--gtm-bg); color: var(--gtm-text);
  border: 1px solid var(--gtm-border); padding: 4px 8px;
  border-radius: 4px; font-size: 13px;
}
.toolbar .sep { width: 1px; height: 22px; background: var(--gtm-border); flex-shrink: 0; }
.toolbar .muted { color: var(--gtm-text-muted); }

/* ── Viz: secondary toolbar (info-bar) ──────────────── */
.toolbar-secondary {
  padding: 3px 14px; font-size: 12px; color: var(--gtm-text-muted);
}

/* ── Viz: data values ───────────────────────────────── */
.val { font-family: ui-monospace, monospace; font-size: 13px; color: var(--gtm-text-mono); }
.label-tag { color: var(--gtm-danger); font-weight: 600; }
.saved { color: var(--gtm-success); font-weight: 600; }
.unsaved { color: var(--gtm-danger); }
.modified { color: var(--gtm-warning); }

/* ── Viz: viewport ──────────────────────────────────── */
#viewport { flex: 1; overflow: hidden; background: #fff; position: relative; cursor: crosshair; }
#scene { position: absolute; transform-origin: 0 0; will-change: transform; }
/* Override Pico's `img { max-width: 100% }` so absolutely-positioned scene
   imgs use their natural dimensions (Pico's rule collapses them to 0 since
   #scene has no intrinsic width). */
#scene img { position: absolute; display: block; transform-origin: 0 0; max-width: none; max-height: none; width: auto; height: auto; }
.img-a { outline: 3px solid var(--gtm-overlay-a); outline-offset: -3px; }
.img-b { outline: 3px solid var(--gtm-overlay-b); outline-offset: -3px; cursor: grab; }
.img-b:active { cursor: grabbing; }

/* ── Viz: help bar ──────────────────────────────────── */
.help-bar {
  position: fixed; bottom: 4px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: rgba(0,0,0,0.35); pointer-events: none; z-index: 5; white-space: nowrap;
}

/* ── Viz: project cards ─────────────────────────────── */
.project-list {
  position: absolute; inset: 0; background: var(--gtm-bg);
  display: flex; flex-direction: column; align-items: center;
  overflow-y: auto; padding: 40px 0; z-index: 20;
}
.project-list h1 { font-size: 22px; margin-bottom: 20px; }

.pcard {
  background: var(--gtm-bg); border: 1px solid var(--gtm-border);
  border-radius: 6px; padding: 14px 22px; margin: 5px; cursor: pointer;
  width: 420px; display: flex; flex-direction: column; align-items: stretch;
  gap: 6px; transition: background .15s;
}
.pcard:hover { background: var(--gtm-surface); border-color: #adb5bd; }
.pcard .prow { display: flex; justify-content: space-between; align-items: center; }
.pcard .pname { font-size: 15px; font-weight: 600; }
.pcard .pstat { font-size: 12px; color: var(--gtm-text-muted); }
.pcard .fp-stat { font-size: 12px; color: var(--gtm-danger); }
.pcard .plinks { display: flex; gap: 8px; font-size: 11px; }
.pcard .plinks a { color: var(--pico-primary); text-decoration: none; }
.pcard .plinks a:hover { text-decoration: underline; }

/* ── Viz: FP mode highlight ─────────────────────────── */
.toolbar.fp-mode { background: #fce4ec; border-bottom-color: var(--gtm-danger); }

/* ── Viz: side panel (matching) ─────────────────────── */
.side-panel {
  position: absolute; top: 0; right: 0; width: 220px; height: 100%;
  background: var(--gtm-surface); border-left: 1px solid var(--gtm-border);
  overflow-y: auto; z-index: 10; font-size: 12px; padding: 8px;
}
.side-panel h3 { font-size: 13px; margin: 0 0 8px; }

.pair-item {
  padding: 4px 6px; margin-bottom: 3px; border-radius: 4px;
  cursor: pointer; display: flex; justify-content: space-between; align-items: center;
}
.pair-item:hover { background: var(--gtm-border); }
.pair-item.active { background: var(--pico-primary-background); color: #fff; }
.pair-item.active .disc { color: #fff; }
.pair-item.active .lbl { color: #fff; }
.pair-item.calibrated { border-left: 3px solid var(--gtm-success); }
.pair-item .disc { color: var(--gtm-text-muted); font-size: 10px; }
.pair-item .lbl { color: var(--gtm-text); }
.pair-item .status { font-size: 10px; }

/* ── Viz: stitch compare ────────────────────────────── */
.sc-container { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.sc-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.sc-panel + .sc-panel { border-left: 2px solid var(--gtm-border); }
.sc-panel-header {
  padding: 6px 14px; background: var(--gtm-surface); font-size: 12px;
  font-weight: 600; text-align: center; flex-shrink: 0;
  display: flex; justify-content: space-between; align-items: center;
}
.sc-panel-header .ph-label { font-size: 14px; }
.sc-panel-header .ph-stats { font-size: 11px; color: var(--gtm-text-muted); }
.sc-panel-vp { flex: 1; overflow: hidden; background: #f0f0f0; position: relative; cursor: grab; }
.sc-panel-vp:active { cursor: grabbing; }
.sc-panel-vp img { position: absolute; transform-origin: 0 0; display: block; }
.sc-legend {
  display: flex; gap: 14px; padding: 6px 14px; background: var(--gtm-surface);
  font-size: 11px; flex-shrink: 0; justify-content: center; border-top: 1px solid var(--gtm-border);
}
.sc-legend-item { display: flex; align-items: center; gap: 4px; }
.sc-legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.stat-val { color: var(--gtm-success); font-family: ui-monospace, monospace; font-weight: 600; }
.stat-bad { color: var(--gtm-danger); font-family: ui-monospace, monospace; font-weight: 600; }
.stat-warn { color: var(--gtm-warning); font-family: ui-monospace, monospace; font-weight: 600; }

/* ── Viz: loading overlay ───────────────────────────── */
.loading-overlay {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; background: var(--gtm-bg); z-index: 10;
  font-size: 16px; color: var(--gtm-text-muted);
}

/* ── Viz: prep page ─────────────────────────────────── */
.prep-grid { display: flex; flex-wrap: wrap; gap: 16px; padding: 20px; justify-content: center; }

.detail-card {
  background: var(--gtm-bg); border: 1px solid var(--gtm-border);
  border-radius: 8px; overflow: hidden; width: 300px;
}
.detail-card-label {
  padding: 6px 10px; font-size: 12px; font-weight: 600; text-align: center;
  background: var(--gtm-surface); border-bottom: 1px solid var(--gtm-border);
}
.detail-card-img { position: relative; }
.detail-card-img img { display: block; width: 100%; }

.ez { position: absolute; cursor: pointer; opacity: 0; transition: opacity .15s; z-index: 2; }
.ez:hover { opacity: 1 !important; }
.ez.top { top: 0; left: 20px; right: 20px; height: 22px; background: rgba(0,140,255,.3); }
.ez.bottom { bottom: 0; left: 20px; right: 20px; height: 22px; background: rgba(0,140,255,.3); }
.ez.left { top: 20px; bottom: 20px; left: 0; width: 22px; background: rgba(0,140,255,.3); }
.ez.right { top: 20px; bottom: 20px; right: 0; width: 22px; background: rgba(0,140,255,.3); }
.ez.selected { opacity: 1 !important; background: rgba(220,53,69,.5) !important; }
.ez.connected { opacity: .7 !important; background: rgba(25,135,84,.3) !important; }

.prep-banner {
  display: none; position: fixed; top: 98px; left: 50%; transform: translateX(-50%);
  background: var(--gtm-danger); color: #fff; padding: 8px 20px;
  border-radius: 6px; font-size: 13px; z-index: 20; white-space: nowrap;
}

.conn-item {
  background: var(--gtm-bg); border: 1px solid var(--gtm-border);
  padding: 8px 14px; margin: 4px 0; border-radius: 4px;
  font-size: 12px; display: flex; justify-content: space-between; align-items: center;
}
.conn-item button {
  background: var(--gtm-danger); border: none; color: #fff;
  padding: 2px 8px; border-radius: 3px; cursor: pointer; font-size: 11px;
}
.conn-item button:hover { filter: brightness(0.9); }

/* ── Viz: review page ───────────────────────────────── */
.review-card {
  background: var(--gtm-bg); border: 2px solid var(--gtm-border);
  border-radius: 8px; overflow: hidden; margin-bottom: 16px;
}
.review-card.FP_NEW { border-color: var(--gtm-danger); }
.review-card.FP_KNOWN { border-color: #ff9800; }
.review-card.FN { border-color: #9c27b0; }
.review-card.TP { border-color: var(--gtm-success); }
.review-card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px; font-size: 13px;
}
.review-card-header .badge { padding: 2px 10px; border-radius: 3px; font-weight: 700; font-size: 12px; margin-right: 6px; }
.badge.FP_NEW { background: var(--gtm-danger); color: #fff; }
.badge.FP_KNOWN { background: #ff9800; color: #000; }
.badge.FN { background: #9c27b0; color: #fff; }
.badge.TP { background: var(--gtm-success); color: #fff; }
.review-card-body { position: relative; background: #f0f0f0; overflow: hidden; height: 75vh; }
.review-card-body canvas { width: 100%; height: 100%; }
.review-card-info {
  padding: 6px 14px; font-size: 11px; color: var(--gtm-text-muted);
  display: flex; gap: 16px; flex-wrap: wrap;
}
.review-card-actions {
  padding: 6px 14px; display: flex; gap: 8px; align-items: center;
  background: var(--gtm-surface);
}
.review-card-actions button {
  padding: 5px 16px; border: none; border-radius: 4px; cursor: pointer;
  font-size: 13px; font-weight: 600;
}
.btn-gt { background: #d4edda; color: #155724; }
.btn-fp { background: #f8d7da; color: #721c24; }
.btn-gt:hover { filter: brightness(0.95); }
.btn-fp:hover { filter: brightness(0.95); }
.review-filter-bar {
  padding: 8px 16px; display: flex; gap: 8px; font-size: 12px;
  background: var(--gtm-surface); border-bottom: 1px solid var(--gtm-border);
  position: sticky; top: 38px; z-index: 9;
}
.review-filter-bar label {
  cursor: pointer; padding: 3px 8px; border-radius: 4px;
  background: var(--gtm-bg); border: 1px solid var(--gtm-border);
}
.review-filter-bar label:hover { background: var(--gtm-surface); }
.review-filter-bar input:checked + span { color: var(--pico-primary); font-weight: 700; }
.proj-tag {
  background: var(--gtm-surface); color: var(--gtm-text-muted);
  padding: 1px 6px; border-radius: 3px; font-size: 11px; margin-left: 8px;
  border: 1px solid var(--gtm-border);
}

/* ── Viz: edges page ────────────────────────────────── */
.edges-card {
  background: var(--gtm-bg); border: 1px solid var(--gtm-border);
  border-radius: 8px; overflow: hidden; margin-bottom: 16px;
}
.edges-card-label {
  padding: 6px 10px; font-size: 13px; font-weight: 600; text-align: center;
  background: var(--gtm-surface); display: flex; justify-content: space-between; align-items: center;
}
.edges-card-body { position: relative; padding: 8px; }
.img-wrap { position: relative; flex-shrink: 0; cursor: crosshair; line-height: 0; }
.img-wrap img { display: block; }
.margin-line { position: absolute; pointer-events: none; }
.margin-line.top { left: 0; right: 0; border-top: 2px solid #ff4444; height: 0; }
.margin-line.bottom { left: 0; right: 0; border-top: 2px solid #00cc66; height: 0; }
.margin-line.left { top: 0; bottom: 0; border-left: 2px solid #ff9900; width: 0; }
.margin-line.right { top: 0; bottom: 0; border-left: 2px solid #4488ff; width: 0; }
.margin-info { font-size: 12px; display: flex; gap: 12px; padding: 8px; flex-wrap: wrap; }
.edge-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px;
  border-radius: 4px; cursor: pointer; transition: background .15s;
}
.edge-row:hover { background: var(--gtm-surface); }
.edge-row.selected { background: var(--pico-primary-background); color: #fff; }
.edge-row.selected .edge-val { color: #fff; }
.edge-row.selected .edge-override { color: #ffcdd2; }
.edge-row.selected .edge-auto { color: rgba(255,255,255,0.7); }
.edge-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.edge-dot.top { background: #ff4444; }
.edge-dot.right { background: #4488ff; }
.edge-dot.bottom { background: #00cc66; }
.edge-dot.left { background: #ff9900; }
.edge-label { width: 50px; font-weight: 600; font-size: 12px; }
.edge-val { font-family: ui-monospace, monospace; font-size: 13px; color: var(--gtm-text-mono); }
.edge-override { font-size: 10px; color: var(--gtm-danger); margin-left: 4px; }
.edge-auto { font-size: 10px; color: var(--gtm-text-muted); margin-left: 4px; }
.edges-card-actions {
  padding: 6px 10px; display: flex; gap: 8px; align-items: center;
  background: var(--gtm-surface);
}
.edges-card-actions button {
  padding: 3px 12px; border: none; border-radius: 4px; cursor: pointer;
  font-size: 12px; font-weight: 600;
}
.btn-save { background: #d4edda; color: #155724; }
.btn-save:hover { filter: brightness(0.95); }
.btn-reset { background: #f8d7da; color: #721c24; }
.btn-reset:hover { filter: brightness(0.95); }
.btn-save:disabled { background: #e9ecef; color: #999; cursor: not-allowed; }
.help-text { font-size: 11px; color: var(--gtm-text-muted); padding: 4px 8px; line-height: 1.5; }

/* ── Viz: DI page ───────────────────────────────────── */
.di-app { background: var(--gtm-surface); padding: 20px; }
.di-app h1 { margin-bottom: 8px; }
.di-subtitle { color: var(--gtm-text-muted); font-size: 14px; margin-bottom: 20px; }

.project-group { margin-bottom: 24px; }
.project-header {
  font-size: 14px; font-weight: 700; color: var(--gtm-text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; padding: 6px 0; border-bottom: 1px solid var(--gtm-border);
  margin-bottom: 8px; position: sticky; top: 0; background: var(--gtm-surface); z-index: 10;
  cursor: pointer; user-select: none;
}
.project-header::before { content: '\25be '; font-size: 11px; }
.project-group.collapsed .project-header::before { content: '\25b8 '; }
.project-group.collapsed .sheet-row { display: none; }

.sheet-row {
  display: flex; gap: 12px; align-items: stretch; background: var(--gtm-bg);
  border-radius: 6px; margin-bottom: 6px; padding: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.sheet-row.verified { border-left: 4px solid var(--gtm-success); }
.sheet-row.has-error { border-left: 4px solid var(--gtm-danger); }

.eval-badge { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 11px; font-weight: 700; }
.eval-badge.tp { background: #d4edda; color: #155724; }
.eval-badge.mismatch { background: #fff3cd; color: #856404; }
.eval-badge.fp { background: #f8d7da; color: #721c24; }
.eval-badge.fn { background: #f8d7da; color: #721c24; }
.eval-badge.tn { background: #f5f5f5; color: #999; }
.pred-text { font-size: 11px; color: #999; font-style: italic; }

.di-filter-bar { margin-bottom: 16px; display: flex; gap: 8px; align-items: center; }
.di-filter-bar button {
  padding: 4px 12px; border: 1px solid var(--gtm-border); border-radius: 4px;
  background: var(--gtm-bg); cursor: pointer; font-size: 12px;
}
.di-filter-bar button.active { background: var(--pico-primary-background); color: white; border-color: var(--pico-primary-background); }

.f1-badge { font-size: 12px; padding: 2px 8px; border-radius: 3px; margin-left: 8px; }
.f1-badge.perfect { background: #d4edda; color: #155724; }
.f1-badge.partial { background: #fff3cd; color: #856404; }
.f1-badge.fail { background: #f8d7da; color: #721c24; }

.sheet-img {
  width: 560px; min-width: 560px; cursor: pointer; border-radius: 4px;
  object-fit: cover; background: #eee;
}
.sheet-info { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.sheet-label { font-size: 12px; color: var(--gtm-text-muted); }
.sheet-fields { display: flex; gap: 8px; align-items: center; }
.sheet-fields label { font-size: 12px; font-weight: 600; color: #555; width: 65px; flex-shrink: 0; }
.sheet-fields input[type="text"] {
  flex: 1; padding: 3px 6px; border: 1px solid var(--gtm-border); border-radius: 3px;
  font-size: 13px; margin-bottom: 0;
}
.sheet-fields input[type="text"]:focus { border-color: var(--pico-primary); outline: none; }
.sheet-actions { display: flex; gap: 8px; align-items: center; margin-top: 2px; }
.sheet-actions label { font-size: 12px; color: #555; }
.di-save-btn {
  padding: 3px 12px; background: var(--pico-primary-background); color: white;
  border: none; border-radius: 3px; cursor: pointer; font-size: 12px;
}
.di-save-btn:hover { filter: brightness(0.9); }
.di-save-btn.saved { background: var(--gtm-success); }

.di-modal-overlay {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.85); z-index: 1000; cursor: zoom-out;
  justify-content: center; align-items: center;
}
.di-modal-overlay.open { display: flex; }
.di-modal-overlay img { max-width: 95%; max-height: 95%; object-fit: contain; }

/* ── Viz: matching list page ────────────────────────── */
.matching-grid { display: flex; flex-wrap: wrap; gap: 16px; }
.matching-card {
  background: var(--gtm-bg); border: 1px solid var(--gtm-border);
  border-radius: 8px; padding: 16px; width: 300px; cursor: pointer;
}
.matching-card:hover { background: var(--gtm-surface); }
.matching-card h3 { margin: 0 0 8px; }
.matching-card .info { color: var(--gtm-text-muted); font-size: 13px; }
.matching-nav { margin-bottom: 20px; }
.matching-nav a { color: var(--pico-primary); margin-right: 16px; }

/* ── Facet sub-type cards (project index + per-project labeling hub) ────────── */
.facet-tables {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; align-items: stretch;
}
@media (max-width: 1100px) {
  .facet-tables { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .facet-tables { grid-template-columns: 1fr; }
}

/* Rigid card: fixed height; only the table body scrolls. Bottom edges of
   all cards align on the same horizontal line regardless of how many
   sub-types or pills they carry. */
.facet-block {
  border: 2px solid var(--ind-ink); background: #fff;
  display: flex; flex-direction: column;
  height: 320px;
}

/* Top bar (fixed) — title · proj count · headline F1. Same height every card. */
.fc-header {
  flex-shrink: 0; padding: 10px 12px 8px;
  display: flex; align-items: baseline; gap: 8px;
  border-bottom: 1px solid #eee;
}
.fc-header h2 {
  margin: 0; font-size: 12px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ind-ink);
}
.fc-header .fc-proj {
  font-size: 10px; color: var(--ind-ink-soft); font-family: monospace;
}
.fc-header .fc-headline {
  margin-left: auto; font-family: monospace; font-weight: 800; font-size: 16px;
  line-height: 1;
}
.fc-header .fc-headline.good { color: var(--ind-green); }
.fc-header .fc-headline.mid  { color: #b88600; }
.fc-header .fc-headline.bad  { color: var(--gtm-danger); }
.fc-header .fc-headline.muted { color: var(--ind-gray); }

/* Pill strip (fixed) — horizontally scrollable when there are many. */
.fc-pills {
  flex-shrink: 0; padding: 6px 12px;
  display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden;
  border-bottom: 1px solid #eee; white-space: nowrap;
  scrollbar-width: thin;
}
.fc-pills::-webkit-scrollbar { height: 4px; }
.fc-pills::-webkit-scrollbar-thumb { background: #ddd; }
.fc-pills:empty { display: none; }
/* Heatmap pills: translucent status-color background + dark on-tone text.
   At a glance, a strip of mostly-green vs mostly-red tells the story without
   reading numbers. */
.fc-pill {
  display: inline-flex; align-items: baseline; gap: 5px; flex-shrink: 0;
  padding: 2px 7px;
  border: 1px solid transparent;
  font-size: 10px; font-family: monospace;
}
.fc-pill .fc-pill-label {
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700;
  opacity: 0.75;
}
.fc-pill .fc-pill-val { font-weight: 800; }
.fc-pill.good {
  background: rgba(46, 125, 50, 0.10); border-color: rgba(46, 125, 50, 0.30);
  color: #1b5e20;
}
.fc-pill.mid {
  background: rgba(246, 201, 69, 0.18); border-color: rgba(184, 134, 0, 0.45);
  color: #6b4d00;
}
.fc-pill.bad {
  background: rgba(220, 53, 69, 0.10); border-color: rgba(220, 53, 69, 0.35);
  color: #8b1a25;
}

/* Table body wrapper — scrolls; header sticks. */
.fst-wrap { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; }
.fst {
  width: 100%; border-collapse: collapse; font-size: 12px; background: #fff;
}
.fst thead {
  position: sticky; top: 0; z-index: 1; background: #fff;
}
.fst th {
  text-align: left; padding: 6px 10px; font-size: 9px;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ind-ink-soft); font-weight: 800;
  border-bottom: 1px solid var(--ind-ink); white-space: nowrap;
}
.fst td {
  padding: 6px 10px; border-bottom: 1px solid #eee;
  vertical-align: middle;
}
.fst tbody tr:last-child td { border-bottom: none; }
.fst tbody tr:hover td { background: #fffaf2; }
.fst .fst-type strong { font-weight: 700; }
.fst .fst-progress, .fst .fst-f1 { font-family: monospace; white-space: nowrap; }
.fst th.fst-f1-head, .fst .fst-f1 { text-align: center; }
.fst .fst-f1.muted { color: var(--ind-gray); }
.fst .fst-progress.muted { color: var(--ind-gray); text-align: center; }
.fst .fst-score {
  display: inline-block; margin-right: 4px; font-size: 11px; line-height: 1;
  transform: translateY(1px);
}
.fst .fst-score.good { color: var(--ind-green); }
.fst .fst-score.mid  { color: var(--ind-yellow); }
.fst .fst-score.bad  { color: var(--gtm-danger); }
.fst .fst-action { width: 1%; text-align: right; white-space: nowrap; }

/* Action button hierarchy:
   - .label.primary → solid orange (the most-urgent row, one per card)
   - .label         → ghost outline (other pending rows)
   - .done          → green check (verified)
   All buttons share min-width so the rightmost column aligns perfectly. */
.fst-btn {
  display: inline-block; box-sizing: border-box;
  min-width: 52px; padding: 3px 8px; font-size: 11px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  text-align: center;
  color: var(--ind-ink); text-decoration: none;
  border: 1px solid var(--ind-ink-soft); background: transparent;
  font-family: monospace;
}
.fst-btn:hover { background: var(--ind-ink); color: #fff; border-color: var(--ind-ink); }
.fst-btn.done {
  color: var(--ind-green); border-color: var(--ind-green); background: transparent;
}
.fst-btn.done:hover { background: var(--ind-green); color: #fff; }
.fst-btn.label {
  color: var(--ind-orange); border-color: rgba(255, 106, 0, 0.45); background: transparent;
}
.fst-btn.label:hover {
  background: var(--ind-orange); color: #fff; border-color: var(--ind-orange);
}
.fst-btn.label.primary {
  background: var(--ind-orange); color: #fff;
  border-color: var(--ind-orange);
  box-shadow: 2px 2px 0 var(--ind-ink);
}
.fst-btn.label.primary:hover { background: var(--ind-orange-hover); }
.fst-btn.muted {
  color: var(--ind-ink-soft); border-color: transparent;
}

/* Clickable rows in the facet sub-type tables — affordance for opening the
   breakdown modal. The action button still navigates via its own anchor. */
.fst tbody tr.fst-clickable { cursor: pointer; }
.fst tbody tr.fst-clickable:hover td { background: #fff4e1; }

/* Score-breakdown modal — opened from a sub-type row in the BI cards. */
.brm-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(26, 26, 26, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.brm-card {
  background: var(--ind-paper, #f5f3ee);
  color: var(--ind-ink, #1a1a1a);
  border: 1px solid var(--ind-ink, #1a1a1a);
  box-shadow: 4px 4px 0 var(--ind-ink, #1a1a1a);
  width: 100%; max-width: 640px; max-height: 90vh;
  display: flex; flex-direction: column;
  font-size: 13px;
}
.brm-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--ind-ink);
}
.brm-header h2 {
  margin: 0; font-size: 14px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.brm-close {
  background: transparent; border: 0; font-size: 18px; cursor: pointer;
  color: var(--ind-ink-soft); padding: 0 4px;
}
.brm-close:hover { color: var(--ind-ink); }

.brm-headline, .brm-dims, .brm-projects {
  padding: 14px 16px; border-bottom: 1px solid #d8d5cc;
}
.brm-projects { border-bottom: 0; overflow-y: auto; flex: 1 1 auto; }

.brm-headline-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.brm-label { color: var(--ind-ink-soft); font-size: 12px; }
.brm-f1 {
  font-family: monospace; font-weight: 800; font-size: 14px;
}
.brm-f1.good { color: var(--ind-green); }
.brm-f1.mid  { color: #b88600; }
.brm-f1.bad  { color: var(--gtm-danger); }
.brm-f1.muted { color: var(--ind-gray); }
.brm-headline-help {
  margin: 8px 0 0; color: var(--ind-ink-soft); font-size: 12px; line-height: 1.45;
}

.brm-dim {
  padding: 8px 0; border-bottom: 1px dashed #d8d5cc;
}
.brm-dim:last-child { border-bottom: 0; }
.brm-dim-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 4px;
}
.brm-dim-head strong { font-size: 13px; }
.brm-dim-recall {
  font-family: monospace; font-weight: 700; font-size: 13px;
}
.brm-dim-recall.good { color: var(--ind-green); }
.brm-dim-recall.mid  { color: #b88600; }
.brm-dim-recall.bad  { color: var(--gtm-danger); }
.brm-dim-recall.muted { color: var(--ind-gray); }
.brm-dim-help {
  font-size: 12px; color: var(--ind-ink-soft); line-height: 1.45;
  margin-bottom: 4px;
}
.brm-dim-counts {
  font-family: monospace; font-size: 11px; color: var(--ind-ink-soft);
}

.brm-projects h3 {
  margin: 0 0 8px; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--ind-ink-soft); font-weight: 800;
}
.brm-proj-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.brm-proj-table th, .brm-proj-table td {
  text-align: left; padding: 4px 8px; border-bottom: 1px solid #e8e5dc;
}
.brm-proj-table th:last-child, .brm-proj-table td:last-child {
  text-align: right; font-family: monospace;
}
.brm-proj-f1.good { color: var(--ind-green); }
.brm-proj-f1.mid  { color: #b88600; }
.brm-proj-f1.bad  { color: var(--gtm-danger); }
.brm-proj-f1.muted { color: var(--ind-gray); }
.brm-empty { color: var(--ind-ink-soft); font-style: italic; }
