/* Tokens. Dark is the base (an ops screen is left open), light follows the system unless the user picked. */
:root {
  --bg: #020617; --card: #0e1223; --card-2: #1a1e2f; --fg: #f8fafc; --muted: #94a3b8; --border: #334155;
  --ok: #22c55e; --warn: #f59e0b; --bad: #f87171; --info: #60a5fa; --primary: #2563eb; --ring: #60a5fa;
  --ok-bg: rgba(34,197,94,.14); --warn-bg: rgba(245,158,11,.14); --bad-bg: rgba(239,68,68,.16); --info-bg: rgba(59,130,246,.16); --idle-bg: rgba(148,163,184,.14);
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --chev: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f8fafc; --card: #ffffff; --card-2: #e9eef6; --fg: #0f172a; --muted: #475569; --border: #dbe3ef;
  --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --info: #1d4ed8; --primary: #1d4ed8; --ring: #1e40af;
  --ok-bg: #dcfce7; --warn-bg: #fef3c7; --bad-bg: #fee2e2; --info-bg: #dbeafe; --idle-bg: #e2e8f0;
  --chev: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f8fafc; --card: #ffffff; --card-2: #e9eef6; --fg: #0f172a; --muted: #475569; --border: #dbe3ef;
    --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --info: #1d4ed8; --primary: #1d4ed8; --ring: #1e40af;
    --ok-bg: #dcfce7; --warn-bg: #fef3c7; --bad-bg: #fee2e2; --info-bg: #dbeafe; --idle-bg: #e2e8f0;
    --chev: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
:root { --g: 16px; }
.wrap { max-width: 1280px; margin: 0 auto; padding: var(--g); }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
button, .btn { font: inherit; color: inherit; background: var(--card-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer; min-height: 36px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
button.danger { color: var(--bad); }
button.small { min-height: 30px; padding: 3px 10px; font-size: 12px; }
svg.i { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.brand svg { color: var(--ok); width: 22px; height: 22px; }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.who { color: var(--muted); font-size: 12px; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.dot.stale { background: var(--warn); }
.dot.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.sub { color: var(--muted); font-size: 12px; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 26px; font-weight: 600; margin-top: 2px; }
.stat .v.sm { font-size: 20px; }

.alerts { margin-bottom: 16px; display: grid; gap: 8px; }
.alert { display: flex; gap: 10px; align-items: flex-start; border-radius: 10px; padding: 10px 12px; border: 1px solid; }
.alert.critical { background: var(--bad-bg); border-color: var(--bad); }
.alert.warn { background: var(--warn-bg); border-color: var(--warn); }
.alert.ok { background: var(--ok-bg); border-color: var(--ok); }
.alert svg { margin-top: 2px; }
.alert.critical svg { color: var(--bad); } .alert.warn svg { color: var(--warn); } .alert.ok svg { color: var(--ok); }

h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 0 10px; font-weight: 600; }
h2.first { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 12px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; min-width: 0; }
.card.bad { border-color: var(--bad); }
.head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.repo { font-weight: 600; overflow-wrap: anywhere; }
a.repo { text-decoration: none; }
a.repo:hover { text-decoration: underline; }
.label { color: var(--muted); font-size: 12px; }
.foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.badge { display: inline-flex; gap: 6px; align-items: center; border-radius: 999px; padding: 3px 10px 3px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.idle, .badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.busy, .badge.app, .badge.info { background: var(--info-bg); color: var(--info); }
.badge.offline, .badge.missing, .badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.unknown, .badge.off, .badge.mute { background: var(--idle-bg); color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.kpi .k { color: var(--muted); font-size: 11px; }
.kpi .v { font-size: 18px; font-weight: 600; }
.kpi .v.warn { color: var(--warn); } .kpi .v.bad { color: var(--bad); }

.runs { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.run { width: 20px; height: 20px; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; font: 600 11px/1 var(--mono); text-decoration: none; border: 1px solid transparent; }
.run.success { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.run.failure { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.run.cancelled, .run.skipped { background: var(--idle-bg); color: var(--muted); border-color: var(--border); }
.run.in_progress { background: var(--info-bg); color: var(--info); border-color: var(--info); }
.run.queued, .run.waiting, .run.pending { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.run.success::after { content: "o"; } .run.failure::after { content: "x"; } .run.cancelled::after, .run.skipped::after { content: "-"; }
.run.in_progress::after { content: ">"; } .run.queued::after, .run.waiting::after, .run.pending::after { content: "."; }
.legend { color: var(--muted); font-size: 11px; margin-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.spark { width: 100%; height: 36px; margin-top: 10px; }
.spark polyline { fill: none; stroke: var(--info); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--info); }
.runners { margin-top: 10px; color: var(--muted); font-size: 12px; display: grid; gap: 2px; }
.err { margin-top: 8px; color: var(--bad); font-size: 12px; overflow-wrap: anywhere; }

.meter { margin: 10px 0; }
.meter .row { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.bar { height: 8px; background: var(--card-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.bar > i.warn { background: var(--warn); } .bar > i.bad { background: var(--bad); }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
td.wrap { overflow-wrap: anywhere; min-width: 160px; }
tr:last-child td { border-bottom: 0; }
td .sub { display: block; }

.row-off { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--card); border: 1px dashed var(--border); border-radius: 10px; margin-bottom: 8px; }
form.add, form.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
label.f { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
input, select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-height: 36px; min-width: 150px; }
select { appearance: none; -webkit-appearance: none; padding-right: 40px; background-image: var(--chev); background-repeat: no-repeat; background-position: right 14px center; background-size: 16px; text-overflow: ellipsis; }
.msg { font-size: 12px; color: var(--muted); margin-top: 8px; min-height: 18px; }
.msg.bad { color: var(--bad); }

.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font: 11px var(--mono); }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .b-ok { fill: var(--ok); } .chart .b-bad { fill: var(--bad); } .chart .b-mute { fill: var(--muted); opacity: .6; } .chart .b-info { fill: var(--info); }
.chart .ln { fill: none; stroke: var(--info); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--info); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 12px; flex-wrap: wrap; }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 8px; }
.timeline { display: grid; gap: 6px; font-size: 13px; max-height: 280px; overflow: auto; }
.timeline .t { display: flex; gap: 10px; align-items: center; justify-content: space-between; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(100%, 380px); padding: 22px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login form { display: grid; gap: 12px; margin-top: 16px; }
.login input { width: 100%; }

dialog { background: var(--card); color: var(--fg); border: 1px solid var(--border); border-radius: 14px; padding: 20px; width: min(92vw, 400px); }
dialog::backdrop { background: rgba(2, 6, 23, .6); }
dialog form { display: grid; gap: 12px; }
dialog input { width: 100%; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; }

.skel { background: linear-gradient(90deg, var(--card-2), var(--card), var(--card-2)); background-size: 200% 100%; animation: sh 1.4s linear infinite; border-radius: 12px; height: 190px; }
@keyframes sh { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .dot.pulse, .skel { animation: none; } }
@media (max-width: 520px) { .kpis { grid-template-columns: repeat(2, 1fr); } :root { --g: 12px; } }

/* ---------- pipelines ---------- */
.pbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 12px 0; }
.plist { display: grid; gap: 10px; }
.prow { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.prow.failed { border-color: var(--bad); }
.prow.running { border-color: var(--info); }
.phead { all: unset; box-sizing: border-box; display: grid; gap: 8px; width: 100%; padding: 12px 14px; cursor: pointer; }
.phead:hover { background: var(--card-2); }
.phead:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.ptop { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ptitle { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pchev svg { transition: transform .2s; color: var(--muted); }
.pchev.open svg { transform: rotate(180deg); }
.pmeta { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.preason { color: var(--bad); font-size: 12px; overflow-wrap: anywhere; }
.pbody { padding: 4px 14px 14px; border-top: 1px solid var(--border); }
.plinks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
a.pipelink { display: grid; gap: 8px; margin-top: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; text-decoration: none; background: var(--bg); }
a.pipelink:hover { border-color: var(--muted); }
.pl-head { display: flex; gap: 8px; align-items: center; min-width: 0; }
.pl-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

/* the four stage chips and the connectors between them */
.flow { display: flex; align-items: center; flex-wrap: wrap; row-gap: 6px; }
.fchip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px 3px 4px; border-radius: 999px; background: var(--idle-bg); color: var(--muted); }
.fchip.done { background: var(--ok-bg); color: var(--ok); }
.fchip.failed, .fchip.missing { background: var(--bad-bg); color: var(--bad); }
.fchip.running { background: var(--info-bg); color: var(--info); }
.fchip.pending { background: var(--warn-bg); color: var(--warn); }
.fchip.none, .fchip.skipped { opacity: .6; }
.fconn { width: 22px; height: 3px; border-radius: 2px; background: var(--border); flex: none; }
.fconn.done { background: var(--ok); }
.fconn.failed { background: var(--bad); }
.fconn.dim { opacity: .5; }
.fconn.flowing { background: repeating-linear-gradient(90deg, var(--info) 0 5px, transparent 5px 10px); background-size: 10px 3px; animation: flowx .7s linear infinite; }
@keyframes flowx { to { background-position: 10px 0; } }

/* the status dot: icon in a ring, a spinning arc while running */
.tdot { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; border: 2px solid var(--border); color: var(--muted); background: var(--card); position: relative; }
.tdot svg.i { width: 12px; height: 12px; stroke-width: 2.6; }
.tdot.done { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.tdot.failed, .tdot.missing { border-color: var(--bad); color: var(--bad); background: var(--bad-bg); }
.tdot.pending { border-style: dashed; color: var(--warn); border-color: var(--warn); }
.tdot.skipped, .tdot.none { opacity: .6; }
.tdot.running { border-color: var(--info-bg); border-top-color: var(--info); animation: spin .9s linear infinite; background: var(--info-bg); }
.tdot.mini { width: 14px; height: 14px; border-width: 2px; }
.fchip .tdot { width: 18px; height: 18px; border-width: 2px; }
.fchip .tdot svg.i { width: 10px; height: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* the tree */
.tree, .tkids { list-style: none; margin: 0; padding: 0; }
.tree { margin-top: 10px; }
.tnode { position: relative; padding: 5px 0; }
.trow { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tlabel { font-weight: 500; overflow-wrap: anywhere; min-width: 0; }
.tmeta { margin-left: auto; color: var(--muted); font: 12px var(--mono); white-space: nowrap; padding-left: 8px; }
a.tmeta { text-decoration: underline; }
.tnote { margin: 2px 0 0 32px; color: var(--muted); font-size: 12px; }
.tnode.pending > .trow .tlabel, .tnode.skipped > .trow .tlabel, .tnode.none > .trow .tlabel { color: var(--muted); font-weight: 400; }
.tkids { position: relative; margin-left: 10px; padding-left: 22px; }
/* the spine joins the children to the node above; its colour is the worst thing below it */
.tkids::before { content: ""; position: absolute; left: 0; top: 0; bottom: 14px; width: 3px; border-radius: 2px; background: var(--border); }
.tkids.s-done::before { background: var(--ok); }
.tkids.s-failed::before { background: var(--bad); }
.tkids.s-running::before { background: repeating-linear-gradient(180deg, var(--info) 0 6px, transparent 6px 12px); background-size: 3px 12px; animation: flowy .8s linear infinite; }
@keyframes flowy { to { background-position: 0 12px; } }
.tkids > .tnode::before { content: ""; position: absolute; left: -22px; top: 16px; width: 18px; height: 3px; background: var(--border); border-radius: 2px; }
.tkids.s-done > .tnode.done::before { background: var(--ok); }
.tkids > .tnode.failed::before, .tkids > .tnode.missing::before { background: var(--bad); }
.tkids > .tnode.running::before { background: var(--info); }
.tnode.enter { animation: tin .38s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes tin { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.tnode.running > .trow .tlabel { color: var(--info); }
.tnode.failed > .trow .tlabel { color: var(--bad); }
.treason { margin: 6px 0 4px 32px; border: 1px solid var(--bad); border-radius: 8px; background: var(--bad-bg); padding: 8px 10px; min-width: 0; }
.treason .rt { font-size: 12px; font-weight: 600; color: var(--bad); margin-bottom: 4px; }
.treason pre { margin: 0; max-height: 220px; overflow: auto; font: 12px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
dialog .dlg { display: grid; gap: 10px; }
@media (prefers-reduced-motion: reduce) {
  .fconn.flowing, .tkids.s-running::before, .tdot.running, .tnode.enter { animation: none; }
  .tdot.running { border-top-color: var(--info); }
}
@media (max-width: 520px) { .tmeta { display: none; } .tnote, .treason { margin-left: 8px; } }

/* Phones: a fingertip is about 44px. Controls grow, the dense run squares stay small but above the 24px minimum, and a repo name is a real target. */
@media (max-width: 640px) {
  button, .btn, select, input:not([type="checkbox"]) { min-height: 44px; }
  button.small { min-height: 40px; }
  .run { width: 28px; height: 28px; }
  a.repo { display: inline-block; padding: 10px 0; }
}
@media (max-width: 640px) {
  .stack, .stack tbody { display: block; }
  .stack tr:first-child { display: none; }
  .stack tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
  .stack td { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 5px 0; border: 0; text-align: right; }
  .stack td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  .stack td:not([data-label]) { justify-content: flex-end; }
}

/* A section that stays closed until it is asked for. */
details.collapse { margin-top: 18px; }
details.collapse > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; list-style: none; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 12px 0; min-height: 44px; }
details.collapse > summary::-webkit-details-marker { display: none; }
details.collapse > summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin-right: 4px; flex: none; }
details.collapse[open] > summary::before { transform: rotate(45deg); }
details.collapse > summary > span:first-child { flex: 1; }
.collapse-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.collapse-body > * { min-width: 0; }

.check { display: flex; align-items: flex-start; gap: 10px; flex-basis: 100%; color: var(--muted); font-size: 13px; cursor: pointer; min-height: 44px; align-items: center; }
.check input { width: 20px; height: 20px; min-height: 0; margin-top: 1px; flex: none; accent-color: var(--primary); }

.agents { display: grid; gap: 8px; margin: 12px 0; }
.agentrow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.agentrow .badge { white-space: normal; min-width: 0; }

.subhead { margin: 18px 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.repotitle { font-size: 22px; margin: 4px 0 2px; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.repohead { margin-bottom: 14px; align-items: flex-start; }
.repohead a.sub { text-decoration: none; }
.jump { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
details.sec { margin-top: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); padding: 0 16px; }
details.sec > summary { color: var(--fg); font-size: 14px; letter-spacing: 0; text-transform: none; font-weight: 600; padding: 12px 0; }
details.sec[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: 12px; }
details.sec .collapse-body { padding-bottom: 16px; }
details.sec .card { background: transparent; }

/* Layout: a sidebar on a desktop, a top bar and a bottom tab bar on a phone. */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.content { min-width: 0; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 14px; padding: 16px 12px; border-right: 1px solid var(--border); background: var(--card); overflow-y: auto; }
.side .brand { padding: 4px 8px 8px; }
.sidenav { display: flex; flex-direction: column; gap: 2px; }
.sidenav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; min-height: 40px; }
.sidenav a:hover, .side-repo:hover { background: var(--card-2); color: var(--fg); }
.sidenav a[aria-current="page"], .side-repo[aria-current="page"] { background: var(--card-2); color: var(--fg); box-shadow: inset 3px 0 0 var(--info); }
.side-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 4px 12px; }
.side-repos { display: flex; flex-direction: column; gap: 2px; }
.side-repo { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; min-height: 36px; }
.sdot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ok); }
.sdot.bad { background: var(--bad); } .sdot.info { background: var(--info); } .sdot.off { background: var(--muted); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 12px; }
.topbar { display: none; }
.scrim { display: none; }

.profile { position: relative; }
.profile-btn { display: flex; align-items: center; gap: 10px; width: 100%; background: transparent; border-color: transparent; padding: 6px 8px; }
.profile-btn:hover { background: var(--card-2); border-color: var(--border); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; }
.who-name { flex: 1; text-align: left; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.menu { position: absolute; bottom: calc(100% + 8px); left: 0; right: 0; min-width: 220px; z-index: 30; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 6px; box-shadow: 0 8px 28px rgba(0, 0, 0, .28); display: grid; gap: 2px; }
.menu[hidden] { display: none; }
.menu-info { color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menuitem { background: transparent; border-color: transparent; width: 100%; justify-content: flex-start; min-height: 40px; }
.menuitem:hover { background: var(--card-2); }

@media (max-width: 860px) {
  .shell { display: block; }
  /* The same sidebar, as a drawer: opened from the menu button, closed by a tap outside, a link or Escape. */
  .side { position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); height: auto; z-index: 40; transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; box-shadow: none; }
  .shell.drawer-open .side { transform: none; visibility: visible; transition: transform .2s ease; box-shadow: 8px 0 28px rgba(0, 0, 0, .3); }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(2, 6, 23, .55); z-index: 35; }
  .shell.drawer-open .scrim { display: block; }
  .side-foot .profile { display: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px var(--g); border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: 10; }
  .topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }
  .topbar .brand h1 { font-size: 16px; }
  .burger { padding: 0; width: 44px; justify-content: center; background: transparent; border-color: transparent; }
  .burger svg.i { width: 22px; height: 22px; }
  .topbar .profile-btn { width: auto; padding: 4px; }
  .topbar .who-name, .topbar .profile-btn svg.i { display: none; }
  .topbar .menu { bottom: auto; top: calc(100% + 8px); left: auto; right: 0; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none !important; } }

/* The row of range and filter controls above a repository's tiles and charts: spaced from them, and lined up to the right. */
.foot.toolbar { margin: 0 0 14px; justify-content: flex-end; }
.foot.toolbar .tools { gap: 12px; }
details.sec .summary { margin-bottom: 16px; }
details.sec .filters { margin-bottom: 14px; }
.sec .card + .card, .sec section + section { margin-top: 14px; }

/* Filters: full width fields with room around them, and clear of the table below. */
.filters { margin: 4px 0 16px; gap: 12px; }
.filters label.f { flex: 1 1 200px; min-width: 0; }
.filters input, .filters select { width: 100%; }
@media (max-width: 640px) {
  .filters label.f { flex-basis: 100%; }
  .stack td:not([data-label]) .treason { flex: 1; min-width: 0; }
}

/* Forms: fields share the row equally, the checkbox sits next to its words, the button keeps its own size. */
form.add { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 16px; align-items: end; }
form.add input:not([type="checkbox"]), form.add select { width: 100%; min-width: 0; }
form.add .check { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; }
.check input { min-width: 0; padding: 0; }
form.add button[type="submit"] { justify-self: start; min-width: 110px; justify-content: center; }

@media (max-width: 640px) {
  /* The first cell of a stacked row is its title, so it needs no column name and reads as the head of the card. */
  .stack td:first-child { justify-content: flex-start; gap: 10px; font-weight: 600; font-size: 15px; padding: 2px 0 8px; }
  .stack td:first-child::before { display: none; }
  .stack td:not([data-label]) { justify-content: flex-start; flex-wrap: wrap; padding-top: 8px; }
  .stack td:not([data-label]) .tools { width: 100%; }
  .stack td:not([data-label]) .tools button { flex: 1 1 auto; justify-content: center; }
  .stack tr { padding: 12px 0; }
}

/* A focus ring is drawn outside its control, so the scrolling wrapper around a table needs room for it or the edge cuts it off. */
.tablewrap { padding: 4px; margin: -4px; }
