/* ---- notes / caveat banner (mandatory on ops views) ---- */
.notes-banner {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-l);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.nb-line { font-size: 0.74rem; color: var(--muted); line-height: 1.35; }
.nb-line::before { content: "› "; color: var(--brand-l); font-weight: 700; }

/* ---- stat cards ---- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.55rem;
}
.statcard {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.sc-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--faint); font-weight: 600; }
.sc-value { font-size: 1.25rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.sc-sub { font-size: 0.7rem; color: var(--muted); }
.rate-null { color: var(--faint); cursor: help; }
.rate-den { color: var(--faint); font-size: 0.72rem; font-weight: 500; margin-left: 0.25rem; }

/* ---- data table ---- */
.otable-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.otable { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.otable th {
  text-align: left; font-weight: 600; color: var(--faint);
  text-transform: uppercase; font-size: 0.66rem; letter-spacing: 0.03em;
  padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border);
  background: var(--surface2); position: sticky; top: 0;
  white-space: nowrap;
}
.otable td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border2); vertical-align: top; }
.otable tbody tr:last-child td, .otable tbody tr:last-child td { border-bottom: none; }
.otable td.num, .otable th.num { text-align: right; font-variant-numeric: tabular-nums; }
.otable tr.row-link { cursor: pointer; }
.otable tr.row-link:hover td { background: var(--surface-open-hover); }
.otable-empty { padding: 1.2rem; text-align: center; color: var(--faint); font-size: 0.82rem; }
.otable-foot {
  padding: 0.5rem 0.6rem; font-size: 0.72rem; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  border-top: 1px solid var(--border); background: var(--surface2);
}
.otable-foot .pager { display: flex; gap: 0.35rem; }
.mono-ref { font-family: var(--mono); font-size: 0.74rem; }

/* skeleton rows */
.skel-orow { height: 32px; border-bottom: 1px solid var(--border2); background:
  linear-gradient(90deg, var(--surface2) 0%, var(--skel-shine) 50%, var(--surface2) 100%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer {
  to { transform: translateX(100%); }
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- resolver picker ---- */
.resolver { position: relative; }
.resolver-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  color: var(--text);
  font-size: 0.82rem;
}
.resolver-input:focus { outline: 2px solid rgba(0, 94, 133, 0.25); border-color: var(--brand-l); }
.resolver-menu {
  position: absolute; z-index: 20; top: calc(100% + 3px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  max-height: 320px; overflow-y: auto; padding: 0.25rem;
}
.resolver-menu[hidden] { display: none; }
.resolver-loading, .resolver-empty, .resolver-note {
  padding: 0.5rem 0.6rem; font-size: 0.76rem; color: var(--muted);
}
.resolver-note { color: var(--amber-d); font-weight: 600; border-bottom: 1px solid var(--border); }
.resolver-item {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.4rem 0.5rem; border-radius: var(--radius-sm); cursor: pointer;
}
.resolver-item:hover, .resolver-item.active { background: var(--surface2); }
.resolver-item .r-top { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.resolver-item .r-name { font-weight: 600; color: var(--text); font-size: 0.82rem; }
.resolver-item .r-sub { font-size: 0.7rem; color: var(--faint); }

.ops-error {
  border: 1px solid color-mix(in srgb, var(--amber) 40%, var(--border));
  background: color-mix(in srgb, var(--amber) 8%, transparent);
  border-radius: var(--radius-sm); padding: 0.7rem 0.85rem;
  color: var(--text); font-size: 0.82rem;
}
.ops-error strong { display: block; margin-bottom: 0.2rem; }

.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: var(--radius-sm); padding: 0.45rem 0.75rem; cursor: pointer;
  font: 600 0.8rem var(--sans);
}
.btn:hover { border-color: var(--brand-l); color: var(--brand-d); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-d); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 0.2rem; }
.field > label { font-size: 0.68rem; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: 0.03em; }
.field input[type="date"], .field input[type="text"], .field select {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.4rem 0.5rem; color: var(--text); font-size: 0.8rem;
}
.win-presets { display: flex; gap: 0.25rem; }
.win-presets .chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 0.2rem 0.5rem; font-size: 0.7rem; cursor: pointer;
}
.win-presets .chip:hover { border-color: var(--brand-l); color: var(--brand-d); }
.win-slider { display: flex; align-items: center; gap: 0.5rem; }
.win-slider input[type="range"] { width: 180px; }
.win-slider .win-val { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.5rem; }

/* bars grow in on fresh renders */
@keyframes fillIn { from { width: 0; } }
.bh-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.score-num {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1;
  letter-spacing: -0.02em;
}
.score-bar-mini {
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: var(--surface3);
  overflow: hidden;
}
.score-bar-mini > i {
  display: block;
  height: 100%;
  border-radius: 2px;
  animation: fillIn 0.45s ease-out both;
}
.score-rank {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--faint);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

/* name cell */
.bh-name { min-width: 0; }
.bh-name .name {
  font-weight: 650;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.bh-name .badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.4rem;
  align-items: center;
  margin-top: 0.2rem;
}
.bh-name .meta-line {
  color: var(--faint);
  font-size: 0.66rem;
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* facet sparkline — the glance hero */
.bh-facets { min-width: 0; }
.facet-row {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}
.facet {
  display: grid;
  grid-template-columns: 14px 1fr 28px;
  gap: 0.3rem;
  align-items: center;
}
.facet-key {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--faint);
  font-family: var(--mono);
  text-align: right;
}
.facet-track {
  height: 5px;
  border-radius: 3px;
  background: var(--surface3);
  overflow: hidden;
  position: relative;
}
.facet-fill {
  height: 100%;
  border-radius: 3px;
  min-width: 2px;
  transition: width 0.2s ease;
  animation: fillIn 0.4s ease-out both;
}
.facet-fill.weak { opacity: 0.9; box-shadow: inset 0 0 0 1px rgba(214, 69, 69, 0.35); }
.facet-fill.strong { }
.facet-pct {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.facet-pct.weak { color: var(--red-d); }
.facet-pct.strong { color: var(--green-d); }

/* edge / drivers glance */
.bh-edge { min-width: 0; }
.edge-stack {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.edge-chip {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  font-size: 0.7rem;
  line-height: 1.25;
  min-width: 0;
}
.edge-chip .tag {
  flex-shrink: 0;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.08rem 0.32rem;
  border-radius: 3px;
  margin-top: 0.1rem;
}
.edge-chip.up .tag { background: rgba(107, 170, 44, 0.18); color: var(--green-d); }
.edge-chip.down .tag { background: rgba(214, 69, 69, 0.14); color: var(--red-d); }
.edge-chip.why .tag { background: rgba(0, 94, 133, 0.12); color: var(--brand-d); }
.edge-chip.neutral .tag { background: var(--surface3); color: var(--faint); }
.edge-chip .txt {
  color: var(--muted);
  min-width: 0;
}
/* Lift/Drag/Balanced stay one line (short by construction — a facet name + a percent);
   the Why chip carries a full sentence and was the one truncating hardest, so it alone
   gets room to wrap onto a second line instead of ending in "…" every time. */
.edge-chip.up .txt, .edge-chip.down .txt {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.edge-chip.why .txt {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.edge-chip.up .txt { color: var(--text); }
.edge-chip.down .txt { color: var(--text); }
.edge-chip.neutral .txt { color: var(--faint); }
.flag-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--amber-d);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.flag-dot::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
}

/* expand chevron hint */
.detail-block {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border2);
}
.detail-block h3 {
  margin: 0 0 0.5rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ---- verdict strip — the always-present award read ---- */
.verdict {
  margin-top: 0.65rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  line-height: 1.45;
}
.verdict.ok {
  background: rgba(107, 170, 44, 0.1);
  border: 1px solid rgba(107, 170, 44, 0.3);
  border-left: 3px solid var(--green);
  color: var(--text);
}
.verdict.ok b { color: var(--green-d); }
.verdict.flag {
  background: rgba(224, 164, 0, 0.1);
  border: 1px solid rgba(224, 164, 0, 0.32);
  border-left: 3px solid var(--amber);
  color: var(--text);
}
.verdict.flag b { color: var(--amber-d); }
.verdict ul {
  margin: 0.3rem 0 0;
  padding-left: 1.1rem;
}
.verdict li { margin-top: 0.15rem; }

/* ---- score breakdown rows — derivation-first ---- */
.bd-row {
  padding: 0.4rem 0 0.45rem;
  border-bottom: 1px solid var(--border2);
}
.bd-row:last-of-type { border-bottom: none; }
.bd-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.6rem;
  margin-bottom: 0.25rem;
}
.bd-name {
  font-weight: 650;
  font-size: 0.76rem;
  color: var(--text);
}
.bd-name::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
  background: var(--facet, var(--brand));
  margin-right: 0.35rem;
}
.bd-weight {
  font-size: 0.64rem;
  color: var(--faint);
  font-weight: 500;
}
.bd-val {
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.bd-val b { color: var(--text); font-family: var(--mono); }
.bd-pts {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.bd-row.weak .bd-pts, .bd-row.weak .bd-val b { color: var(--red-d); }
.bd-derive {
  margin-top: 0.28rem;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.45;
}
.bd-floor {
  display: block;
  margin-top: 0.12rem;
  color: var(--red-d);
  font-weight: 600;
}
.bd-total {
  margin-top: 0.45rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--border);
  font-size: 0.74rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.bd-total b { color: var(--text); font-family: var(--mono); }

.contrib-track {
  height: 8px;
  border-radius: 4px;
  background: var(--surface3);
  overflow: hidden;
  position: relative;
}
.contrib-fill { height: 100%; border-radius: 4px; animation: fillIn 0.4s ease-out both; }
.contrib-fill.weak { background: var(--red) !important; }

/* "How this score works" explainer */
.how-it-works {
  margin-top: 0.6rem;
  border-top: 1px solid var(--border2);
  padding-top: 0.45rem;
}
.how-it-works summary {
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--brand);
  user-select: none;
}
.how-it-works summary:hover { color: var(--brand-l); }
.how-it-works p {
  margin: 0.45rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.5;
}
.how-it-works p b { color: var(--text); }

/* no-score placeholder facets */
.no-score-msg {
  font-size: 0.72rem;
  color: var(--faint);
  font-style: italic;
}

/* align numeric columns everywhere mono is used */
.score-num, .score-rank, .facet-pct, .bd-val, .bd-pts, .bd-total,
.sense-v, .panel-header .count, .filter-chip .n {
  font-variant-numeric: tabular-nums;
}
/* ---- card / panel ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 72px);
}
.filter-chip {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.08s, box-shadow 0.12s;
}
.filter-chip:hover { border-color: var(--brand-l); color: var(--brand-d); }
.filter-chip:active { transform: scale(0.96); }
.filter-chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 94, 133, 0.35);
}
.filter-chip.active:hover { color: #fff; }
.filter-chip .n { opacity: 0.7; font-weight: 500; margin-left: 0.2rem; font-family: var(--mono); font-size: 0.68rem; }

/* ---- pills / badges ---- */
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.2;
}
.pill.brand { background: rgba(0, 94, 133, 0.12); color: var(--brand-d); }
.pill.accent { background: rgba(245, 130, 31, 0.14); color: var(--accent-d); }
.pill.green { background: rgba(107, 170, 44, 0.16); color: var(--green-d); }
.pill.amber { background: rgba(224, 164, 0, 0.16); color: var(--amber-d); }
.pill.red { background: rgba(214, 69, 69, 0.14); color: var(--red-d); }
.pill.neutral { background: var(--surface3); color: var(--muted); }
