/* ============================================================
   PROOF — components
   ============================================================ */

/* ---------------- panel ---------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 13px 16px 11px;
  border-bottom: 1px solid var(--hairline);
}
.panel-head-tight { padding-bottom: 12px; border-bottom: none; }
.panel-body { padding: 14px 16px 16px; }
.panel-body-flush { padding: 0; }
.panel-foot {
  padding: 9px 16px; border-top: 1px solid var(--hairline);
  background: var(--surface-sunken);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

/* ---------------- claim: every number is a claim ----------
   A figure that carries provenance. Hover reveals the affordance;
   click (or ? when focused) opens the Trust Rail. */
.claim {
  display: inline-flex; align-items: baseline; gap: 3px;
  border-radius: 3px;
  padding: 0 2px; margin: 0 -2px;
  cursor: pointer;
  position: relative;
  transition: background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  font-variant-numeric: tabular-nums;
}
.claim::after {
  content: "";
  position: absolute; left: 2px; right: 2px; bottom: -1px;
  height: 1px;
  background: var(--hairline-strong);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}
.claim:hover::after, .claim:focus-visible::after { opacity: 1; }
.claim:hover { background: var(--surface-wash); }
.claim[data-active="true"] { background: var(--claim-active); box-shadow: inset 0 0 0 1px var(--seq-400); }

/* freshness — data ages visually.
   Perceive staleness before reading a timestamp. */
.claim[data-fresh="stale"]   { opacity: .74; }
.claim[data-fresh="expired"] { opacity: .52; }
.claim[data-fresh="expired"]::before {
  content: ""; position: absolute; inset: -1px -2px;
  border-radius: 3px;
  background: repeating-linear-gradient(135deg, transparent 0 3px, var(--surface-wash) 3px 6px);
  pointer-events: none;
}

/* thin sample — visually degraded, never hidden, never silently shown */
.thin-n {
  position: relative;
  background: repeating-linear-gradient(135deg, transparent 0 4px, var(--ghost-wash) 4px 8px);
  border-radius: 2px;
}

/* ---------------- stat tile ---------------- */
.stat {
  display: flex; flex-direction: column; gap: 3px;
  min-width: 0;
}
.stat-label { display: block; font-size: var(--fs-xs); color: var(--ink-muted); }
.stat-value { display: block; font-size: var(--fs-xl); font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.stat-value-lg { font-size: 30px; }
.stat-sub { display: block; font-size: var(--fs-xs); color: var(--ink-secondary); }
.stat-row {
  display: grid; gap: 1px;
  background: var(--hairline);
  border-radius: var(--r-md);
  overflow: hidden;
}
.stat-row > .stat { background: var(--surface); padding: 12px 14px; }

.delta { font-size: var(--fs-xs); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.delta[data-dir="up-good"]   { color: var(--good-text); }
.delta[data-dir="down-bad"]  { color: var(--critical-text); }
.delta[data-dir="up-bad"]    { color: var(--critical-text); }
.delta[data-dir="down-good"] { color: var(--good-text); }
.delta[data-dir="flat"]      { color: var(--ink-muted); }

/* ---------------- chips & pills ---------------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs); font-weight: 550;
  padding: 2px 7px;
  border-radius: 20px;
  border: 1px solid var(--hairline-strong);
  color: var(--ink-secondary);
  white-space: nowrap;
}
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dot, var(--ink-muted)); flex: none; }
.chip-sq { width: 7px; height: 7px; border-radius: 2px; background: var(--dot, var(--ink-muted)); flex: none; }

/* status chips ALWAYS carry icon + label — never colour alone */
.status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs); font-weight: 600;
  padding: 2px 8px 2px 6px;
  border-radius: 20px;
  white-space: nowrap;
}
.status svg { width: 11px; height: 11px; flex: none; }
.status[data-s="good"]     { background: var(--good-wash);     color: var(--good-text); }
.status[data-s="warning"]  { background: var(--warning-wash);  color: var(--ink); }
.status[data-s="serious"]  { background: var(--serious-wash);  color: var(--ink); }
.status[data-s="critical"] { background: var(--critical-wash); color: var(--critical-text); }
.status[data-s="neutral"]  { background: var(--surface-wash);  color: var(--ink-secondary); }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-sm); font-weight: 550;
  padding: 6px 11px;
  border-radius: var(--r-md);
  border: 1px solid var(--hairline-strong);
  color: var(--ink);
  background: var(--surface);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-wash); }
.btn-primary {
  background: var(--ink); color: var(--surface); border-color: var(--ink);
}
.btn-primary:hover { opacity: .88; background: var(--ink); }
.btn-ghost { border-color: transparent; color: var(--ink-secondary); }
.btn-ghost:hover { background: var(--surface-wash); color: var(--ink); }
.btn-sm { padding: 3px 8px; font-size: var(--fs-xs); }
.btn svg { width: 13px; height: 13px; flex: none; }

/* segmented control */
.seg {
  display: inline-flex;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
}
.seg button {
  font-size: var(--fs-xs); font-weight: 550;
  padding: 4px 10px;
  color: var(--ink-secondary);
  border-right: 1px solid var(--hairline);
}
.seg button:last-child { border-right: none; }
.seg button[aria-pressed="true"] { background: var(--surface-wash-2); color: var(--ink); font-weight: 650; }
.seg button:hover { background: var(--surface-wash); }

/* ---------------- ledger table ---------------- */
.ledger { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.ledger th {
  text-align: left;
  font-size: var(--fs-micro); font-weight: 650; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-muted);
  padding: 9px 12px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
  position: sticky; top: 0; z-index: 2;
  white-space: nowrap;
}
.ledger th.num, .ledger td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ledger td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}
.ledger tbody tr { transition: background var(--t-fast) var(--ease); }
.ledger tbody tr:hover { background: var(--surface-wash); }
.ledger tbody tr[data-sel="true"] { background: var(--surface-wash-2); }
.ledger tbody tr.clickable { cursor: pointer; }
.ledger tbody tr:last-child td { border-bottom: none; }
.ledger .cell-strong { font-weight: 600; color: var(--ink); }

/* row accent for track identity — paired with a text label in the row */
.row-accent { box-shadow: inset 3px 0 0 var(--track); }

/* ---------------- meter ---------------- */
.meter {
  height: 6px; border-radius: 3px;
  background: var(--seq-100);
  overflow: hidden;
  position: relative;
}
.meter-fill { height: 100%; background: var(--fill, var(--seq-400)); border-radius: 3px 0 0 3px; transition: width var(--t-base) var(--ease); }
.meter-target {
  position: absolute; top: -2px; bottom: -2px; width: 1.5px;
  background: var(--ink); border-radius: 1px;
}
.meter-ghost {
  position: absolute; top: 0; bottom: 0;
  background: var(--ghost-wash);
  border-right: 1px dashed var(--ghost);
}

/* ---------------- the Wall ----------------
   Where Medical and Commercial data meet. Not an error —
   a rendered boundary you can point at. */
.wall {
  position: relative;
  border: 1px dashed var(--wall-line);
  border-radius: var(--r-md);
  background: repeating-linear-gradient(
    135deg, transparent 0 6px, var(--surface-wash) 6px 12px);
  padding: 16px;
  color: var(--wall-ink);
  display: flex; flex-direction: column; gap: 6px;
  align-items: flex-start;
}
.wall-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-micro); font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase;
  background: var(--surface);
  border: 1px solid var(--wall-line);
  border-radius: 3px;
  padding: 2px 7px;
}
.wall-note { font-size: var(--fs-xs); max-width: 46ch; line-height: 1.5; }

/* an inline wall seam inside a table/grid */
.wall-seam {
  background: repeating-linear-gradient(135deg, transparent 0 5px, var(--surface-wash) 5px 10px);
  color: var(--wall-ink);
  font-size: var(--fs-xs);
  text-align: center;
  letter-spacing: .04em;
}

/* ---------------- trace spine ---------------- */
.trace {
  display: grid;
  gap: 0;
  position: relative;
}
.trace-hop {
  display: grid;
  grid-template-columns: 128px 20px 1fr;
  gap: 0 14px;
  align-items: start;
  padding: 0;
  opacity: 0;
  animation: fade-up 380ms var(--ease) forwards;
}
.trace-when {
  text-align: right;
  padding-top: 11px;
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.trace-gutter { display: flex; flex-direction: column; align-items: center; }
.trace-node {
  width: 11px; height: 11px; border-radius: 50%;
  margin-top: 13px;
  background: var(--surface);
  border: 2px solid var(--hairline-strong);
  flex: none;
  box-shadow: 0 0 0 2px var(--surface);
  z-index: 1;
}
.trace-hop[data-kind="outcome"]     .trace-node { background: var(--good);    border-color: var(--good); }
.trace-hop[data-kind="action"]      .trace-node { background: var(--t1);      border-color: var(--t1); }
.trace-hop[data-kind="routed"]      .trace-node { background: var(--surface); border-color: var(--t1); }
.trace-hop[data-kind="theme"]       .trace-node { background: var(--surface); border-color: var(--hairline-strong); }
.trace-hop[data-kind="insight"]     .trace-node { background: var(--surface); border-color: var(--hairline-strong); }
.trace-hop[data-kind="interaction"] .trace-node { background: var(--ink-muted); border-color: var(--ink-muted); }
.trace-link { width: 2px; flex: 1; background: var(--hairline); min-height: 20px; }
.trace-hop:last-child .trace-link { display: none; }

.trace-card {
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 10px 13px 11px;
  margin-bottom: 8px;
  min-width: 0;
}
.trace-kind {
  font-size: var(--fs-micro); font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-muted);
  margin-bottom: 3px;
}
.trace-text { font-size: var(--fs-sm); line-height: 1.5; }
.trace-meta svg { width: 11px; height: 11px; flex: none; }
.trace-meta {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--hairline);
  font-size: var(--fs-xs); color: var(--ink-muted);
}

/* confidence pip on each hop */
.conf {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-micro); color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.conf-track { display: inline-flex; gap: 1.5px; }
.conf-pip { width: 4px; height: 8px; border-radius: 1px; background: var(--hairline-strong); }
.conf-pip[data-on="true"] { background: var(--ink-secondary); }

/* ---------------- empty / unknown states ----------------
   Empty-because-unknown is not empty-because-zero. */
.unknown {
  display: flex; flex-direction: column; gap: 6px;
  align-items: center; justify-content: center;
  padding: 26px 18px;
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--r-md);
  background: repeating-linear-gradient(135deg, transparent 0 6px, var(--surface-wash) 6px 12px);
  text-align: center;
}
.unknown-mark {
  font-size: var(--fs-lg); font-weight: 700; color: var(--ink-muted);
  letter-spacing: .04em;
}
.unknown-text { font-size: var(--fs-xs); color: var(--ink-secondary); max-width: 42ch; line-height: 1.5; }

.zero { padding: 26px 18px; text-align: center; }

/* ---------------- tooltip ---------------- */
.tip {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  background: var(--surface-raised);
  border: 1px solid var(--ring);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: 8px 10px;
  font-size: var(--fs-xs);
  min-width: 128px; max-width: 280px;
  opacity: 0;
  transition: opacity 90ms var(--ease);
}
.tip[data-open="true"] { opacity: 1; }
.tip-title { font-weight: 650; font-size: var(--fs-sm); margin-bottom: 4px; }
.tip-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 1.5px 0; }
.tip-row .k { color: var(--ink-muted); display: inline-flex; align-items: center; gap: 5px; }
.tip-row .v { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------------- legend ----------------
   Always present for ≥2 series. Identity never colour-alone. */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--ink-secondary); }
.legend-key { width: 9px; height: 9px; border-radius: 2px; background: var(--key); flex: none; }
.legend-key-line { width: 13px; height: 2px; border-radius: 1px; background: var(--key); flex: none; }
.legend-key-band {
  width: 13px; height: 9px; border-radius: 2px; flex: none;
  background: var(--key); opacity: .18;
  border-top: 2px solid var(--key);
}
.legend-key-dash {
  width: 13px; height: 0; flex: none;
  border-top: 2px dashed var(--ghost);
}

/* ---------------- chart frame ---------------- */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart-note { font-size: var(--fs-micro); color: var(--ink-muted); margin-top: 7px; }

.axis-text { font-size: 10.5px; fill: var(--ink-muted); font-variant-numeric: tabular-nums; }
.axis-line { stroke: var(--hairline-strong); stroke-width: 1; }
.grid-line { stroke: var(--hairline); stroke-width: 1; }

/* table-view toggle satisfies the contrast relief rule */
.table-view { max-height: 260px; overflow: auto; margin-top: 10px; border-top: 1px solid var(--hairline); }

/* ---------------- misc ---------------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
@media (max-width: 1320px) { .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 1080px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0,1fr); }
}

.scroll-x { overflow-x: auto; }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
