/* Advisory ledger. Shares cc.opensec.in's visual system: Instrument Sans + IBM Plex Mono,
   pure-black canvas, near-black surfaces, lime primary actions and validated chart series. */

@font-face { font-family: "Instrument Sans"; font-weight: 400; font-display: swap; src: url("/fonts/instrument-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 500; font-display: swap; src: url("/fonts/instrument-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 600; font-display: swap; src: url("/fonts/instrument-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

:root {
  font-family: "Instrument Sans", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
  text-rendering: geometricPrecision;
  color-scheme: dark;
  --canvas: #000000;
  --surface: #101111;
  --surface-raised: #181919;
  --surface-hover: #1d1f1e;
  --ink: #f3f5f3;
  --ink-strong: #ffffff;
  --muted: #969b97;
  --muted-2: #676c68;
  --line: #292c2a;
  --line-soft: #202321;
  --accent: #bafc6b;
  --accent-ink: #080d04;
  --amber: #e8bc68;
  --red: #f07676;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #9085e9;
  --series-5: #d55181;
  --critical: #f65e6a;
  --high: #ff8a4c;
  --medium: #e5c25c;
  --low: #8bad83;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sidebar: 212px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { min-width: 320px; background: var(--canvas); }
::selection { color: var(--accent-ink); background: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.wrap { overflow-wrap: anywhere; }
.error-text { color: var(--red); }
.warn-text { color: var(--amber); }
.icon { flex: none; }
.boot { color: var(--muted); font-size: 12px; }

/* ---------- buttons ---------- */

.button, .text-button, .icon-button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.button { padding: 0 13px; }
.button:hover, .text-button:hover, .icon-button:hover { background: var(--surface-hover); border-color: color-mix(in srgb, var(--line) 50%, var(--ink)); }
.button:disabled, .text-button:disabled { opacity: .5; cursor: not-allowed; }
.button--primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.button--primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink-strong)); border-color: transparent; }
.button--secondary { background: transparent; }
.text-button { padding: 0 10px; background: transparent; border-color: transparent; color: var(--muted); }
.text-button:hover { color: var(--ink); }
.icon-button { width: 32px; padding: 0; background: transparent; }
.link-button { padding: 0; border: 0; background: none; color: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.spin { display: inline-flex; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- sign in (matches cc.opensec.in) ---------- */

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--canvas); }
.auth-card { width: min(100%, 410px); padding: 28px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 24px 80px rgb(0 0 0 / 28%); }
.auth-brand { display: flex; align-items: center; gap: 11px; padding-bottom: 24px; border-bottom: 1px solid var(--line-soft); }
.auth-brand img { width: 38px; height: 38px; object-fit: contain; }
.auth-brand div { display: grid; gap: 2px; }
.auth-brand span { color: var(--muted); font: 500 11px/1 var(--mono); letter-spacing: .14em; }
.auth-brand strong { color: var(--ink-strong); font-size: 15px; letter-spacing: -.02em; }
.auth-copy { margin: 27px 0 24px; }
.auth-eyebrow { display: block; margin-bottom: 9px; color: var(--accent); font: 600 11px/1 var(--mono); letter-spacing: .15em; }
.auth-copy h1 { margin: 0 0 7px; color: var(--ink-strong); font-size: 25px; font-weight: 600; letter-spacing: -.035em; }
.auth-copy p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.auth-methods { display: grid; gap: 9px; }
.auth-submit { width: 100%; height: 43px; justify-content: center; gap: 8px; font-size: 12px; font-weight: 600; }
.auth-submit.is-busy { pointer-events: none; opacity: .8; }
.auth-error[hidden] { display: none; }
.auth-error { margin: 13px 0 0; color: var(--red); font-size: 11px; line-height: 1.5; }

/* ---------- shell ---------- */

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); background: var(--canvas); }
.sidebar { position: sticky; top: 0; z-index: 20; height: 100vh; display: flex; flex-direction: column; padding: 18px 12px 14px; background: var(--canvas); border-right: 1px solid var(--line); }
.sidebar-brand { height: 34px; display: flex; align-items: center; gap: 10px; margin: 0 8px 32px; }
.sidebar-brand span { color: var(--ink-strong); font-size: 13px; font-weight: 600; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; display: block; object-fit: contain; }
.sidebar nav { display: grid; gap: 3px; }
.sidebar-section-label { padding: 14px 10px 4px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.sidebar-section-label:first-child { padding-top: 0; }
.sidebar nav button { width: 100%; height: 38px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 13px; text-align: left; cursor: pointer; }
.sidebar nav button:hover { color: var(--ink); background: var(--surface-hover); }
.sidebar nav button.active { color: var(--ink-strong); background: var(--surface-hover); }
.sidebar nav button.active .icon { color: var(--accent); }
.nav-badge { margin-left: auto; padding: 1px 6px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font: 500 10px/1.5 var(--mono); }
.sidebar-account { display: grid; gap: 10px; margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.sidebar-account__identity { min-width: 0; display: flex; align-items: center; gap: 9px; }
.sidebar-account__identity > div { min-width: 0; display: grid; gap: 2px; }
.sidebar-account__identity strong { overflow: hidden; color: var(--ink-strong); font-size: 11px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account__identity small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-hover); color: var(--accent); font: 600 11px var(--mono); }
.sidebar-account__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.sidebar-account__actions button { height: 30px; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px; border: 1px solid var(--line-soft); border-radius: 6px; color: var(--muted); background: transparent; font-size: 11px; cursor: pointer; }
.sidebar-account__actions button:only-child { grid-column: 1 / -1; }
.sidebar-account__actions button:hover { color: var(--ink); border-color: var(--line); background: var(--surface-hover); }
.mobile-menu, .mobile-close, .scrim { display: none; }

.main-column { min-width: 0; }
.topbar { height: 64px; position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: color-mix(in srgb, var(--canvas) 92%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 14px; line-height: 1.15; font-weight: 600; letter-spacing: -.015em; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.last-sync { display: flex; align-items: center; gap: 7px; margin-right: 6px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.last-sync i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.last-sync.is-running i { animation: pulse 1.2s ease-in-out infinite; }
.last-sync.is-partial i { background: var(--amber); }
.last-sync.is-failed i { background: var(--red); }
@keyframes pulse { 50% { opacity: .25; } }

.content { width: 100%; max-width: 1420px; margin: 0 auto; padding: 0 24px 36px; outline: none; }
.overview-page, .advisories-page, .changes-page, .sync-page { display: flex; flex-direction: column; gap: 12px; }
.sync-page { padding-top: 24px; }
.notices { display: grid; gap: 8px; padding-top: 18px; }
.notice { margin: 0; padding: 10px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12px; }
.notice--error { border-color: color-mix(in srgb, var(--red) 40%, var(--line)); color: #ffc9c9; }
.notice--warn { border-color: color-mix(in srgb, var(--amber) 40%, var(--line)); color: #f3dfb4; }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 40; max-width: min(420px, calc(100vw - 32px)); margin: 0; padding: 11px 14px; border: 1px solid color-mix(in srgb, var(--red) 40%, var(--line)); border-radius: 8px; background: var(--surface-raised); color: #ffc9c9; font-size: 12px; box-shadow: 0 12px 30px rgb(0 0 0 / 50%); }

.range-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 24px 0 2px; }
.last-updated { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.last-updated i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.range-control, .segmented { display: flex; flex-wrap: wrap; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.range-control button, .segmented button { min-width: 42px; height: 28px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.range-control button.active { background: var(--ink-strong); color: var(--canvas); font-weight: 600; }
.segmented button.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.segmented small { font: 500 10px var(--mono); opacity: .75; }
.range-control button:hover:not(.active), .segmented button:hover:not(.active) { color: var(--ink); background: var(--surface-hover); }

/* ---------- panels ---------- */

.panel { min-width: 0; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); overflow: hidden; }
.panel-heading { min-height: 48px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.panel-heading__text { min-width: 0; flex: 1 1 auto; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.panel-heading__action { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.panel-heading h2 { margin: 0; font-size: 13px; font-weight: 600; }
.panel-heading span { color: var(--muted); font-size: 11px; }
.empty-row { margin: 0; padding: 18px 16px; color: var(--muted); font-size: 12px; }
.empty-state { display: grid; justify-items: start; gap: 8px; padding: 26px 18px; }
.empty-state p { margin: 0; font-size: 13px; }
.empty-state small { color: var(--muted); font-size: 12px; }

/* ---------- overview ---------- */

.usage-overview { padding: 18px; }
.usage-overview__heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 0 2px 15px; }
.usage-overview__heading > div { display: grid; gap: 5px; }
.usage-overview__heading h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.02em; }
.usage-overview__heading span { color: var(--muted); font-size: 11px; }
.usage-overview__heading > small { padding-top: 3px; color: var(--muted); font: 400 11px var(--mono); white-space: nowrap; }
.usage-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.usage-metric { min-width: 0; display: flex; align-items: center; gap: 13px; padding: 14px 16px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--surface-raised); text-align: left; cursor: pointer; }
.usage-metric:hover { border-color: var(--line); background: var(--surface-hover); }
.usage-metric__icon { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: color-mix(in srgb, var(--surface-hover) 75%, transparent); }
.usage-metric > div { min-width: 0; flex: 1; display: grid; gap: 6px; }
.usage-metric small, .usage-metric > div > span { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.usage-metric strong { color: var(--ink-strong); font: 500 20px/1.1 var(--mono); letter-spacing: -.03em; }
.usage-metric__suffix { color: var(--muted); font: 400 12px var(--mono); letter-spacing: 0; }

.chart-band { margin-top: 9px; padding: 14px 16px 12px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--surface-raised); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.chart-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 12px; height: 3px; flex: 0 0 auto; border-radius: 2px; }
.chart-legend i.dashed { background: linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px, currentColor 7px 12px) !important; }
.chart-legend small { color: var(--muted); font-size: 11px; white-space: nowrap; }
.chart-legend strong { color: var(--ink-strong); font: 500 11px var(--mono); }
.line-chart { position: relative; height: 170px; margin-top: 10px; border-radius: 6px; }
.line-chart svg { display: block; overflow: visible; }
.line-chart:focus-visible { outline-offset: 4px; }
.grid-line { stroke: var(--line); stroke-dasharray: 2 4; }
.axis-label { fill: var(--muted); font: 400 10px var(--mono); }
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-line.is-dashed { stroke-dasharray: 4 3; }
.cursor-line { stroke: var(--muted-2); stroke-width: 1; }
.cursor-dot { stroke: var(--surface-raised); stroke-width: 2; }
.chart-tooltip { position: absolute; top: 4px; z-index: 2; min-width: 160px; display: grid; gap: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); font-size: 11px; box-shadow: 0 8px 24px rgb(0 0 0 / 35%); pointer-events: none; }
.chart-tooltip[hidden] { display: none; }
.chart-tooltip strong { font-weight: 600; }
.chart-tooltip span { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.chart-tooltip i { width: 8px; height: 8px; border-radius: 50%; }
.chart-tooltip b { margin-left: auto; color: var(--ink-strong); font: 500 11px var(--mono); }
.chart-caption { margin: 6px 0 0; color: var(--muted); font: 400 11px/1.5 var(--mono); }
.chart-data { margin-top: 6px; }
.chart-data summary { width: fit-content; color: var(--muted); font-size: 11px; cursor: pointer; }
.chart-data summary:hover { color: var(--ink); }
.chart-data .table-scroll { max-height: 220px; margin-top: 8px; }

.analytics-band { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 9px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--surface-raised); overflow: hidden; }
.analytics-band > span { min-width: 0; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px; padding: 14px 16px; border-right: 1px solid var(--line-soft); }
.analytics-band > span:last-child { border-right: 0; }
.analytics-band small { color: var(--muted); font-size: 11px; }
.analytics-band small em { display: block; margin-top: 2px; color: var(--muted-2); font-style: normal; }
.analytics-band strong { color: var(--ink-strong); font: 500 15px var(--mono); text-align: right; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.composition { display: grid; gap: 14px; padding: 16px; }
.composition__bar { height: 10px; display: flex; gap: 2px; overflow: hidden; border-radius: 3px; background: var(--line); }
.composition__bar span { min-width: 3px; }
.composition__rows { display: grid; gap: 2px; }
.composition__rows button { min-height: 32px; display: grid; grid-template-columns: minmax(0, 1fr) auto 44px; align-items: center; gap: 10px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; text-align: left; cursor: pointer; }
.composition__rows button:hover:not(:disabled) { background: var(--surface-hover); }
.composition__rows button:disabled { cursor: default; }
.composition__rows span { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 12px; }
.composition__rows i { width: 8px; height: 8px; border-radius: 50%; }
.composition__rows strong { font: 500 12px var(--mono); }
.composition__rows small { color: var(--muted); font: 400 11px var(--mono); text-align: right; }

.repo-bars { display: grid; gap: 2px; padding: 12px 8px 14px; }
.repo-bars > button { min-height: 32px; display: grid; grid-template-columns: minmax(120px, 1.1fr) minmax(0, 1.4fr) 30px; align-items: center; gap: 12px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; text-align: left; cursor: pointer; }
.repo-bars > button:hover { background: var(--surface-hover); }
.repo-bars__name { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.repo-bars__track { height: 8px; display: flex; gap: 1px; overflow: hidden; border-radius: 3px; background: var(--line-soft); }
.repo-bars__track i { height: 100%; }
.repo-bars > button strong { font: 500 12px var(--mono); text-align: right; }
.repo-bars__legend { display: flex; gap: 14px; margin: 8px 8px 0; color: var(--muted); font-size: 11px; }
.repo-bars__legend span { display: inline-flex; align-items: center; gap: 6px; }
.repo-bars__legend i { width: 8px; height: 8px; border-radius: 2px; }

.analytics-band--standalone { margin-top: 0; border-color: var(--line); background: var(--surface); }

.timeline-day + .timeline-day { border-top: 1px solid var(--line); }
.timeline-day__label { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); background: var(--surface-raised); color: var(--muted); font: 500 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.timeline-day__label span { padding: 0 6px; border: 1px solid var(--line); border-radius: 99px; font-size: 10px; letter-spacing: 0; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline-row { display: grid; grid-template-columns: 52px minmax(190px, 250px) minmax(0, 1fr); align-items: baseline; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.timeline-row:last-child { border-bottom: 0; }
.timeline-row:hover { background: var(--surface-hover); }
.timeline-row__time { color: var(--muted); font: 400 11px var(--mono); }
.timeline-row__subject { min-width: 0; display: grid; gap: 3px; }
.change-pill { justify-self: start; max-width: 100%; display: inline-flex; align-items: center; gap: 7px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface-raised); color: var(--ink); font: 400 11px/1.4 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.change-pill i { width: 7px; height: 7px; flex: none; border-radius: 50%; }
.empty-state__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.empty-hero { display: grid; justify-items: center; gap: 12px; padding: 44px 24px; text-align: center; }
.empty-hero__icon { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-raised); color: var(--accent); }
.empty-hero h2 { margin: 4px 0 0; color: var(--ink-strong); font-size: 15px; font-weight: 600; letter-spacing: -.02em; }
.empty-hero p { max-width: 560px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.empty-hero__facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 0; margin: 6px 0 4px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--surface-raised); overflow: hidden; }
.empty-hero__facts > div { min-width: 150px; padding: 11px 18px; border-right: 1px solid var(--line-soft); text-align: left; }
.empty-hero__facts > div:last-child { border-right: 0; }
.empty-hero__facts dt { color: var(--muted); font-size: 11px; }
.empty-hero__facts dd { margin: 3px 0 0; color: var(--ink-strong); font: 500 12px var(--mono); }

.change-list { margin: 0; padding: 0; list-style: none; }
.change { display: grid; grid-template-columns: minmax(170px, 240px) minmax(0, 1fr); column-gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
.change:last-child { border-bottom: 0; }
.change__what { grid-row: 1 / span 2; display: flex; align-items: baseline; gap: 8px; color: var(--muted); font: 400 11px/1.5 var(--mono); }
.change__what i { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--muted-2); transform: translateY(-1px); }
.change--accent .change__what { color: var(--ink); }
.change--accent .change__what i { background: var(--accent); }
.change--ink .change__what { color: var(--ink); }
.change--ink .change__what i { background: var(--ink); }
.change--warn .change__what i { background: var(--amber); }
.change__title { padding: 0; border: 0; background: none; font-size: 13px; font-weight: 500; text-align: left; cursor: pointer; }
.change__title:hover { text-decoration: underline; text-underline-offset: 3px; }
.change__meta { display: flex; flex-wrap: wrap; gap: 3px 10px; margin-top: 3px; color: var(--muted); font-size: 11px; }

/* ---------- advisories table ---------- */

.table-panel { background: color-mix(in srgb, var(--surface) 92%, var(--surface-raised)); }
.table-toolbar { display: grid; grid-template-columns: minmax(240px, 2fr) repeat(4, minmax(130px, 1fr)); gap: 10px; align-items: end; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { color: var(--muted); font-size: 11px; font-weight: 500; }
input, select, textarea { width: 100%; min-height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink-strong); background-color: var(--canvas); font-size: 12px; transition: border-color .15s ease-out; }
/* Native select arrows sit against the border; draw one with the same inset as the search icon. */
select { appearance: none; padding-right: 34px; background-image: url("/chevron-down.svg"); background-repeat: no-repeat; background-position: right 11px center; background-size: 15px; text-overflow: ellipsis; cursor: pointer; }
select:hover { background-image: url("/chevron-down.svg"); }
textarea { padding: 9px 11px; font: 400 12px/1.6 var(--mono); resize: vertical; }
input:hover, input:focus, select:hover, select:focus, textarea:hover, textarea:focus { border-color: color-mix(in srgb, var(--line) 40%, var(--ink)); }
.search-field { position: relative; display: flex; align-items: center; }
.search-field .icon { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search-field input { padding-left: 33px; }

.ledger-table { overflow-x: auto; }
.ledger-table__head, .ledger-row { min-width: 1000px; display: grid; grid-template-columns: minmax(300px, 3fr) 150px 110px minmax(110px, 1fr) 80px 90px 90px 20px; align-items: center; gap: 12px; padding: 0 16px; }
.ledger-table__head { min-height: 36px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.ledger-row { width: 100%; min-height: 66px; padding-top: 10px; padding-bottom: 10px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; color: var(--ink); font-size: 12px; text-align: left; cursor: pointer; }
.ledger-row:last-child { border-bottom: 0; }
.ledger-row:hover { background: var(--surface-hover); }
.ledger-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ledger-row > span { min-width: 0; }
.ledger-row__title { display: grid; gap: 4px; }
.ledger-row__title strong { font-size: 13px; font-weight: 500; line-height: 1.35; }
.ledger-row__title small { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.ledger-row .ledger-row__title small .mono { font-size: 10.5px; letter-spacing: -.01em; }
.ledger-row__title .tag { align-self: center; font-size: 10px; line-height: 16px; }
.ledger-row.is-unavailable .ledger-row__title strong { color: var(--muted); }
.ledger-row__chevron { display: flex; align-items: center; justify-content: flex-end; color: var(--muted-2); }
.ledger-row .mono { font-size: 12px; }
.tag { padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); }
.cell-hint { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.35; }

.status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; line-height: 1.4; white-space: nowrap; }
.status i { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: currentColor; }
.status--triage { color: var(--series-1); }
.status--draft { color: var(--amber); }
.status--accepted { color: var(--accent); }
.status--published { color: var(--series-4); }
.status--closed, .status--withdrawn { color: var(--series-2); }
.status--unknown { color: var(--muted-2); }
.status--healthy { color: var(--accent); }
.status--failing { color: var(--red); }
.status__label { color: var(--ink); }
.severity { display: inline-flex; align-items: baseline; gap: 6px; line-height: 1.4; white-space: nowrap; }
.severity i { align-self: center; }
.severity i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.severity small { color: var(--muted); font: 400 11px var(--mono); }
.sev-critical i { background: var(--critical); }
.sev-high i { background: var(--high); }
.sev-medium i { background: var(--medium); }
.sev-low i { background: var(--low); }
.inbox.is-unread { color: var(--ink-strong); }
.inbox.is-unread::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }

/* ---------- sync ---------- */

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 9px 22px; margin: 0; padding: 16px; font-size: 12px; }
.facts dt { color: var(--muted); }
.facts dd { min-width: 0; margin: 0; }
.account-list, .plain-list, .passkey-list { margin: 0; padding: 0; list-style: none; }
.account-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.account-list li:last-child { border-bottom: 0; }
.account-list li > span:nth-child(2) { display: grid; gap: 3px; min-width: 0; }
.account-list strong { font-size: 13px; font-weight: 500; }
.account-list small { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.plain-list li { padding: 9px 16px; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
.plain-list li:last-child { border-bottom: 0; }
.plain-list small { color: var(--muted); }
.table-scroll { overflow: auto; }
.data-table, .chart-data table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th, .chart-data th { position: sticky; top: 0; padding: 9px 16px; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 11px; font-weight: 500; text-align: left; text-transform: uppercase; letter-spacing: .05em; }
.data-table td, .chart-data td { padding: 8px 16px; border-bottom: 1px solid var(--line-soft); }
.chart-data th, .chart-data td { padding: 6px 10px; font-family: var(--mono); }
.chart-data th { background: var(--surface-raised); }

/* ---------- dialogs ---------- */

.dialog { width: min(560px, calc(100vw - 32px)); max-height: 90vh; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgb(0 0 0 / 60%); }
.dialog--wide { width: min(840px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgb(0 0 0 / 72%); }
/* showModal() focuses the dialog itself; its controls keep their own focus rings. */
.dialog:focus-visible { outline: none; }
.dialog-body { display: grid; gap: 16px; padding: 0 24px 24px; }
/* The header stays in view while long advisories scroll, so the close button is always reachable. */
.dialog-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 0 14px; border-bottom: 1px solid var(--line-soft); background: var(--surface); }
.dialog-head > div { display: grid; gap: 6px; min-width: 0; }
.dialog-head small { color: var(--muted); font-size: 11px; line-height: 1.5; }
.dialog-head small .mono { font-size: 10.5px; }
.dialog-head h2 { margin: 0; color: var(--ink-strong); font-size: 19px; font-weight: 600; line-height: 1.35; letter-spacing: -.025em; }
.dialog-actions, .detail-actions { display: flex; gap: 8px; }
.dialog-actions { justify-content: flex-end; }
.hint { margin: -6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.form-message { min-height: 1.4em; margin: 0; color: var(--muted); font-size: 11px; }
.facts--detail { padding: 14px 16px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--surface-raised); }
.note-form { display: grid; gap: 8px; }
.note-form textarea { font-family: inherit; font-size: 12px; }
.note-form__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail-section h3 { margin: 0 0 6px; font-size: 13px; font-weight: 600; }
.detail-section .plain-list li { padding: 7px 0; }
.credit--accepted { color: var(--accent); }
.credit--declined { color: var(--red); }
.credit--pending { color: var(--muted); }
.prose { font-size: 12.5px; line-height: 1.7; overflow-wrap: anywhere; }
.prose h4 { margin: 14px 0 4px; font-size: 12.5px; }
.prose p { margin: 0 0 10px; white-space: pre-wrap; }
.prose pre { max-height: 360px; margin: 0 0 12px; padding: 12px; overflow: auto; border: 1px solid var(--line-soft); border-radius: 8px; background: var(--canvas); font: 400 11px/1.6 var(--mono); }
.passkey-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.passkey-list li > span:nth-child(2) { display: grid; gap: 2px; }
.passkey-list strong { font-size: 13px; font-weight: 500; }
.passkey-list small { color: var(--muted); font-size: 11px; }
.passkey-list .empty-row { display: block; padding: 10px 0; }
.passkey-icon { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; color: var(--accent); }
.inline-form { display: flex; align-items: end; gap: 8px; }
.inline-form .field { flex: 1; }

/* ---------- responsive ---------- */

@media (max-width: 1150px) {
  .usage-metrics, .analytics-band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-band > span:nth-child(2) { border-right: 0; }
  .analytics-band > span:nth-child(-n + 2) { border-bottom: 1px solid var(--line-soft); }
  .overview-grid { grid-template-columns: 1fr; }
  .table-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-toolbar .search-field { grid-column: 1 / -1; }
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: min(280px, 84vw); transform: translateX(-102%); transition: transform .18s ease; }
  .menu-open .sidebar { transform: none; box-shadow: 0 0 60px rgb(0 0 0 / 60%); }
  .menu-open .scrim { position: fixed; inset: 0; z-index: 25; display: block; border: 0; background: rgb(0 0 0 / 60%); }
  .mobile-menu { display: inline-flex; margin-left: -6px; }
  .mobile-close { display: inline-flex; margin-left: auto; }
  .topbar { padding: 0 16px; }
  .content { padding: 0 16px 32px; }
}

@media (max-width: 760px) {
  .last-sync { display: none; }
  .label-wide { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .usage-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .usage-metric { padding: 12px; }
  .usage-metric__icon { display: none; }
  .usage-overview { padding: 12px; }
  .usage-overview__heading > small { display: none; }
  .table-toolbar { grid-template-columns: 1fr 1fr; }
  .ledger-table__head { display: none; }
  .ledger-row { min-width: 0; grid-template-columns: 1fr 1fr; gap: 10px 12px; padding: 14px 16px; }
  .ledger-row__title { grid-column: 1 / -1; }
  .ledger-row > span[data-label]::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--muted); font: 500 10px var(--mono); letter-spacing: .06em; text-transform: uppercase; }
  .ledger-row__chevron { display: none; }
  .change { grid-template-columns: 1fr; row-gap: 3px; }
  .timeline-row { grid-template-columns: 44px minmax(0, 1fr); row-gap: 6px; }
  .timeline-row__subject { grid-column: 1 / -1; }
  .empty-hero__facts { flex-direction: column; width: 100%; }
  .empty-hero__facts > div { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .empty-hero__facts > div:last-child { border-bottom: 0; }
  .change__what { grid-row: auto; }
  .repo-bars > button { grid-template-columns: minmax(0, 1fr) 30px; }
  .repo-bars__track { grid-column: 1 / -1; grid-row: 2; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 8px; }
  .dialog-body { padding: 0 16px 20px; }
  .dialog-head { padding-top: 18px; }
  .inline-form { flex-direction: column; align-items: stretch; }
}

@media (max-width: 1150px) and (pointer: coarse) {
  input, select, textarea { min-height: 44px; font-size: 16px; }
  .button { min-height: 40px; }
}

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