/* =====================================================================
   Repo Deck v2 — editorial-terminal dashboard
   Theme system: each theme = a CSS class on <body>, swaps the tokens.
   ===================================================================== */

:root {
  /* tokens populated per-theme */
  --bg:           #14110F;
  --bg-panel:     #1B1815;
  --bg-raised:    #221E18;
  --bg-soft:      #1F1B16;
  --border:       #2A2620;
  --border-soft:  #221E18;
  --text:         #F0E8D8;
  --text-muted:   #8E867A;
  --text-dim:     #5A5447;
  --accent:       #E8B547;
  --accent-soft:  rgba(232,181,71,0.14);
  --pass:         oklch(0.74 0.12 142);
  --pass-soft:    color-mix(in oklab, var(--pass) 18%, transparent);
  --warn:         oklch(0.78 0.13 75);
  --warn-soft:    color-mix(in oklab, var(--warn) 18%, transparent);
  --fail:         oklch(0.66 0.16 28);
  --fail-soft:    color-mix(in oklab, var(--fail) 18%, transparent);
  --unknown:      #4A4339;

  --row-h:        80px;
  --scale:        1;
  --radius:       6px;
  --radius-lg:    10px;
  --shadow-card:  0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 24px -12px rgba(0,0,0,0.45);

  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Theme: paper (light) */
body.theme-paper {
  --bg:           #EEE7D6;
  --bg-panel:     #F7F1E2;
  --bg-raised:    #FBF6EA;
  --bg-soft:      #E6DFCE;
  --border:       #D8CFB8;
  --border-soft:  #E5DDC8;
  --text:         #221C12;
  --text-muted:   #6E6553;
  --text-dim:     #9C9382;
  --accent:       #B4760F;
  --accent-soft:  rgba(180,118,15,0.12);
  --pass:         oklch(0.55 0.13 142);
  --warn:         oklch(0.58 0.13 75);
  --fail:         oklch(0.55 0.16 28);
  --shadow-card:  0 1px 0 rgba(255,255,255,0.6) inset, 0 6px 18px -10px rgba(60,40,10,0.18);
}

/* Theme: mono (cold neutral dark) */
body.theme-mono {
  --bg:           #0E0E0F;
  --bg-panel:     #161617;
  --bg-raised:    #1D1D1F;
  --bg-soft:      #1A1A1B;
  --border:       #262628;
  --border-soft:  #1F1F21;
  --text:         #E7E7E8;
  --text-muted:   #8B8B8E;
  --text-dim:     #56565A;
  --accent:       #E7E7E8;
  --accent-soft:  rgba(231,231,232,0.10);
  --pass:         oklch(0.78 0.09 152);
  --warn:         oklch(0.80 0.10 80);
  --fail:         oklch(0.68 0.14 25);
  --unknown:      oklch(0.48 0.02 250);
}

/* ===================== Base ===================== */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: calc(14px * var(--scale));
  line-height: 1.45;
  font-feature-settings: "ss01" on, "cv11" on;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* monospaced uppercase mini-labels — the spine of the system */
.label {
  font-family: var(--font-mono);
  font-size: calc(10.5px * var(--scale));
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}

.label-tiny {
  font-family: var(--font-mono);
  font-size: calc(9.5px * var(--scale));
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 500;
}

.mono { font-family: var(--font-mono); }
.num  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

a { color: inherit; text-decoration: none; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===================== Top bar ===================== */

.topbar {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
  overflow: visible;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
  flex: 1 1 auto;
  max-width: min(900px, calc(100vw - 200px));
  padding-block: 4px;
}

.brand-link {
  display: flex;
  align-items: center;
  max-width: 100%;
  line-height: normal;
  color: inherit;
  text-decoration: none;
}

.brand-link:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

.brand-mark {
  width: 30px; height: 30px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--bg);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-logo {
  display: block;
  width: min(100%, min(520px, calc(100vw - 220px)));
  height: auto;
  max-height: 96px;
  object-fit: contain;
  object-position: left center;
  flex-shrink: 1;
}

.auth-demo {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.search {
  position: relative;
  max-width: 520px;
  width: 100%;
  justify-self: center;
}
.search input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px 9px 36px;
  border-radius: var(--radius);
  font: inherit;
  font-size: 13px;
}
.search input::placeholder { color: var(--text-dim); }
.search input:focus { outline: 1px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.search svg {
  position: absolute;
  left: 12px;
  top: 50%; transform: translateY(-50%);
  color: var(--text-dim);
}
.search kbd {
  position: absolute;
  right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  background: var(--bg-soft);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rate-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.rate-chip .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--pass);
}
.rate-chip.warn .dot { background: var(--warn); }
.rate-chip.fail .dot { background: var(--fail); }

.auth-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.auth-chip .avatar {
  width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), oklch(0.6 0.13 60));
  color: var(--bg);
  display: grid; place-items: center;
  font-size: 9px;
  font-weight: 600;
}

.btn {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:hover { background: var(--bg-raised); border-color: var(--text-dim); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--bg-soft); }

/* ===================== Portfolio strip ===================== */

.portfolio {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr 1fr;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.portfolio .cell {
  padding: 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-right: 1px solid var(--border-soft);
  position: relative;
}
.portfolio .cell:last-child { border-right: 0; }
.portfolio .cell .label { color: var(--text-dim); }
.portfolio .value {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.portfolio .value .unit { color: var(--text-dim); font-size: 18px; margin-left: 2px; }
.portfolio .delta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.portfolio .delta.pos { color: var(--pass); }
.portfolio .delta.neg { color: var(--fail); }

.distrib {
  display: flex;
  height: 8px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--bg-soft);
  margin-top: 4px;
}
.distrib > * { height: 100%; }
.distrib .seg-pass { background: var(--pass); }
.distrib .seg-warn { background: var(--warn); }
.distrib .seg-fail { background: var(--fail); }

.distrib-legend {
  display: flex;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 4px;
}
.distrib-legend span::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}
.distrib-legend .l-pass::before { background: var(--pass); }
.distrib-legend .l-warn::before { background: var(--warn); }
.distrib-legend .l-fail::before { background: var(--fail); }

/* ===================== Main layout ===================== */

.main {
  display: grid;
  grid-template-columns: 220px 380px 1fr;
  flex: 1;
  min-height: 0;
}
.main > * { min-height: 0; }

/* ----- Rail (filters) ----- */

.rail {
  border-right: 1px solid var(--border);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: var(--bg);
  overflow-y: auto;
}
.rail-section { display: flex; flex-direction: column; gap: 8px; }
.rail-section .label { margin-bottom: 4px; }

.filter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: background 120ms ease, color 120ms ease;
}
.filter-item:hover { background: var(--bg-soft); color: var(--text); }
.filter-item.active {
  background: var(--accent-soft);
  color: var(--text);
}
.filter-item .left { display: flex; align-items: center; gap: 10px; }
.filter-item .dot {
  width: 7px; height: 7px; border-radius: 50%;
}
.filter-item .dot.pass { background: var(--pass); }
.filter-item .dot.warn { background: var(--warn); }
.filter-item .dot.fail { background: var(--fail); }
.filter-item .dot.all  { background: var(--text-dim); }
.filter-item .count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.filter-item.active .count { color: var(--text-muted); }

/* ----- Repo list ----- */

.list-pane {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}
.list-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.list-head-left {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
  min-width: 0;
}
.btn-sm {
  font-size: 10.5px;
  padding: 5px 10px;
  letter-spacing: 0.04em;
}
.list-head .title {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}
.list-head .count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.sort-select {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
}

.repo-list {
  flex: 1;
  overflow-y: auto;
}

.repo-row {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 12px;
  transition: background 120ms ease;
  position: relative;
}
.repo-row .repo-pick {
  padding-top: 2px;
}
.repo-row .repo-pick input {
  cursor: pointer;
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}
.repo-row::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: transparent;
  transition: background 120ms ease;
}
.repo-row:hover { background: var(--bg-soft); }
.repo-row.selected {
  background: var(--bg-soft);
}
.repo-row.selected::before { background: var(--accent); }

.repo-row .name {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.005em;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.repo-row .name .vis-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
}
.repo-row .name .vis-dot.public { background: var(--pass); }

.repo-row .desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.repo-meta {
  display: flex;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
  align-items: center;
}
.repo-meta .lang-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.repo-meta .lang-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim);
}

/* lang colors */
.lang-dot[data-lang="Python"]     { background: #3572A5; }
.lang-dot[data-lang="TypeScript"] { background: #3178C6; }
.lang-dot[data-lang="Rust"]       { background: #DEA584; }
.lang-dot[data-lang="Go"]         { background: #00ADD8; }
.lang-dot[data-lang="PHP"]        { background: #777BB4; }

/* ===== QA visualization (mode-switched via body.viz-*) ===== */

.qa-strip {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.qa-pip {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--unknown);
}
.qa-pip.pass { background: var(--pass); }
.qa-pip.warn { background: var(--warn); }
.qa-pip.fail { background: var(--fail); }
.qa-pip.unknown { background: var(--unknown); }

.qa-pips {
  display: flex; gap: 4px;
  margin-top: 8px;
}
.qa-pips .pip {
  width: 18px; height: 4px; border-radius: 2px;
  background: var(--unknown);
}
.qa-pips .pip.pass { background: var(--pass); }
.qa-pips .pip.warn { background: var(--warn); }
.qa-pips .pip.fail { background: var(--fail); }
.qa-pips .pip.unknown { background: var(--unknown); }

.qa-bar-row {
  display: flex; gap: 2px;
  margin-top: 8px;
  height: 6px;
}
.qa-bar-row .seg {
  flex: 1;
  border-radius: 2px;
  background: var(--bg-soft);
  position: relative;
  overflow: hidden;
}
.qa-bar-row .seg .fill {
  position: absolute;
  left: 0; bottom: 0;
  width: 100%;
}
.qa-bar-row .seg.pass .fill { background: var(--pass); }
.qa-bar-row .seg.warn .fill { background: var(--warn); }
.qa-bar-row .seg.fail .fill { background: var(--fail); }
.qa-bar-row .seg.unknown .fill { background: var(--unknown); }

/* score "thumb" — ring or badge */
.score-thumb {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  position: relative;
  flex-shrink: 0;
}
.score-ring {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.score-ring .ring-bg { stroke: var(--bg-soft); }
.score-ring .ring-fg { stroke: var(--pass); transition: stroke-dasharray 240ms ease; }
.score-thumb.warn .score-ring .ring-fg { stroke: var(--warn); }
.score-thumb.fail .score-ring .ring-fg { stroke: var(--fail); }
.score-thumb.unknown .score-ring .ring-fg { stroke: var(--unknown); }
.score-thumb .score-num {
  position: absolute;
  inset: 0;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.score-thumb.unknown .score-num { color: var(--text-dim); }

/* score-badge (bar mode) */
.score-badge-large {
  min-width: 56px;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 14px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.score-badge-large.pass { background: var(--pass-soft); color: var(--pass); border-color: var(--pass-soft); }
.score-badge-large.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-soft); }
.score-badge-large.fail { background: var(--fail-soft); color: var(--fail); border-color: var(--fail-soft); }
.score-badge-large.unknown { color: var(--text-dim); }
.score-badge-large .lbl {
  display: block;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-top: 2px;
}

/* ===================== Detail pane ===================== */

.detail {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg-panel);
}

.detail-empty {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.detail-empty .ascii {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  white-space: pre;
  line-height: 1.4;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.6;
}

.detail-head {
  padding: 28px 32px 22px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 28px;
}
.detail-head h1 {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.detail-head h1 .org { color: var(--text-dim); }
.detail-head .blurb {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 70ch;
  margin-bottom: 14px;
}
.detail-meta {
  display: flex;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  flex-wrap: wrap;
}
.detail-meta b { color: var(--text-muted); font-weight: 500; }

.detail-head-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}
.gauge {
  width: 96px; height: 96px;
  position: relative;
}
.gauge svg { transform: rotate(-90deg); }
.gauge .gauge-num {
  position: absolute;
  inset: 0;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.gauge .gauge-lbl {
  text-align: center;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.gauge.pass .gauge-lbl { color: var(--pass); }
.gauge.warn .gauge-lbl { color: var(--warn); }
.gauge.fail .gauge-lbl { color: var(--fail); }

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-body { padding: 8px 32px 40px; }

.section {
  padding: 22px 0;
  border-bottom: 1px solid var(--border-soft);
}
.section:last-child { border-bottom: 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-head .label {
  color: var(--text-muted);
}
.section-head .meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

/* QA check rows */
.check-row {
  display: grid;
  grid-template-columns: 28px 1fr 60px;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  align-items: start;
}
.check-row:last-child { border-bottom: 0; }
.check-row .chip {
  width: 24px; height: 24px;
  border-radius: 4px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  background: var(--unknown);
  color: var(--bg);
}
.check-row .chip.pass { background: var(--pass); color: var(--bg); }
.check-row .chip.warn { background: var(--warn); color: var(--bg); }
.check-row .chip.fail { background: var(--fail); color: var(--bg); }

.check-row .body .name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}
.check-row .body .bar {
  height: 4px;
  background: var(--bg-soft);
  border-radius: 2px;
  overflow: hidden;
  margin: 6px 0 8px;
  max-width: 320px;
}
.check-row .body .bar > div { height: 100%; }
.check-row .body .bar.pass > div { background: var(--pass); }
.check-row .body .bar.warn > div { background: var(--warn); }
.check-row .body .bar.fail > div { background: var(--fail); }

.check-row .body .recs {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.check-row .body .recs ul { padding-left: 18px; margin-top: 4px; }
.check-row .body .recs li { padding: 2px 0; }

.check-row .score {
  font-family: var(--font-mono);
  font-size: 16px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text);
}
.check-row .score .small {
  display: block;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 2px;
}
.check-row.pass .score { color: var(--pass); }
.check-row.warn .score { color: var(--warn); }
.check-row.fail .score { color: var(--fail); }

/* Missing items */
.missing-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.miss-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.miss-row .ico {
  width: 26px; height: 26px;
  border-radius: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--text-muted);
}
.miss-row .name {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
}
.miss-row .desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.prio {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.prio.critical { color: var(--fail); border-color: color-mix(in oklab, var(--fail) 50%, transparent); background: var(--fail-soft); }
.prio.high     { color: var(--warn); border-color: color-mix(in oklab, var(--warn) 50%, transparent); background: var(--warn-soft); }
.prio.medium   { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 50%, transparent); background: var(--accent-soft); }
.prio.low      { color: var(--text-dim); }

.btn-fix {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}
.btn-fix:hover { border-color: var(--accent); color: var(--accent); }

/* Drawer mode for the detail panel */
body.detail-drawer .main { grid-template-columns: 220px 1fr; }
body.detail-drawer .detail {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(820px, 100vw);
  z-index: 60;
  background: var(--bg-panel);
  box-shadow: -20px 0 60px rgba(0,0,0,0.4);
  transform: translateX(100%);
  transition: transform 240ms ease;
}
body.detail-drawer .detail.open { transform: translateX(0); }
body.detail-drawer .detail-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease;
}
body.detail-drawer .detail-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
body:not(.detail-drawer) .detail-backdrop { display: none; }
body:not(.detail-drawer) .detail-close { display: none; }

.detail-close {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: transparent;
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.detail-close:hover { color: var(--text); border-color: var(--text-dim); }

/* ===================== Density modes ===================== */

body.density-compact .repo-row { padding: 10px 20px; }
body.density-compact .repo-row .desc { display: none; }
body.density-compact .repo-row .qa-strip,
body.density-compact .repo-row .qa-pips,
body.density-compact .repo-row .qa-bar-row { margin-top: 6px; }
body.density-compact .portfolio .cell { padding: 14px 24px; }
body.density-compact .portfolio .value { font-size: 24px; }
body.density-compact .detail-head { padding: 22px 32px 18px; }
body.density-compact .check-row { padding: 10px 0; }

body.density-spacious .repo-row { padding: 20px 24px; }
body.density-spacious .portfolio .cell { padding: 26px 28px; }
body.density-spacious .portfolio .value { font-size: 36px; }
body.density-spacious .detail-head { padding: 36px 40px 28px; }
body.density-spacious .detail-body { padding: 12px 40px 56px; }
body.density-spacious .check-row { padding: 18px 0; }

/* ===================== Tweaks panel ===================== */

#tweaks-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 280px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
  padding: 14px;
  z-index: 200;
  display: none;
}
#tweaks-panel.open { display: block; }
#tweaks-panel header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
#tweaks-panel header .label {
  color: var(--accent);
}
#tweaks-panel header button {
  color: var(--text-muted); font-size: 14px;
}
.tw-section { margin-bottom: 14px; }
.tw-section:last-child { margin-bottom: 0; }
.tw-section .lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.tw-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.tw-row.three { grid-template-columns: repeat(3, 1fr); }
.tw-row.two { grid-template-columns: repeat(2, 1fr); }
.tw-opt {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--text-muted);
  text-align: center;
}
.tw-opt.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.tw-swatch-row { display: flex; gap: 8px; }
.tw-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
}
.tw-swatch.active { border-color: var(--text); transform: scale(1.06); }

/* ===================== Toast ===================== */
#toast-container {
  position: fixed;
  bottom: 16px; right: 16px;
  z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(420px, 92vw);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 10px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  font-family: var(--font-sans);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  animation: slideIn 240ms ease;
}
.toast.success { border-left-color: var(--pass); }
.toast.error   { border-left-color: var(--fail); }
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ===================== Progress modal ===================== */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center; justify-content: center;
  z-index: 500;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: min(480px, 92vw);
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.modal h3 {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
.modal .status { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.modal .bar {
  height: 6px; background: var(--bg-soft); border-radius: 3px; overflow: hidden;
}
.modal .bar > div {
  height: 100%; background: var(--accent); transition: width 240ms ease;
}
.modal .details {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
  text-align: center;
}
.modal-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}
.modal-actions .btn {
  font-size: 11px;
}

/* ===================== Responsive ===================== */

@media (max-width: 1180px) {
  .main { grid-template-columns: 64px 360px 1fr; }
  .rail { padding: 14px 8px; }
  .rail .label, .filter-item .count, .filter-item .lbl-text { display: none; }
  .filter-item { justify-content: center; padding: 10px; }
  .filter-item .dot { width: 10px; height: 10px; }
}

@media (max-width: 880px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; padding: 12px 16px; gap: 12px; }
  .brand { max-width: min(900px, calc(100vw - 108px)); }
  .brand-logo { width: min(100%, calc(100vw - 108px)); max-height: 88px; }
  .search { display: none; }
  .portfolio { grid-template-columns: 1fr 1fr; }
  .portfolio .cell { padding: 14px 16px; border-bottom: 1px solid var(--border-soft); }
  .main { display: block; }
  .rail { flex-direction: row; padding: 12px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .filter-item { padding: 6px 10px; white-space: nowrap; }
  .list-pane { border-right: 0; border-bottom: 1px solid var(--border); }
  .detail { min-height: 60vh; }
}
