/* CodeCheck UI. The CSP is "style-src 'self'" with no script-src: every style lives here
   (no style attributes in the templates) and nothing depends on JavaScript. Proportional
   sizes (severity bars, charts) are drawn as inline SVG attributes, which the CSP allows. */

:root {
  color-scheme: light dark;
  --bg: #f6f8fa; --surface: #fff; --surface-2: #f0f3f6; --line: #d8dee4; --line-soft: #eaeef2;
  --fg: #1b1f24; --fg-2: #3d4651; --muted: #59636e;
  --accent: #0f766e; --accent-hover: #115e59; --on-accent: #fff; --accent-soft: #d5f5ef;
  --high: #c62828; --medium: #9a6700; --low: #0b62c4;
  --high-soft: #fde2e2; --medium-soft: #fbeec8; --low-soft: #dcebfc;
  --bar-high: #e5534b; --bar-medium: #d4a72c; --bar-low: #4a9eed; --track: #e6eaef;
  --danger: #b42318;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14; --surface: #11161d; --surface-2: #161c24; --line: #222a35; --line-soft: #1a212b;
    --fg: #e6edf3; --fg-2: #c5d0dc; --muted: #93a1b1;
    --accent: #2dd4bf; --accent-hover: #5eead4; --on-accent: #04201c; --accent-soft: #12312c;
    --high: #ff9b9b; --medium: #f5c66a; --low: #8cc8ff;
    --high-soft: #3a1618; --medium-soft: #3a2c10; --low-soft: #0f2740;
    --bar-high: #ff7b7b; --bar-medium: #f5b83d; --bar-low: #6cb6ff; --track: #1a212b;
    --danger: #ff9b9b;
  }
}

* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 var(--sans); color: var(--fg); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
code, .mono { font-family: var(--mono); }
h1 { margin: 0; font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
h1.repo { font: 600 1.55rem var(--mono); letter-spacing: -.02em; overflow-wrap: anywhere; }
h2 { margin: 0; font-size: 1.15rem; font-weight: 600; }
h3 { margin: 0; font-size: 1rem; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 72rem; margin: 0 auto; padding: .8rem 1.5rem; display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.75rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--fg); font-weight: 700; font-size: 1.05rem; }
.brand:hover { color: var(--fg); text-decoration: none; }
.brand svg { color: var(--accent); }
.version { font: 500 .7rem var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 0 .5rem; }
.mainnav { display: flex; gap: .25rem; flex: 1 1 auto; }
.mainnav a { color: var(--muted); padding: .35rem .75rem; border-radius: 8px; font-weight: 500; }
.mainnav a:hover { color: var(--fg); background: var(--surface-2); text-decoration: none; }
.mainnav a[aria-current="page"] { color: var(--fg); background: var(--surface-2); }
.user { display: flex; align-items: center; gap: .7rem; color: var(--muted); font-size: .9rem; }
.user button { min-height: 2rem; padding: 0 .8rem; font-size: .85rem; }
.avatar { width: 1.75rem; height: 1.75rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: .72rem; font-weight: 700; }

/* Layout */
main { max-width: 72rem; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; display: flex; flex-direction: column; gap: 1.5rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; }
.page-head > div:first-child { flex: 1 1 28rem; min-width: 0; }
.back { font-size: .85rem; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: .25rem 1rem; color: var(--muted); font-size: .85rem; margin-top: .35rem; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.section-head > :first-child { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad { padding: 1.25rem 1.5rem; }
.card.hero { padding: 2rem; display: flex; flex-direction: column; gap: 1.1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); }
.stack { display: flex; flex-direction: column; gap: .75rem; }

/* Forms and buttons */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 2.5rem; padding: 0 1.1rem; font: 600 .95rem var(--sans); cursor: pointer;
  color: var(--on-accent); background: var(--accent); border: 0; border-radius: 10px; text-decoration: none; }
button:hover, .button:hover { background: var(--accent-hover); color: var(--on-accent); text-decoration: none; }
.button.secondary, button.secondary { background: transparent; color: var(--fg); border: 1px solid var(--line); font-weight: 500; }
.button.secondary:hover, button.secondary:hover { background: var(--surface-2); color: var(--fg); }
button.link { min-height: 0; padding: 0; background: none; color: var(--accent); font-weight: 500; }
button.link:hover { background: none; color: var(--accent-hover); text-decoration: underline; }
button.link.danger { color: var(--danger); }
button.big, .button.big { min-height: 3.25rem; padding: 0 1.6rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=text], select { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .8rem; }
form.inline { display: flex; gap: .6rem; flex-wrap: wrap; margin: 0; }
form.inline input[type=text] { flex: 1 1 18rem; min-width: 0; }
form.inline-form { display: inline; margin: 0; }
form.inline-form + form.inline-form { margin-left: .75rem; }
form.fields { display: grid; gap: .75rem; max-width: 24rem; }
.urlfield { flex: 1 1 22rem; display: flex; align-items: center; gap: .6rem; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 .9rem; min-height: 3.25rem; }
.urlfield:focus-within { border-color: var(--accent); }
.urlfield svg { color: var(--muted); flex: none; }
.urlfield input[type=text] { flex: 1; border: 0; background: transparent; padding: 0; font-family: var(--mono); outline: none; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-size: .82rem; color: var(--muted); }
.chip { border: 1px solid var(--line); border-radius: 99px; padding: .1rem .65rem; color: var(--fg-2); }
.chips .push { margin-left: auto; }

/* Messages */
.error { color: var(--danger); font-weight: 600; }
.alert { padding: .8rem 1rem; border-radius: 10px; border: 1px solid; font-weight: 500; }
.alert.error { background: var(--high-soft); border-color: var(--bar-high); color: var(--fg); }
.alert.warn { background: var(--medium-soft); border-color: var(--bar-medium); color: var(--fg); }
.alert.ok, .ok { color: var(--accent); font-weight: 600; }
.empty { padding: 2.5rem 1.5rem; text-align: center; color: var(--muted); }

/* Stat tiles */
.stat { padding: 1.1rem 1.25rem; }
.stat .label { color: var(--muted); font-size: .82rem; }
.stat .value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; }
.stat .value.accent { color: var(--accent); }
.stat.sev { display: block; color: var(--fg); }
.stat.sev:hover { text-decoration: none; border-color: var(--muted); }
.stat.sev.current { border-color: var(--accent); }
.stat .tag { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.stat .hint { font-size: .78rem; color: var(--muted); }
.stat.donut { display: flex; align-items: center; gap: 1.1rem; }
.delta { font-size: .82rem; margin-left: .5rem; }
.delta.up { color: var(--high); } .delta.down { color: var(--accent); } .delta.same { color: var(--muted); }

/* Severity */
.t-high { color: var(--high); } .t-medium { color: var(--medium); } .t-low { color: var(--low); }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: .15rem .55rem; border-radius: 6px; white-space: nowrap; }
.badge.high { background: var(--high-soft); color: var(--high); }
.badge.medium { background: var(--medium-soft); color: var(--medium); }
.badge.low { background: var(--low-soft); color: var(--low); }
.badge.admin { background: var(--accent-soft); color: var(--accent); }
.sevbar { display: block; width: 100%; height: 8px; border-radius: 99px; }
.sevbar .track { fill: var(--track); }
.f-high { fill: var(--bar-high); } .f-medium { fill: var(--bar-medium); } .f-low { fill: var(--bar-low); }
.s-high { stroke: var(--bar-high); } .s-medium { stroke: var(--bar-medium); } .s-low { stroke: var(--bar-low); }
.s-track { stroke: var(--track); }
.f-fg { fill: var(--fg); }
.counts { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .8rem; color: var(--muted); margin-top: .35rem; }
.counts b { font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .8rem; color: var(--fg-2); }
.legend .dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 2px; margin-right: .35rem; vertical-align: middle; }
.dot.high { background: var(--bar-high); } .dot.medium { background: var(--bar-medium); } .dot.low { background: var(--bar-low); }

/* Status pills */
.pill { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 600; padding: .15rem .65rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; }
.pill.completed { background: var(--accent-soft); color: var(--accent); }
.pill.failed { background: var(--high-soft); color: var(--high); }
.pill.active { background: var(--low-soft); color: var(--low); }
.indeterminate { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.indeterminate::after { content: ""; display: block; width: 35%; height: 100%; border-radius: 99px; background: var(--accent); animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }

/* Lists (scans, findings) */
.rows { overflow-x: auto; }
.row { display: grid; gap: 1rem; padding: .85rem 1.25rem; align-items: center; border-bottom: 1px solid var(--line-soft); }
.row:last-child { border-bottom: 0; }
.row.head { padding-block: .6rem; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; border-bottom-color: var(--line); }
.scan-row { grid-template-columns: minmax(14rem, 2.4fr) minmax(7rem, 1fr) minmax(12rem, 2.2fr) 12rem; min-width: 48rem; }
.scan-row .repo { font: 500 .9rem var(--mono); color: var(--fg); overflow-wrap: anywhere; }
.row-actions { display: flex; justify-content: flex-end; gap: .9rem; font-size: .9rem; white-space: nowrap; }
.row.head .row-actions { font-size: inherit; }
.row-actions .quiet { color: var(--muted); }
.finding { grid-template-columns: 5.5rem minmax(0, 1fr); align-items: start; }
.finding .loc { font: 500 .85rem var(--mono); color: var(--fg); overflow-wrap: anywhere; }
.finding .msg { margin-top: .2rem; overflow-wrap: anywhere; }
.finding .tags { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .4rem; font-size: .78rem; color: var(--muted); }
.finding .tags .mono { overflow-wrap: anywhere; }
.tagbox { border: 1px solid var(--line); border-radius: 6px; padding: 0 .4rem; color: var(--fg-2); }
.resolved .loc, .resolved .msg { color: var(--muted); }
.resolved .loc { text-decoration: line-through; }

table { width: 100%; border-collapse: collapse; }
.rows table { min-width: 36rem; }
th, td { text-align: left; padding: .7rem 1.25rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; overflow-wrap: break-word; }
th { white-space: nowrap; overflow-wrap: normal; color: var(--muted); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; border-bottom-color: var(--line); }
tbody tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; }

/* Filters and paging */
.segmented { display: inline-flex; flex-wrap: wrap; gap: .25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .25rem; }
.segmented a { color: var(--muted); padding: .3rem .85rem; border-radius: 7px; font-size: .9rem; }
.segmented a:hover { color: var(--fg); background: var(--surface-2); text-decoration: none; }
.segmented a.active { color: var(--fg); background: var(--surface-2); font-weight: 600; }
.pager { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; }
.pagesize { display: flex; gap: .5rem; align-items: center; margin: 0; font-size: .9rem; }
.pagesize button { min-height: 2.2rem; }
.pages { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.pages a, .pages strong, .pages span { min-width: 2.2rem; padding: .3rem .6rem; border-radius: 8px; text-align: center; }
.pages a:hover { background: var(--surface-2); text-decoration: none; }
.pages strong { background: var(--surface-2); }

/* Progress of a running scan */
.progress { display: flex; gap: .9rem; align-items: flex-start; padding: 1rem 1.25rem; }
.spinner { flex: none; width: 1.1rem; height: 1.1rem; margin-top: .2rem; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; }
.spinner.stopped { animation: none; opacity: .35; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } .indeterminate::after { animation: none; width: 100%; opacity: .5; } }

/* Coverage */
.coverage { display: flex; flex-direction: column; gap: .6rem; }

/* Trend chart */
.chart { display: block; width: 100%; height: auto; max-height: 17rem; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); font: 11px var(--sans); }
.chart a:hover rect { opacity: .8; }

/* Diff */
.diff-head { display: flex; align-items: center; gap: .6rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--line); }
.diff-head h3 { flex: 1; }
.diff-icon { width: 1.4rem; height: 1.4rem; border-radius: 6px; display: grid; place-items: center; font-weight: 700; }
.diff-icon.new { background: var(--high-soft); color: var(--high); }
.diff-icon.resolved { background: var(--accent-soft); color: var(--accent); }
.two-col { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(22rem, 100%), 1fr)); align-items: start; }
.summary { display: flex; gap: 1.5rem; flex-wrap: wrap; }

/* Sign-in */
.signin { min-height: calc(100vh - 4rem); display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: center; gap: 3rem 4.5rem; padding: 3rem 1.5rem; max-width: 72rem; margin: 0 auto; }
.signin .pitch { flex: 1 1 24rem; max-width: 34rem; display: flex; flex-direction: column; gap: 1.25rem; }
.signin .pitch h1 { font-size: 2.6rem; line-height: 1.1; letter-spacing: -.03em; }
.signin .pitch p { font-size: 1.05rem; color: var(--muted); }
.signin .panel { flex: 0 1 24rem; padding: 2rem; display: flex; flex-direction: column; gap: 1.1rem; }
.button.github { width: 100%; min-height: 3.25rem; background: var(--fg); color: var(--bg); }
.button.github:hover { background: var(--fg-2); color: var(--bg); }

@media (max-width: 40rem) {
  main { padding: 1.25rem 1rem 3rem; }
  .card.hero { padding: 1.25rem; }
  .signin .pitch h1 { font-size: 2rem; }
  .chips .push { margin-left: 0; }
  .scan-row { min-width: 0; grid-template-columns: minmax(0, 1fr) auto; gap: .6rem 1rem; }
  .scan-row > :nth-child(3) { grid-column: 1 / -1; }
  .scan-row .row-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .row.head.scan-row { display: none; }
  .stat .value { font-size: 1.6rem; }
}

details.tools { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .9rem; }
details.tools summary { cursor: pointer; font-weight: 600; }
details.tools fieldset { border: 0; margin: .8rem 0 0; padding: 0; }
details.tools legend { font-weight: 600; padding: 0; }
.check { display: flex; gap: .5rem; align-items: center; margin: .25rem 0; }
