/* Malware scanner dashboard. Colours are tokens; dark mode is its own set of steps, not a flip. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --grid: #e1e0d9;
  --accent: #2a78d6;
  --accent-strong: #256abf;
  --link: #256abf;
  --on-accent: #ffffff;
  /* status: fixed in both modes, always paired with an icon and a label */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --neutral: #898781;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --grid: #2c2c2a;
    --accent: #3987e5;
    --accent-strong: #1c5cab;
    --link: #6da7ec;
    --on-accent: #ffffff;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #242422;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --grid: #2c2c2a;
  --accent: #3987e5;
  --accent-strong: #1c5cab;
  --link: #6da7ec;
  --on-accent: #ffffff;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--link); text-underline-offset: 2px; }
code, pre { font-family: var(--mono); font-size: 0.86em; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 32px 0 12px; font-weight: 600; }
h3 { font-size: 1rem; margin: 24px 0 8px; font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* ---- layout ---- */
.demo-banner { background: color-mix(in srgb, var(--warning) 22%, var(--surface)); color: var(--ink); text-align: center; padding: 6px 16px; font-size: 0.88rem; border-bottom: 1px solid var(--border); }
.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.top-inner { max-width: 1240px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; color: var(--ink); text-decoration: none; }
nav { display: flex; gap: 4px; }
nav a { color: var(--ink-2); text-decoration: none; padding: 6px 10px; border-radius: 6px; }
nav a:hover { background: var(--surface-2); color: var(--ink); }
nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); font-weight: 550; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.top-right form { margin: 0; }
main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 16px 48px; }
footer { color: var(--ink-2); font-size: 0.8rem; text-align: center; padding: 16px; border-top: 1px solid var(--border); }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .sub { margin: 0; color: var(--ink-2); max-width: 70ch; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.actions form { margin: 0; }
.back { display: inline-block; margin-bottom: 12px; text-decoration: none; }
.grid2 { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; margin-bottom: 16px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card h2:first-child { margin-top: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 440px; margin: 40px auto; }
.card-title { margin: 0; padding: 16px 16px 8px; }
.pad { padding: 16px; margin: 0; }

.secondary-text { color: var(--ink-2); font-size: 0.86rem; }
.nowrap { white-space: nowrap; }
.callout { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 12px 16px; margin: 0 0 16px; }
.callout.warn { border-left-color: var(--warning); }
.callout ol { margin: 8px 0 0; padding-left: 20px; }
.flash { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--good); border-radius: 8px; padding: 10px 14px; margin: 0 0 16px; }
.error { color: var(--critical); margin: 8px 0; min-height: 0; }
.error:empty { display: none; }

/* ---- buttons and fields ---- */
button, .button {
  font: inherit; font-weight: 550; font-size: 0.92rem; border-radius: 8px; padding: 7px 14px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.4;
}
button:hover, .button:hover { background: var(--surface-2); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.primary:hover { background: var(--accent-strong); filter: brightness(1.12); }
.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.ghost:hover { color: var(--ink); }
.danger { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 50%, transparent); background: transparent; }
.wide { width: 100%; justify-content: center; margin-top: 8px; }
.icon-btn { padding: 7px; border-color: transparent; background: transparent; color: var(--ink-2); }

.field { display: block; margin: 0 0 14px; font-weight: 550; font-size: 0.9rem; border: 0; padding: 0; min-width: 0; }
.field legend { padding: 0; margin-bottom: 4px; }
.field input:not([type="radio"]):not([type="checkbox"]), .field select, .table-tools input, .table-tools select {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-weight: 400; color: var(--ink);
  background: var(--page); border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px;
}
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 4px 0; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.estimate { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin: 4px 0 12px; font-size: 0.9rem; }
.estimate:empty { display: none; }
.estimate code { display: block; margin-top: 6px; color: var(--ink-2); word-break: break-all; }
.confirm { background: color-mix(in srgb, var(--warning) 14%, var(--surface)); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }

/* ---- badges and tags ---- */
.badge {
  --c: var(--neutral);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 0.84rem; font-weight: 550;
  padding: 2px 9px 2px 7px; border-radius: 999px; color: var(--ink);
  background: color-mix(in srgb, var(--c) 13%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.badge .ic { color: var(--c); }
.v-infected { --c: var(--critical); }
.v-review { --c: var(--warning); }
.v-ssh_error { --c: var(--serious); }
.v-partial, .v-not_scanned { --c: var(--neutral); }
.v-clean { --c: var(--good); }
.r-high { --c: var(--critical); }
.r-medium { --c: var(--warning); }
.r-low { --c: var(--good); }
.l-red { color: var(--critical); }
.l-amber { color: var(--warning); }
.l-info { color: var(--neutral); }
.l-ok { color: var(--good); }
.tag { display: inline-block; font-size: 0.78rem; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); }
.tag.s-done { color: var(--ink); }
.tag.s-failed, .tag.s-interrupted { border-color: color-mix(in srgb, var(--critical) 45%, transparent); }
.tag.s-running { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.pill { display: inline-flex; align-items: center; gap: 8px; font-size: 0.84rem; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); color: var(--ink); text-decoration: none; max-width: 340px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

/* ---- stat tiles and meters ---- */
.section-label { font-size: 0.95rem; margin: 28px 0 10px; }
.section-label span { color: var(--ink-2); font-weight: 400; font-size: 0.86rem; margin-left: 6px; }
.tiles { margin-bottom: 20px; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile {
  --c: var(--neutral);
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-weight: 400;
}
.tile:hover { background: var(--surface); border-color: var(--border-strong); }
.tile[aria-pressed="true"] { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
.tile.risk { --c: var(--accent); }
.tile-label { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 0.86rem; font-weight: 550; }
.tile-label .ic { color: var(--c); }
.tile-value { font-size: 2rem; font-weight: 650; line-height: 1.15; color: var(--ink); }
.tile-note { color: var(--ink-2); font-size: 0.78rem; }
.coverage { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.coverage-text { white-space: nowrap; color: var(--ink-2); font-size: 0.9rem; }
.coverage-text strong { color: var(--ink); }
.track { flex: 1; height: 8px; background: var(--grid); border-radius: 4px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width 0.4s ease; }

/* ---- tables ---- */
.table-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table-tools input { flex: 1 1 220px; width: auto; margin: 0; }
.table-tools select { flex: 0 1 190px; width: auto; margin: 0; }
.count { margin-left: auto; color: var(--ink-2); font-size: 0.86rem; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; vertical-align: top; padding: 10px 16px; border-bottom: 1px solid var(--border); }
thead th { font-size: 0.8rem; font-weight: 600; color: var(--ink-2); background: var(--surface); }
tbody tr:last-child > * { border-bottom: 0; }
table.sites tbody tr { cursor: pointer; }
table.sites tbody tr:hover, #history tbody tr:hover { background: var(--surface-2); }
#history tbody tr { cursor: pointer; }
#history tbody tr[aria-selected="true"] { background: var(--surface-2); }
.site-cell a { font-weight: 550; color: var(--ink); text-decoration: none; }
.site-cell a:hover { text-decoration: underline; }
.found { max-width: 46ch; }
table.plain th { font-weight: 550; width: 1%; white-space: nowrap; }
table.plain th, table.plain td { padding: 6px 12px; }
.sources { margin-top: 16px; overflow-x: auto; }
.sources code { word-break: break-all; }
.sources summary { cursor: pointer; color: var(--ink-2); }

/* ---- site page ---- */
table.checks th[scope="row"] { width: 30%; font-weight: 550; }
table.checks .state { width: 120px; white-space: nowrap; }
.finding { display: flex; gap: 8px; margin-bottom: 6px; }
.finding:last-child { margin-bottom: 0; }
.finding > .ic { margin-top: 3px; }
.finding details { margin-top: 4px; }
.finding summary { cursor: pointer; color: var(--ink-2); font-size: 0.86rem; }
.paths { margin: 6px 0 0; padding: 0; list-style: none; max-height: 260px; overflow: auto; }
.paths li { padding: 2px 0; word-break: break-all; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.facts > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; }
.facts span { color: var(--ink-2); font-size: 0.82rem; }
.facts strong { font-size: 1.05rem; font-weight: 600; }
.facts em { font-style: normal; color: var(--ink-2); font-size: 0.8rem; }
.flags { padding-left: 20px; }
.h-note { margin-left: 8px; vertical-align: 2px; }
.job-msg:empty { display: none; }

/* ---- logs ---- */
.log { background: var(--surface-2); border-radius: 8px; padding: 12px; margin: 8px 0; max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.log:empty { display: none; }
.log.tall { max-height: none; margin: 0; border-radius: 0; background: var(--surface); }
.log.tall.short { max-height: 420px; }
.job-head { margin: 0 0 10px; }

@media (max-width: 640px) {
  .top-inner { gap: 10px; }
  .top-right { margin-left: 0; width: 100%; }
  .pill { max-width: 100%; flex: 1; }
  h1 { font-size: 1.35rem; }
  .tile-value { font-size: 1.6rem; }
  th, td { padding: 8px 12px; }
  .row { grid-template-columns: 1fr; }
  .coverage { flex-direction: column; align-items: stretch; gap: 6px; }
  .coverage .track { flex: none; }
  .count { margin-left: 0; width: 100%; }
  /* tables become stacked cards: no sideways scrolling on a phone */
  table.sites thead { display: none; }
  table.sites tbody tr, table.checks tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }
  table.sites td, table.checks th, table.checks td { display: block; padding: 0; border: 0; width: auto; }
  table.sites td:nth-child(1) { grid-column: 2; grid-row: 1; }
  table.sites td:nth-child(2) { grid-column: 1; grid-row: 1; }
  table.sites td:nth-child(3) { grid-column: 1 / -1; max-width: none; }
  table.sites td:nth-child(5) { text-align: right; }
  table.checks, table.checks tbody { display: block; }
  table.checks th[scope="row"] { width: auto; }
  table.checks .state { grid-column: 2; grid-row: 1; width: auto; }
  table.checks td:last-child { grid-column: 1 / -1; }
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; }
  table.stack tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  table.stack td { padding: 2px 0; border: 0; }
  table.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--ink-2); font-size: 0.86rem; }
  table.users td { display: block; padding: 4px 16px; border: 0; }
  table.users thead { display: none; }
  table.users tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--border); }
}
@media (forced-colors: active) {
  .badge, .tile, .tag { border: 1px solid CanvasText; }
  .fill { background: Highlight; }
}

/* ---- team pages ---- */
.who { color: var(--ink-2); text-decoration: none; font-size: 0.9rem; white-space: nowrap; }
.who:hover { color: var(--ink); }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 2px 4px 2px 0; }
form.inline select { font: inherit; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--page); color: var(--ink); }
.actions-cell { white-space: nowrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }
.warn-text { color: var(--critical); }
code.secret { font-size: 1rem; padding: 2px 8px; background: var(--surface-2); border-radius: 6px; user-select: all; }
