/* Dark by default; the light theme is opt-in from the sidebar toggle. */
:root {
  color-scheme: dark;
  --bg: #0c0f14; --side: #0f131a; --panel: #151a22; --raised: #1c222d; --field: #10141b; --hover: #1a202a;
  --line: #252c38; --line-soft: #1e242e; --ink: #e8ebf1; --muted: #8b95a7; --faint: #5d6778;
  --accent: #5b9dff; --accent-strong: #7db1ff; --on-accent: #08111f;
  --critical: #c58cff; --high: #ff7b72; --medium: #ffa657; --low: #e3c341; --info: #8b95a7; --ok: #56d364;
  --shadow: 0 1px 0 rgba(255,255,255,.02) inset, 0 8px 24px rgba(0,0,0,.25);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f8; --side: #ffffff; --panel: #ffffff; --raised: #f6f8fb; --field: #ffffff; --hover: #f4f7fb;
  --line: #dfe4ec; --line-soft: #e9edf3; --ink: #18202b; --muted: #5f6b7c; --faint: #8e99a9;
  --accent: #1f6feb; --accent-strong: #1a5fd0; --on-accent: #ffffff;
  --critical: #8031c7; --high: #cf2f2f; --medium: #c2620a; --low: #8f7400; --info: #5f6b7c; --ok: #1a7f37;
  --shadow: 0 1px 2px rgba(20,30,50,.06), 0 6px 18px rgba(20,30,50,.05);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scrollbar-color: var(--line) transparent; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.55 Inter, "Segoe UI", system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; }
.mono { font-family: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 13px; margin: 0 0 10px; }

/* ---------- shell: sidebar + content ---------- */
.side { position: fixed; inset: 0 auto 0 0; width: 228px; background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px 14px; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; font-weight: 650; font-size: 15px; letter-spacing: -.01em; color: var(--ink); }
.brand:hover { text-decoration: none; color: var(--ink); }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: linear-gradient(140deg, var(--accent), #8b6cff); color: #fff; }
.brand small { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); letter-spacing: 0; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.side nav a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.side nav a.on, .side .foot a.on { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-strong); }
.side nav details { display: flex; flex-direction: column; gap: 2px; }
.side nav summary.sect { list-style: none; display: flex; align-items: center; gap: 8px; border-radius: 8px; user-select: none; }
.side nav summary.sect:hover { color: var(--ink); }
.side nav summary.sect::after { content: "›"; font-size: 15px; line-height: 1; transition: transform .12s; }
.side nav summary.sect > span:first-child { flex: 1; }
.side nav details[open] > summary.sect::after { transform: rotate(90deg); }
.side nav details[open] > summary.sect .count { display: none; }
.side nav .sect { padding: 12px 10px 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.side nav details:first-child > .sect { padding-top: 0; }
.side nav svg, .side .foot svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side .foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 2px; }
.side .foot a, .side .foot button { display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); font: inherit; font-weight: 500; text-align: left; justify-content: flex-start; cursor: pointer; height: auto; }
.side .foot a:hover, .side .foot button:hover { background: var(--hover); color: var(--ink); text-decoration: none; filter: none; }
.side .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell { margin-left: 228px; }
main { max-width: 1680px; margin: 0 auto; padding: 26px 32px 72px; }
body.bare .shell { margin-left: 0; }
@media (max-width: 900px) {
  .side { position: static; width: auto; flex-direction: row; align-items: center; padding: 8px 12px; gap: 6px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand { padding: 0 8px 0 0; } .brand small, .side nav a span, .side nav .sect, .side .foot span { display: none; }
  .side nav { flex-direction: row; } .side .foot { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; }
  .shell { margin-left: 0; } main { padding: 18px 14px 60px; }
}

/* ---------- headings and layout ---------- */
h1 { font-size: 23px; font-weight: 650; letter-spacing: -.02em; margin: 0 0 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
h2 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); align-items: start; }
.grid > .panel { margin-bottom: 0; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.row:last-child { margin-bottom: 0; }

/* ---------- stat tiles ---------- */
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.tile { position: relative; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px 14px; color: inherit; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--c, var(--line)); }
.tile:hover { text-decoration: none; color: inherit; border-color: color-mix(in srgb, var(--c, var(--accent)) 55%, var(--line)); transform: translateY(-1px); }
.tile b { display: block; font-size: 32px; font-weight: 650; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--c, var(--ink)); }
.tile span { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap;
  position: sticky; top: var(--bar, 0px); background: var(--panel); z-index: 2; box-shadow: 0 1px 0 var(--line); border-bottom: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
/* ---------- settings: one column, each setting a row with its name and help on the left ---------- */
.settings { max-width: 880px; }
.settings .panel > h2 { margin-bottom: 6px; }
.setrow { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 6px 28px; align-items: center; padding: 13px 0; border-top: 1px solid var(--line-soft); }
.setrow b, .choice b { display: block; font-weight: 550; }
.setrow small, .choice small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.setrow > input:not([type=number]), .setrow > select { width: 100%; }
.setrow > select { max-width: 180px; }
.setrow label { margin: 0; }
.setfoot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.choice { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 11px 0; border-top: 1px solid var(--line-soft); white-space: normal; cursor: pointer; }
.choice input { margin-top: 3px; }
.dangerzone { border-color: color-mix(in srgb, var(--high) 40%, var(--line)); }
@media (max-width: 700px) { .setrow { grid-template-columns: 1fr; } }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable::after { content: "↕"; margin-left: 5px; opacity: .35; }
th.sortable[data-dir]::after { opacity: 1; color: var(--accent-strong); }
th.sortable[data-dir=up]::after { content: "↑"; }
th.sortable[data-dir=down]::after { content: "↓"; }
table.fixed { table-layout: fixed; }
table.fixed td { overflow-wrap: anywhere; }
td.wrap { overflow-wrap: anywhere; min-width: 220px; }
td .sub { color: var(--muted); font-size: 12px; margin-top: 1px; }

/* ---------- chips ---------- */
.sev, .pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  letter-spacing: .02em; white-space: nowrap; line-height: 1.5; vertical-align: middle; }
.sev { --c: var(--info); color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 32%, transparent); text-transform: capitalize; min-width: 78px; }
.sev::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.sev-critical { --c: var(--critical); } .sev-high { --c: var(--high); } .sev-medium { --c: var(--medium); } .sev-low { --c: var(--low); }
.pill { --c: var(--muted); color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 28%, transparent); text-transform: capitalize; }
.pill.ok { --c: var(--ok); } .pill.bad { --c: var(--high); } .pill.warn { --c: var(--medium); }

/* ---------- forms and buttons ---------- */
input, select, textarea { font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
input:not([type=checkbox]):not([type=radio]), select { height: 34px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; padding: 0; vertical-align: -2px; }
textarea { width: 100%; min-height: 120px; font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 12.5px; }
/* Buttons, one rule everywhere: neutral by default; .primary (filled) for the one main action of a
   page or panel; .danger for anything that deletes or aborts. a.btn is a link that looks the same. */
button, a.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 500; height: 34px;
  padding: 0 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; text-decoration: none;
  color: var(--ink); background: var(--raised); border: 1px solid var(--line); transition: filter .12s, background .12s, border-color .12s; }
button:hover, a.btn:hover { border-color: var(--faint); color: var(--ink); text-decoration: none; }
button.primary, a.btn.primary { color: var(--on-accent); background: var(--accent); border-color: var(--accent); font-weight: 600; }
button.primary:hover, a.btn.primary:hover { filter: brightness(1.1); border-color: var(--accent); color: var(--on-accent); }
button.danger, a.btn.danger { background: color-mix(in srgb, var(--high) 12%, transparent); color: var(--high); border-color: color-mix(in srgb, var(--high) 40%, transparent); }
button.danger:hover, a.btn.danger:hover { background: color-mix(in srgb, var(--high) 22%, transparent); color: var(--high); border-color: color-mix(in srgb, var(--high) 40%, transparent); }
button:disabled { opacity: .45; cursor: default; filter: none; }
td button, td a.btn { height: 28px; padding: 0 11px; font-size: 13px; }
form.inline { display: inline; }
label { margin-right: 14px; }

/* ---------- messages ---------- */
.flash { display: flex; align-items: center; gap: 12px; background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.flash.row { margin-bottom: 14px; }

/* ---------- pinned bars ---------- */
.pinned { position: sticky; top: 0; z-index: 3; background: var(--panel); padding: 12px 0; margin: -12px 0 0; }
.panel.pinned { margin: 0 0 16px; }

/* ---------- findings list ---------- */
details > summary { cursor: pointer; }
details.panel > summary { list-style: none; display: flex; align-items: center; gap: 8px; font-weight: 600; }
details.panel > summary::before, details.finding > summary::before { content: "›"; display: inline-block; width: 12px; color: var(--faint); font-size: 16px; line-height: 1; transition: transform .12s; }
details[open].panel > summary::before, details[open].finding > summary::before { transform: rotate(90deg); }
details summary::-webkit-details-marker { display: none; }
details.finding { border-bottom: 1px solid var(--line-soft); }
details.finding:last-child { border-bottom: 0; }
details.finding:target > summary { background: var(--hover); }
details.finding summary { list-style: none; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 8px; border-radius: 8px; }
details.finding summary:hover { background: var(--hover); }
details.finding .body { margin: 2px 0 14px 32px; background: var(--raised); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
/* Labelled lines: a narrow column of labels, the text beside it. */
.facts { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 9px 16px; margin: 0; padding: 14px 16px; }
.facts:empty { display: none; }
.facts dt { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding-top: 2px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts code { display: block; padding: 7px 10px; border-radius: 7px; background: var(--field); border: 1px solid var(--line-soft); color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; white-space: pre-wrap; }
/* The actions sit in a strip under the facts: each has a label over one joined input-and-button control. */
details.finding .acts { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding: 12px 16px 14px; border-top: 1px solid var(--line); background: var(--panel); }
.facts:empty + .acts { border-top: 0; }
.act { flex: 1 1 320px; display: flex; flex-direction: column; gap: 6px; margin: 0; min-width: 0; }
.act.wide { flex: 1.5 1 440px; }
.act.last { flex: none; margin-left: auto; }
.act .legend { margin: 0; }
.act .legend .by { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--faint); }
.join { display: flex; min-width: 0; }
.join > input { flex: 1; min-width: 0; border-radius: 8px 0 0 8px; }
.join > button { border-radius: 0; margin-left: -1px; }
.join > button:last-child { border-radius: 0 8px 8px 0; }
.join > :focus, .join > button:hover { position: relative; z-index: 1; }
@media (max-width: 700px) { .facts { grid-template-columns: 1fr; gap: 2px; } .facts dd { margin-bottom: 8px; } details.finding .body { margin-left: 0; } }

/* ---------- progress ---------- */
.bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), #8b6cff); transition: width .4s; }
.now { display: flex; gap: 12px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.now .step { flex: 1; min-width: 260px; font-weight: 600; }
.spin { width: 13px; height: 13px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- sign-in pages ---------- */
.auth { max-width: 400px; margin: 9vh auto 0; padding: 28px; }
.auth h1 { font-size: 20px; margin-bottom: 14px; }
.auth .brand { padding: 0 0 22px; }
.auth label { display: block; margin: 0 0 14px; white-space: normal; color: var(--muted); font-size: 13px; }
.auth label input { display: block; width: 100%; margin-top: 5px; font-size: 15px; height: 40px !important; }
.auth button { width: 100%; height: 40px; margin-top: 4px; }
.qr { text-align: center; margin: 14px 0; }
.qr svg { background: #fff; border-radius: 10px; max-width: 100%; height: auto; }
.side nav .count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; text-align: center; font-size: 11.5px; font-weight: 700;
  background: var(--accent); color: var(--on-accent); line-height: 18px; }
dialog.modal { width: min(460px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 14px; padding: 22px; background: var(--panel);
  color: var(--ink); box-shadow: 0 24px 60px rgba(0,0,0,.45); }
dialog.modal::backdrop { background: rgba(5,8,12,.6); backdrop-filter: blur(2px); }
dialog.modal #awsstep { font-weight: 600; overflow-wrap: anywhere; }
dialog.modal:focus, dialog.modal:focus-visible { outline: none; }
/* Settings: at most two or three roomy columns, never four squeezed ones. */
.grid.wide { grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); }
/* Findings: status tabs, and the action row inside a finding. */
.tabs { display: flex; gap: 4px; margin: -4px 0 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs a { display: flex; align-items: center; gap: 8px; padding: 8px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--accent-strong); border-bottom-color: var(--accent); }
.tabs a.on .pill { --c: var(--accent); }

/* ---------- forms laid out as labelled fields ---------- */
.fields { display: grid; gap: 14px 18px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; min-width: 0; }
.field > span, .legend { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.field input, .field select { width: 100%; }
.fieldset { margin-bottom: 18px; }
.fieldset > .legend { margin-bottom: 8px; }
/* A tick box drawn as a toggle chip: lit when chosen. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; display: inline-flex; align-items: center; gap: 7px; margin: 0; padding: 5px 13px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--raised); color: var(--muted); font-weight: 500; cursor: pointer; user-select: none; transition: background .12s, border-color .12s, color .12s; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip small { color: var(--faint); font-size: 12px; font-weight: 400; }
.chip:hover { border-color: var(--faint); }
.chip:has(input:checked) { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent-strong); }
.chip:has(input:checked)::before { content: "✓"; font-size: 12px; font-weight: 700; }
.chip:has(input:focus-visible) { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); }
.chip:has(input:disabled) { cursor: default; }
.chip:has(input:disabled:not(:checked)) { opacity: .45; }
/* Two-way switch between views of the same list. */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg a { padding: 6px 14px; color: var(--muted); font-weight: 500; background: var(--raised); }
.seg a + a { border-left: 1px solid var(--line); }
.seg a:hover { color: var(--ink); text-decoration: none; }
.seg a.on { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-strong); }
/* Rows that open something. */
tr.go { cursor: pointer; }
tr.go td:last-child { color: var(--faint); text-align: right; font-size: 16px; }
.crumb { display: inline-block; margin-bottom: 10px; color: var(--muted); }
.acts-cell { white-space: nowrap; text-align: right; }
.acts-cell form.inline + form.inline, .acts-cell a.btn + form.inline, .acts-cell form.inline + a.btn, .acts-cell button + button, .acts-cell button + a.btn, .acts-cell a.btn + button { margin-left: 6px; }

/* ---------- dashboard: the panels share the window, and a long list scrolls inside its panel ---------- */
body.fill main { height: 100vh; display: flex; flex-direction: column; padding-bottom: 26px; }
body.fill main > * { flex: none; }
body.fill main > .dash { flex: 1; min-height: 0; display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1.25fr) minmax(0, 1fr); }
.dash > .panel { margin: 0; display: flex; flex-direction: column; min-height: 0; }
.dash > .panel > * { flex: none; }
.dash > .panel > .scroll { flex: 1; min-height: 0; overflow: auto; margin: 0 -18px; padding: 0 18px; scrollbar-width: thin; }
.dash > .panel > .scroll:last-child { margin-bottom: -18px; padding-bottom: 10px; }
.dash .empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); }
.dash .empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
/* A narrow or short window goes back to an ordinary page that scrolls as a whole. */
@media (max-width: 1000px), (max-height: 680px) {
  body.fill main { height: auto; display: block; padding-bottom: 60px; }
  body.fill main > .dash { display: block; }
  .dash > .panel { margin-bottom: 16px; min-height: 180px; }
  .dash > .panel > .scroll { overflow: visible; }
}
