/* Repository-insights dashboard. See ../DESIGN.md; the page CSP forbids inline styles, so every hue is a class. */
:root {
  color-scheme: light;
  --plane: #f4f5f7; --surface: #ffffff; --surface-2: #f8f9fa;
  --ink: #111316; --ink-2: #4a4f57; --muted: #646a73;
  --hair: #dfe2e6; --hair-strong: #c9cdd3;
  --accent: #2a78d6; --accent-ink: #1c5cab; --accent-wash: rgba(42,120,214,.09);
  --seq-0: #eceff2; --seq-1: #cde2fb; --seq-2: #86b6ef; --seq-3: #3987e5; --seq-4: #1c5cab; --seq-5: #0d366b;
  --bar: #3987e5; --bar-hover: #1c5cab; --ref: #646a73;
  --m1: #eb6834; --m2: #1baf7a; --m3: #eda100; --m4: #e87ba4; --m5: #008300; --m6: #6250d6;
  --pop-shadow: 0 8px 24px rgba(17,19,22,.14), 0 1px 2px rgba(17,19,22,.08);
  --danger: #c23b3a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane: #0f1012; --surface: #17181a; --surface-2: #1d1f22;
    --ink: #eceef1; --ink-2: #b9bec6; --muted: #8d939c;
    --hair: #2a2d31; --hair-strong: #3a3e44;
    --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: rgba(57,135,229,.16);
    --seq-0: #222428; --seq-1: #184f95; --seq-2: #256abf; --seq-3: #3987e5; --seq-4: #6da7ec; --seq-5: #b7d3f6;
    --bar: #3987e5; --bar-hover: #86b6ef; --ref: #8d939c;
    --m1: #d95926; --m2: #199e70; --m3: #c98500; --m4: #d55181; --m5: #008300; --m6: #9085e9;
    --pop-shadow: 0 8px 24px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
    --danger: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0f1012; --surface: #17181a; --surface-2: #1d1f22;
  --ink: #eceef1; --ink-2: #b9bec6; --muted: #8d939c;
  --hair: #2a2d31; --hair-strong: #3a3e44;
  --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: rgba(57,135,229,.16);
  --seq-0: #222428; --seq-1: #184f95; --seq-2: #256abf; --seq-3: #3987e5; --seq-4: #6da7ec; --seq-5: #b7d3f6;
  --bar: #3987e5; --bar-hover: #86b6ef; --ref: #8d939c;
  --m1: #d95926; --m2: #199e70; --m3: #c98500; --m4: #d55181; --m5: #008300; --m6: #9085e9;
  --pop-shadow: 0 8px 24px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
    --danger: #e66767;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--plane); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* Top bar */
.top {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--hair);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.brand svg { display: block; }
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--hair-strong); color: var(--ink-2); font-size: 12px; white-space: nowrap;
}
.top .spacer { flex: 1; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border: 1px solid var(--hair-strong); border-radius: 6px; background: var(--surface-2); cursor: pointer;
  font-size: 13px; font-weight: 500; transition: background-color .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--accent-wash); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 14px; height: 14px; }

.page { max-width: 1240px; margin: 0 auto; padding: 28px 24px 48px; }

/* Opening sentence */
.lede { margin-bottom: 20px; }
.sentence { font-size: 28px; line-height: 1.35; font-weight: 400; margin: 0 0 6px; letter-spacing: -0.01em; max-width: 30em; text-wrap: balance; }
.sentence strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.slot {
  display: inline-flex; align-items: baseline; gap: 4px; padding: 0 6px; margin: 0 -1px;
  border: 0; border-radius: 6px; background: var(--accent-wash); color: var(--accent-ink);
  font: inherit; cursor: pointer; transition: background-color .15s ease;
}
.slot:hover, .slot[aria-expanded="true"] { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.slot svg { width: .55em; height: .55em; align-self: center; }
.sub { font-size: 16px; color: var(--ink-2); margin: 0; }
.sub .slot { font-size: 16px; padding: 0 5px; }

.counters {
  display: flex; flex-wrap: wrap; margin: 18px 0 0; padding: 0;
  border: 1px solid var(--hair); border-radius: 8px; background: var(--surface);
}
.counter { flex: 1 1 160px; padding: 12px 16px; border-left: 1px solid var(--hair); min-width: 0; }
.counter:first-child { border-left: 0; }
.counter dt { font-size: 12px; color: var(--muted); }
.counter dd { margin: 2px 0 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.counter .value { font-size: 20px; font-weight: 600; }
.delta { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.delta svg { width: 10px; height: 10px; vertical-align: -1px; }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.col { display: grid; gap: 20px; min-width: 0; }
@media (max-width: 1023px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.box { background: var(--surface); border: 1px solid var(--hair); border-radius: 8px; min-width: 0; }
.box-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between;
  padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--hair); border-radius: 8px 8px 0 0;
}
.box-head h2 { font-size: 14px; font-weight: 600; margin: 0; }
.box-head .hint { font-size: 12px; color: var(--muted); }
.box-body { padding: 16px; }
details.table-view { border-top: 1px solid var(--hair); }
details.table-view > summary { padding: 8px 16px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
details.table-view > div { padding: 0 16px 12px; max-height: 280px; overflow: auto; }

/* Calendar */
.cal-wrap { overflow-x: auto; padding-bottom: 4px; }
.cal { display: grid; grid-template-columns: 28px auto; gap: 6px; width: max-content; }
.cal-days { display: grid; grid-template-rows: repeat(7, 12px); gap: 3px; font-size: 10.5px; color: var(--muted); padding-top: 18px; }
.cal-days span { line-height: 12px; }
.cal-months { position: relative; height: 15px; font-size: 10.5px; color: var(--muted); margin-bottom: 3px; }
.cal-months span { position: absolute; top: 0; }
.cal-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); grid-auto-columns: 12px; gap: 3px; }
.cal-grid:focus-visible { outline-offset: 4px; }
.cell { width: 12px; height: 12px; border-radius: 2px; background: var(--seq-0); outline: 1px solid rgba(127,127,127,.06); outline-offset: -1px; }
.cell[data-l="1"] { background: var(--seq-1); } .cell[data-l="2"] { background: var(--seq-2); }
.cell[data-l="3"] { background: var(--seq-3); } .cell[data-l="4"] { background: var(--seq-4); }
.cell[data-l="5"] { background: var(--seq-5); }
.cell.none { opacity: .4; }
.cal-steps { margin: 6px 0 0; font-size: 12px; }
.table-note { margin: 10px 0 0; font-size: 12px; }
.cal-range { position: relative; height: 16px; margin-top: 4px; }
.cal-range span { position: absolute; top: 0; height: 6px; border: 1.5px solid var(--accent); border-top: 0; border-radius: 0 0 3px 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cell.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--ink); }
.cal-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
.scale { display: inline-flex; align-items: center; gap: 3px; }
.scale .cell { display: inline-block; }

/* Bars */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 200px; overflow: visible; }
.chart .grid line { stroke: var(--hair); }
.chart .axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--bar); transition: fill .15s ease; }
.chart .bar.hot { fill: var(--bar-hover); }
.chart .ref { stroke: var(--ref); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .ref-label { fill: var(--ink-2); font-size: 11px; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.chart .hit { fill: transparent; cursor: default; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--hair); vertical-align: middle; }
td.mono, td.r, td.delta { white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
.tree-wrap { overflow-x: auto; }
.tree { min-width: 620px; }
.tree tr.company td { background: var(--surface); }
.tree tr.company td:first-child { font-weight: 600; }
.tree tr.project td:first-child { padding-left: 38px; }
.tree tr.project td { color: var(--ink-2); }
.tree tr.project[hidden] { display: none; }
.toggle {
  width: 22px; height: 22px; display: inline-grid; place-items: center; margin-right: 6px; vertical-align: middle;
  border: 0; border-radius: 4px; background: transparent; cursor: pointer; color: var(--muted);
}
.toggle:hover { background: var(--accent-wash); color: var(--ink); }
.toggle svg { width: 12px; height: 12px; transition: transform .18s ease; }
.toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.linkish { border: 0; background: none; padding: 0; cursor: pointer; font-weight: inherit; text-align: left; }
.linkish:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.share { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.share-track { flex: 1; height: 6px; border-radius: 3px; background: var(--seq-0); overflow: hidden; }
.share-fill { height: 100%; background: var(--ink-2); border-radius: 3px; }
.share span { width: 40px; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ink-2); }
.chips { display: inline-flex; gap: 4px; margin-left: 8px; flex-wrap: wrap; vertical-align: middle; }
.chip { padding: 0 6px; border: 1px solid var(--hair); border-radius: 999px; font-size: 11.5px; color: var(--muted); }
.note-inline { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.mix { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.mix-top { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.minibar { display: flex; gap: 1px; width: 84px; height: 8px; border-radius: 2px; overflow: hidden; }
.minibar i { display: block; height: 100%; }

/* Language bar */
.langbar { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; margin-bottom: 14px; }
.langbar i { display: block; height: 100%; min-width: 2px; transition: opacity .15s ease; }
.langbar.dim i:not(.hot) { opacity: .3; }
.models { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.models li { display: grid; grid-template-columns: 12px minmax(0,1fr) auto auto; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; }
.models li:hover, .models li.hot { background: var(--surface-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); }
.models .name { display: flex; flex-direction: column; min-width: 0; }
.models .name .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.models .client { font-size: 11.5px; color: var(--muted); }
.models .pct { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.models .val { font-variant-numeric: tabular-nums; font-weight: 500; min-width: 64px; text-align: right; }
.group-label { font-size: 11.5px; color: var(--muted); margin: 10px 6px 2px; }
.group-label:first-child { margin-top: 0; }
.insight { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--hair); border-radius: 6px; background: var(--surface-2); font-size: 13px; color: var(--ink-2); }
.insight b { color: var(--ink); font-weight: 600; }

/* Coverage and not-measured */
.meter-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 12px; padding: 8px 0; border-bottom: 1px solid var(--hair); }
.meter-row:last-child { border-bottom: 0; padding-bottom: 0; }
.meter-row:first-child { padding-top: 0; }
.meter-row .label { font-weight: 500; }
.meter-row .fig { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.meter-row .why { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
.todo { display: grid; grid-template-columns: 18px minmax(0,1fr); gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--hair); }
.todo:first-child { padding-top: 0; } .todo:last-child { border-bottom: 0; padding-bottom: 0; }
.todo svg { width: 16px; height: 16px; color: var(--muted); margin-top: 2px; }
.todo .t { font-weight: 500; }
.todo .d { grid-column: 2; font-size: 12.5px; color: var(--muted); }

/* Tabs */
.tabs { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--hair); border-radius: 7px; background: var(--surface); }
.tab { border: 0; background: transparent; padding: 3px 10px; border-radius: 5px; font-size: 12.5px; cursor: pointer; color: var(--ink-2); }
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab[aria-selected="true"], .tab[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent-ink); font-weight: 600; }

/* Empty */
.empty { padding: 28px 8px; text-align: center; color: var(--muted); font-size: 13px; }

/* Popover menus and tooltip */
.menu {
  position: fixed; inset: auto; margin: 0; padding: 4px; min-width: 220px;
  border: 1px solid var(--hair-strong); border-radius: 8px; background: var(--surface); color: var(--ink);
  box-shadow: var(--pop-shadow); font-size: 14px;
}
.menu-title { font-size: 11.5px; color: var(--muted); padding: 6px 10px 4px; }
.menu [role="menuitemradio"] {
  display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border: 0; border-radius: 5px; background: transparent; cursor: pointer; text-align: left;
}
.menu [role="menuitemradio"]:hover, .menu [role="menuitemradio"]:focus-visible { background: var(--accent-wash); outline: none; }
.menu [role="menuitemradio"] svg { width: 14px; height: 14px; visibility: hidden; color: var(--accent-ink); }
.menu [aria-checked="true"] svg { visibility: visible; }
.menu [aria-checked="true"] { font-weight: 600; }
.menu .aside { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; }
.menu hr { border: 0; border-top: 1px solid var(--hair); margin: 4px 0; }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none; max-width: 280px;
  padding: 8px 10px; border-radius: 6px; border: 1px solid var(--hair-strong);
  background: var(--surface); color: var(--ink); box-shadow: var(--pop-shadow); font-size: 12.5px;
}
.tooltip .tt-title { font-weight: 600; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; }
.tooltip .tt-row span:first-child { color: var(--ink-2); }
.tooltip .dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; box-shadow: none; }

footer.defs { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--hair); display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 28px; font-size: 12.5px; color: var(--ink-2); }
footer.defs dt { font-weight: 600; color: var(--ink); }
footer.defs dd { margin: 2px 0 0; }

@media (max-width: 640px) {
  .top { padding: 10px 16px; }
  .page { padding: 20px 16px 40px; }
  .sentence { font-size: 22px; }
  .counter { flex-basis: 50%; border-left: 0; border-top: 1px solid var(--hair); }
  .counter:nth-child(-n+2) { border-top: 0; }
  .counter:nth-child(even) { border-left: 1px solid var(--hair); }
  #breakdown { overflow-x: auto; padding: 12px; }
  #breakdown .share { min-width: 84px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Brand mark, model hues and the token form */
.brand .b1 { fill: var(--seq-1); } .brand .b2 { fill: var(--seq-2); }
.brand .b3 { fill: var(--seq-3); } .brand .b4 { fill: var(--seq-4); }
.m1 { background: var(--m1); } .m2 { background: var(--m2); } .m3 { background: var(--m3); }
.m4 { background: var(--m4); } .m5 { background: var(--m5); } .m6 { background: var(--m6); }
.m0 { background: var(--muted); }
.token { display: flex; gap: 6px; align-items: center; }
.token[hidden], .btn[hidden] { display: none; }
.token input {
  height: 30px; width: 220px; padding: 0 10px; border: 1px solid var(--hair-strong); border-radius: 6px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 13px;
}
.status { margin: 0 0 16px; color: var(--ink-2); }
.status[hidden] { display: none; }
.status.error { color: var(--danger); }
.toggle-spacer { display: inline-block; width: 28px; }
.chip { text-decoration: none; }
a.chip:hover { color: var(--accent-ink); border-color: var(--accent); }
.insight a { color: inherit; }

/* Administration page */
a.btn { color: var(--ink); text-decoration: none; }
a.brand { color: var(--ink); text-decoration: none; }
.btn.small { height: 26px; padding: 0 10px; font-size: 12.5px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: var(--danger); }
.btn.primary.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.primary.danger:hover { filter: brightness(.92); }
.btn:disabled { opacity: .55; cursor: progress; }
.page.narrow { max-width: 980px; }
.page-title { font-size: 24px; font-weight: 600; margin: 0 0 16px; letter-spacing: -0.01em; }
.table-scroll { overflow-x: auto; padding: 4px 8px 8px; }
.admin-table { min-width: 620px; }
.admin-table td:last-child { text-align: right; width: 1%; white-space: nowrap; }
.admin-table .device-name { font-weight: 500; }
.repo-list { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.chip.warn { color: var(--ink); border-color: var(--m3); background: color-mix(in srgb, var(--m3) 14%, transparent); }
.chip.ok { color: var(--ink-2); border-color: var(--m2); }
.chip.off { color: var(--muted); border-style: dashed; }
.dialog {
  width: min(520px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--hair-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink); box-shadow: var(--pop-shadow);
}
.dialog::backdrop { background: rgba(15,16,18,.45); }
.dialog h2 { font-size: 17px; font-weight: 600; margin: 0 0 6px; }
.dialog p { margin: 0 0 14px; font-size: 13px; }
.field { display: grid; gap: 4px; margin-bottom: 12px; font-size: 13px; font-weight: 500; }
.field input, .field textarea {
  width: 100%; padding: 6px 10px; border: 1px solid var(--hair-strong); border-radius: 6px;
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 400; font-size: 13.5px;
}
.field textarea { resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.field [aria-invalid="true"] { border-color: var(--danger); }
.problems { margin: 0 0 12px; padding-left: 18px; color: var(--danger); font-size: 13px; }
.problems:empty { display: none; }
p.problems { padding-left: 0; }
.consequences { margin: 10px 0 14px; padding-left: 18px; font-size: 13px; color: var(--ink-2); display: grid; gap: 6px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
.head-actions { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-actions { display: inline-flex; gap: 6px; }
.secret { display: flex; gap: 8px; margin-bottom: 12px; }
.secret input {
  flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid var(--hair-strong); border-radius: 6px;
  background: var(--surface-2); color: var(--ink); font-size: 12.5px;
}
