/* Visor Security console. One stylesheet; every colour is a token below.
   Light is the default; dark applies with prefers-color-scheme unless the viewer picked a theme
   (html[data-theme=light|dark], from the `theme` cookie). Components: .page-head, .stats,
   .filters, .table, .badge, .card, .dl, .empty, .banner, .pager, .btn. No inline styles anywhere
   (the CSP forbids them). */

:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 6px;
  --radius-sm: 4px;
  --sidebar-w: 224px;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-hover: #f3f5f9;
  --border: #e2e5ea;
  --border-strong: #cdd2da;
  --text: #18202c;
  --text-2: #586274;
  --text-3: #8a93a3;
  --accent: #2c5bd0;
  --accent-hover: #234bb0;
  --accent-weak: #e9effc;
  --accent-text: #ffffff;
  --ok: #16794a;        --ok-weak: #e5f4ec;
  --warn: #8a5a00;      --warn-weak: #fdf3dc;     --warn-border: #f0d9a3;
  --danger: #b4232f;    --danger-weak: #fbe9ea;   --danger-border: #f1c3c6;
  --info: #2c5bd0;      --info-weak: #e9effc;
  --muted-weak: #eef0f3;
  --focus: 0 0 0 3px rgba(44, 91, 208, .35);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --sidebar-bg: #111827;
  --sidebar-text: #c9d0dc;
  --sidebar-text-2: #8791a2;
  --sidebar-active: #1f2a3d;
  --sidebar-border: #1f2735;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --surface: #151920;
    --surface-2: #1a1f28;
    --surface-hover: #1d2330;
    --border: #262d39;
    --border-strong: #354052;
    --text: #e5e9f0;
    --text-2: #a0a9b8;
    --text-3: #6f7a8c;
    --accent: #7ea3ff;
    --accent-hover: #9bb7ff;
    --accent-weak: #1c2741;
    --accent-text: #0e1116;
    --ok: #5cc28f;        --ok-weak: #15291f;
    --warn: #e2b04f;      --warn-weak: #2c2413;   --warn-border: #4a3c1c;
    --danger: #f2747c;    --danger-weak: #2e171a; --danger-border: #55252a;
    --info: #7ea3ff;      --info-weak: #1c2741;
    --muted-weak: #20262f;
    --focus: 0 0 0 3px rgba(126, 163, 255, .4);
    --shadow: none;
    --sidebar-bg: #0a0d12;
    --sidebar-text: #c9d0dc;
    --sidebar-text-2: #7d8798;
    --sidebar-active: #18202d;
    --sidebar-border: #1a202b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #151920;
  --surface-2: #1a1f28;
  --surface-hover: #1d2330;
  --border: #262d39;
  --border-strong: #354052;
  --text: #e5e9f0;
  --text-2: #a0a9b8;
  --text-3: #6f7a8c;
  --accent: #7ea3ff;
  --accent-hover: #9bb7ff;
  --accent-weak: #1c2741;
  --accent-text: #0e1116;
  --ok: #5cc28f;        --ok-weak: #15291f;
  --warn: #e2b04f;      --warn-weak: #2c2413;   --warn-border: #4a3c1c;
  --danger: #f2747c;    --danger-weak: #2e171a; --danger-border: #55252a;
  --info: #7ea3ff;      --info-weak: #1c2741;
  --muted-weak: #20262f;
  --focus: 0 0 0 3px rgba(126, 163, 255, .4);
  --shadow: none;
  --sidebar-bg: #0a0d12;
  --sidebar-text: #c9d0dc;
  --sidebar-text-2: #7d8798;
  --sidebar-active: #18202d;
  --sidebar-border: #1a202b;
  color-scheme: dark;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; line-height: 1.3; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 11.5px; letter-spacing: -.01em; }
/* form controls set `font: inherit`, which beats .mono; monospace fields say so explicitly */
input.mono, textarea.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: -.01em; }
/* [hidden] must win over component display rules (.btn is inline-flex, .chip is inline-flex...) */
[hidden] { display: none !important; }
/* free text people wrote (notes): keep their line breaks, wrap long words */
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 10; background: var(--surface); padding: 8px 12px; border-radius: var(--radius); }
.skip:focus { left: 8px; }
svg.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--sidebar-bg); color: var(--sidebar-text); border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; color: #fff; }
.brand svg.icon { width: 22px; height: 22px; color: #7ea3ff; }
.brand b { display: block; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.brand span { display: block; font-size: 11.5px; color: var(--sidebar-text-2); }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 1px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--sidebar-text-2); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius);
  color: var(--sidebar-text); font-size: 13.5px;
}
.nav a:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.nav a[aria-current="page"] { background: var(--sidebar-active); color: #fff; box-shadow: inset 2px 0 0 #7ea3ff; }
.nav a .soon { margin-left: auto; font-size: 10.5px; color: var(--sidebar-text-2); border: 1px solid var(--sidebar-border); padding: 0 6px; border-radius: 99px; }
.sidebar-foot { margin-top: auto; padding: 12px 14px 14px; border-top: 1px solid var(--sidebar-border); font-size: 12.5px; }
.who { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; min-width: 0; }
.who b { color: #fff; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { color: var(--sidebar-text-2); }
.foot-actions { display: flex; gap: 6px; }
.foot-actions form { margin: 0; }
.foot-actions button {
  background: transparent; color: var(--sidebar-text); border: 1px solid var(--sidebar-border);
  border-radius: var(--radius); padding: 4px 9px; font: inherit; font-size: 12px; cursor: pointer;
}
.foot-actions button:hover { background: var(--sidebar-active); color: #fff; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.content { padding: 22px 28px 48px; max-width: 1440px; width: 100%; }

/* ---------------------------------------------------------------- banners */
.banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 28px; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.banner svg.icon { margin-top: 1px; }
.banner.warn { background: var(--warn-weak); color: var(--warn); border-color: var(--warn-border); }
.banner.info { background: var(--info-weak); color: var(--info); }
/* the public preview's notice (posture/demo.py): on every page, always in view */
.banner.demo-banner { background: var(--info-weak); color: var(--info); position: sticky; top: 0; z-index: 30; }
.banner.demo-banner a { color: inherit; text-decoration: underline; margin-left: 6px; }
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); margin-bottom: 16px; font-size: 13px;
}
.notice.ok { background: var(--ok-weak); border-color: transparent; color: var(--ok); }
.notice.warn { background: var(--warn-weak); border-color: var(--warn-border); color: var(--warn); }
.notice.danger { background: var(--danger-weak); border-color: var(--danger-border); color: var(--danger); }

/* ---------------------------------------------------------------- page head */
.crumbs { font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--text-2); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); margin-top: 3px; font-size: 13px; }
.page-head .actions { display: flex; gap: 8px; align-items: center; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- stats strip (counts as filters, not charts) */
/* a strip too wide for the screen wraps onto another row (never a sideways scroll); the dividers are 1px
   shadows to the right and below each count, and the strip clips the ones that fall on its outer edge */
.stats { display: flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 14px; overflow: hidden; box-shadow: var(--shadow); }
.stat { flex: 1 1 140px; min-width: 0; padding: 10px 14px; box-shadow: 1px 0 0 var(--border), 0 1px 0 var(--border); color: var(--text); display: block; }
.stat:hover { background: var(--surface-hover); text-decoration: none; color: var(--text); }
.stat .v { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .k { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.stat[aria-current="true"] { background: var(--accent-weak); box-shadow: inset 0 -2px 0 var(--accent); }
.stat.warn .v { color: var(--warn); }
.stat.danger .v { color: var(--danger); }

/* ---------------------------------------------------------------- filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters .search { position: relative; flex: 1 1 260px; max-width: 380px; }
.filters .search svg.icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.filters .search input { padding-left: 30px; width: 100%; }
.filters .search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
input[type="search"], input[type="text"], input[type="email"], input[type="url"], input[type="password"],
input[type="date"], input[type="month"], select, textarea {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 6px 9px; min-height: 32px;
}
textarea { width: 100%; min-height: 72px; resize: vertical; line-height: 1.45; }
select { padding-right: 26px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
select.is-set { border-color: var(--accent); background-color: var(--accent-weak); }
kbd { font-family: var(--mono); font-size: 11px; color: var(--text-3); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--surface-2); }
.filters .clear { font-size: 12.5px; margin-left: 2px; }
.filters select { max-width: 260px; text-overflow: ellipsis; }
/* an applied filter without a select of its own (set by a link), with its remove link */
.chip {
  display: inline-flex; align-items: center; gap: 2px; min-height: 26px; padding: 0 2px 0 9px; border-radius: 99px;
  background: var(--accent-weak); color: var(--accent); font-size: 12.5px; font-weight: 500; white-space: nowrap;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.chip a { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: inherit; font-size: 14px; line-height: 1; }
.chip a:hover { background: var(--surface); text-decoration: none; }
.js .nojs-only { display: none; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; font-weight: 500;
  padding: 6px 12px; min-height: 32px; border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); text-decoration: none; color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.95); }
.btn.danger-outline { color: var(--danger); border-color: var(--danger-border); }
.btn.danger-outline:hover { background: var(--danger-weak); }
.btn.small { padding: 3px 9px; min-height: 26px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- tables */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--text-2); background: var(--surface-2);
  padding: 8px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; vertical-align: bottom;
}
.table th a { color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; }
.table th a:hover { color: var(--text); text-decoration: none; }
.table th a[aria-sort] { color: var(--text); }
.table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-hover); }
.table tr.flagged td { background: var(--danger-weak); }
.table tr.flagged:hover td { background: var(--danger-weak); }
.table .r { text-align: right; }
.table .who-cell { display: flex; flex-direction: column; min-width: 0; }
.table .who-cell a, .table .who-cell .primary { font-weight: 500; color: var(--text); }
.table .who-cell a:hover { color: var(--accent); }
.table .who-cell small { color: var(--text-2); font-size: 12px; }
.table .stack small { display: block; color: var(--text-2); font-size: 12px; }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px 0; margin-bottom: 22px; font-size: 12.5px; color: var(--text-2); }
.table.compact td, .table.compact th { padding: 6px 10px; }
.cell-stale { color: var(--warn); }
/* hostnames and ids never break at their hyphens, and a badge stays on one line; a cell holding several
   (a status badge and an "automatically" badge, a title over a hostname) wraps between them when the table
   is short of room, which a browser does only then. What still does not fit scrolls inside .table-wrap. */
.table small.mono, .table td.mono { white-space: nowrap; }
.table td.nowrap, .table td .nowrap, .table label.nowrap { white-space: normal; }
.table td .badge { margin-block: 1px; }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500; line-height: 18px;
  padding: 0 7px; border-radius: 99px; background: var(--muted-weak); color: var(--text-2); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-weak); color: var(--ok); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.danger { background: var(--danger-weak); color: var(--danger); }
.badge.info { background: var(--info-weak); color: var(--info); }
.count { display: inline-block; min-width: 20px; text-align: center; font-size: 11.5px; font-weight: 600; padding: 0 6px; line-height: 18px; border-radius: 99px; background: var(--danger-weak); color: var(--danger); font-variant-numeric: tabular-nums; }
.count.zero { background: transparent; color: var(--text-3); font-weight: 400; }

/* ---------------------------------------------------------------- cards / definition lists */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 16px; align-items: start; margin-bottom: 22px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.card-body { padding: 12px 14px; }
.card.danger-zone { border-color: var(--danger-border); }
.card.danger-zone .card-head { color: var(--danger); }
.dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); margin: 0; font-size: 13px; }
.dl dt { color: var(--text-2); padding: 7px 14px; border-bottom: 1px solid var(--border); }
.dl dd { margin: 0; padding: 7px 14px 7px 0; border-bottom: 1px solid var(--border); min-width: 0; overflow-wrap: anywhere; }
.dl dt:nth-last-of-type(1), .dl dd:last-of-type { border-bottom: 0; }
.section { margin-bottom: 22px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.section-head .muted { font-size: 12.5px; }
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.form-row label { font-size: 12.5px; font-weight: 500; }
.help { font-size: 12.5px; color: var(--text-2); }
.field-error { font-size: 12.5px; color: var(--danger); font-weight: 500; }
[aria-invalid="true"] { border-color: var(--danger); }
[aria-invalid="true"]:focus { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-weak); }
.form-row .check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.form-row .check input { margin-top: 3px; }
.help + form { margin-top: 12px; }
.stack-gap > * + * { margin-top: 8px; }
details.more summary { cursor: pointer; color: var(--accent); font-size: 12.5px; margin-top: 2px; }
ul.plain { list-style: none; margin: 4px 0 0; padding: 0; font-size: 12.5px; }
ul.plain li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
form + p.help { margin-top: 10px; }
#bulk-reason { flex: 0 1 320px; }
hr.rule { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }

/* ---------------------------------------------------------------- empty states */
.empty { text-align: center; padding: 44px 20px; color: var(--text-2); }
.empty svg.icon { width: 28px; height: 28px; color: var(--text-3); margin-bottom: 10px; }
.empty h3 { color: var(--text); font-size: 14px; margin-bottom: 4px; }
.empty p { max-width: 460px; margin: 0 auto; font-size: 13px; }
.empty .btn { margin-top: 14px; }
.empty.boxed { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }

/* ---------------------------------------------------------------- pager */
.pager { display: flex; gap: 6px; }
.pager a, .pager span { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 12.5px; }
.pager a:hover { background: var(--surface-hover); text-decoration: none; }
.pager span { color: var(--text-3); }

/* ---------------------------------------------------------------- sign-in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 26px 26px 22px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-brand svg.icon { width: 26px; height: 26px; color: var(--accent); }
.auth-brand b { display: block; font-size: 15px; }
.auth-brand span { font-size: 12.5px; color: var(--text-2); }
.auth-card .choice { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 6px; cursor: pointer; }
.auth-card .choice:hover { background: var(--surface-hover); }
.auth-card .choice input { accent-color: var(--accent); }
.auth-card .choice .who-cell { display: flex; flex-direction: column; min-width: 0; }
.auth-card .choice small { color: var(--text-2); font-size: 12px; }
.auth-card a.choice { color: var(--text); text-decoration: none; }
.auth-card a.choice.current { border-color: var(--accent); background: var(--accent-weak); }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 8px; }
.auth-foot { margin-top: 14px; font-size: 12px; color: var(--text-3); text-align: center; }

/* ---------------------------------------------------------------- responsive: laptop and tablet
   Every list fits its screen without a sideways scroll (checked on every console page from 360 to 1920px):
   - 1600px and up: every column.
   - 1280-1599px: columns marked .hide-md go (the few on the widest tables).
   - 1181-1279px: columns marked .hide-sm go too (first seen, agent version, assignee and the like), and the
     overview's two columns stack.
   - 1180px and under (tablets either way up, small laptops): list tables become cards, in two columns of
     fields from 601px; under 861px the .hide-sm fields leave the cards as well (see the phone block). */
@media (min-width: 1280px) and (max-width: 1599px) {
  .table .hide-md { display: none; }
}
@media (min-width: 1181px) and (max-width: 1279px) {
  .table .hide-sm, .table .hide-md { display: none; }
  .table th, .table td { padding-left: 8px; padding-right: 8px; }
}
@media (max-width: 1279px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .content { padding: 18px 18px 40px; }
  .banner { padding: 10px 18px; }
}
@media (max-width: 860px) {
  :root { --sidebar-w: 64px; }
  .brand div, .nav a span, .nav-label, .who, .nav a .soon { display: none; }
  .brand { justify-content: center; padding: 16px 0; }
  .nav a { justify-content: center; padding: 9px 0; }
  .foot-actions { flex-direction: column; }
  .sidebar-foot { padding: 10px 8px; }
  .table .hide-sm { display: none; }
  .table th, .table td { padding-left: 8px; padding-right: 8px; }
  .foot-actions button { padding: 4px 4px; font-size: 11px; white-space: nowrap; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .nav a, .stat, select, input { transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease; }
}
/* the phone top bar (base.html) exists only under 600px; see "responsive: phone" at the end */
.topbar { display: none; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

/* The join page of a personal invite link (templates/join/page.html) */
.join-card { max-width: 560px; }
.join-card p { margin: 0 0 12px; line-height: 1.5; }
.join-title { font-size: 18px; margin: 0 0 12px; }
.join-step { margin: 16px 0 8px; }
.join-step h2 { font-size: 15px; margin: 0 0 8px; }

/* ---------------------------------------------------------------- overview: verdict, next actions, setup */
.verdict { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 18px; }
.verdict.ok { border-left-color: var(--ok); }
.verdict.warn { border-left-color: var(--warn); }
.verdict.danger { border-left-color: var(--danger); }
.verdict.info { border-left-color: var(--info); }
.verdict-head { display: flex; gap: 10px; align-items: flex-start; }
.verdict-head svg.icon { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.verdict.ok .verdict-head svg.icon { color: var(--ok); }
.verdict.warn .verdict-head svg.icon { color: var(--warn); }
.verdict.danger .verdict-head svg.icon { color: var(--danger); }
.verdict.info .verdict-head svg.icon { color: var(--info); }
.verdict-head h2 { font-size: 18px; }
.next-actions { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--border); }
.next-actions li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.next-actions li:last-child { border-bottom: 0; }
.next-actions .na-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--warn); }
.next-actions li.danger .na-dot { background: var(--danger); }
.next-actions .na-text { flex: 1 1 auto; min-width: 0; color: var(--text); }
.next-actions .na-text:hover { color: var(--accent); }
.verdict-foot { margin-top: 8px; }
.setup-steps { list-style: none; margin: 0; padding: 0; }
.setup-steps li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.setup-steps li:last-child { border-bottom: 0; }
.setup-steps .step-mark { display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-strong); font-size: 12px; font-weight: 600; color: var(--text-2); }
.setup-steps li.done .step-mark { background: var(--ok-weak); border-color: transparent; color: var(--ok); }
.setup-steps li.done .step-text b { color: var(--text-2); }
.setup-steps .step-mark svg.icon { width: 13px; height: 13px; }
.setup-steps .step-text { flex: 1 1 auto; min-width: 0; }
.setup-steps .step-text .help { margin-top: 2px; }
.setup form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.unknown .badge { margin-right: 2px; }
.help.block { display: block; margin-top: 4px; }
.table-note { margin-top: 6px; }
.table-wrap.flat { border: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none; }
@media (max-width: 600px) {
  .next-actions li { flex-wrap: wrap; }
  .setup-steps li { flex-wrap: wrap; }
}

/* ===================================================================================================
   Trends, exports and the monthly report (console review item 12). Charts are inline SVG drawn on the
   server (templates/_charts.html); every colour below is a theme token, so light, dark and print all
   work without a script.
   =================================================================================================== */
.trend-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 12.5px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.seg a { padding: 3px 10px; color: var(--text-2); border-right: 1px solid var(--border); text-decoration: none; }
.seg a:last-child { border-right: 0; }
.seg a:hover { background: var(--surface-hover); }
.seg a[aria-current] { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.trend-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 8px; }
.chart-card { margin: 0; padding: 12px 14px; }
.chart-card figcaption h3 { font-size: 13.5px; margin: 0; display: flex; justify-content: space-between; gap: 8px; }
.chart-card .chart-link { font-weight: 400; font-size: 12.5px; }
.chart-sum { margin: 2px 0 8px; font-size: 13px; color: var(--text); }
.chart-card .help { margin-top: 6px; }
svg.chart { display: block; width: 100%; height: 104px; overflow: visible; }
.chart .c-grid { stroke: var(--border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .c-stroke { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart .c-area { fill: var(--accent-weak); }
.chart.c-alt .c-stroke { stroke: var(--ok); }
.chart.c-alt .c-area { fill: var(--ok-weak); }
.chart .c-hit { fill: transparent; }
.chart .c-hit:hover { fill: var(--text); fill-opacity: .06; }
.c-new { fill: var(--warn); background: var(--warn); }
.c-closed { fill: var(--ok); background: var(--ok); }
.c-handled { fill: var(--ok); background: var(--ok); }
.c-needs { fill: var(--danger); background: var(--danger); }
.chart-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.chart-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 0; padding: 0; font-size: 12px; color: var(--text-2); }
.chart-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.chart-data { margin-bottom: 6px; }
.chart-data .table-wrap { margin-top: 8px; max-height: 360px; overflow: auto; }
.export-form { display: inline-flex; margin: 0; }
.print-btn { display: none; }
.js .print-btn { display: inline-flex; }

/* the monthly report: one page for a manager */
.report { max-width: 980px; }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.report-title { font-size: 20px; margin: 0; }
.report-head .sub { color: var(--text-2); margin-top: 3px; font-size: 13px; }
.report-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; }
.report-nav form { display: inline-flex; gap: 6px; align-items: center; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 12px 0 16px; }
.kpi { padding: 10px 12px; }
.kpi .kpi-k { font-size: 12px; color: var(--text-2); }
.kpi .kpi-v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .kpi-d { font-size: 12px; color: var(--text-2); }
.risks { margin: 0; padding: 4px 14px 8px 32px; }
.risks li { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.risks li:last-child { border-bottom: 0; }
.report-foot { margin-top: 14px; }

@media (max-width: 860px) {
  .trend-grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ===================================================================================================
   Responsive: list tables become cards at 1180px and under (tablets either way up, small laptops, phones).
   Each row is a card and each cell is labelled from its data-label. A table whose cells carry no
   data-label stays a table and scrolls inside its .table-wrap.
   =================================================================================================== */
@media (max-width: 1180px) {
  /* each row a card (only tables whose cells carry data-label: the column header, on every body cell) */
  .table-wrap:has(> table.table > tbody > tr > td[data-label]) { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  table.table:has(> tbody > tr > td[data-label]),
  table.table:has(> tbody > tr > td[data-label]) > tbody,
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr,
  table.table:has(> tbody > tr > td[data-label]) > tfoot,
  table.table:has(> tbody > tr > td[data-label]) > tfoot > tr,
  table.table:has(> tbody > tr > td[data-label]) > tfoot > tr > td { display: block; width: 100%; }
  /* a form under the rows (the detection timeline's "Add a note") gets a card of its own */
  table.table:has(> tbody > tr > td[data-label]) > tfoot > tr > td {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  }
  /* the header row stays only as a "Sort by" bar, and only when it has sort links */
  table.table:has(> tbody > tr > td[data-label]) > thead { display: block; }
  table.table:has(> tbody > tr > td[data-label]) > thead:not(:has(a)) {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  }
  table.table:has(> tbody > tr > td[data-label]) > thead > tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
  table.table:has(> tbody > tr > td[data-label]) > thead > tr::before { content: "Sort by"; font-size: 12.5px; color: var(--text-2); margin-right: 2px; }
  table.table:has(> tbody > tr > td[data-label]) > thead th { display: none; position: static; background: none; border: 0; padding: 0; }
  table.table:has(> tbody > tr > td[data-label]) > thead th:has(a):not(.hide-sm) { display: block; }
  table.table:has(> tbody > tr > td[data-label]) > thead th a {
    min-height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); font-size: 13px;
  }
  table.table:has(> tbody > tr > td[data-label]) > thead th a[aria-sort] { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 10px; padding: 6px 0;
  }
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr.flagged { background: var(--danger-weak); border-color: var(--danger-border); }
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > td,
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > th,
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr:hover > td { background: transparent; }
  /* the label sits in a left column; the cell's own content flows as it does in the table */
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > td {
    display: block; position: relative; min-height: 30px; padding: 5px 14px 5px calc(36% + 10px);
    border: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; min-width: 0;
  }
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > td::before {
    content: attr(data-label); position: absolute; left: 14px; top: 6px; width: calc(36% - 18px);
    color: var(--text-2); font: 500 12.5px/1.35 var(--font); letter-spacing: 0; overflow-wrap: normal;
  }
  /* an unlabelled cell (an actions column) spans the card; its controls wrap */
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > td[data-label=""]:not(.hide-sm) { padding: 8px 14px 5px; }
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > td[data-label=""]::before { content: none; }
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > td .title-row,
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > td form { flex-wrap: wrap; }
  /* a row header (the charts' "numbers behind" table) is the card's title */
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > th { display: block; padding: 4px 14px 6px; border: 0; font-weight: 600; text-align: left; }
  table.table:has(> tbody > tr > td[data-label]) .nowrap,
  table.table:has(> tbody > tr > td[data-label]) small.mono,
  table.table:has(> tbody > tr > td[data-label]) td.mono,
  table.table:has(> tbody > tr > td[data-label]) .badge { white-space: normal; overflow-wrap: anywhere; }
  /* findings grouped by person or app: the group's findings sit under its card */
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr:has(> td.group-rows) {
    margin-top: -12px; border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; padding-top: 0;
  }
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > td.group-rows { display: block; padding: 0 14px 6px; }
  td.group-rows table.table > tbody > tr { box-shadow: none; background: var(--surface-2); }
  .chart-data .table-wrap { max-height: none; }
}
/* with room for it, a card lays its fields out in two columns; the title cell, an actions cell and a
   group's own findings take the full width */
@media (min-width: 601px) and (max-width: 1180px) {
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > :is(th, td:first-child:not([data-label="Select"]), td[data-label="Select"] + td, td[data-label=""], td.group-rows) { grid-column: 1 / -1; }
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > td::before { width: calc(32% - 18px); }
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > td { padding-left: calc(32% + 6px); }
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > :is(td:first-child:not([data-label="Select"]), td[data-label="Select"] + td) { padding-left: calc(16% + 6px); }
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > :is(td:first-child:not([data-label="Select"]), td[data-label="Select"] + td)::before { width: calc(16% - 18px); }
  /* the bulk-select box sits in the card's top-right corner, beside the title, not on a row of its own */
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > td[data-label="Select"] { grid-area: 1 / 2; justify-self: end; z-index: 1; padding: 5px 14px; min-height: 0; }
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > td[data-label="Select"]::before { content: none; }
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > td[data-label="Select"] + td { grid-row: 1; padding-right: 52px; }
}
@media (max-width: 860px) {
  table.table:has(> tbody > tr > td[data-label]) > tbody > tr > td.hide-sm { display: none; }
}

/* ===================================================================================================
   Responsive: phone (console review item 15). Under 600px nothing scrolls sideways:
   - the sidebar becomes a top bar with a <details> menu (opens without a script);
   - list tables are cards (the block above), one column of fields;
   - key/value grids, stat strips, filters and forms stack; touch targets are at least 44px.
   =================================================================================================== */
@media (max-width: 600px) {
  body { font-size: 15px; }
  .shell { display: block; }
  .sidebar { display: none; }

  /* top bar + menu */
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: 0; z-index: 40;
    background: var(--sidebar-bg); color: var(--sidebar-text); border-bottom: 1px solid var(--sidebar-border);
    padding: 0 8px 0 4px; min-height: 52px;
  }
  .topbar .brand { padding: 8px 10px; }
  .topbar .brand div { display: block; }
  .topbar .brand b, .topbar .brand span { display: inline; }
  .topbar .brand span { margin-left: 4px; }
  .menu > summary {
    list-style: none; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; min-width: 44px;
    padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--sidebar-border); cursor: pointer; color: #fff; font-size: 14px;
  }
  .menu > summary::-webkit-details-marker { display: none; }
  .menu[open] > summary { background: var(--sidebar-active); }
  .menu-panel {
    position: absolute; left: 0; right: 0; top: 100%; background: var(--sidebar-bg); border-bottom: 1px solid var(--sidebar-border);
    max-height: calc(100vh - 52px); overflow-y: auto; box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  }
  .menu-panel .nav { padding: 6px 8px; }
  .menu-panel .nav a { min-height: 44px; padding: 0 12px; font-size: 15px; justify-content: flex-start; }
  .menu-panel .nav a span, .menu-panel .nav-label { display: block; }
  .menu-panel .sidebar-foot { padding: 10px 16px 14px; }
  .menu-panel .who { display: flex; }
  .menu-panel .foot-actions { flex-direction: row; gap: 8px; }
  .menu-panel .foot-actions button {
    min-height: 44px; min-width: 44px; padding: 0 14px; font-size: 14px;
    display: inline-flex; align-items: center; justify-content: center;
  }

  /* the public preview's notice: no longer pinned (the top bar is), and it wraps */
  .banner.demo-banner { position: static; }
  .banner { padding: 10px 16px; }
  .banner > div { min-width: 0; overflow-wrap: anywhere; }

  .content { padding: 14px 12px 40px; }
  h1 { font-size: 19px; }
  .page-head { margin-bottom: 14px; align-items: flex-start; }
  .page-head .actions, .section-head { flex-wrap: wrap; }
  .section-head { align-items: center; }
  .crumbs { flex-wrap: wrap; }
  .card-head { flex-wrap: wrap; gap: 6px; }
  .card-body, .dl dd, .note-text, code { overflow-wrap: anywhere; }

  /* touch targets */
  .btn, .btn.small { min-height: 44px; padding: 8px 14px; font-size: 14px; }
  input[type="search"], input[type="text"], input[type="email"], input[type="url"], input[type="password"],
  input[type="date"], input[type="month"], select { min-height: 44px; font-size: 16px; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
  .pager a, .pager span { min-height: 44px; padding: 0 14px; }
  .table-foot { flex-wrap: wrap; gap: 8px; }
  .seg a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; }
  .chip { min-height: 36px; }
  .chip a { width: 44px; height: 44px; margin: -4px -2px -4px 0; }
  /* (padding, not flex: a flex summary loses its disclosure triangle) */
  details.more > summary, .chart-data > summary, td.group-rows > details > summary { padding: 12px 0; }
  td.group-rows > details > summary { color: var(--accent); }
  .auth-card .choice { min-height: 48px; }

  /* filters and forms take the full width */
  .filters .search { flex: 1 1 100%; max-width: none; }
  .filters select { flex: 1 1 calc(50% - 4px); max-width: none; min-width: 0; }
  .filters .btn { flex: 1 1 auto; justify-content: center; }
  .filters .search kbd { display: none; }
  #bulk-reason { flex: 1 1 100%; }
  input[type="text"], input[type="email"], input[type="url"], textarea { max-width: 100%; }

  /* stat strips: a 2-column grid instead of a sideways scroll */
  .stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { min-height: 44px; }

  /* key/value grids stack: the key above its value */
  .dl { grid-template-columns: minmax(0, 1fr); }
  .dl dt { padding: 8px 14px 0; border-bottom: 0; font-size: 12.5px; }
  .dl dd { padding: 2px 14px 8px; }

  /* overview, trends and the monthly report */
  .next-actions li { display: grid; grid-template-columns: 8px minmax(0, 1fr); column-gap: 10px; row-gap: 6px; align-items: center; }
  .next-actions li .btn { grid-column: 2; justify-self: start; }
  .kpi .kpi-v { font-size: 20px; }
  .chart-card figcaption h3 { flex-wrap: wrap; }
  .trend-tools { gap: 8px; }
  a.trend { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }

  /* sign-in, sign-up and join pages */
  .auth { padding: 12px; align-items: start; }
  .auth-card { padding: 20px 16px 18px; }
}

@media print {
  @page { size: A4; margin: 12mm; }
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) {
    --bg: #ffffff; --surface: #ffffff; --surface-2: #ffffff; --text: #000000; --text-2: #333333; --text-3: #555555;
    --border: #cccccc; --border-strong: #999999; --accent: #1f4fb8; --accent-weak: #dfe7f8;
    --ok: #16794a; --ok-weak: #dcefe4; --warn: #8a5a00; --warn-weak: #fdf3dc; --danger: #b4232f;
    --danger-weak: #fbe9ea; --info: #1f4fb8; --info-weak: #dfe7f8; --shadow: none; color-scheme: light;
  }
  body { background: #fff; color: #000; }
  .shell { display: block; }
  .sidebar, .topbar, .banner, .skip, .no-print, .print-btn, .report-nav, .chart-data, .export-form { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card, .chart-card, .kpi, figure, .verdict { break-inside: avoid; }
  .report .trend-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  a { color: inherit; text-decoration: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* 0015: the kept text of a blocked harmful command (detections/detail.html) */
.command-text { white-space: pre-wrap; word-break: break-all; max-height: 16rem; overflow: auto; margin: .25rem 0;
  padding: .5rem .75rem; border: 1px solid var(--border, currentColor); border-radius: 6px; }
