/*
 * MagePatch dashboard.
 *
 * Calm until it isn't: surfaces stay neutral and hue is reserved for state, so a red
 * or amber mark always means something. One family, Recursive, carries both voices --
 * its Sans for the interface, its Mono (the same skeleton, MONO axis) for the CVE ids,
 * patch ids and commands this product is made of. Self-hosted: a security dashboard
 * makes no third-party requests.
 */

@font-face {
    font-family: "Recursive";
    src: url("../fonts/recursive-latin-4UhccVQ.woff2") format("woff2");
    font-weight: 300 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --font: "Recursive", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "Recursive", ui-monospace, SFMono-Regular, Menlo, monospace;

    --canvas: #f2f4f7;
    --surface: #ffffff;
    --surface-2: #f7f8fa;
    --ink: #101828;
    --ink-2: #344054;
    --muted: #5d6b7e;
    --line: #e2e6ec;
    --line-strong: #c8cfd9;

    --accent: #2b4acb;
    --accent-hover: #2139a6;
    --accent-ink: #ffffff;
    --accent-soft: #e9edfb;

    --ok: #067647;      --ok-bg: #e5f4ec;      --ok-line: #a9dcc1;
    --warn: #93520a;    --warn-bg: #fdf1dd;    --warn-line: #f0cb8e;
    --crit: #b42318;    --crit-bg: #fdebe9;    --crit-line: #f4b8b1;
    --off: #475467;     --off-bg: #eceff3;     --off-line: #c8cfd9;
    --info: #2b4acb;    --info-bg: #eef1fc;    --info-line: #c3cdf3;

    --bar-ok: #17a361;
    --bar-warn: #e8a22b;
    --bar-crit: #d92d20;
    --bar-off: #667085;
    --bar-unknown: #d0d5dd;

    /* Filled buttons in a status colour: Adobe's P1 and P2. */
    --crit-solid: #b42318;  --crit-solid-hover: #912018;  --crit-solid-ink: #ffffff;
    --warn-solid: #f2b62e;  --warn-solid-hover: #e0a316;  --warn-solid-ink: #3d2603;

    --shadow: 0 1px 2px rgb(16 24 40 / 0.05);
    --shadow-pop: 0 12px 32px -8px rgb(16 24 40 / 0.22);

    --t-xs: 12.5px;
    --t-s: 13.5px;
    --t-m: 15px;
    --t-l: 17px;
    --t-xl: 26px;
    --t-display: clamp(30px, 4.4vw, 46px);

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --canvas: #0f141b;
        --surface: #161d27;
        --surface-2: #1b2430;
        --ink: #e8edf4;
        --ink-2: #c3ccd8;
        --muted: #95a1b2;
        --line: #263142;
        --line-strong: #364459;

        --accent: #4a66e0;
        --accent-hover: #5c77ec;
        --accent-ink: #ffffff;
        --accent-soft: #1d2747;

        --ok: #5fd69a;      --ok-bg: #10291d;      --ok-line: #1f5a3c;
        --warn: #f2be6b;    --warn-bg: #33250f;    --warn-line: #6b4a17;
        --crit: #ff9a8f;    --crit-bg: #3a1714;    --crit-line: #7a2c25;
        --off: #b0bac8;     --off-bg: #222b37;     --off-line: #3a4759;
        --info: #9db0ff;    --info-bg: #1a2240;    --info-line: #34437a;

        --bar-ok: #2fb875;
        --bar-warn: #e9a83a;
        --bar-crit: #f0483b;
        --bar-off: #7d8899;
        --bar-unknown: #3a4657;

        --crit-solid: #d92d20;  --crit-solid-hover: #e5463a;  --crit-solid-ink: #ffffff;
        --warn-solid: #f2b62e;  --warn-solid-hover: #f6c654;  --warn-solid-ink: #2b1b02;

        --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
        --shadow-pop: 0 16px 40px -8px rgb(0 0 0 / 0.6);

        color-scheme: dark;
    }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--canvas);
    color: var(--ink);
    font: 400 var(--t-m)/1.55 var(--font);
    font-variation-settings: "MONO" 0;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3 { color: var(--ink); text-wrap: balance; }
h1 { font-size: var(--t-xl); font-weight: 720; line-height: 1.15; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: var(--t-l); font-weight: 650; line-height: 1.3; letter-spacing: -0.01em; margin: 0 0 12px; }
h3 { font-size: var(--t-m); font-weight: 650; margin: 0 0 8px; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
td a, .crumbs a, nav a { text-decoration: none; }
td a:hover { text-decoration: underline; }

code, kbd, pre, .mono {
    font-family: var(--font-mono);
    font-variation-settings: "MONO" 1;
    font-size: 0.9em;
}

pre {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--ink);
}

time, td, .num { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: var(--t-s); }
.nowrap { white-space: nowrap; }
.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }

/* ---------- Header ---------- */

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 28px; min-height: 60px; }

.brand {
    display: inline-flex; align-items: center; gap: 10px;
    color: var(--ink); text-decoration: none;
    font-weight: 800; font-size: 16px; letter-spacing: -0.02em;
}
.brand:hover { color: var(--ink); }
.brand svg { width: 26px; height: 26px; }

.mainnav { display: flex; align-items: stretch; gap: 4px; align-self: stretch; }
.mainnav a {
    display: inline-flex; align-items: center;
    padding: 0 10px;
    color: var(--muted);
    font-size: 14px; font-weight: 560;
    box-shadow: inset 0 -2px 0 transparent;
    transition: color 150ms ease, box-shadow 150ms ease;
}
.mainnav a:hover { color: var(--ink); }
.mainnav a.active { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }

.topbar__end { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: var(--t-s); }
.topbar__user { color: var(--muted); max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__end a { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.topbar__end a:hover { color: var(--ink); }

main.wrap { flex: 1; padding-top: 32px; padding-bottom: 72px; }

footer { border-top: 1px solid var(--line); }
footer .wrap { padding: 20px 24px; color: var(--muted); font-size: var(--t-xs); display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Page head ---------- */

.crumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; font-size: var(--t-s); color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }
.crumbs span[aria-hidden] { color: var(--line-strong); }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin: 0 0 28px; }
.page-head__text { min-width: 0; flex: 1 1 420px; }
.page-head__title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.lede { color: var(--muted); margin: 8px 0 0; max-width: 72ch; }
.lede code { color: var(--ink-2); }

.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: var(--t-s); }
.meta li { display: inline-flex; align-items: center; gap: 6px; }
.meta strong { color: var(--ink-2); font-weight: 600; }

section + section, .section { margin-top: 40px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin: 0 0 12px; }
.section-head h2 { margin: 0; }
.section-head p, .section-head__hint { margin: 0; color: var(--muted); font-size: var(--t-s); }

/* A result block that folds away (Vulnerabilities, Patches, …): the head is its toggle. */
.fold + .fold, section + .fold { margin-top: 40px; }
.fold > summary { cursor: pointer; list-style: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary h2 { display: inline-flex; align-items: center; gap: 10px; }
.fold > summary h2::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform 150ms ease; }
.fold[open] > summary h2::before { transform: rotate(45deg); margin-top: -4px; }
.fold:not([open]) > summary { margin-bottom: 0; }
.fold > summary:hover h2::before { border-color: var(--ink); }
.count { color: var(--muted); font-weight: 500; margin-left: 4px; }

/* ---------- Surfaces ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }

dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 20px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: var(--t-s); padding-top: 1px; }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; margin: 0; padding: 0; }
.facts > div { padding: 14px 18px; border-left: 1px solid var(--line); }
.facts > div:first-child { border-left: 0; }
.facts dt { color: var(--muted); font-size: var(--t-xs); margin: 0 0 4px; }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.facts dd .muted { font-weight: 400; }
.facts dd .badge { margin-left: 4px; vertical-align: 1px; }
.facts__action { margin-top: 8px; }
.card__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 12px 12px; font-size: var(--t-s); color: var(--muted); }
.card__foot p { margin: 0; }

/* ---------- Status ---------- */

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 9px 2px 8px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: var(--t-xs); font-weight: 600; line-height: 1.5;
    white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge--cap { text-transform: capitalize; }

.s-HEALTHY, .s-VERIFIED, .s-PROTECTED, .s-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.s-WARNING, .s-PARTIAL, .s-DRIFTED, .s-POTENTIALLY_VULNERABLE, .s-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.s-CRITICAL, .s-MISSING, .s-CONFLICT, .s-VULNERABLE, .s-crit { background: var(--crit-bg); color: var(--crit); border-color: var(--crit-line); }
.s-OFFLINE { background: var(--off-bg); color: var(--off); border-color: var(--off-line); }
.s-UNKNOWN, .s-NOT_APPLICABLE, .s-NOT_CONNECTED, .s-off { background: transparent; color: var(--muted); border-color: var(--line-strong); }
.s-OFFLINE .dot, .s-UNKNOWN .dot, .s-NOT_APPLICABLE .dot, .s-NOT_CONNECTED .dot { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }

.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 1px 8px;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--ink-2);
    font-size: var(--t-xs); font-weight: 560;
    white-space: nowrap;
}
.chip--prod { background: var(--ink); border-color: var(--ink); color: var(--surface); }

.envs { display: flex; flex-wrap: wrap; gap: 6px; }
.env-link {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 3px 10px 3px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-2);
    font-size: var(--t-s);
}
.env-link:hover { border-color: var(--line-strong); color: var(--ink); text-decoration: none !important; }
.env-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--bar-unknown); }
.env-dot.s-HEALTHY { background: var(--bar-ok); }
.env-dot.s-WARNING { background: var(--bar-warn); }
.env-dot.s-CRITICAL { background: var(--bar-crit); }
.env-dot.s-OFFLINE { background: transparent; box-shadow: inset 0 0 0 2px var(--bar-off); }
.env-dot.s-UNKNOWN { background: transparent; box-shadow: inset 0 0 0 2px var(--line-strong); }

.priority { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; padding: 1px 7px; border-radius: 6px; font-size: var(--t-xs); font-weight: 750; border: 1px solid transparent; }

/* ---------- Verdict (dashboard) ---------- */

.verdict { margin: 0 0 32px; }
.verdict__title {
    font-size: var(--t-display);
    font-weight: 780;
    line-height: 1.04;
    letter-spacing: -0.035em;
    max-width: 20ch;
}
.verdict--crit .verdict__title .verdict__n { color: var(--crit); }
.verdict--warn .verdict__title .verdict__n { color: var(--warn); }
.verdict--ok .verdict__title .verdict__n { color: var(--ok); }
.verdict .lede { margin-top: 12px; }

.fleetbar {
    display: flex;
    gap: 3px;
    height: 14px;
    margin: 24px 0 14px;
}
.fleetbar span { flex-grow: var(--n); flex-basis: 0; min-width: 6px; border-radius: 4px; }
.b-crit { background: var(--bar-crit); }
.b-warn { background: var(--bar-warn); }
.b-off { background: repeating-linear-gradient(135deg, var(--bar-off) 0 4px, color-mix(in srgb, var(--bar-off) 55%, transparent) 4px 7px); }
.b-unknown { background: var(--bar-unknown); }
.b-ok { background: var(--bar-ok); }
.fleetbar--intro span { transform-origin: left center; animation: grow 700ms cubic-bezier(.2, .7, .2, 1) both; }
.fleetbar--intro span:nth-child(2) { animation-delay: 60ms; }
.fleetbar--intro span:nth-child(3) { animation-delay: 120ms; }
.fleetbar--intro span:nth-child(4) { animation-delay: 180ms; }
.fleetbar--intro span:nth-child(5) { animation-delay: 240ms; }
@keyframes grow { from { transform: scaleX(0); opacity: 0; } to { transform: scaleX(1); opacity: 1; } }

.legend { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0; padding: 0; list-style: none; font-size: var(--t-s); color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.legend a { color: var(--muted); display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.legend a:hover { color: var(--ink); }
.legend a[aria-current] { color: var(--ink); font-weight: 600; }
.legend strong { color: var(--ink); font-weight: 700; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.live { display: inline-flex; align-items: center; gap: 8px; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--bar-ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bar-ok) 25%, transparent); }

/* ---------- Next steps ---------- */

.steps { margin: 0 0 40px; }
.steps__list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.step {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 14px;
    padding: 14px 16px 14px 18px;
    border-top: 1px solid var(--line);
    position: relative;
}
.step:first-child { border-top: 0; }
.step::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--tone); }
.step--critical { --tone: var(--bar-crit); --tone-ink: var(--crit); }
.step--warning { --tone: var(--bar-warn); --tone-ink: var(--warn); }
.step--info { --tone: var(--accent); --tone-ink: var(--info); }
.step__icon { color: var(--tone-ink); display: flex; }
.step__icon .icon { width: 18px; height: 18px; }
.step__title { margin: 0; font-weight: 620; color: var(--ink); }
.step__detail { margin: 2px 0 0; color: var(--muted); font-size: var(--t-s); max-width: 80ch; }
.steps__more { margin-top: 10px; font-size: var(--t-s); }
.steps__more > summary { cursor: pointer; color: var(--accent); font-weight: 600; width: fit-content; }
.steps__more[open] > summary { margin-bottom: 10px; }

.all-clear {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 18px;
    border: 1px solid var(--ok-line);
    background: var(--ok-bg);
    border-radius: 12px;
    color: var(--ok);
}
.all-clear p { margin: 0; color: var(--ink-2); }
.all-clear strong { color: var(--ok); }
.all-clear .icon { width: 20px; height: 20px; }

/* ---------- Callouts & flashes ---------- */

.callout {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 14px 16px;
    border: 1px solid var(--c-line);
    border-left: 3px solid var(--c-ink);
    background: var(--c-bg);
    border-radius: 10px;
    color: var(--ink-2);
    margin: 0 0 16px;
}
.callout > .icon { color: var(--c-ink); margin-top: 2px; }
.callout p { margin: 0; }
.callout p + p, .callout p + ul, .callout ul + p { margin-top: 6px; }
.callout ul { margin: 6px 0 0; padding-left: 18px; }
.callout strong { color: var(--ink); }
.callout__body { min-width: 0; flex: 1; }
.callout--ok { --c-ink: var(--ok); --c-bg: var(--ok-bg); --c-line: var(--ok-line); }
.callout--warn { --c-ink: var(--warn); --c-bg: var(--warn-bg); --c-line: var(--warn-line); }
.callout--crit { --c-ink: var(--crit); --c-bg: var(--crit-bg); --c-line: var(--crit-line); }
.callout--info { --c-ink: var(--info); --c-bg: var(--info-bg); --c-line: var(--info-line); }

.flashes { margin: 0 0 24px; }
.flashes .callout { animation: settle 240ms ease-out both; }
@keyframes settle { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- Buttons & forms ---------- */

button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: 600 14px/1 var(--font);
    font-variation-settings: "MONO" 0;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
button:hover, .btn:hover { background: var(--surface-2); border-color: var(--muted); color: var(--ink); }
.btn--primary, button.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover, button.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn--crit, button.btn--crit { background: var(--crit-solid); border-color: var(--crit-solid); color: var(--crit-solid-ink); }
.btn--crit:hover, button.btn--crit:hover { background: var(--crit-solid-hover); border-color: var(--crit-solid-hover); color: var(--crit-solid-ink); }
.btn--warn, button.btn--warn { background: var(--warn-solid); border-color: var(--warn-solid); color: var(--warn-solid-ink); }
.btn--warn:hover, button.btn--warn:hover { background: var(--warn-solid-hover); border-color: var(--warn-solid-hover); color: var(--warn-solid-ink); }
.btn--danger, button.btn--danger { color: var(--crit); border-color: var(--crit-line); }
.btn--danger:hover, button.btn--danger:hover { background: var(--crit-bg); border-color: var(--crit); color: var(--crit); }
.btn--ghost, button.btn--ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn--ghost:hover, button.btn--ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--ink); }
.btn--sm, button.btn--sm { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

input, select, textarea {
    font: 400 14px/1.4 var(--font);
    min-height: 36px;
    padding: 7px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    min-width: 0;
    max-width: 100%;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}
select { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6b7e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; background-size: 14px; }
input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:hover, select:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input.mono { font-family: var(--font-mono); font-variation-settings: "MONO" 1; font-size: 13.5px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: var(--t-s); font-weight: 600; color: var(--ink-2); }
.field .hint { margin: 0; font-size: var(--t-xs); color: var(--muted); font-weight: 400; }
.field input, .field select { width: 100%; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.fields--stack { grid-template-columns: 1fr; }
.bulletin-card__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.card__subhead { margin: 22px 0 10px; font-size: var(--t-s); font-weight: 650; color: var(--ink); }
.card__subhead .hint { font-weight: 400; color: var(--muted); margin-left: 6px; }
.table-wrap--flat { box-shadow: none; }
dl.kv--versions { gap: 6px 18px; font-size: var(--t-s); }
dl.kv--versions dt { color: var(--ink-2); font-weight: 560; }
dd.versions { font-family: var(--font-mono); font-variation-settings: "MONO" 1; font-size: 0.95em; color: var(--muted); }
.fix-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px 32px; }
.fix-grid__label { margin: 0 0 8px; font-size: var(--t-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.fix-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: var(--t-s); }
.fix-list li { display: flex; flex-direction: column; gap: 2px; }
.fix-links { margin-top: 16px; }
.chip--ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); margin-left: 6px; }
.callout.fill-in { align-items: center; flex-wrap: wrap; margin: 0; }
.callout.fill-in > .callout__body { flex: 1 1 280px; }
.callout.fill-in > .btn { margin-left: auto; }
.job-pick { display: grid; grid-template-columns: minmax(220px, 320px) minmax(0, 1fr); gap: 16px 24px; align-items: start; margin-bottom: 16px; }
.job-help { padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: var(--t-s); }
.job-help p { margin: 0; }
.job-help p + p, .job-help div + p { margin-top: 6px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 20px; }

.filters, .toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.toolbar__search { position: relative; flex: 1 1 220px; max-width: 320px; }
.toolbar__search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.toolbar__search input { width: 100%; padding-left: 34px; }
.toolbar__spacer { flex: 1; }

/* ---------- Tables ---------- */

.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: var(--t-xs); font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color 120ms ease; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
td.muted, td .muted { color: var(--muted); }
td > code:first-child { white-space: nowrap; }
td strong a, td > a:first-child { font-weight: 600; color: var(--ink); }
td > a:first-child:hover { color: var(--accent); }
.cell-sub { display: block; color: var(--muted); font-size: var(--t-xs); margin-top: 2px; }
.cell-actions { text-align: right; white-space: nowrap; }
.card table { font-size: var(--t-s); }

.empty {
    padding: 36px 24px;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    border: 1px dashed var(--line-strong);
    border-radius: 12px;
}
.empty strong { display: block; color: var(--ink); font-size: var(--t-l); margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

.pagination { display: flex; align-items: center; gap: 10px; margin: 16px 0 0; }
.pagination .muted { margin-right: auto; font-size: var(--t-s); }

/* ---------- Sequences (onboarding, agent setup, registry draft) ---------- */

.sequence { list-style: none; margin: 0; padding: 0; counter-reset: seq; }
.sequence > li { counter-increment: seq; position: relative; padding: 0 0 26px 46px; }
.sequence > li::before {
    content: counter(seq);
    position: absolute; left: 0; top: -2px;
    width: 30px; height: 30px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--surface);
    border: 1.5px solid var(--line-strong);
    color: var(--ink-2);
    font-weight: 700; font-size: 13px;
}
.sequence > li::after { content: ""; position: absolute; left: 15px; top: 32px; bottom: 4px; width: 1.5px; background: var(--line); }
.sequence > li:last-child { padding-bottom: 0; }
.sequence > li:last-child::after { display: none; }
.sequence > li.is-done::before { content: "✓"; background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.sequence > li.is-current::before { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sequence h3 { margin: 2px 0 6px; font-size: var(--t-m); }
.sequence__body > p, details.disclosure > p { color: var(--muted); max-width: 76ch; }
.sequence__body > * + * { margin-top: 10px; }

.codeblock { position: relative; }
.codeblock pre { padding-right: 84px; white-space: pre-wrap; overflow-wrap: anywhere; }
.codeblock .copy { position: absolute; top: 8px; right: 8px; }
.codeblock--nowrap pre { white-space: pre; overflow-wrap: normal; overflow-x: auto; }

/* ---------- Bulletins (Patches page) ---------- */

.bulletins { list-style: none; margin: 0; padding: 0; }
.bulletin {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    gap: 4px 14px;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid var(--line);
}
.bulletin:first-child { border-top: 0; padding-top: 4px; }
.bulletin__title { font-weight: 600; color: var(--ink); text-decoration: none; }
.bulletin__title:hover { color: var(--accent); text-decoration: underline; }
.bulletin__meta { display: block; margin-top: 2px; color: var(--muted); font-size: var(--t-xs); }
.bulletin__actions { display: flex; gap: 8px; }

details.disclosure > summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: var(--t-s); list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before { content: ""; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform 150ms ease; }
details.disclosure[open] > summary::before { transform: rotate(45deg); }
details.disclosure[open] > summary { margin-bottom: 12px; }

.variant-row { grid-template-columns: 180px minmax(160px, 2fr) minmax(160px, 1.4fr) minmax(140px, 1.4fr); gap: 8px; margin-bottom: 8px; }
.variant-row--head { display: grid; margin-bottom: 6px; font-size: var(--t-xs); font-weight: 600; color: var(--muted); }
.variant-add { margin: 18px 0 8px; font-size: var(--t-s); font-weight: 600; color: var(--ink-2); }
.variant-add .hint { margin-left: 6px; font-size: var(--t-xs); font-weight: 400; color: var(--muted); }

/* ---------- Environment page ---------- */

.subnav { display: flex; flex-wrap: wrap; gap: 4px; margin: 32px 0 20px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; width: fit-content; max-width: 100%; }
.subnav a { padding: 6px 12px; border-radius: 7px; color: var(--muted); font-size: var(--t-s); font-weight: 560; }
.subnav a:hover { background: var(--surface-2); color: var(--ink); }

.tabs__label { margin: 22px 0 10px; font-size: var(--t-s); font-weight: 600; color: var(--ink-2); }
.tabs__list { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; max-width: 760px; margin: 0 0 26px; }
.tabs__list [role="tab"] {
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 12px; row-gap: 3px;
    justify-content: stretch; min-height: 0; padding: 14px 16px; text-align: left; white-space: normal;
    border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink);
    font-weight: 400; line-height: 1.35;
}
.tabs__list [role="tab"] > .icon { grid-row: 1 / span 2; width: 22px; height: 22px; color: var(--muted); }
.tab__title { font-size: var(--t-m); font-weight: 650; }
.tab__hint { grid-column: 2; color: var(--muted); font-size: var(--t-xs); }
.tab__radio { grid-column: 3; grid-row: 1 / span 2; width: 18px; height: 18px; border: 1.5px solid var(--line-strong); border-radius: 50%; transition: border-color 150ms ease, border-width 150ms ease; }
.tabs__list [role="tab"]:hover { background: var(--surface-2); border-color: var(--muted); color: var(--ink); }
.tabs__list [role="tab"]:hover .tab__radio { border-color: var(--muted); }
.tabs__list [role="tab"][aria-selected="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); box-shadow: 0 0 0 1px var(--accent); }
.tabs__list [role="tab"][aria-selected="true"] > .icon { color: var(--accent); }
.tabs__list [role="tab"][aria-selected="true"] .tab__radio { border: 5px solid var(--accent); }
.tabs:not(.tabs--ready) > .tabs__label, .tabs:not(.tabs--ready) > .tabs__list { display: none; }
.tabs__panel > p.muted { margin: 0 0 18px; max-width: 76ch; }
.tabs__panel:focus-visible { outline-offset: 6px; }

details.why { margin-top: 8px; }
details.why > summary { display: inline-flex; cursor: pointer; font-weight: 600; font-size: var(--t-xs); padding: 2px 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink-2); list-style: none; }
details.why > summary::-webkit-details-marker { display: none; }
details.why[open] > summary { margin-bottom: 10px; }
details.why .kv { font-size: var(--t-xs); margin-bottom: 10px; }
details.why .parts { list-style: none; margin: 0; padding: 0; }
table.why-hunks { font-size: var(--t-xs); border: 1px solid var(--line); }
table.why-hunks th, table.why-hunks td { padding: 5px 8px; }

.file { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.file + .file { margin-top: 8px; }
.file > summary { cursor: pointer; padding: 10px 14px; font-size: var(--t-s); list-style: none; }
.file > summary::-webkit-details-marker { display: none; }
.file[open] > summary { border-bottom: 1px solid var(--line); }
.file pre { border: 0; border-radius: 0 0 10px 10px; }

.danger-zone { margin-top: 56px; padding: 18px 20px; border: 1px solid var(--crit-line); border-radius: 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.danger-zone h2 { margin: 0 0 2px; font-size: var(--t-m); }
.danger-zone p { margin: 0; color: var(--muted); font-size: var(--t-s); max-width: 70ch; }

/* ---------- Dialog ---------- */

dialog {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0;
    width: min(520px, calc(100vw - 32px));
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-pop);
}
dialog::backdrop { background: rgb(16 24 40 / 0.45); backdrop-filter: blur(2px); }
dialog[open] { animation: pop 180ms ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
.dialog__head { padding: 20px 22px 0; }
.dialog__head p { color: var(--muted); font-size: var(--t-s); margin-top: 6px; }
.dialog__body { padding: 18px 22px; }
.dialog__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 14px 14px; }

/* ---------- Sign in ---------- */

.auth { display: grid; place-items: center; padding: 6vh 0 40px; }
.auth__panel { width: min(400px, 100%); }
.auth h1 { font-size: 30px; letter-spacing: -0.03em; }
.auth .card { margin-top: 24px; padding: 24px; }
.auth button { width: 100%; margin-top: 4px; }

/* ---------- Responsive & preferences ---------- */

@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .wrap { padding: 0 16px; }
    footer .wrap { padding: 18px 16px; }
    .topbar .wrap { flex-wrap: wrap; gap: 0 16px; padding-top: 10px; }
    .mainnav { order: 3; width: calc(100% + 16px); overflow-x: auto; min-height: 44px; margin: 0 -8px; gap: 0; scrollbar-width: none; }
    .mainnav a { padding: 0 8px; white-space: nowrap; }
    .topbar__user { display: none; }
    main.wrap { padding-top: 24px; }
    .step { grid-template-columns: auto minmax(0, 1fr); }
    .step > .btn { grid-column: 2; justify-self: start; margin-top: 8px; }
    .bulletin { grid-template-columns: 40px minmax(0, 1fr); }
    .bulletin__actions { grid-column: 2; }
    .variant-row { grid-template-columns: minmax(0, 1fr); margin-bottom: 16px; }
    .variant-row--head { display: none; }
    .job-pick { grid-template-columns: 1fr; }
    .facts { grid-template-columns: 1fr 1fr; }
    .facts > div { border-left: 0; border-top: 1px solid var(--line); }
    .facts > div:nth-child(-n+2) { border-top: 0; }
    .facts > div:nth-child(even) { border-left: 1px solid var(--line); }
    th, td { padding: 10px 12px; }
}

@media (pointer: coarse) {
    button, .btn, input, select { min-height: 44px; }
    .btn--sm, button.btn--sm { min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
