/* ScanPanel — responsive control panel */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8f0;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-2: #14b8a6;
  --accent-soft: #eef2ff;
  --side-bg: #0f172a;
  --side-text: #cbd5e1;
  --side-muted: #64748b;
  --side-hover: #1e293b;
  --c-clean: #16a34a;   --c-clean-bg: #dcfce7;
  --c-maybe: #d97706;   --c-maybe-bg: #fef3c7;
  --c-spam: #dc2626;    --c-spam-bg: #fee2e2;
  --c-virus: #9333ea;   --c-virus-bg: #f3e8ff;
  --c-rel: #2563eb;     --c-rel-bg: #dbeafe;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 16px rgba(15,23,42,.05);
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111a2e;
  --surface-2: #0f172a;
  --border: #1f2a44;
  --text: #e2e8f0;
  --text-2: #b6c2d4;
  --muted: #8494ab;
  --accent: #818cf8;
  --accent-soft: #1e1b4b;
  --side-bg: #070c18;
  --side-hover: #131c31;
  --c-clean: #4ade80;   --c-clean-bg: rgba(74,222,128,.13);
  --c-maybe: #fbbf24;   --c-maybe-bg: rgba(251,191,36,.13);
  --c-spam: #f87171;    --c-spam-bg: rgba(248,113,113,.14);
  --c-virus: #c084fc;   --c-virus-bg: rgba(192,132,252,.14);
  --c-rel: #60a5fa;     --c-rel-bg: rgba(96,165,250,.14);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h2 { font-size: 1.02rem; font-weight: 650; margin-bottom: .75rem; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 0 .3em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-size: .9em; }
.break { word-break: break-all; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ellipsis-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.lead { color: var(--text-2); margin: 0 0 1rem; max-width: 70ch; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--side-bg) 248px, transparent 248px); }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.1rem; padding: 4px 10px 18px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 12px; color: var(--side-text); padding: 9px 12px; border-radius: 10px; font-weight: 500; font-size: .93rem; }
.nav a:hover { background: var(--side-hover); text-decoration: none; color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(99,102,241,.28), rgba(99,102,241,.08)); color: #fff; box-shadow: inset 3px 0 0 #818cf8; }
.nav a span { flex: 1; }
.nav-label { text-transform: uppercase; font-size: .7rem; letter-spacing: .09em; color: var(--side-muted); padding: 18px 12px 6px; font-weight: 600; }
.badge { background: #f59e0b; color: #1f1300; font-size: .7rem; font-weight: 700; border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center; }
.side-foot { border-top: 1px solid #1e293b; padding-top: 12px; margin-top: 12px; display: flex; align-items: center; gap: 6px; }
.me { flex: 1; display: flex; align-items: center; gap: 10px; color: var(--side-text); padding: 6px; border-radius: 10px; min-width: 0; }
.me:hover, .me.active { background: var(--side-hover); text-decoration: none; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #6366f1, #14b8a6); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-text b { color: #fff; font-size: .88rem; font-weight: 600; }
.me-text small { color: var(--side-muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-actions { display: flex; }
.side-actions form { margin: 0; }
.sidebar .icon-btn { color: var(--side-text); }
.sidebar .icon-btn:hover { background: var(--side-hover); color: #fff; }

.icon-btn { background: none; border: 0; color: var(--text-2); width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(10px); -webkit-backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.3rem; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; }
.top-search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; width: min(380px, 40vw); color: var(--muted); }
.top-search input[type=search] { border: 0; outline: 0; box-shadow: none; background: none; padding: 9px 0; min-height: 0; border-radius: 0; width: 100%; color: var(--text); font: inherit; font-size: .9rem; }
.top-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; max-width: 1500px; width: 100%; }
.scrim, .tabbar { display: none; }

/* ---------- cards & layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-wide-left { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); align-items: start; }
.stack-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.narrow { max-width: 620px; }
.table-card { padding: 0; overflow: hidden; }
.table-card > .card-head { padding: 16px 20px 0; }
.toolbar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.grow { flex: 1; }

/* ---------- KPIs */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; color: var(--text); display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); overflow: hidden; transition: transform .15s, border-color .15s; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--k, var(--accent)); }
.kpi:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--k, var(--accent)); }
.kpi-label { color: var(--muted); font-size: .8rem; font-weight: 600; }
.kpi-val { font-size: 1.75rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .75rem; color: var(--muted); }
.kpi-total { --k: var(--accent); }
.kpi-clean { --k: var(--c-clean); }
.kpi-maybe { --k: var(--c-maybe); }
.kpi-spam  { --k: var(--c-spam); }
.kpi-virus { --k: var(--c-virus); }
.kpi-held  { --k: #f59e0b; background: linear-gradient(135deg, color-mix(in srgb, #f59e0b 12%, var(--surface)), var(--surface)); }

/* ---------- chart */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.bar-clean { fill: var(--c-clean); }
.bar-maybe { fill: var(--c-maybe); }
.bar-spam  { fill: var(--c-spam); }
.bar-virus { fill: var(--c-virus); }
.chart g:hover rect { opacity: .82; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: .82rem; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot-clean { background: var(--c-clean); } .dot-maybe { background: var(--c-maybe); } .dot-spam { background: var(--c-spam); } .dot-virus { background: var(--c-virus); }
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.rank li { display: grid; grid-template-columns: minmax(0, 1fr) 90px 40px; gap: 12px; align-items: center; font-size: .9rem; }
.rank li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.rank b { text-align: right; font-variant-numeric: tabular-nums; }
.rank-bar { width: 100%; height: 6px; }
.rank-bar .track { fill: var(--surface-2); }
.rank-bar .fill { fill: var(--c-spam); }

/* ---------- message list (dashboard) */
.msg-list { list-style: none; margin: 0 -20px -20px; padding: 0; }
.msg-list li + li { border-top: 1px solid var(--border); }
.msg-list a { display: grid; gap: 2px; padding: 12px 20px; color: var(--text); }
.msg-list a:hover { background: var(--surface-2); text-decoration: none; }
.ml-top { display: flex; justify-content: space-between; gap: 12px; }
.ml-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: .92rem; }
.ml-top time { color: var(--muted); font-size: .8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ml-subj { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.ml-meta { display: flex; gap: 8px; align-items: center; min-width: 0; font-size: .8rem; }

/* ---------- pills & scores */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 650; padding: 2px 9px; border-radius: 999px; white-space: nowrap; line-height: 1.5; }
.pill-clean { color: var(--c-clean); background: var(--c-clean-bg); }
.pill-maybe { color: var(--c-maybe); background: var(--c-maybe-bg); }
.pill-spam { color: var(--c-spam); background: var(--c-spam-bg); }
.pill-virus { color: var(--c-virus); background: var(--c-virus-bg); }
.pill-released { color: var(--c-rel); background: var(--c-rel-bg); }
.pill-learn { color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); }
.pill-muted { color: var(--muted); background: var(--surface-2); }
.score { font-family: var(--mono); font-size: .8rem; font-weight: 600; padding: 1px 6px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.score-low { color: var(--c-clean); }
.score-mid { color: var(--c-maybe); background: var(--c-maybe-bg); }
.score-high { color: var(--c-spam); background: var(--c-spam-bg); }

/* ---------- forms */
.field { display: flex; flex-direction: column; gap: 5px; margin: 0; border: 0; padding: 0; min-width: 0; }
.field > span { font-size: .8rem; font-weight: 600; color: var(--text-2); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], input:not([type]), select {
  font: inherit; font-size: .92rem; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; width: 100%; min-height: 40px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; cursor: pointer; }
.form { display: flex; flex-direction: column; gap: 14px; }
.row-2 { display: flex; gap: 12px; }
.w-port { width: 110px; }
.check { display: flex; align-items: center; gap: 9px; font-size: .92rem; cursor: pointer; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 16px; padding-top: 4px; }
.form-btns { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-btns form { margin: 0; }
.inline-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin: 0; }
.danger-zone { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--border); }
.code-input { font-family: var(--mono); letter-spacing: .3em; font-size: 1.1rem !important; max-width: 200px; }
.note { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 4px 14px; font-size: .88rem; color: var(--text-2); }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: .88rem; font-weight: 600; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 14px; min-height: 38px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--border) 50%, var(--muted)); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); border-color: transparent; }
.btn-good { color: var(--c-clean); border-color: color-mix(in srgb, var(--c-clean) 40%, var(--border)); background: var(--c-clean-bg); }
.btn-good:hover { background: color-mix(in srgb, var(--c-clean) 20%, var(--surface)); }
.btn-bad { color: var(--c-spam); border-color: color-mix(in srgb, var(--c-spam) 35%, var(--border)); }
.btn-bad:hover { background: var(--c-spam-bg); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: .82rem; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- alerts */
.alert { padding: 11px 14px; border-radius: 10px; font-size: .9rem; border: 1px solid; }
.alert-success { color: var(--c-clean); background: var(--c-clean-bg); border-color: color-mix(in srgb, var(--c-clean) 30%, transparent); }
.alert-error { color: var(--c-spam); background: var(--c-spam-bg); border-color: color-mix(in srgb, var(--c-spam) 30%, transparent); }
.alert[data-dismiss] { cursor: pointer; }

/* ---------- filters */
.filters { display: flex; flex-direction: column; gap: 14px; padding: 16px 20px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 13px; border-radius: 999px; font-size: .84rem; font-weight: 600; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); }
.chip:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.filter-row .field:not(.grow) { width: 160px; }
.filter-btns { display: flex; gap: 6px; }
.more-toggle { display: none; }

/* ---------- tables */
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tr[data-href] { cursor: pointer; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .cb { width: 42px; text-align: center; }
.tbl.msgs { table-layout: fixed; }
.tbl.msgs th:nth-child(2) { width: 118px; }
.tbl.msgs th:nth-child(3) { width: 20%; }
.tbl.msgs th:nth-child(4) { width: 20%; }
.tbl.msgs th:nth-child(6) { width: 76px; }
.tbl.msgs th:nth-child(7) { width: 170px; }
.t-subj a { color: var(--text); font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-time { color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; font-size: .85rem; }
.t-from, .t-to { font-size: .86rem; }
.t-status { white-space: nowrap; }
.t-status .pill-learn { display: none; }
.dir { color: var(--accent); font-weight: 700; margin-right: 4px; }
.rules td { padding: 6px 10px; }
.rules .pos { color: var(--c-spam); font-weight: 600; }
.rules .neg { color: var(--c-clean); font-weight: 600; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions form { display: inline; margin: 0; }
.bulk-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; opacity: .5; pointer-events: none; transition: opacity .15s; }
.bulk-bar.on { opacity: 1; pointer-events: auto; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; padding: 14px; border-top: 1px solid var(--border); }
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .ic { width: 40px; height: 40px; stroke-width: 1.4; opacity: .6; }
.big-code { font-size: 3rem; font-weight: 800; color: var(--accent); letter-spacing: -.03em; }

/* ---------- message detail */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: .9rem; font-weight: 500; align-self: flex-start; }
.msg-head { border-top: 4px solid var(--k, var(--border)); }
.status-clean { --k: var(--c-clean); } .status-maybe { --k: var(--c-maybe); } .status-spam { --k: var(--c-spam); }
.status-virus { --k: var(--c-virus); } .status-released { --k: var(--c-rel); }
.msg-title { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.msg-title h2 { font-size: 1.25rem; margin-bottom: 4px; word-break: break-word; }
.msg-title p { margin: 0; }
.msg-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 9px 14px; margin: 0; font-size: .9rem; }
.kv dt { color: var(--muted); font-weight: 600; font-size: .82rem; padding-top: 1px; }
.kv dd { margin: 0; min-width: 0; }
details summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "›"; font-size: 1.3rem; line-height: 1; color: var(--muted); transition: transform .15s; margin-bottom: .75rem; }
details[open] summary::before { transform: rotate(90deg); }
.pre { font-family: var(--mono); font-size: .8rem; line-height: 1.55; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; overflow: auto; max-height: 420px; white-space: pre-wrap; word-break: break-all; margin: 0; }
.pre-tall { max-height: 75vh; }

/* ---------- users / aliases */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-family: var(--mono); font-size: .78rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; }
.alias-list { list-style: none; padding: 0; margin: 0 0 14px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.alias-list li { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; }
.alias-list li + li { border-top: 1px solid var(--border); }
.alias-list li .mono { flex: 1; min-width: 0; word-break: break-all; }
.alias-list form { margin: 0; }
.totp-setup { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.qr { background: #fff; padding: 10px; border-radius: 12px; border: 1px solid var(--border); line-height: 0; }
.qr img { width: 180px; height: 180px; image-rendering: pixelated; }
.secret { font-size: 1rem; letter-spacing: .05em; background: var(--surface-2); padding: 8px 12px; border-radius: 8px; display: inline-block; }

/* ---------- system */
.svc { list-style: none; margin: 0; padding: 0; }
.svc li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.svc li:last-child { border: 0; }
.svc li .muted { margin-left: auto; }
.svc-dot { width: 10px; height: 10px; border-radius: 50%; }
.svc-ok { background: var(--c-clean); box-shadow: 0 0 0 4px var(--c-clean-bg); }
.svc-bad { background: var(--c-spam); box-shadow: 0 0 0 4px var(--c-spam-bg); }
.svc-off { background: var(--muted); }

/* ---------- auth */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(99,102,241,.22), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, rgba(20,184,166,.18), transparent 60%), var(--bg); }
.auth-wrap { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; font-weight: 750; font-size: 1.4rem; letter-spacing: -.02em; }
.auth-card { display: flex; flex-direction: column; gap: 16px; padding: 28px; }
.auth-card h1 { font-size: 1.35rem; }
.auth-card p { margin: -8px 0 0; }
.auth-foot { text-align: center; color: var(--muted); font-size: .8rem; margin: 0; }

/* ---------- responsive */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .grid-2, .grid-wide-left { grid-template-columns: minmax(0, 1fr); }
  .tbl.msgs th:nth-child(4), .tbl.msgs td:nth-child(4) { display: none; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 50; transform: translateX(-100%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(2,6,23,.5); z-index: 40; }
  .menu-btn { display: inline-grid; margin-left: -8px; }
  .topbar { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); gap: 8px; }
  .topbar h1 { font-size: 1.1rem; }
  .top-search { display: none; }
  .content { padding: 16px 14px calc(88px + env(safe-area-inset-bottom)); gap: 14px; }
  .card { padding: 16px; border-radius: 12px; }
  .msg-list { margin: 0 -16px -16px; }
  .msg-list a { padding: 12px 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi-val { font-size: 1.45rem; }
  .kpi-held { grid-column: 1 / -1; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 8px; color: var(--muted); font-size: .7rem; font-weight: 600; }
  .tabbar a .ic { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--accent); }
  .tabbar a:hover { text-decoration: none; }
  .tabbar .badge { position: absolute; top: 4px; left: calc(50% + 6px); font-size: .62rem; padding: 0 5px; }

  .filters { padding: 14px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 0 14px 2px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .filter-row .field:not(.grow) { width: calc(50% - 6px); }
  .filter-row .field.grow { flex-basis: 100%; }
  .filter-btns { width: 100%; }
  .filter-btns .btn { flex: 1; }
  .more-toggle { display: inline-flex; }
  .filters:not(.show-more) .filter-row .field.adv { display: none; }
  .bulk-bar:not(.on) { display: none; }

  /* message table -> cards */
  .tbl.msgs, .tbl.msgs tbody { display: block; }
  .tbl.msgs thead { display: block; }
  .tbl.msgs thead tr { display: flex; align-items: center; }
  .tbl.msgs thead th { display: none; }
  .tbl.msgs thead th.cb { display: block; width: auto; padding: 10px 16px; background: none; border: 0; }
  .tbl.msgs thead th.cb::after { content: "Alles selecteren"; font-size: .78rem; text-transform: none; letter-spacing: 0; margin-left: 10px; vertical-align: 3px; }
  .tbl.msgs tr { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; grid-template-areas: "cb from time" "cb subj subj" "cb status score"; gap: 2px 8px; padding: 12px 16px 12px 6px; border-top: 1px solid var(--border); }
  .tbl.msgs td { display: block; padding: 0; border: 0; }
  .tbl.msgs tbody tr:hover td { background: none; }
  .tbl.msgs .cb { grid-area: cb; align-self: center; width: auto; }
  .tbl.msgs .t-time { grid-area: time; font-size: .78rem; }
  .tbl.msgs .t-from { grid-area: from; font-weight: 600; font-size: .9rem; }
  .tbl.msgs .t-to { display: none !important; }
  .tbl.msgs .t-subj { grid-area: subj; }
  .tbl.msgs .t-subj a { font-weight: 400; color: var(--text-2); font-size: .88rem; }
  .tbl.msgs .t-status { grid-area: status; padding-top: 4px; }
  .tbl.msgs .t-score { grid-area: score; padding-top: 4px; }
  .table-card > .card-head { padding: 14px 16px 0; }
  .bulk-bar { width: 100%; }
  .bulk-bar [data-bulk-count] { width: 100%; }

  /* generic stacked tables */
  .tbl.stack thead { display: none; }
  .tbl.stack, .tbl.stack tbody, .tbl.stack tr, .tbl.stack td { display: block; }
  .tbl.stack tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .tbl.stack td { border: 0; padding: 3px 0; display: flex; gap: 10px; text-align: left; }
  .tbl.stack td[data-label]::before { content: attr(data-label); flex: 0 0 110px; color: var(--muted); font-size: .78rem; font-weight: 600; padding-top: 2px; }
  .tbl.stack td.num { text-align: left; }
  .tbl.stack .row-actions { justify-content: flex-start; padding-top: 8px; }

  .msg-title { flex-direction: column; }
  .msg-badges { justify-content: flex-start; }
  .actions .btn { flex: 1 1 calc(50% - 8px); }
  .kv { grid-template-columns: 110px minmax(0, 1fr); }
  .row-2 { flex-direction: column; }
  .w-port { width: 100%; }
  .toolbar > .btn { width: 100%; }
}

/* spacing for stacked blocks inside cards */
.card > .kv + .pre, .card > .kv + .form-btns, .card > .pre + .form-btns { margin-top: 14px; }
.card > .form-btns + details { margin-top: 18px; }
textarea { font: inherit; font-size: .88rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; width: 100%; resize: vertical; }
textarea.mono { font-family: var(--mono); font-size: .82rem; }
textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=file] { font: inherit; font-size: .85rem; color: var(--text-2); }
input[type=file]::file-selector-button { font: inherit; font-weight: 600; font-size: .82rem; margin-right: 10px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.import-errors { margin-top: 14px; }
.import-errors ul { margin: 6px 0 0; padding-left: 18px; max-height: 260px; overflow: auto; }
#import { scroll-margin-top: 80px; }
