/* ============================================================================
   Brix design tokens — "lab/refractometer" identity: clean, scientific, digital,
   with a splash of pixel (Pac-Man-style) fruit. The green→amber→red "ripeness
   gradient" is the signature motif (it's also the biplot color scale).
   ============================================================================ */
:root {
  /* Surfaces — soft off-white "lab paper", not stark white */
  --bg:        #fafaf7;
  --bg-soft:   #f3f3ee;
  --surface:   #ffffff;
  --line:      #e4e4dd;
  --grey-soft: #eee;

  /* Ink */
  --ink:    #181a17;
  --muted:  #6b6f68;

  /* Ripeness scale — the brand's core motif (under-ripe → ripe → over-ripe) */
  --unripe:  #5ba34a;   /* green  */
  --ripe:    #e8a33d;   /* amber — the "°Bx" sugar reading, primary accent */
  --overripe:#c0432e;   /* red    */
  --green:      #2e7d32; /* legacy alias (kept so existing rules resolve) */
  --green-soft: #e9f1e7;
  --amber-soft: #fbf0db;

  /* Digital accent — cool, technical (links, data) */
  --digital:      #1e7e83;
  --digital-soft: #e4f1f1;

  --ripeness-gradient: linear-gradient(90deg, var(--unripe), var(--ripe), var(--overripe));

  /* Type — humanist sans for prose, mono for "measurements" (numbers, °Bx, labels) */
  --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, monospace;

  /* Shape */
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  color: var(--ink);
}

.wrap { max-width: 960px; margin: 0 auto; padding: 1.5rem 2rem 3rem; }

h1 { margin: 0 0 .25rem; }
/* Page heading carries a leading fruit sprite + the project name; flex-align them
   so the 2.2rem sprite sits centered on the title instead of dropping below the
   baseline (the inline vertical-align is tuned for 1em fruits, not the big one). */
main.wrap > h1 { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h2 { margin: 1.5rem 0 .5rem; font-size: 1.15rem; }
p.sub { color: var(--muted); margin-top: 0; }
a { color: #1565c0; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top nav */
.nav {
  display: flex;
  gap: 1.25rem;
  align-items: baseline;
  border-bottom: 2px solid var(--line);
  padding: .9rem 2rem;
}
.nav .brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.nav a { color: var(--muted); }
.nav a.active { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--ink); padding-bottom: .35rem; }

/* Landing cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-top: 1rem; }
.card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  color: var(--ink);
}
.card:hover { border-color: #bbb; text-decoration: none; background: var(--bg-soft); }
.card .step { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.card h3 { margin: .2rem 0 .4rem; }
.card p { margin: 0 0 .6rem; color: var(--muted); font-size: .9rem; }

/* Badges */
.badge { display: inline-block; font-size: .78rem; padding: .12rem .5rem; border-radius: 999px; background: var(--grey-soft); color: var(--muted); }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.empty { background: var(--grey-soft); color: var(--muted); }

/* Tables */
table { width: 100%; border-collapse: collapse; margin-top: .5rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
th { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tbody tr:nth-child(even) { background: var(--bg-soft); }
td.num { font-variant-numeric: tabular-nums; text-align: right; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.flag-yes { color: var(--green); }
.flag-no { color: #ccc; }
caption { caption-side: bottom; color: var(--muted); font-size: .85rem; padding-top: .6rem; text-align: left; }

/* Stub / empty states */
.panel { border: 1px solid var(--line); border-radius: 8px; padding: 1.5rem; background: var(--bg-soft); color: var(--muted); }
.panel code { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: .05rem .35rem; }

/* Detail (key/value) */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.2rem; margin: .5rem 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

footer { color: var(--muted); font-size: .85rem; margin-top: 2.5rem; border-top: 1px solid var(--line); padding-top: 1rem; }

#biplot { width: 100%; max-width: 900px; height: 600px; cursor: pointer; }

/* Biplot controls */
.biplot-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem;
  margin: .25rem 0 1rem; font-size: .9rem; color: var(--muted); }
.biplot-controls .ctl { cursor: pointer; user-select: none; }
.biplot-controls .ctl input { vertical-align: middle; margin-right: .3rem; }
.biplot-controls .ctl-group { display: inline-flex; align-items: center; gap: .6rem; }
.biplot-controls .ctl-hint { margin-left: auto; font-style: italic; }

/* Biplot axis/size/color pickers */
.axis-pickers { gap: .9rem 1.4rem; }
.axis-pickers .picker { display: inline-flex; align-items: center; gap: .35rem;
  font-weight: 600; color: var(--ink); }
.axis-pickers select {
  font: inherit; font-weight: 400; padding: .2rem .35rem; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; color: var(--ink); cursor: pointer;
}
.axis-pickers select:disabled { color: #bbb; background: var(--bg-soft); cursor: default; }

/* Report page (full-pipeline view) */
.report-rule { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0 1rem; }
.stage-head { margin: 0 0 1rem; }
.stage-head .stage-tag { font-size: .8rem; font-weight: 400; color: var(--muted);
  margin-left: .5rem; text-transform: uppercase; letter-spacing: .04em; }
.report-jump a { font-weight: 600; }

/* Spend strip (landing) */
.spend { margin: 1rem 0; padding: .6rem .9rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-soft); color: var(--muted); font-size: .9rem; }
.spend .spend-total { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.spend .badge { margin-left: .35rem; }

/* Drill-down meta line */
p.meta { color: var(--muted); font-size: .9rem; margin-top: 0; }
p.meta code { font-size: .85em; }

/* Findings / prose sections (squeeze + note detail) */
.finding { margin: 1.2rem 0; }
.finding h2 { border-bottom: 1px solid var(--line); padding-bottom: .25rem; }
.finding p { margin: .5rem 0; }
.finding sup a { text-decoration: none; }
.finding.verdict { border-left: 3px solid var(--green); padding-left: 1rem; background: var(--green-soft); border-radius: 0 8px 8px 0; }
.finding.verdict h2 { border-bottom: none; }

details.sources { margin-top: .5rem; font-size: .9rem; }
details.sources summary { color: var(--muted); cursor: pointer; }
ol.cite { margin: .5rem 0; padding-left: 1.4rem; }
ol.cite li { color: var(--muted); word-break: break-all; margin: .15rem 0; }

/* Note scorecard */
.scorecard { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; margin: 1rem 0; }
.metric { border: 1px solid var(--line); border-radius: 8px; padding: .7rem .8rem; text-align: center; }
.metric.headline { background: var(--green-soft); border-color: var(--green); }
.metric-val { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric-max { font-size: .9rem; font-weight: 400; color: var(--muted); }
.metric-lbl { font-size: .82rem; color: var(--muted); }
.metric-conf { font-size: .72rem; color: var(--muted); margin-top: .2rem; }
dl.kv.tags { grid-template-columns: max-content 1fr; max-width: 360px; }

/* Status badges */
.badge.draft { background: #fff4e5; color: #a05a00; }
.badge.reviewed { background: var(--green-soft); color: var(--green); }

/* Liveness badges */
.badge.live { background: var(--green-soft); color: var(--green); }
.badge.offline { background: #fdecea; color: #b3261e; }

/* Composite metric cards span two columns in the scorecard grid */
.metric.wide { grid-column: span 2; text-align: left; }
.metric.wide .metric-val { font-size: 1.4rem; }

/* Self-review form */
.finding.self-review { border-left: 3px solid var(--line); padding-left: 1rem; }
.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem 1rem; margin: .6rem 0; }
.review-grid label, .review-text { display: flex; flex-direction: column; font-size: .82rem; color: var(--muted); gap: .25rem; }
.review-grid input, .review-text textarea {
  font: inherit; padding: .35rem .5rem; border: 1px solid var(--line);
  border-radius: 6px; color: var(--ink); background: #fff;
}
.review-text { margin: .6rem 0; }
.finding.self-review button {
  font: inherit; cursor: pointer; padding: .45rem 1rem; border: 1px solid var(--green);
  border-radius: 6px; background: var(--green); color: #fff;
}
.finding.self-review button:hover { background: #276b2a; }

/* v3: market sizing, competitors, personas */
.figures {
  font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink);
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 6px;
  padding: .5rem .7rem; display: inline-block;
}
.rationale {
  margin-top: .8rem; border-left: 3px solid var(--line); padding: .1rem 0 .1rem 1rem;
}
.rationale h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 0 0 .3rem; }
.finding .count, .finding .figures + * { color: var(--muted); }
.finding h2 .count {
  font-size: .85rem; font-weight: 400; color: var(--muted);
  background: var(--grey-soft); border-radius: 999px; padding: .05rem .5rem; margin-left: .4rem;
}

.comp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-top: .8rem; }
.comp-card { border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1rem; background: var(--bg-soft); }
.comp-card h3 { margin: 0 0 .3rem; font-size: 1rem; }
.comp-card .comp-summary { color: var(--muted); font-size: .9rem; margin: .2rem 0 .6rem; }
.comp-card dl.kv { font-size: .88rem; }
.swl { margin: .5rem 0 .1rem; }
.swl span { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.swl.strengths span { color: var(--green); }
.swl.weaknesses span { color: #b3261e; }
ul.sw { margin: .1rem 0 .4rem 1.1rem; padding: 0; font-size: .88rem; color: var(--ink); }
ul.sw li { margin: .12rem 0; }

.sizing-card { border-left: 3px solid var(--green); padding-left: 1rem; }
.sizing-card h2 { border-bottom: none; }

.persona-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-top: .8rem; }
.persona-card { border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1rem; }
.persona-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.persona-head h3 { margin: 0; font-size: 1rem; }
.persona-desc { color: var(--muted); font-size: .88rem; margin: .35rem 0; }
.persona-rationale { font-size: .9rem; margin: .35rem 0 0; }

/* competitiveness badges */
.badge.comp-none { background: var(--grey-soft); color: var(--muted); }
.badge.comp-low { background: #fdecea; color: #b3261e; }
.badge.comp-medium { background: #fff4e5; color: #a05a00; }
.badge.comp-high { background: var(--green-soft); color: var(--green); }

.finding.positioning { border-left: 3px solid var(--line); padding-left: 1rem; background: var(--bg-soft); border-radius: 0 8px 8px 0; }
.finding.positioning h2 { border-bottom: none; }

/* Offering scenario cards (persona × option simulation) */
.scenario-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-top: .8rem; }
.scenario-card { border: 1px solid var(--line); border-radius: 8px; padding: .8rem .9rem; }
.scenario-card.is-mvp { border-color: var(--green); background: var(--green-soft); }
.scenario-card header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.scenario-card h3 { margin: 0; font-size: 1rem; }
.scenario-desc { color: var(--muted); font-size: .85rem; margin: .35rem 0 .5rem; }
.scenario-rev { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: .2rem 0 .4rem; }
.scenario-rev span { font-size: .8rem; font-weight: 400; color: var(--muted); }
.scenario-card dl.kv { font-size: .85rem; gap: .2rem .8rem; }

/* Persona × option cross-tab */
.crosstab-wrap { overflow-x: auto; }
table.crosstab { width: 100%; border-collapse: collapse; margin: .6rem 0; font-size: .88rem; }
table.crosstab th, table.crosstab td { border: 1px solid var(--line); padding: .4rem .55rem; text-align: center; vertical-align: top; }
table.crosstab th { background: var(--bg-soft); font-size: .78rem; color: var(--muted); }
table.crosstab th.opt-col, table.crosstab th.ours-col { writing-mode: horizontal-tb; max-width: 7rem; }
table.crosstab th.ours-col { background: var(--green-soft); color: var(--green); }
table.crosstab .persona-col { text-align: left; max-width: 16rem; }
table.crosstab .persona-sub { display: block; color: var(--muted); font-weight: 400; font-size: .82rem; margin-top: .1rem; }
table.crosstab td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
table.crosstab .chk { color: var(--green); font-weight: 700; }
table.crosstab .no { color: #ccc; }
table.crosstab.compact { font-size: .82rem; }
.sim-math { margin-top: .6rem; font-size: .9rem; }
.sim-math summary { color: var(--muted); cursor: pointer; }
.sim-math h4 { margin: .8rem 0 .2rem; font-size: .92rem; }
.sim-math h4 .sub { font-weight: 400; }

/* product comprehension card ("what it is") */
.product-card { border-left: 3px solid var(--green); padding: .6rem 1rem 1rem; margin: 1rem 0 1.4rem; background: var(--bg-soft); border-radius: 0 8px 8px 0; }
.product-card h2 { border-bottom: none; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.product-card .muted { font-size: .82rem; margin: .1rem 0 .6rem; }
.product-card ul.features { margin: .4rem 0 .6rem 1.1rem; padding: 0; }
.product-card ul.features li { margin: .2rem 0; font-size: .92rem; }
.conf-high { font-size: .72rem; font-weight: 600; color: var(--green); text-transform: uppercase; letter-spacing: .03em; }
.conf-medium { font-size: .72rem; font-weight: 600; color: #a05a00; text-transform: uppercase; letter-spacing: .03em; }
.conf-low { font-size: .72rem; font-weight: 600; color: #b3261e; text-transform: uppercase; letter-spacing: .03em; }

/* --- Pipeline progress page --- */
.run-panel { border: 1px solid var(--line, #e3e3e0); border-radius: 10px; padding: 1.1rem 1.2rem; margin: 0 0 1.4rem; background: #fcfcfb; }
.run-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.run-badge { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .18rem .5rem; border-radius: 999px; color: #fff; }
.run-badge.idle { background: #9ca3af; }
.run-badge.running { background: #2563eb; animation: run-pulse 1.4s ease-in-out infinite; }
.run-badge.done { background: var(--green, #5a7d3a); }
.run-badge.error { background: #b3261e; }
.run-badge.stalled { background: #a05a00; }
@keyframes run-pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
.run-cmd { font-weight: 600; font-family: ui-monospace, monospace; }
.run-meta { color: #777; font-size: .85rem; }
.run-bar-wrap { height: 12px; background: #ececea; border-radius: 999px; overflow: hidden; }
.run-bar { height: 100%; width: 0; background: linear-gradient(90deg, #78b45a, #2563eb); transition: width .4s ease; }
.run-counts { margin: .4rem 0 .9rem; }
.run-stats { display: flex; flex-wrap: wrap; gap: 1.6rem; margin: 0 0 .6rem; }
.run-stats div { display: flex; flex-direction: column; }
.run-stats dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: #888; }
.run-stats dd { margin: .1rem 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.run-actions { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; margin-top: .9rem; padding-top: .9rem; border-top: 1px dashed #e3e3e0; }
.run-actions-label { font-size: .8rem; color: #666; font-weight: 600; }
.run-btn { font: inherit; font-size: .86rem; padding: .4rem .8rem; border: 1px solid #c8c8c4; border-radius: 7px; background: #fff; cursor: pointer; }
.run-btn:hover:not(:disabled) { border-color: #2563eb; color: #2563eb; }
.run-btn:disabled { opacity: .45; cursor: not-allowed; }
.run-btn small { color: #999; font-weight: 400; }
.run-msg { font-size: .82rem; color: #555; font-family: ui-monospace, monospace; }
.run-note { margin: .6rem 0 0; font-size: .82rem; }
.run-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; align-items: start; }
@media (max-width: 820px) { .run-split { grid-template-columns: 1fr; } }
.run-feed { width: 100%; border-collapse: collapse; font-size: .85rem; }
.run-feed th, .run-feed td { text-align: left; padding: .28rem .5rem; border-bottom: 1px solid #efefec; font-variant-numeric: tabular-nums; }
.run-feed th { font-size: .7rem; text-transform: uppercase; letter-spacing: .03em; color: #888; }
.run-feed .num { text-align: right; }
.run-log { background: #1e1e1e; color: #d6d6d6; padding: .8rem; border-radius: 8px; font-size: .78rem; line-height: 1.45; max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.run-log-name { font-weight: 400; font-size: .78rem; }

/* Biplot hourly-rate input */
.rate-input { width: 4.2em; font: inherit; padding: .1rem .25rem; margin: 0 .1rem; border: 1px solid #c8c8c4; border-radius: 4px; text-align: right; }

/* Job loading screen: streamed "reports ready" list */
.ready-list { list-style: none; padding: 0; margin: .5rem 0; columns: 2; }
.ready-list li { margin: .2rem 0; break-inside: avoid; }
.stage-list { list-style: none; padding: 0; margin: .5rem 0; }
.stage-list .stage-error, .ready-list .stage-error { color: #b3261e; }

/* Report tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid #e3e3e0; margin: 1rem 0 1.2rem; flex-wrap: wrap; }
.tab { font: inherit; font-size: .95rem; padding: .5rem .9rem; border: none; background: none; cursor: pointer; color: #666; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab:hover { color: #2563eb; }
.tab.active { color: #1a1a1a; font-weight: 600; border-bottom-color: #2563eb; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Compact competitor cards (logo + summary; details collapsed) */
.comp-head { display: flex; align-items: center; gap: .6rem; }
.comp-logo { width: 40px; height: 40px; object-fit: contain; border-radius: 6px; background: #fff; flex: none; }
.comp-head h3 { margin: 0; }
.comp-detail { margin-top: .5rem; }
.comp-detail > summary { cursor: pointer; color: #2563eb; font-size: .85rem; }
.repo-evidence { margin: 1rem 0; }
.repo-evidence > summary { cursor: pointer; color: #555; }

/* Print: stack every tab single-column, drop chrome (page-friendly handout) */
@media print {
  .nav, .tabs, .run-btn, button, .comp-detail > summary, footer { display: none !important; }
  .tab-panel { display: block !important; page-break-inside: avoid; }
  .comp-detail[open], .comp-detail { display: block; }
  .comp-detail > div, .comp-detail dl { display: block !important; }
  .persona-grid, .comp-grid, .scenario-grid { grid-template-columns: 1fr !important; display: block !important; }
  .persona-card, .comp-card, .scenario-card { break-inside: avoid; margin-bottom: .6rem; }
  a { color: #000; text-decoration: none; }
  #persona-biplot, #comp-biplot { page-break-inside: avoid; }
}

/* Repo-selection price bar */
.price-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.price-amt { font-size: 1.5rem; margin-left: .6rem; }
.nudge { color: #5a7d3a; font-size: .85rem; margin-top: .25rem; min-height: 1.1em; }
tr.purchased { background: #fafaf8; }
.size-cell { white-space: nowrap; color: #555; }

/* Biplot advanced (per-measure scenario + scale) disclosure */
.biplot-advanced { margin: .2rem 0 .8rem; font-size: .9rem; }
.biplot-advanced > summary { cursor: pointer; color: #555; font-size: .82rem; padding: .2rem 0; user-select: none; }
.biplot-advanced > summary:hover { color: #2563eb; }
.adv-grid { display: flex; flex-direction: column; gap: .45rem; padding: .5rem 0 .2rem; }
.adv-row { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem; }
.adv-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #888; width: 4.5em; flex: none; }
.adv-cell { display: inline-flex; align-items: center; gap: .25rem; font-size: .82rem; color: #555; }
.adv-cell select { font: inherit; font-size: .82rem; }

/* --- SaaS app (auth / repos / job / results) --- */
.nav-spacer { flex: 1; }
.nav-user { color: #666; font-size: .9rem; margin-right: .6rem; }
.signin-row { display: flex; gap: .6rem; flex-wrap: wrap; margin: .6rem 0; }
.stage-list { list-style: none; padding: 0; margin: .6rem 0; }
.stage-list li { padding: .2rem 0; font-size: .9rem; }
.stage-list .stage-active { font-weight: 600; color: #2563eb; }
.stage-list .stage-done { color: var(--green, #5a7d3a); }
.stage-list .stage-error { color: #b3261e; }
.stage-list .stage-pending { color: #9ca3af; }

/* --- Repo selection menu --- */
.repo-controls { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: 0 0 1rem; }
.repo-controls-spacer { flex: 1; }
.run-btn.ghost { background: #fff; border: 1px solid #c8c8c4; color: #333; padding: .35rem .7rem; }
.run-btn.ghost:hover { border-color: #2563eb; color: #2563eb; }
.repo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: .6rem;
  margin-bottom: 5.5rem; }
.repo-card { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .8rem;
  border: 1px solid #e3e3e0; border-radius: 10px; background: #fff; cursor: pointer;
  transition: border-color .12s, box-shadow .12s, background .12s; }
.repo-card:hover { border-color: #b9c2d0; box-shadow: 0 1px 6px rgba(0,0,0,.05); }
.repo-card.sel { border-color: #2563eb; background: #f3f7ff; box-shadow: 0 0 0 1px #2563eb inset; }
.repo-card input.repo-cb { margin-top: .2rem; width: 16px; height: 16px; flex: none; cursor: pointer; }
.repo-card-main { min-width: 0; flex: 1; }
.repo-card-name { font-weight: 600; word-break: break-word; }
.repo-card-desc { font-size: .82rem; color: #666; margin: .15rem 0 .35rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.repo-card-meta { display: flex; flex-wrap: wrap; gap: .35rem .6rem; align-items: center;
  font-size: .76rem; color: #777; }
.repo-meta-item { white-space: nowrap; }
.chip { font-size: .68rem; padding: .08rem .4rem; border-radius: 999px; background: #eef0f2;
  color: #555; white-space: nowrap; }
.chip-lang { background: #e7effe; color: #2456c8; }
.chip-done { background: #e3f3e0; color: #3f7a34; }
.chip-mut { background: #f0f0ee; color: #999; }
/* sticky price footer */
.price-bar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center;
  justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 0; padding: .8rem 1.1rem;
  border: 1px solid #e3e3e0; border-radius: 12px; background: rgba(255,255,255,.96);
  box-shadow: 0 -2px 14px rgba(0,0,0,.08); backdrop-filter: blur(4px); }
.price-bar-info { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; }
.price-count { font-weight: 600; }
.price-amt { font-size: 1.4rem; font-weight: 700; }
.nudge { color: #3f7a34; font-size: .85rem; }
@media (max-width: 560px) { .repo-grid { grid-template-columns: 1fr; } }

/* --- Report: TOC document layout --- */
.report-layout { display: grid; grid-template-columns: 200px 1fr; gap: 2rem; align-items: start; }
.report-toc { position: sticky; top: 1rem; align-self: start; }
.report-toc nav { display: flex; flex-direction: column; gap: .1rem; border-left: 2px solid #ececea; }
.report-toc .toc-link { padding: .35rem .8rem; color: #777; text-decoration: none; font-size: .9rem;
  border-left: 2px solid transparent; margin-left: -2px; }
.report-toc .toc-link:hover { color: #2563eb; }
.report-toc .toc-link.active { color: #1a1a1a; font-weight: 600; border-left-color: #2563eb; }
.report-section { scroll-margin-top: 1rem; padding-bottom: 1.4rem; margin-bottom: 1.4rem; border-bottom: 1px solid #efefec; }
.report-section:last-child { border-bottom: 0; }
.report-section > h2 { margin-top: 0; }
.report-chart { height: 420px; margin: .6rem 0 1rem; }
@media (max-width: 820px) {
  .report-layout { grid-template-columns: 1fr; }
  .report-toc { position: static; }
  .report-toc nav { flex-direction: row; flex-wrap: wrap; border-left: 0; }
  .report-toc .toc-link { border-left: 0; border-bottom: 2px solid transparent; }
  .report-toc .toc-link.active { border-left: 0; border-bottom-color: #2563eb; }
}

/* Today vs Full-potential economics */
.econ-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1rem 0 .4rem; }
.econ-card { border: 1px solid #e3e3e0; border-radius: 12px; padding: 1rem 1.2rem; }
.econ-card.is-mvp { background: #f4f8f1; border-color: #cfe3c4; }
.econ-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #777; }
.econ-rev { font-size: 2rem; font-weight: 700; margin: .2rem 0 0; }
.econ-rev span { font-size: 1rem; font-weight: 400; color: #888; }
.econ-sub { font-size: .82rem; color: #888; margin-bottom: .7rem; }
.econ-stats { display: flex; gap: 1.6rem; margin: 0; }
.econ-stats dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: #999; }
.econ-stats dd { margin: .1rem 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .econ-compare { grid-template-columns: 1fr; } }

/* Scenario stage list + stats table */
.stage-list { list-style: none; padding: 0; margin: .6rem 0 1.2rem; display: flex; flex-direction: column; gap: .5rem; }
.stage-block { border: 1px solid #e9e9e6; border-radius: 9px; padding: .6rem .9rem; }
.stage-block.is-mvp { background: #f4f8f1; border-color: #cfe3c4; }
.stage-block h4 { margin: 0 0 .25rem; display: flex; align-items: center; gap: .5rem; }
.stage-rev { margin-left: auto; color: #3f7a34; font-variant-numeric: tabular-nums; }
.stage-block p { margin: 0; color: #444; font-size: .92rem; }
table.scenario-stats { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.scenario-stats th, table.scenario-stats td { padding: .4rem .6rem; border-bottom: 1px solid #efefec;
  text-align: left; font-variant-numeric: tabular-nums; }
table.scenario-stats th.num, table.scenario-stats td.num { text-align: right; }
table.scenario-stats tr.is-mvp { background: #f7faf5; }

/* Print: drop the TOC, single column, show everything inline */
@media print {
  .nav, .report-toc, .run-btn { display: none !important; }
  .report-layout { grid-template-columns: 1fr; }
  .report-chart { height: 320px; }
  .econ-compare, .persona-grid, .comp-grid { grid-template-columns: 1fr 1fr; }
  .report-section { break-inside: avoid; }
}

/* --- Reports list (a user's past jobs) --- */
.report-list { display: flex; flex-direction: column; gap: .6rem; }
.report-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1rem; border: 1px solid #e3e3e0; border-radius: 10px; background: #fff;
  text-decoration: none; color: inherit; transition: border-color .12s, box-shadow .12s; }
a.report-row:hover { border-color: #2563eb; box-shadow: 0 1px 6px rgba(0,0,0,.05); }
[data-theme="dark"] .report-row { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] a.report-row:hover { border-color: #2f6fed; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.report-row.is-dead { opacity: .6; cursor: default; }
.report-row-title { font-weight: 600; display: flex; align-items: baseline; gap: .6rem; }
.report-row-date { font-size: .8rem; font-weight: 400; color: #999; }
.report-row-repos { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.report-row-side { display: flex; align-items: center; gap: .8rem; flex: none; }
.report-row-price { font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .report-row { flex-direction: column; align-items: flex-start; } }

/* ============================================================================
   Lab identity — applied theme (overrides the base rules above via cascade).
   ============================================================================ */
body { background: var(--bg); font-family: var(--font-sans); color: var(--ink); }
.wrap { max-width: 1000px; }
h1, h2, h3 { letter-spacing: -0.01em; }
a { color: var(--digital); }

/* Mono "measurement" treatment for figures / labels / °Bx */
.mono, .num, .metric-val, .report-row-price, .price-amt { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Nav — thin, technical */
.nav { background: var(--surface); border-bottom: 1px solid var(--line); }
.nav .brand { display: inline-flex; align-items: center; gap: .45rem; letter-spacing: -0.02em; }
.nav-user { font-family: var(--font-mono); font-size: .85rem; }

/* Buttons — flat, precise, amber primary */
.run-btn { background: var(--ink); color: #fff; border: 1px solid var(--ink); border-radius: var(--radius-sm);
  padding: .5rem .9rem; font: 600 .9rem/1 var(--font-sans); cursor: pointer; transition: transform .08s, background .12s; display: inline-block; }
.run-btn:hover:not(:disabled) { background: #000; text-decoration: none; }
.run-btn:disabled { opacity: .4; cursor: not-allowed; }
.run-btn.primary { background: var(--ripe); border-color: var(--ripe); color: #3a2a07; }
.run-btn.primary:hover { background: #d8951f; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin: 0 0 1rem; }

/* ---- Pixel fruit (Pac-Man style) — each project's identity icon ---- */
.fruit { width: 1.05em; height: 1.05em; vertical-align: -0.16em; image-rendering: pixelated; flex: none; }
.fruit-lg { width: 2.2rem; height: 2.2rem; }
.fruit-chip { display: inline-flex; align-items: center; gap: .4rem; }
.fruit-chip.muted { color: var(--muted); }

/* ---- Ranked-results rows: this-run highlight + blinded comparisons ---- */
#rank tr.is-current > td { background: var(--green-soft); }
#rank tr.is-current > td:first-child { box-shadow: inset 3px 0 0 var(--ripe); }
#rank tr.is-blinded { opacity: .6; }
.badge.run { background: var(--amber-soft, #fbedd6); color: #9a6a13; }
[data-theme="dark"] .badge.run { color: var(--ripe); }

/* ---- Norms: percentile context against the judged-project pool ---- */
.finding.norms .norm-list { list-style: none; margin: .8rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .9rem; }
.norm-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.norm-label { font-weight: 600; }
.norm-val { font-variant-numeric: tabular-nums; color: var(--green); font-weight: 700; }
.norm-bar { position: relative; height: 7px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--line); margin: .35rem 0 .3rem; overflow: hidden; }
.norm-bar > span { position: absolute; inset: 0 auto 0 0; display: block; height: 100%; border-radius: 999px; background: var(--ripeness-gradient, var(--green)); }
.norm-foot { font-size: .85rem; color: var(--muted); }

/* ---- Landing ---- */
.hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: 2rem; align-items: center;
  padding: 1.5rem 0 2rem; }
.hero-kicker { font-family: var(--font-mono); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--digital); }
.hero h1 { font-size: 2.4rem; line-height: 1.08; margin: .5rem 0 .7rem; }
.hero p.lead { font-size: 1.08rem; color: var(--muted); margin: 0 0 1.2rem; max-width: 34ch; }
.hero-art { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; min-height: 300px; }
.ripeness-bar { height: 8px; border-radius: 999px; background: var(--ripeness-gradient); margin: 1.1rem 0; }
.signin-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 1rem 0; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.step .step-n { font-family: var(--font-mono); color: var(--ripe); font-weight: 700; }
.section-band { border-top: 1px solid var(--line); margin: 2rem 0 0; padding-top: 1.5rem; }
.pain { font-size: 1.5rem; line-height: 1.3; max-width: 24ch; font-weight: 600; }
.pricing-ladder { display: flex; gap: .5rem; flex-wrap: wrap; font-family: var(--font-mono); }
.pricing-ladder span { border: 1px solid var(--line); border-radius: 999px; padding: .3rem .7rem; background: var(--surface); font-size: .85rem; }
@media (max-width: 720px) { .hero, .steps { grid-template-columns: 1fr; } }

/* ---- Style guide page ---- */
.sg-swatches { display: flex; flex-wrap: wrap; gap: .8rem; }
.sg-swatch { width: 96px; }
.sg-chip { height: 56px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.sg-swatch code { font-size: .72rem; color: var(--muted); }
.sg-fruit-grid { display: flex; flex-wrap: wrap; gap: 1.1rem; align-items: center; }
.sg-fruit-grid figure { margin: 0; text-align: center; font-size: .72rem; color: var(--muted); }

/* ============================================================================
   Identity v2 — arcade-lab type, dark mode, tighter spacing.
   ============================================================================ */
:root {
  --font-pixel: "Silkscreen", ui-monospace, monospace;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* Dark mode (arcade): near-black surfaces, the ripeness gradient pops. */
[data-theme="dark"] {
  --bg: #121419; --bg-soft: #181b21; --surface: #1b1f27; --line: #2c323d;
  --ink: #eceae3; --muted: #9aa0a8;
  --green-soft: #182a1c; --amber-soft: #2a2110; --digital-soft: #122526;
}
/* Report "is-mvp" highlights + card borders hardcode light values — flip them in dark. */
[data-theme="dark"] .econ-card.is-mvp,
[data-theme="dark"] .stage-block.is-mvp,
[data-theme="dark"] table.scenario-stats tr.is-mvp { background: var(--green-soft); border-color: var(--green); }
[data-theme="dark"] .econ-card,
[data-theme="dark"] .stage-block,
[data-theme="dark"] .stage-list .stage-block { border-color: var(--line); }
/* Stage descriptions hardcode #444 (near-invisible on the dark surface) — lift them. */
[data-theme="dark"] .stage-block p { color: var(--muted); }
[data-theme="dark"] .stage-rev { color: var(--green-bright, #7bc47f); }
[data-theme="dark"] .econ-label, [data-theme="dark"] .econ-rev span,
[data-theme="dark"] .econ-sub, [data-theme="dark"] .econ-stats dt { color: var(--muted); }

/* Headings + UI chrome go techy/monospace; body stays readable sans. */
h1, h2, h3 { font-family: var(--font-mono); font-weight: 700; }
.nav .brand { font-family: var(--font-pixel); font-size: .95rem; letter-spacing: 0; }
.hero-kicker, .step-n, .run-badge { font-family: var(--font-pixel); }
.run-btn, .chip, .pricing-ladder, .nav a, .tab { font-family: var(--font-mono); }
.hero h1 { font-size: 2.2rem; letter-spacing: -0.03em; }

/* Spacing rhythm */
.hero { padding: 2.2rem 0 1rem; gap: 2.6rem; }
.hero p.lead { margin-bottom: 1rem; }
.section-band { margin-top: 2.6rem; padding-top: 1.7rem; }
.steps { gap: 1.1rem; margin: 1.2rem 0 .5rem; }
.step h3 { margin-top: .6rem; }
.hero-art { display: flex; align-items: center; }

/* Theme toggle */
.theme-toggle { background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: var(--radius-sm); width: 30px; height: 30px; cursor: pointer; font-size: 1rem;
  line-height: 1; padding: 0; }
.theme-toggle:hover { color: var(--ink); border-color: var(--muted); }

/* Dark overrides for components that hardcode light colors */
[data-theme="dark"] .nav { background: var(--surface); }
[data-theme="dark"] .run-btn { background: #2a2f38; color: var(--ink); border-color: #3a414d; }
[data-theme="dark"] .run-btn:hover:not(:disabled) { background: #333a45; }
[data-theme="dark"] .run-btn.primary { background: var(--ripe); color: #2a1e05; border-color: var(--ripe); }
[data-theme="dark"] .step-n { color: var(--ripe); }
[data-theme="dark"] table.crosstab th, [data-theme="dark"] .run-feed th { color: var(--muted); }
[data-theme="dark"] .hero-art svg line { stroke: var(--line); }
[data-theme="dark"] .chip { background: var(--bg-soft); border-color: var(--line); }
[data-theme="dark"] code { background: var(--bg-soft); }

/* Apple step icons sit fully inside their card (no top clipping) */
.step .step-n { line-height: 0; margin-bottom: .55rem; }
.step .step-n .fruit { width: 2rem; height: 2rem; vertical-align: top; }

/* Dark-mode polish for report/results components that predate the tokens */
[data-theme="dark"] .run-panel,
[data-theme="dark"] .scenario-card,
[data-theme="dark"] .comp-card,
[data-theme="dark"] .persona-card,
[data-theme="dark"] .finding,
[data-theme="dark"] .product-card,
[data-theme="dark"] .card { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .run-feed th, [data-theme="dark"] .run-feed td,
[data-theme="dark"] table.crosstab th, [data-theme="dark"] table.crosstab td { border-color: var(--line); }
[data-theme="dark"] .tabs { border-color: var(--line); }
[data-theme="dark"] .tab.active { color: var(--ink); border-color: var(--ripe); }
[data-theme="dark"] .report-toc nav { border-color: var(--line); }
[data-theme="dark"] .toc-link.active { color: var(--ink); }
[data-theme="dark"] .metric { border-color: var(--line); }
[data-theme="dark"] .ours-col, [data-theme="dark"] .ours-col th { background: var(--green-soft); }
[data-theme="dark"] .biplot-advanced summary { color: var(--muted); }
[data-theme="dark"] select, [data-theme="dark"] input[type="number"],
[data-theme="dark"] .rate-input { background: var(--bg-soft); color: var(--ink); border-color: var(--line); }

/* Accent pop + landing closing CTA + pain line */
.pop { color: #b9791a; font-weight: 800; }
[data-theme="dark"] .pop { color: var(--ripe); }
.pain { max-width: none; }
.cta-band { text-align: center; margin-top: 2.8rem; padding: 2.2rem 0 1rem; border-top: 1px solid var(--line); }
.cta-h { font-size: 1.5rem; margin: 0 0 1.1rem; }

/* Repo picker: sticky tracker + selection tray */
.price-bar { display: block; position: sticky; bottom: 0; z-index: 5;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem 1rem; box-shadow: 0 -2px 12px rgba(0,0,0,.06); }
.price-bar-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.selected-tray { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .7rem; }
.sel-chip { display: inline-flex; align-items: center; gap: .35rem; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 999px; padding: .22rem .25rem .22rem .55rem;
  font: .82rem var(--font-mono); }
.sel-x { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 1rem;
  line-height: 1; padding: 0 .3rem; }
.sel-x:hover { color: var(--overripe); }

/* Dark-mode polish for the repo picker */
[data-theme="dark"] .repo-card { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .repo-card.sel { border-color: var(--ripe); background: var(--amber-soft); }
[data-theme="dark"] .repo-card-desc, [data-theme="dark"] .repo-meta-item { color: var(--muted); }

/* --- Blue Ribbon Repos (state-fair leaderboard) --- */
.ribbon-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin: 1rem 0 1.6rem; }
.ribbon-card { display: flex; flex-direction: column; gap: .35rem; padding: 1.2rem 1.1rem .9rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-decoration: none; color: inherit; position: relative; transition: transform .12s, box-shadow .12s, border-color .12s; }
.ribbon-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.10); border-color: #2f6fed; }
.ribbon-badge { font-size: 1.9rem; line-height: 1; }
.ribbon-cat { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #2f6fed; font-weight: 700; }
.ribbon-name { font-size: 1.15rem; font-weight: 700; font-family: var(--font-mono); word-break: break-word; }
.ribbon-desc { font-size: .85rem; color: var(--muted); flex: 1; }
.ribbon-meta { margin-top: .3rem; display: flex; flex-direction: column; }
.ribbon-val { font-size: 1.25rem; font-weight: 800; color: var(--overripe); }
[data-theme="dark"] .ribbon-val { color: var(--ripe); }
.ribbon-cta { margin-top: .5rem; font-size: .82rem; font-weight: 600; color: #2f6fed; }
.fairground { text-align: center; margin-top: 1.5rem; }
.locked-panel { border: 2px dashed var(--line); border-radius: 14px; padding: 2rem 1.4rem; max-width: 620px; margin: 0 auto; background: var(--bg-soft); }
.locked-panel .lock-icon { font-size: 2.2rem; }
.locked-panel h2 { margin: .4rem 0 .6rem; }
.locked-panel p { color: var(--muted); margin: 0 auto 1.1rem; max-width: 48ch; }
.explainer { border: 1px solid var(--line); border-radius: 12px; background: var(--bg-soft); padding: 1.1rem 1.3rem; margin: .4rem 0 1.4rem; }
.explainer h2 { margin: 0 0 .7rem; font-size: 1.1rem; }
.explainer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.explainer-grid > div { font-size: .9rem; color: var(--muted); line-height: 1.5; }
.ex-term { display: block; font-family: var(--font-mono); font-weight: 700; color: var(--ink); font-size: .82rem; margin-bottom: .35rem; }
.explainer-cta { margin: 1.5rem 0 0; padding-top: 1.1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .92rem; }
.ribbon-today { font-size: .78rem; color: var(--muted); margin-top: .1rem; }

/* Examples gallery (public showcase) */
.example-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; margin-top: 1.3rem; }
.example-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; background: var(--surface); }
.example-card h2 { margin: 0 0 .55rem; font-size: 1.05rem; }
.example-top { margin: 0 0 .85rem; padding-left: 1.15rem; font-size: .9rem; }
.example-top li { margin: .18rem 0; }
