:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --hover: rgba(21, 23, 28, .045);
  --line: #e4e6ea;
  --line-strong: #d2d5db;
  --ink: #15171c;
  --ink-2: #454c59;
  --muted: #697080;
  --focus: #3b6fe0;
  --header-h: 52px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);

  --close-solid: #6d28d9; --close-tint: #f5f0ff; --close-line: #d9c8fb;
  --critical-bg: #fdecec; --critical-fg: #9f1d1d; --critical-dot: #d03b3b;
  --serious-bg: #fdf0e8;  --serious-fg: #93390f;  --serious-dot: #e2703f;
  --warning-bg: #fcf5e1;  --warning-fg: #724d00;  --warning-dot: #d99a00;
  --security-bg: #eaf0fd; --security-fg: #1f3f8f; --security-dot: #3b6fe0;
  --good-bg: #e7f5ea;     --good-fg: #15622a;     --good-dot: #1f9d3a;
  --neutral-bg: #eff0f3;  --neutral-fg: #4b5260;  --neutral-dot: #9aa0aa;
  --info-bg: #edf1f6;     --info-fg: #334155;     --info-dot: #64748b;
  --add: #1a7f37; --del: #b42318;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #161920;
    --surface-2: #1b1f27;
    --hover: rgba(255, 255, 255, .04);
    --line: #262b34;
    --line-strong: #353b47;
    --ink: #e9ebf0;
    --ink-2: #b7bdc9;
    --muted: #8d94a3;
    --focus: #7aa2ff;
    --shadow: none;

    --close-solid: #7c4ddb; --close-tint: #1d1730; --close-line: #43307a;
    --critical-bg: #3a1618; --critical-fg: #ffb4b0; --critical-dot: #ef5a5a;
    --serious-bg: #38210f;  --serious-fg: #ffc3a0;  --serious-dot: #ec835a;
    --warning-bg: #332910;  --warning-fg: #f3d27c;  --warning-dot: #e6ad1d;
    --security-bg: #172440; --security-fg: #aac4ff; --security-dot: #6f97ff;
    --good-bg: #13301d;     --good-fg: #9be3ad;     --good-dot: #3cc062;
    --neutral-bg: #232730;  --neutral-fg: #b7bdc9;  --neutral-dot: #7b8290;
    --info-bg: #1f2530;     --info-fg: #c1cad8;     --info-dot: #8a96aa;
    --add: #4ac26b; --del: #ff7b72;

    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: calc(var(--header-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.mono, kbd, .pr-number { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.num, .filter-count, .board-count { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 50; padding: 8px 12px; background: var(--ink); color: var(--bg); border-radius: 8px; text-decoration: none; }
.skip-link:focus { top: 8px; }

/* App header */
.app-header {
  position: sticky; top: 0; z-index: 20;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.app-header-inner { max-width: 1480px; height: 100%; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; }
.brand-mark { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 7px; background: var(--ink); color: var(--surface); font-weight: 700; font-size: 14px; }
.brand-name { font-weight: 650; letter-spacing: -.01em; }
.brand-repo { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-repo::before { content: "/"; margin-right: 10px; color: var(--line-strong); }
.snapshot { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.snapshot-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good-dot); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good-dot) 18%, transparent); }
.snapshot.is-error .snapshot-dot { background: var(--critical-dot); box-shadow: 0 0 0 3px color-mix(in srgb, var(--critical-dot) 18%, transparent); }

/* Layout */
.layout { max-width: 1480px; margin: 0 auto; padding: 20px; display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 24px; align-items: start; }
.content { min-width: 0; display: grid; gap: 16px; }

/* Sidebar filters */
.sidebar { position: sticky; top: calc(var(--header-h) + 20px); max-height: calc(100vh - var(--header-h) - 40px); overflow-y: auto; overscroll-behavior: contain; }
.filters { position: relative; display: grid; gap: 14px; }
.filters[aria-busy="true"] { min-height: 320px; border-radius: var(--radius); background: var(--hover); }
.filter-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.filter-title { margin: 0 0 4px; padding: 0 8px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.filter {
  width: 100%; height: 30px; padding: 0 8px;
  display: flex; align-items: center; gap: 9px;
  border: 1px solid transparent; border-radius: 7px; background: transparent;
  color: var(--ink-2); text-align: left; font-size: 13.5px;
}
.filter:hover { background: var(--hover); color: var(--ink); }
.filter.active { background: var(--surface); border-color: var(--line); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.filter-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-count { color: var(--muted); font-size: 12px; font-weight: 500; }
.filter.zero .filter-name, .filter.zero .filter-count { color: var(--muted); opacity: .75; }
.filter[data-filter="should-close"]:not(.zero) .filter-count { color: var(--close-solid); font-weight: 650; }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.dot.tone-close { background: var(--close-solid); }
.dot.tone-critical { background: var(--critical-dot); }
.dot.tone-serious { background: var(--serious-dot); }
.dot.tone-warning { background: var(--warning-dot); }
.dot.tone-security { background: var(--security-dot); }
.dot.tone-good { background: var(--good-dot); }
.dot.tone-neutral { background: var(--neutral-dot); }

/* Summary cards */
.summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.card {
  display: grid; gap: 2px; padding: 12px 14px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
button.card:hover { border-color: var(--line-strong); }
.card.active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.card-label { display: flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 12.5px; font-weight: 500; }
.card-value { font-size: 26px; line-height: 1.2; font-weight: 650; letter-spacing: -.02em; }
.card-hint { color: var(--muted); font-size: 12px; }
.card.feature { background: var(--close-tint); border-color: var(--close-line); box-shadow: inset 0 3px 0 var(--close-solid), var(--shadow); }
.card.feature.active { border-color: var(--close-solid); box-shadow: inset 0 3px 0 var(--close-solid), inset 0 0 0 1px var(--close-solid); }
.card.is-loading .card-value { color: var(--line-strong); }

/* Board */
.board { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.toolbar { position: sticky; top: var(--header-h); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; }
.board-title { margin: 0; font-size: 15px; font-weight: 650; white-space: nowrap; }
.board-count { margin-left: 4px; padding: 1px 7px; border-radius: 999px; background: var(--neutral-bg); color: var(--ink-2); font-size: 12px; font-weight: 600; }
.board-count:empty { display: none; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.search {
  position: relative; display: flex; align-items: center; gap: 8px;
  width: 320px; height: 32px; padding: 0 8px 0 10px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
}
.search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
.search svg { flex: none; width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 13.5px; }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search kbd { padding: 0 5px; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--muted); font-size: 11px; line-height: 16px; }
.search:focus-within kbd { display: none; }
.sort { position: relative; display: block; }
.sort::after { content: ""; position: absolute; right: 11px; top: 12px; width: 5px; height: 5px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); pointer-events: none; }
.sort select { appearance: none; -webkit-appearance: none; height: 32px; padding: 0 28px 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 13px; cursor: pointer; }
.ghost-button { height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13px; font-weight: 500; white-space: nowrap; }
.ghost-button:hover:not(:disabled) { background: var(--hover); border-color: var(--line-strong); }
.ghost-button:disabled { opacity: .5; cursor: default; }

.table-head, .pr-main {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) minmax(170px, 280px) 150px 92px;
  grid-template-areas: "toggle pr labels status size";
  column-gap: 14px;
}
.table-head { padding: 7px 14px; border-top: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
.num { text-align: right; }

/* Rows */
.pr-list:focus { outline: none; }
.pr-row { position: relative; border-bottom: 1px solid var(--line); }
.pr-row:last-child { border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
.pr-row.is-close { box-shadow: inset 3px 0 0 var(--close-solid); }
.pr-row.is-critical { box-shadow: inset 3px 0 0 var(--critical-dot); }
.pr-main { padding: 10px 14px; align-items: start; cursor: pointer; }
.pr-row:hover { background: var(--surface-2); }
.pr-row.open { background: var(--surface-2); }
.toggle { grid-area: toggle; display: grid; place-items: center; width: 24px; height: 24px; margin-top: 1px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.toggle:hover { background: var(--hover); color: var(--ink); }
.toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.pr-row.open .toggle svg { transform: rotate(90deg); }
.cell-pr { grid-area: pr; min-width: 0; }
.pr-title { display: block; font-weight: 550; line-height: 1.35; text-decoration: none; overflow-wrap: anywhere; }
.pr-title:hover { text-decoration: underline; text-underline-offset: 2px; }
.pr-number { margin-right: 2px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.byline { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.byline .mono { font-size: 11.5px; }
.cell-labels { grid-area: labels; display: flex; flex-wrap: wrap; gap: 4px; align-content: flex-start; padding-top: 1px; }
.cell-status { grid-area: status; display: grid; gap: 2px; min-width: 0; }
.cell-size { grid-area: size; display: grid; gap: 2px; font-size: 12.5px; white-space: nowrap; }
.sub { color: var(--muted); font-size: 12px; }
.add { color: var(--add); }
.del { color: var(--del); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 7px;
  border: 1px solid transparent; border-radius: 5px;
  font-size: 11.5px; font-weight: 550; white-space: nowrap;
  background: var(--info-bg); color: var(--info-fg);
}
.badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--info-dot); }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 550; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--info-dot); flex: none; }
.tone-critical { --t-bg: var(--critical-bg); --t-fg: var(--critical-fg); --t-dot: var(--critical-dot); }
.tone-serious  { --t-bg: var(--serious-bg);  --t-fg: var(--serious-fg);  --t-dot: var(--serious-dot); }
.tone-warning  { --t-bg: var(--warning-bg);  --t-fg: var(--warning-fg);  --t-dot: var(--warning-dot); }
.tone-security { --t-bg: var(--security-bg); --t-fg: var(--security-fg); --t-dot: var(--security-dot); }
.tone-good     { --t-bg: var(--good-bg);     --t-fg: var(--good-fg);     --t-dot: var(--good-dot); }
.tone-neutral  { --t-bg: var(--neutral-bg);  --t-fg: var(--neutral-fg);  --t-dot: var(--neutral-dot); }
.tone-info     { --t-bg: var(--info-bg);     --t-fg: var(--info-fg);     --t-dot: var(--info-dot); }
.badge[class*="tone-"] { background: var(--t-bg); color: var(--t-fg); }
.badge[class*="tone-"] i, .status[class*="tone-"] i { background: var(--t-dot); }

/* "Should close" is the one solid badge, with a ⊘ glyph, so it never blends in. */
.badge.tone-close { background: var(--close-solid); color: #fff; font-weight: 650; }
.badge.tone-close i, .status.tone-close i {
  width: 9px; height: 9px; background: none;
  border: 1.5px solid currentColor; border-radius: 50%;
  background-image: linear-gradient(45deg, transparent 42%, currentColor 42%, currentColor 58%, transparent 58%);
}
.status.tone-close { color: var(--close-solid); }
@media (prefers-color-scheme: dark) { .status.tone-close { color: #b69aff; } }

/* Expanded detail */
.detail { padding: 0 14px 14px 52px; cursor: auto; }
.note { max-width: 82ch; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 13.5px; line-height: 1.55; }
.pr-row.is-close .note { border-color: var(--close-line); }
.pr-row.is-critical .note { border-color: color-mix(in srgb, var(--critical-dot) 40%, var(--line)); }
.meta { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 10px 0 0; font-size: 12.5px; }
.meta div { display: flex; gap: 6px; }
.meta .wide { flex-basis: 100%; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; color: var(--ink-2); font-weight: 500; text-transform: capitalize; }
.meta .wide dd { text-transform: none; }
.meta .conf-low { color: var(--serious-fg); }
.meta .conf-high { color: var(--good-fg); }
.links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0; font-size: 12.5px; font-weight: 550; }
.links a { color: var(--focus); text-decoration: none; }
.links a:hover { text-decoration: underline; }

/* Loading, empty, error */
.skeleton { height: 58px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, transparent 0, var(--hover) 40%, transparent 80%) 0 0 / 200% 100%, linear-gradient(var(--hover), var(--hover)) 52px 14px / 42% 12px no-repeat, linear-gradient(var(--hover), var(--hover)) 52px 34px / 22% 10px no-repeat; animation: shimmer 1.2s linear infinite; }
.skeleton:last-child { border-bottom: 0; }
@keyframes shimmer { to { background-position: -200% 0, 52px 14px, 52px 34px; } }
.state-panel { display: grid; justify-items: center; gap: 6px; padding: 56px 20px; text-align: center; }
.state-title { margin: 0; font-size: 15px; font-weight: 650; }
.state-copy { margin: 0 0 10px; max-width: 46ch; color: var(--muted); font-size: 13.5px; }
.state-panel.is-error .state-title { color: var(--critical-fg); }

/* Method & footer */
.method { padding: 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.method summary { padding: 12px 0; font-weight: 600; cursor: pointer; }
.method > p { max-width: 90ch; margin: 0 0 14px; color: var(--ink-2); font-size: 13.5px; line-height: 1.6; }
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px 20px; margin: 0 0 16px; }
.legend dt { margin-bottom: 4px; }
.legend dd { margin: 0; color: var(--muted); font-size: 12.5px; }
.footer { display: flex; justify-content: space-between; gap: 16px; padding: 4px 2px 12px; color: var(--muted); font-size: 12.5px; }
.footer p { margin: 0; }

/* Responsive */
@media (max-width: 1180px) {
  .summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .search { width: 240px; }
  .table-head, .pr-main { grid-template-columns: 24px minmax(0, 1fr) minmax(150px, 220px) 132px 84px; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 14px; }
  .sidebar { position: static; max-height: none; overflow: visible; margin: 0 -14px; }
  .filters { display: flex; gap: 6px; overflow-x: auto; padding: 0 14px 2px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .filters[aria-busy="true"] { min-height: 32px; margin: 0 14px; }
  .filter-group, .filter-group ul { display: contents; }
  .filter-title { display: none; }
  .filter { width: auto; height: 32px; padding: 0 11px; border-color: var(--line); border-radius: 999px; background: var(--surface); white-space: nowrap; }
  .filter-name { overflow: visible; }
  .filter.active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
  .content { display: contents; }
  .summary { order: -1; }
  .toolbar-row { flex-wrap: wrap; }
  .toolbar-actions { flex: 1 1 100%; }
  .search { flex: 1; width: auto; }
  .search kbd { display: none; }
  .table-head { display: none; }
  .pr-main { grid-template-columns: 24px minmax(0, 1fr) auto; grid-template-areas: "toggle pr pr" ". labels labels" ". status size"; row-gap: 8px; column-gap: 10px; }
  .cell-status, .cell-size { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
  .detail { padding-left: 48px; }
}

@media (max-width: 560px) {
  .brand-repo { display: none; }
  .app-header-inner { padding: 0 14px; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .summary .card:first-child { grid-column: 1 / -1; grid-template-columns: 1fr auto; align-items: center; }
  .summary .card:first-child .card-value { grid-row: 1 / span 2; grid-column: 2; }
  .card { padding: 10px 12px; }
  .card-value { font-size: 22px; }
  .card-hint { display: none; }
  .toolbar { position: static; }
  .toolbar-actions { flex-wrap: wrap; }
  .search { flex-basis: 100%; }
  .sort, .sort select { flex: 1; width: 100%; }
  .ghost-button#expand-all { flex: 1; }
  .pr-main { padding: 12px; column-gap: 8px; }
  .detail { padding: 0 12px 12px 12px; }
  .byline { white-space: normal; }
  .footer { flex-direction: column; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media (forced-colors: active) {
  .badge, .card, .filter.active { border-color: CanvasText; }
  .pr-row.is-close, .pr-row.is-critical { border-left: 3px solid CanvasText; }
  .dot, .badge i, .status i { forced-color-adjust: none; }
}
