/*! Golem Guard © 2026 Roberto J. Franco-Del Toro. All rights reserved. Proprietary license — see LICENSE.txt. */
:root {
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #ffffff;
  --accent: #2563eb;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;

  /* Grade / score scale */
  --g-a: #15803d;   --g-a-bg: #dcfce7;
  --g-b: #0f766e;   --g-b-bg: #ccfbf1;
  --g-c: #b45309;   --g-c-bg: #fef3c7;
  --g-d: #c2410c;   --g-d-bg: #ffedd5;
  --g-f: #b91c1c;   --g-f-bg: #fee2e2;

  /* Priority tiers (fills) and their text colours on the page background */
  --p1: #b91c1c; --p2: #ea580c; --p3: #d97706; --p4: #0e7490; --p5: #64748b;
  --p1-text: #b91c1c; --p2-text: #ea580c; --p3-text: #b45309; --p4-text: #0e7490;

  /* Surfaces and states (light theme) */
  --surface-2: #f1f5f9;          /* subtle fills: hovers, bar tracks, chips, code */
  --surface-3: #f8fafc;          /* row hover, evidence blocks, not-assessed cards */
  --accent-hover: #1d4ed8;
  --hover-border: #93c5fd;
  --select-bg: #eff6ff;          /* menu hover, filter pills */
  --pill-text: #1e40af; --pill-border: #bfdbfe; --pill-hover: #dbeafe;
  --chip-text: #334155;
  --open-bg: #fee2e2;     --open-text: #991b1b;
  --progress-bg: #fef3c7; --progress-text: #92400e;
  --resolved-bg: #dcfce7; --resolved-text: #166534;
  --warn-border: #fdba74; --ok-border: #86efac;
  --danger: #b91c1c; --danger-hover: #991b1b;
  --overlay: rgba(15, 23, 42, .45);
  --raised-shadow: 0 10px 30px rgba(15, 23, 42, .18);
  color-scheme: light;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06);

  /* Type scale. Every step is in rem, so it follows the fluid root size below and the user's own text-size setting. */
  --fs-2xs: .7143rem;  --fs-xs: .7857rem;  --fs-sm: .8571rem;  --fs-md: .9286rem;  --fs-base: 1rem;
  --fs-lg: 1.071rem;   --fs-xl: 1.286rem;  --fs-2xl: 1.429rem; --fs-3xl: 1.571rem; --fs-4xl: 1.714rem; --fs-5xl: 2.143rem;

  /* Fluid spacing: page gutter, gaps between cards, gaps inside grids (about 12-36px, 12-24px and 8-16px). */
  --gutter: clamp(.75rem, .35rem + 1.6vw, 2.25rem);
  --gap: clamp(.75rem, .5rem + .9vw, 1.5rem);
  --gap-s: clamp(.5rem, .35rem + .6vw, 1rem);

  /* Motion: quick, settled responses; nothing moves when the user prefers reduced motion. */
  --ease-out-expo: cubic-bezier(.16, 1, .3, 1);
  --dur-fast: .15s;
  --dur: .35s;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* ---------- Dark theme ----------
   theme.js sets data-theme="dark" before first paint, from the saved choice or the system setting.
   Colours keep WCAG AA contrast for text on --card and --bg. */
:root[data-theme="dark"] {
  --sidebar: #0a0f1c; --sidebar-hover: #1a2338; --sidebar-text: #cbd5e1;
  --accent: #3b82f6; --accent-hover: #2563eb;
  --bg: #0b1220; --card: #111a2e; --border: #24324a; --text: #e2e8f0; --muted: #94a3b8;
  --g-a: #4ade80; --g-a-bg: rgba(34, 197, 94, .16);
  --g-b: #2dd4bf; --g-b-bg: rgba(20, 184, 166, .16);
  --g-c: #fbbf24; --g-c-bg: rgba(245, 158, 11, .16);
  --g-d: #fb923c; --g-d-bg: rgba(249, 115, 22, .16);
  --g-f: #f87171; --g-f-bg: rgba(239, 68, 68, .16);
  --p1-text: #f87171; --p2-text: #fb923c; --p3-text: #fbbf24; --p4-text: #22d3ee;
  --surface-2: #1a2540; --surface-3: #0f1829;
  --hover-border: #3b5b8f; --select-bg: #172554;
  --pill-text: #bfdbfe; --pill-border: #1e3a8a; --pill-hover: #1e3a8a;
  --chip-text: #cbd5e1;
  --open-bg: rgba(239, 68, 68, .18);     --open-text: #fca5a5;
  --progress-bg: rgba(245, 158, 11, .18); --progress-text: #fcd34d;
  --resolved-bg: rgba(34, 197, 94, .18);  --resolved-text: #86efac;
  --warn-border: #9a3412; --ok-border: #166534;
  --danger: #dc2626; --danger-hover: #b91c1c;
  --overlay: rgba(2, 6, 23, .7);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --raised-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* Fluid root: ~13px on small windows, 14px at 1440px wide, up to 17px on large displays (at the default 16px
   browser text size). In rem, so a larger browser text size enlarges the whole app too. */
html { font-size: clamp(.8125rem, .65rem + .25vw, 1.0625rem); }
body { margin: 0; font-size: 1rem; line-height: 1.45; overflow-x: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: var(--fs-sm); }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: clamp(200px, 15vw, 280px) minmax(0, 1fr); min-height: 100vh; min-height: 100svh; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 22px; }
.brand-mark { width: clamp(36px, 2.8vw, 48px); height: auto; aspect-ratio: 1; flex: none; display: block; }
.brand-text { display: grid; line-height: 1.15; min-width: 0; }
.brand-sub { font-size: var(--fs-xs); color: #94a3b8; }
.brand-name { color: #fff; font-weight: 700; font-size: 1.143rem; letter-spacing: .01em; }
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.nav-item {
  width: 100%; text-align: left; background: none; border: 0; border-radius: 8px;
  padding: 10px 12px; color: var(--sidebar-text); cursor: pointer; border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item[aria-current="page"] { background: var(--sidebar-hover); color: var(--sidebar-active); border-left-color: var(--accent); font-weight: 600; }
.app-meta { margin-top: auto; font-size: var(--fs-xs); color: #94a3b8; padding: 0 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: grid; gap: 8px;
  padding: clamp(10px, 1vw, 16px) var(--gutter); background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-label { font-weight: 600; color: var(--muted); }
#workspace { padding: clamp(12px, 1.6vw, 32px) var(--gutter) clamp(24px, 3vw, 48px); }
.view { display: grid; gap: var(--gap); }
.page-title { font-size: var(--fs-3xl); }
.section-title { font-size: var(--fs-lg); margin-top: 4px; }

/* ---------- Controls ---------- */
select, input[type="search"] {
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; background: var(--card); min-height: 36px;
}
select:focus-visible, input:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn {
  border: 1px solid var(--border); background: var(--card); border-radius: 8px; padding: 7px 12px;
  cursor: pointer; min-height: 36px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.icon-btn { border: 0; background: none; font-size: var(--fs-4xl); line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 6px; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar input[type="search"] { min-width: 220px; flex: 1; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; padding: clamp(14px, 1.3vw, 24px); }
.card-title { font-size: var(--fs-lg); }

/* Summary */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: clamp(14px, 2vw, 32px); align-items: center; }
.summary-id { display: flex; gap: 16px; align-items: center; }
.summary h1 { font-size: var(--fs-3xl); }
.grade-badge {
  width: clamp(64px, 5.5vw, 100px); aspect-ratio: 1; border-radius: 14px; display: grid; place-content: center; text-align: center;
  font-weight: 800; flex: none; border: 2px solid currentColor;
}
.grade-badge .g-letter { font-size: var(--fs-5xl); line-height: 1; }
.grade-badge .g-score { font-size: var(--fs-md); font-weight: 600; }
.trend { margin: 6px 0 0; font-weight: 600; font-size: var(--fs-md); }
.trend.up { color: var(--g-a); }
.trend.down { color: var(--g-f); }
.trend.flat { color: var(--muted); }

.benchmark { display: grid; gap: 8px; }
.bench-row { display: grid; grid-template-columns: minmax(100px, auto) 1fr 3em; gap: 10px; align-items: center; }
.bench-label { font-size: var(--fs-sm); color: var(--muted); }
.bench-val { font-weight: 700; text-align: right; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; width: 0; background: var(--muted); }
.bar-bench { background: #94a3b8; }

.summary-stats { display: flex; gap: 22px; margin: 0; }
.summary-stats div { text-align: center; }
.summary-stats dt { font-size: var(--fs-sm); color: var(--muted); }
.summary-stats dd { margin: 2px 0 0; font-size: var(--fs-3xl); font-weight: 700; }

/* Grade colors (shared by badges, bars, pills) */
.grade-A { color: var(--g-a); background: var(--g-a-bg); }
.grade-B { color: var(--g-b); background: var(--g-b-bg); }
.grade-C { color: var(--g-c); background: var(--g-c-bg); }
.grade-D { color: var(--g-d); background: var(--g-d-bg); }
.grade-F { color: var(--g-f); background: var(--g-f-bg); }
.fill-A { background: var(--g-a); } .fill-B { background: var(--g-b); } .fill-C { background: var(--g-c); }
.fill-D { background: var(--g-d); } .fill-F { background: var(--g-f); }

.txt-A { color: var(--g-a); } .txt-B { color: var(--g-b); } .txt-C { color: var(--g-c); } .txt-D { color: var(--g-d); } .txt-F { color: var(--g-f); }
.score-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 99px; font-weight: 700; font-size: var(--fs-sm); }

/* Domain grid */
.domain-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: var(--gap-s); }
.domain-card {
  text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; cursor: pointer; display: grid; gap: 8px; box-shadow: var(--shadow);
}
.domain-card:hover { border-color: var(--hover-border); }
.domain-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); }
.domain-name { font-weight: 600; font-size: var(--fs-md); min-height: 2.5em; }
.domain-score { font-size: var(--fs-4xl); font-weight: 800; }
.domain-issues { font-size: var(--fs-sm); color: var(--muted); }
.domain-card .bar-track { height: 6px; }

/* Split: matrix + findings */
.split { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(0, 2.6fr); gap: var(--gap); align-items: start; }

/* Matrix */
.matrix { display: grid; grid-template-columns: minmax(60px, auto) repeat(3, 1fr); gap: 6px; margin-top: 14px; }
.matrix-axis { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); display: flex; align-items: center; justify-content: center; text-align: center; }
.matrix-axis.row { justify-content: flex-start; }
.matrix-corner { font-size: var(--fs-2xs); color: var(--muted); display: flex; align-items: flex-end; }
.matrix-cell {
  border: 2px solid transparent; border-radius: 8px; aspect-ratio: 16 / 10; min-height: 52px; cursor: pointer; color: #fff;
  display: grid; place-content: center; text-align: center; gap: 1px;
}
.matrix-cell .m-count { font-size: var(--fs-2xl); font-weight: 800; line-height: 1; }
.matrix-cell .m-tier { font-size: var(--fs-2xs); opacity: .9; font-weight: 600; }
.matrix-cell.empty { opacity: .35; }
.matrix-cell[aria-pressed="true"] { border-color: var(--text); box-shadow: 0 0 0 2px #fff inset; }
.matrix.has-active .matrix-cell[aria-pressed="false"] { opacity: .4; }
.cell-P1 { background: var(--p1); } .cell-P2 { background: var(--p2); } .cell-P3 { background: var(--p3); }
.cell-P4 { background: var(--p4); } .cell-P5 { background: var(--p5); }
.tier-legend { list-style: none; display: flex; gap: 6px; padding: 0; margin: 14px 0 0; flex-wrap: wrap; }

/* Badges */
.tier { display: inline-block; min-width: 30px; text-align: center; padding: 2px 7px; border-radius: 6px; font-weight: 700; font-size: var(--fs-xs); color: #fff; }
.tier-P1 { background: var(--p1); } .tier-P2 { background: var(--p2); } .tier-P3 { background: var(--p3); }
.tier-P4 { background: var(--p4); } .tier-P5 { background: var(--p5); }
.sev { font-weight: 600; font-size: var(--fs-sm); }
.sev-Critical { color: var(--p1-text); } .sev-High { color: var(--p2-text); } .sev-Medium { color: var(--p3-text); } .sev-Low { color: var(--p4-text); }
.status { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.status-Open { background: var(--open-bg); color: var(--open-text); }
.status-In-Progress { background: var(--progress-bg); color: var(--progress-text); }
.status-Resolved { background: var(--resolved-bg); color: var(--resolved-text); }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); font-size: var(--fs-xs); font-weight: 600; color: var(--chip-text); }

/* Findings */
.findings-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; margin: 8px 0; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; background: var(--select-bg); color: var(--pill-text); border: 1px solid var(--pill-border);
  border-radius: 99px; padding: 3px 4px 3px 10px; font-size: var(--fs-sm); font-weight: 600;
}
.pill button { border: 0; background: none; cursor: pointer; color: inherit; font-size: 1rem; line-height: 1; border-radius: 99px; padding: 0 5px; }
.pill button:hover { background: var(--pill-hover); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; white-space: nowrap; }
th .sort-btn { border: 0; background: none; padding: 0; cursor: pointer; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; display: inline-flex; gap: 4px; }
th[aria-sort="ascending"] .sort-btn::after { content: "▲"; }
th[aria-sort="descending"] .sort-btn::after { content: "▼"; }
th .sort-btn::after { content: "↕"; opacity: .45; font-size: var(--fs-2xs); }
th[aria-sort] .sort-btn::after { opacity: 1; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-3); }
tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
td.title-cell { font-weight: 600; min-width: 180px; }
td.host-cell { word-break: break-all; min-width: 120px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-sm); color: var(--chip-text); }
.empty-state { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty-state strong { display: block; color: var(--text); font-size: var(--fs-lg); margin-bottom: 4px; }
.row-count { margin: 10px 0 0; font-size: var(--fs-sm); color: var(--muted); }

/* Portfolio */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: var(--gap-s); }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi dt { font-size: var(--fs-sm); color: var(--muted); }
.kpi dd { margin: 4px 0 0; font-size: var(--fs-4xl); font-weight: 800; }
.kpi { margin: 0; }
.delta-up { color: var(--g-a); font-weight: 700; }
.delta-down { color: var(--g-f); font-weight: 700; }
.mini-bar { width: clamp(80px, 8vw, 180px); }

/* Drawer */
.backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(clamp(380px, 36vw, 680px), 100vw); background: var(--card); z-index: 21;
  display: flex; flex-direction: column; box-shadow: var(--raised-shadow);
}
@keyframes slide { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: var(--fs-xl); margin-top: 2px; }
.drawer-body { padding: 18px 20px 30px; overflow-y: auto; display: grid; gap: 20px; }
.drawer-body h3 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; }
.evidence { margin: 0; background: var(--surface-3); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-sm); white-space: pre-wrap; word-break: break-word; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.checklist input { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.checklist input:checked + span { text-decoration: line-through; color: var(--muted); }

/* Assess Target */
.assess-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: var(--fs-md); }
.field.grow { flex: 1 1 min(100%, 360px); }
.field.grow input { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 38px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.field.grow input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 36px; }
.input-clear {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%); width: 30px; height: 30px;
  border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: var(--fs-xl); line-height: 1; cursor: pointer;
}
.input-clear:hover { background: var(--surface-2); color: var(--text); }
.input-clear[hidden] { display: none; }
.actions-field { flex-direction: row; display: flex; gap: 8px; padding-top: 25px; }
.topbar-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 36px; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.topbar .progress { margin-top: 0; }
#assess-status:empty { display: none; }
.welcome { text-align: center; padding: 48px 24px; }
.welcome h1 { font-size: var(--fs-2xl); margin-bottom: 8px; }
.welcome p { max-width: 620px; margin: 0 auto; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.hint-error { color: var(--g-f); margin: 0; font-weight: 600; }
.hint-ok { color: var(--g-a); margin: 0; font-weight: 600; }
.progress { margin-top: 14px; height: 8px; }
.progress-fill { background: var(--accent); }
#assess-status { margin: 0; }
.privacy-note { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 10px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
#assess-report h3 { font-size: var(--fs-lg); margin-bottom: 10px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 16px; margin-bottom: 14px; }
.report-grid h4.sub-h { margin-top: 10px; }
.report-grid h4 { margin: 0 0 6px; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.plain-list { margin: 0; padding-left: 18px; font-size: var(--fs-md); display: grid; gap: 3px; word-break: break-word; }
td.actions { display: flex; gap: 6px; justify-content: flex-end; }
tr.no-pointer { cursor: default; }
.domain-card.not-assessed { background: var(--surface-3); border-style: dashed; }

.hint-warn { color: var(--g-d); margin: 0; font-weight: 600; }
.net-ok { color: var(--g-a); font-weight: 600; }
.net-bad { color: var(--g-f); font-weight: 600; }
.advice { margin-top: 12px; padding: 12px 14px; border-radius: 8px; background: var(--g-d-bg); border: 1px solid var(--warn-border); display: grid; gap: 6px; justify-items: start; }
.advice p { margin: 0; }
.incomplete-note { grid-column: 1 / -1; display: block; margin: 0; order: 9; font-size: var(--fs-md); }
.grade-badge.incomplete { border-style: dashed; }
.chip-warn { background: var(--g-d-bg); color: var(--g-d); margin-left: 6px; }
.advice-ok { background: var(--g-a-bg); border-color: var(--ok-border); }
.advice .request { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-sm); background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; user-select: all; word-break: break-word; }

.site-footer { flex: none; padding: 6px var(--gutter); border-top: 1px solid var(--border); background: var(--card); }
.copyline { margin: 0; font-size: var(--fs-xs); color: var(--muted); line-height: 1.35; }
.copyline a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.footline { margin-bottom: 3px; }
.footline strong { color: var(--text); font-weight: 600; }

.export-menu { position: relative; }
.export-menu > summary { list-style: none; display: inline-flex; align-items: center; user-select: none; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu .menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 260px; display: grid;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--raised-shadow); padding: 6px; }
.export-menu .menu button { text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 6px; cursor: pointer; }
.export-menu .menu button:hover, .export-menu .menu button:focus-visible { background: var(--select-bg); }

/* ---------- Top bar: one compact row (form · target tools), hints underneath ---------- */
/* The top bar carries only what applies to every results page (target switcher, export, run progress and messages);
   the assessment form lives on Run Assessment. It disappears when it has nothing to show. */
.topbar { display: flex; flex-wrap: wrap; align-items: center; column-gap: clamp(10px, 1.5vw, 24px); row-gap: 4px; }
.topbar:has(#target-tools[hidden]):has(#assess-progress[hidden]):has(#assess-status:empty) { display: none; }
.topbar-row { display: contents; }

/* Run Assessment form */
.assess-card { display: grid; gap: 10px; }
.assess-card .assess-form { gap: 10px; align-items: end; flex-wrap: nowrap; }
.assess-card .assess-form .field.grow { flex: 1 1 260px; min-width: 220px; }
.assess-card .assess-form .field { gap: 3px; }
.assess-card .assess-form .field label { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.assess-card .actions-field { padding-top: 0; }
.assess-card #target-hint { margin: 0; min-height: 1.3em; }
/* The target tools sit beside the form when there is room and wrap below it when there is not. */
#assess-status { order: 1; flex: 1 1 320px; min-width: 0; word-break: break-word; }
#target-tools { order: 2; flex: 0 0 auto; margin-left: auto; flex-wrap: nowrap; }
#assess-progress { order: 3; flex: 1 1 100%; }
#vendor-select { max-width: clamp(160px, 18vw, 300px); }
thead th { position: sticky; top: 0; background: var(--card); z-index: 1; }

/* ---------- Desktop: the app fits the window; only lists scroll inside their cards ---------- */
@media (min-width: 1024px) and (min-height: 600px) {
  html, body { height: 100%; overflow: hidden; }
  .shell { height: 100vh; height: 100dvh; min-height: 0; }
  .main { height: 100vh; height: 100dvh; overflow: hidden; }
  #workspace { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column;
    padding: clamp(8px, 1.6vh, 24px) clamp(12px, 1.8vw, 32px); }
  .view:not([hidden]), .welcome:not([hidden]) { flex: 1; min-height: 0; }
  .view { gap: clamp(8px, 1.6vh, 20px); }
  .card { padding: clamp(10px, 1.8vh, 22px) var(--gap); }
  .page-title { font-size: clamp(1.1rem, 2.4vh, 1.6rem); }

  /* Vendor Rating: summary, domains, then matrix + findings take the remaining height */
  #view-vendor { grid-template-rows: auto auto auto minmax(0, 1fr); }
  .summary { gap: clamp(10px, 1.6vw, 28px); }
  .grade-badge { width: clamp(52px, 8.5vh, 92px); }
  .grade-badge .g-letter { font-size: clamp(1.5rem, 3.6vh, 2.3rem); }
  .summary h1 { font-size: clamp(1.15rem, 2.6vh, 1.7rem); }
  .summary-stats dd { font-size: clamp(1.15rem, 2.6vh, 1.7rem); }
  .section-title { margin: 0; font-size: clamp(.9rem, 1.8vh, 1.1rem); }
  .domain-card { padding: clamp(8px, 1.3vh, 16px) clamp(10px, 1vw, 16px); gap: clamp(3px, .7vh, 8px); }
  .domain-name { min-height: 0; }
  .domain-score { font-size: clamp(1.2rem, 3vh, 1.9rem); line-height: 1.1; }
  .split { min-height: 0; height: 100%; align-items: stretch; }
  .matrix-card, .findings-card { display: flex; flex-direction: column; min-height: 0; }
  .matrix { flex: 1; min-height: 0; grid-template-rows: auto repeat(4, minmax(0, 1fr)); margin-top: clamp(6px, 1.2vh, 14px); }
  .matrix-cell { aspect-ratio: auto; min-height: 0; }
  .matrix-cell .m-count { font-size: clamp(1rem, 2.6vh, 1.6rem); }
  .tier-legend { margin-top: clamp(6px, 1.2vh, 14px); }
  .findings-card .table-wrap, #view-portfolio .table-wrap, #view-explorer .table-wrap {
    flex: 1; min-height: 0; overflow: auto; }

  /* Portfolio, Explorer, Details: header rows fixed, the list card fills the rest */
  #view-portfolio { grid-template-rows: auto auto minmax(0, 1fr); }
  #view-explorer { grid-template-rows: auto minmax(0, 1fr); }
  #view-assess, #view-verify { overflow-y: auto; align-content: start; padding-right: 4px; }
  #view-portfolio > .card, #view-explorer > .card { display: flex; flex-direction: column; min-height: 0; }
  .welcome { display: grid; place-content: center; }
}

/* Desktop rows never wrap: summary in three columns, the five domains in one row */
@media (min-width: 1024px) and (min-height: 600px) {
  .summary { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.2fr) auto; }
  .domain-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .domain-name { font-size: clamp(.78rem, .9vw, .93rem); }
}
@media (min-width: 1024px) and (max-width: 1279px) {
  .bench-row { grid-template-columns: minmax(84px, auto) 1fr 2.6em; }
  .summary-stats { gap: 12px; }
}
/* Short desktop windows: drop secondary text so everything still fits */
@media (min-width: 1024px) and (min-height: 600px) and (max-height: 760px) {
  .matrix-card > .muted, .domain-issues, #bench-note { display: none; }
  .summary-stats dt { font-size: var(--fs-2xs); }
}

/* Matrix and findings stack on medium widths */
@media (max-width: 1180px) {
  .split { grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr); }
}

/* ---------- Tablets and phones: natural page scroll, stacked layout ---------- */
@media (max-width: 1023px), (max-height: 599px) {
  .split { grid-template-columns: 1fr; }
  .matrix-card { max-width: 640px; width: 100%; }
  .topbar { position: static; }
  .assess-card .assess-form { flex-wrap: wrap; }
  #target-tools { margin-left: 0; flex-wrap: wrap; }
  #assess-status { flex-basis: 100%; }
  .table-wrap { max-height: none; }
  .matrix-cell { aspect-ratio: auto; min-height: clamp(48px, 7vh, 72px); }
}
@media (max-width: 900px) {
  /* minmax(0, …): the nav bar's tabs scroll sideways instead of setting the page's minimum width. */
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center;
    gap: 10px; padding: 8px 12px; flex-wrap: nowrap; }
  .brand { padding: 0; flex: none; }
  .brand-sub { display: none; }
  .sidebar nav { flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .nav-list { display: flex; gap: 2px; flex-wrap: nowrap; }
  .nav-item { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; border-radius: 6px; padding: 7px 10px; }
  .nav-item[aria-current="page"] { border-bottom-color: var(--accent); }
  .app-meta { display: none; }
  .report-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .assess-card .assess-form { display: grid; grid-template-columns: 1fr 1fr; }
  .assess-card .assess-form .field.grow, .assess-card .actions-field { grid-column: 1 / -1; }
  .assess-card .assess-form #cap-row[hidden] + .actions-field { grid-column: 1 / -1; }
  .assess-card .assess-form select, #vendor-select { width: 100%; max-width: none; }
  .assess-card .assess-form .field.grow { min-width: 0; }
  #assess-run { flex: 1; }
  #target-tools { display: grid; grid-template-columns: auto 1fr; width: 100%; }
  #target-tools #export-csv { grid-column: 1 / -1; }
  .summary-id { align-items: flex-start; }
  .summary-stats { justify-content: space-between; }
  .bench-row { grid-template-columns: 96px 1fr 2.6em; }
  .toolbar > * { flex: 1 1 100%; }
  .toolbar input[type="search"] { min-width: 0; }
  .welcome { padding: 28px 16px; }
  .assess-form:has(#cap-row[hidden]) > .field:nth-child(2) { grid-column: 1 / -1; }
  .matrix-cell { aspect-ratio: auto; min-height: 48px; }
  .matrix { grid-template-columns: minmax(54px, auto) repeat(3, 1fr); }

  .drawer { width: 100vw; }
  .kv { grid-template-columns: 100px 1fr; }
}

/* ---------- Tables adapt to their own card, not the window ----------
   A findings table squeezed into a narrow slot (phone, or beside the matrix on a small laptop) turns into stacked
   cards, one finding per card, with labels taken from the column headers. */
.table-wrap { container: table / inline-size; }
@container table (max-width: 34rem) {
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-wrap tr { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: var(--card);
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .table-wrap td { border: 0; padding: 0; min-width: 0; }
  .table-wrap td[data-label]::before { content: attr(data-label); display: block; font-size: var(--fs-2xs); text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted); font-weight: 700; margin-bottom: 1px; }
  .table-wrap td.title-cell { grid-column: 1 / -1; min-width: 0; font-size: var(--fs-lg); }
  .table-wrap td.title-cell::before { display: none; }
  .table-wrap td.actions { grid-column: 1 / -1; justify-content: flex-start; }
  .table-wrap td.actions::before { display: none; }
  .table-wrap td.host-cell { min-width: 0; }
}

/* ---------- Motion (only when the user has not asked for reduced motion) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .btn, .nav-item, .icon-btn, .pill button, .export-menu .menu button { transition: background-color var(--dur-fast) var(--ease-out-expo), color var(--dur-fast) var(--ease-out-expo); }
  .domain-card { transition: border-color var(--dur-fast) var(--ease-out-expo), box-shadow var(--dur-fast) var(--ease-out-expo), transform var(--dur-fast) var(--ease-out-expo); }
  .domain-card:hover { transform: translateY(-2px); }
  .matrix-cell { transition: transform var(--dur-fast) var(--ease-out-expo), opacity var(--dur-fast) var(--ease-out-expo); }
  .matrix-cell:hover { transform: scale(1.03); }
  .bar-fill { transition: width var(--dur) var(--ease-out-expo); }
  .backdrop { animation: fade .25s var(--ease-out-expo); }
  .drawer { animation: slide .45s var(--ease-out-expo); }
  /* Switching sections cross-fades (View Transitions API, where supported). */
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; animation-timing-function: var(--ease-out-expo); }
}

/* ---------- Theme picker (sidebar) ---------- */
.theme-pick { display: grid; gap: 4px; margin: 18px 8px 0; }
.theme-pick label { font-size: var(--fs-xs); color: #94a3b8; }
.theme-pick select { background: var(--sidebar-hover); color: var(--sidebar-text); border-color: #334155; min-height: 32px; padding: 4px 8px; }
@media (max-width: 900px) {
  .theme-pick { margin: 0; flex: none; }
  .theme-pick label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .theme-pick select { min-height: 30px; }
}

/* ---------- Delete-all dialog ---------- */
.dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(30rem, calc(100vw - 2rem));
  background: var(--card); color: var(--text); box-shadow: var(--raised-shadow); }
.dialog::backdrop { background: var(--overlay); }
.dialog form { display: grid; gap: 10px; padding: clamp(16px, 3vw, 24px); }
.dialog h2 { font-size: var(--fs-xl); }
.dialog p { margin: 0; }
.phrase { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-lg); font-weight: 700; padding: 8px 12px;
  background: var(--surface-2); border: 1px dashed var(--border); border-radius: 8px; user-select: none; -webkit-user-select: none; }
#wipe-input { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 38px; background: var(--card);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
#wipe-input:focus-visible { outline: 2px solid var(--danger); outline-offset: 2px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

/* ---------- Verify report ---------- */
.verify-card { display: grid; gap: 14px; }
.drop-zone { display: grid; place-items: center; gap: 4px; text-align: center; padding: clamp(20px, 4vw, 40px) 16px; cursor: pointer;
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface-3); }
.drop-zone:hover, .drop-zone.over { border-color: var(--accent); background: var(--select-bg); }
.drop-zone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.verify-hash { display: grid; gap: 6px; }
.verify-hash label { font-weight: 600; font-size: var(--fs-md); }
.hash-row { display: flex; gap: 8px; flex-wrap: wrap; }
.hash-row input { flex: 1 1 18rem; min-width: 0; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 38px;
  background: var(--card); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
#verify-result { display: grid; gap: 10px; justify-items: start; }
#verify-result > .verdict { justify-self: stretch; }
.verdict { display: grid; gap: 8px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); }
.verdict h3 { font-size: var(--fs-lg); }
.verdict.ok { background: var(--g-a-bg); border-color: var(--ok-border); }
.verdict.ok h3 { color: var(--g-a); }
.verdict.bad { background: var(--g-f-bg); border-color: var(--g-f); }
.verdict.bad h3 { color: var(--g-f); }
.verdict.warn { background: var(--g-d-bg); border-color: var(--warn-border); }
.verdict.warn h3 { color: var(--g-d); }
.verdict .kv { grid-template-columns: minmax(8rem, auto) 1fr; }
.hash { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-sm); word-break: break-all; }
