/* D3V WORKSPACE design system. One file, no overrides: tokens -> base -> layout -> components -> pages -> responsive. */

/* ============================== tokens ============================== */
:root {
  color-scheme: light;
  --bg: #f5f4fa;
  --bg-glow: radial-gradient(900px 500px at 15% -10%, rgba(124, 58, 237, 0.10), transparent 60%),
             radial-gradient(800px 460px at 100% 0%, rgba(192, 38, 211, 0.06), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f8f7fc;
  --surface-3: #efedf6;
  --elevated: #ffffff;
  --border: rgba(24, 16, 48, 0.08);
  --border-strong: rgba(24, 16, 48, 0.16);
  --text: #120e1f;
  --text-2: #4b4660;
  --muted: #8a85a0;
  --accent: #7c3aed;
  --accent-soft: rgba(124, 58, 237, 0.10);
  --accent-text: #6d28d9;
  --grad: linear-gradient(135deg, #7c3aed 0%, #a855f7 55%, #c026d3 100%);
  --good: #16a34a; --good-text: #15803d; --good-soft: rgba(22, 163, 74, 0.12);
  --warn: #f59e0b; --warn-text: #b45309; --warn-soft: rgba(245, 158, 11, 0.14);
  --serious: #f97316; --serious-text: #c2410c; --serious-soft: rgba(249, 115, 22, 0.13);
  --critical: #e11d48; --critical-text: #be123c; --critical-soft: rgba(225, 29, 72, 0.11);
  --blue-text: #1d4ed8; --blue-soft: rgba(37, 99, 235, 0.11);
  --aqua-text: #0f766e; --aqua-soft: rgba(13, 148, 136, 0.12);
  --grid: #e9e6f2; --axis: #cfcadf; --series-1: #7c3aed;
  --shadow: 0 1px 2px rgba(18, 14, 31, 0.04), 0 10px 30px -12px rgba(18, 14, 31, 0.12);
  --shadow-glow: 0 8px 24px -8px rgba(124, 58, 237, 0.45);
  --radius: 16px; --radius-sm: 10px;
  --side-w: 248px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07050c;
  --bg-glow: radial-gradient(1000px 560px at 8% -12%, rgba(124, 58, 237, 0.22), transparent 62%),
             radial-gradient(900px 520px at 100% -8%, rgba(192, 38, 211, 0.12), transparent 60%);
  --surface: #110e19;
  --surface-2: #0d0a14;
  --surface-3: #1b1726;
  --elevated: #16121f;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f2fa;
  --text-2: #bdb7cf;
  --muted: #7d7790;
  --accent: #8b5cf6;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --accent-text: #c4b5fd;
  --good-text: #4ade80; --good-soft: rgba(74, 222, 128, 0.12);
  --warn-text: #fbbf24; --warn-soft: rgba(251, 191, 36, 0.12);
  --serious-text: #fb923c; --serious-soft: rgba(251, 146, 60, 0.13);
  --critical-text: #fb7185; --critical-soft: rgba(251, 113, 133, 0.13);
  --blue-text: #93c5fd; --blue-soft: rgba(96, 165, 250, 0.14);
  --aqua-text: #5eead4; --aqua-soft: rgba(45, 212, 191, 0.12);
  --grid: #221d2e; --axis: #343046; --series-1: #8b5cf6;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 18px 40px -20px rgba(0, 0, 0, 0.8);
}

/* ============================== base ============================== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html, body { margin: 0; }
body { background: var(--bg-glow), var(--bg); background-attachment: fixed; color: var(--text); font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased; letter-spacing: -0.006em; font-feature-settings: "cv11", "ss01"; }
a { color: var(--accent-text); text-decoration: none; transition: color .15s; }
a:hover { color: var(--text); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 15px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { padding: 1px 6px; border-radius: 6px; background: var(--surface-3); }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
::selection { background: rgba(139, 92, 246, 0.35); }
a, button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--accent) 35%, transparent) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 9px; }

/* utilities */
.muted { color: var(--muted); } .text-2 { color: var(--text-2); } .small { font-size: 12.5px; }
.nowrap { white-space: nowrap; } .right { text-align: right; } .mt { margin-top: 16px; } .mb { margin-bottom: 18px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 16px; } .grow { flex: 1; min-width: 0; }
.inline { display: inline; } form.inline { display: inline-flex; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ============================== layout ============================== */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(to right, var(--surface) var(--side-w), transparent var(--side-w)); }
.shell > div { min-width: 0; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 18px 14px;
  background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; z-index: 40; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-logo { width: 36px; height: 36px; border-radius: 11px; box-shadow: 0 0 0 1px var(--border), 0 0 22px rgba(139, 92, 246, 0.35); transition: transform .3s var(--ease); }
.brand:hover .brand-logo { transform: rotate(-6deg) scale(1.05); }
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: 0.05em; }
.brand-name span { margin-left: 3px; font-size: .78em; font-weight: 600; letter-spacing: .16em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-name.big { font-size: 22px; margin-top: 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500;
  transition: background .15s, color .15s; position: relative; }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad); }
.nav a.active svg { color: var(--accent-text); }
.nav .count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--grad); color: #fff;
  font-size: 11px; font-weight: 700; text-align: center; line-height: 19px; }
.nav .count.muted { background: var(--surface-3); color: var(--text-2); }
.nav .dot { margin-left: auto; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px 6px 0; border-top: 1px solid var(--border); }
.pilot { display: flex; align-items: center; gap: 8px; padding: 0 6px; font-size: 12.5px; color: var(--text-2); }
.showcase-toggle .btn { width: 100%; justify-content: flex-start; }
.main { min-width: 0; padding: 28px 32px 56px; max-width: 1480px; animation: enter .4s var(--ease) both; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head > div:first-child { min-width: 0; }
.page-head .sub { margin-top: 6px; color: var(--text-2); max-width: 780px; }
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 18px; }
.grid > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============================== cards ============================== */
.card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
:root[data-theme="dark"] .card { background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0) 120px), var(--surface); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap; padding: 15px 20px; border-bottom: 1px solid var(--border); }
.card-head .hint { color: var(--muted); font-size: 12.5px; }
.stat { position: relative; padding: 18px 20px; overflow: hidden; }
.stat::after { content: ""; position: absolute; right: -50px; bottom: -70px; width: 170px; height: 170px; border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.14), transparent 70%); pointer-events: none; }
.stat .label { display: flex; gap: 7px; align-items: center; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.stat .label svg { color: var(--accent-text); }
.stat .value { margin-top: 8px; font-size: 30px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .value .small { font-size: 13px; font-weight: 600; letter-spacing: 0; }
.stat .foot { margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.meter { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 12px; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--grad); transition: width .7s var(--ease); }
.meter.good > span { background: linear-gradient(90deg, #16a34a, #4ade80); }

/* ============================== buttons ============================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--elevated); color: var(--text); font: 600 13.5px var(--font); cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .2s, transform .1s, filter .15s; text-decoration: none; }
.btn:hover { background: var(--surface-3); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: var(--shadow-glow); }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.danger { color: var(--critical-text); }
.btn.danger:hover { background: var(--critical-soft); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn.is-on { background: var(--accent-soft); color: var(--accent-text); }
.btn[disabled], .btn.loading { opacity: .55; pointer-events: none; }
.btn.loading::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================== badges, tags, dots ============================== */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 23px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  white-space: nowrap; background: var(--surface-3); color: var(--text-2); border: 1px solid color-mix(in srgb, currentColor 18%, transparent); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.b-PENDING, .b-LOST, .b-NO_REPLY, .b-cancelled, .b-NOT_INTERESTED, .b-AUTO_REPLY, .b-OTHER, .b-WRONG_PERSON { background: var(--surface-3); color: var(--muted); }
.b-QUEUED, .b-SENT, .b-queued, .b-draft { background: var(--accent-soft); color: var(--accent-text); }
.b-FOLLOWED_UP { background: var(--blue-soft); color: var(--blue-text); }
.b-REPLIED, .b-QUESTION { background: var(--aqua-soft); color: var(--aqua-text); }
.b-INTERESTED, .b-WON, .b-sent, .b-ok { background: var(--good-soft); color: var(--good-text); }
.b-OPTED_OUT, .b-UNSUBSCRIBE, .b-DELAYED { background: var(--serious-soft); color: var(--serious-text); }
.b-BOUNCED, .b-INVALID, .b-failed, .b-error, .b-BOUNCE, .b-hot { background: var(--critical-soft); color: var(--critical-text); }
.b-warm { background: var(--warn-soft); color: var(--warn-text); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; vertical-align: middle; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.dot.warn { background: var(--warn); }
.dot.off { background: var(--critical); box-shadow: 0 0 0 3px var(--critical-soft); }
.dot.run { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.grade { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; font-size: 11.5px; font-weight: 800; vertical-align: middle; }
.grade-A { background: var(--good-soft); color: var(--good-text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--good) 35%, transparent); }
.grade-B { background: var(--accent-soft); color: var(--accent-text); }
.grade-C { background: var(--surface-3); color: var(--text-2); }
.avatar { width: 36px; height: 36px; flex: none; border-radius: 11px; display: grid; place-items: center; font-weight: 800; font-size: 14px;
  color: #fff; background: var(--grad); box-shadow: var(--shadow-glow); }

/* ============================== forms ============================== */
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
label.f .help, .help { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font: 14px var(--font); transition: border-color .15s, box-shadow .15s, background .15s; }
textarea { height: auto; min-height: 120px; padding: 11px 12px; line-height: 1.55; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: 12.5px; min-height: 280px; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--border-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
input[type=file] { font: 13px var(--font); color: var(--text-2); }
.check { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid > * { min-width: 0; }
.form-grid .full { grid-column: 1 / -1; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.filters input[type=search] { flex: 1 1 240px; max-width: 320px; }
.filters select { width: auto; flex: 0 1 auto; }
.switch { position: relative; width: 42px; height: 24px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: var(--axis); cursor: pointer; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--grad); }
.switch input:checked + span::after { transform: translateX(18px); }
.key-row { padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); flex-wrap: wrap; background: var(--surface-2); }

/* ============================== tabs & chips ============================== */
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { position: relative; padding: 10px 14px; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); }
.tabs a.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; border-radius: 2px; background: var(--grad); }
.tabs .n { margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 11px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2); font: 600 12.5px var(--font); cursor: pointer; white-space: nowrap; transition: all .15s; }
.chip:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 40%, var(--border-strong)); }
.chip.active { background: var(--grad); border-color: transparent; color: #fff; box-shadow: var(--shadow-glow); }
.chip .n { color: var(--muted); font-weight: 600; }
.chip.active .n { color: rgba(255, 255, 255, .8); }

/* ============================== tables ============================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { padding: 11px 14px; text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr { transition: background .12s; }
table.t tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-title { font-weight: 700; color: var(--text); }
a.cell-title:hover { color: var(--accent-text); }
.cell-sub { color: var(--muted); font-size: 12.5px; }
.ai-line { margin-top: 2px; font-size: 12.5px; color: var(--text-2); }
.icons { display: flex; gap: 8px; align-items: center; }
.icons a { display: inline-flex; color: var(--muted); }
.icons a:hover { color: var(--accent-text); }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); }
.bulkbar { display: none; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 16px; background: var(--accent-soft); color: var(--accent-text);
  border-bottom: 1px solid var(--border); font-weight: 600; }
.bulkbar.show { display: flex; }
.bulkbar select { width: auto; }

/* ============================== lists, kv, empty ============================== */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 13px 20px; border-bottom: 1px solid var(--border); color: inherit; transition: background .12s; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover, .mail-row-item:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); color: inherit; }
.mail-row-item { align-items: flex-start; }
.list-item .title { font-weight: 700; color: var(--text); }
.list-item .snippet { color: var(--text-2); font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.unread .title::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.kv { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 10px 14px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding-top: 2px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.issues { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; }
.issues li { display: flex; gap: 8px; align-items: flex-start; }
.issues li svg { color: var(--critical-text); margin-top: 2px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty-icon { width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 14px; background: var(--grad); box-shadow: var(--shadow-glow); opacity: .9;
  -webkit-mask: radial-gradient(circle, transparent 7px, #000 8px); mask: radial-gradient(circle, transparent 7px, #000 8px); }

/* ============================== feedback ============================== */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash { padding: 11px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); font-weight: 600; animation: enter .3s var(--ease) both; }
.flash.ok { border-color: color-mix(in srgb, var(--good) 30%, transparent); background: var(--good-soft); color: var(--good-text); }
.flash.error { border-color: color-mix(in srgb, var(--critical) 30%, transparent); background: var(--critical-soft); color: var(--critical-text); }
.banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 13px 16px; margin-bottom: 18px;
  border-radius: var(--radius); background: var(--warn-soft); color: var(--warn-text); font-weight: 600; border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); }
.banner.info { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.showcase-banner { display: flex; gap: 8px; align-items: center; padding: 10px 14px; margin-bottom: 18px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 600; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 20px; border-bottom: 1px solid var(--border); transition: background .15s; }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row:hover { background: color-mix(in srgb, var(--accent-soft) 30%, transparent); }
.modal-bg { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; padding: 16px;
  background: rgba(5, 3, 10, 0.6); backdrop-filter: blur(6px); }
.modal-bg.show { display: flex; animation: enter .2s var(--ease); }
.modal { width: min(660px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }

/* ============================== email & thread ============================== */
.timeline { display: flex; flex-direction: column; gap: 12px; }
.email { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); overflow: hidden; }
.email-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.email-body { padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; color: var(--text-2); }
.email.in { box-shadow: inset 3px 0 0 var(--aqua-text); }
.email.out { box-shadow: inset 3px 0 0 var(--accent); }
.email.bounce { box-shadow: inset 3px 0 0 var(--critical); }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; display: inline-block; width: 10px; margin-right: 4px; color: var(--muted); transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }
details.why > summary { color: var(--accent-text); display: inline-flex; gap: 6px; align-items: center; }
pre.log { margin: 0; padding: 14px 16px; max-height: 440px; overflow: auto; background: var(--surface-2); font: 12px/1.6 var(--mono);
  white-space: pre-wrap; border-top: 1px solid var(--border); color: var(--text-2); }

/* mail preview: always light, like Gmail */
.mail { color-scheme: light; background: #fff; color: #202124; border: 1px solid #dadce0; border-radius: 14px; overflow: hidden;
  font: 14px/1.55 Arial, Helvetica, sans-serif; box-shadow: 0 10px 30px -14px rgba(0, 0, 0, .45); }
.mail-label { padding: 8px 16px; background: #f6f8fc; border-bottom: 1px solid #eceff1; font-size: 11px; color: #5f6368; text-transform: uppercase; letter-spacing: .06em; }
.mail-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 16px;
  background: #f2f6fc; border-bottom: 1px solid #eceff1; font-size: 13.5px; }
.mail-row .mr-from { font-weight: 700; color: #1f1f1f; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row .mr-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #5f6368; }
.mail-row .mr-subject { font-weight: 700; color: #1f1f1f; }
.mail-row .mr-time { font-size: 12px; font-weight: 700; color: #1f1f1f; white-space: nowrap; }
.mail-subject { padding: 18px 20px 6px; font-size: 21px; line-height: 1.35; color: #1f1f1f; overflow-wrap: anywhere; }
.mail-meta { display: flex; gap: 12px; align-items: flex-start; padding: 10px 20px 4px; }
.mail-avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; background: #6d28d9; color: #fff; display: grid; place-items: center; font-size: 17px; font-weight: 600; }
.mail-from { min-width: 0; font-size: 14px; color: #1f1f1f; }
.mail-from .addr, .mail-from .to { color: #5f6368; font-size: 12px; }
.mail-date { margin-left: auto; color: #5f6368; font-size: 12px; white-space: nowrap; }
.mail-body { padding: 8px 20px 26px 72px; white-space: pre-wrap; overflow-wrap: anywhere; color: #222; }
.mail-body a { color: #1a73e8; text-decoration: underline; }
.mail-empty { color: #80868b; font-style: italic; }

/* ============================== charts & funnels ============================== */
.viz { position: relative; }
.viz svg { display: block; width: 100%; height: 220px; overflow: visible; }
.viz .gridline { stroke: var(--grid); stroke-width: 1; }
.viz .baseline { stroke: var(--axis); stroke-width: 1; }
.viz .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz .bar { fill: var(--series-1); transition: opacity .15s; }
.viz .bar.dim { opacity: .3; }
.viz .hit { fill: transparent; }
.tooltip { position: absolute; z-index: 5; min-width: 150px; padding: 9px 11px; border-radius: 10px; background: var(--elevated); border: 1px solid var(--border-strong);
  box-shadow: 0 14px 34px -10px rgba(0, 0, 0, .5); font-size: 12.5px; opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; pointer-events: none; }
.tooltip.show { opacity: 1; transform: none; }
.tooltip .tt-title { font-weight: 700; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 16px; color: var(--text-2); }
.tooltip .tt-row b { color: var(--text); font-variant-numeric: tabular-nums; }
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 60px; gap: 12px; align-items: center; font-size: 13px; color: inherit; }
.funnel-row.wide { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 42px; }
.funnel-row .track { display: block; height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.funnel-row .fill { display: block; height: 100%; min-width: 3px; border-radius: 999px; background: var(--grad); transition: width .7s var(--ease); }
.funnel-row .n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============================== website analysis ============================== */
.findings { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.finding-row { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 10px; align-items: start; }
.sev { display: inline-block; padding: 3px 0; border-radius: 6px; text-align: center; font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.sev-critical { background: var(--critical-soft); color: var(--critical-text); }
.sev-high { background: var(--serious-soft); color: var(--serious-text); }
.sev-medium { background: var(--warn-soft); color: var(--warn-text); }
.sev-low { background: var(--surface-3); color: var(--text-2); }

/* ============================== live activity ============================== */
.live-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.live-toolbar .chips { flex: 1 1 auto; }
.live-toolbar input[type=search] { max-width: 260px; }
.live-grid { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: 360px; }
.live-side { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-right: 1px solid var(--border); }
.live-feed { height: 440px; overflow-y: auto; padding: 10px 0; background: var(--surface-2); font: 12.5px/1.6 var(--mono); border-radius: 0 0 var(--radius) 0; }
.live-grid.tall .live-feed { height: calc(100vh - 380px); min-height: 440px; }
.live-line { display: grid; grid-template-columns: 70px 100px minmax(0, 1fr); gap: 10px; padding: 3px 16px; border-left: 2px solid transparent; }
.live-line .t { color: var(--muted); }
.live-line .j { color: var(--accent-text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-line .m { color: var(--text-2); overflow-wrap: anywhere; }
.live-line.start { border-left-color: var(--accent); } .live-line.start .m { color: var(--text); }
.live-line.done { border-left-color: var(--good); } .live-line.done .m { color: var(--good-text); }
.live-line.error { border-left-color: var(--critical); background: var(--critical-soft); } .live-line.error .m { color: var(--critical-text); }
.live-line.fresh { animation: fresh 1.4s ease-out; }
@keyframes fresh { from { background: var(--accent-soft); } to { background: transparent; } }
.job-chip { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; }
.job-chip .when { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
h1 .dot { width: 10px; height: 10px; }

/* ============================== auth, error, public ============================== */
.login-page { background: radial-gradient(ellipse at top, rgba(124, 58, 237, .28), transparent 60%), var(--bg); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(400px, 100%); }
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 24px; }
.login-brand img { border-radius: 26px; box-shadow: 0 0 50px rgba(139, 92, 246, .5); }
.error-page { min-height: 65vh; display: grid; place-items: center; text-align: center; }
.error-page .code { font-size: 72px; font-weight: 900; line-height: 1; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* showcase mode */
.showcase .pii { filter: blur(5px); user-select: none; }
.showcase .mail .pii { filter: blur(4px); }
.bottom-nav { display: none; }

/* ============================== motion preferences ============================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ============================== responsive ============================== */
@media (max-width: 1200px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 > .span2 { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; transform: translateX(-102%); transition: transform .25s var(--ease);
    box-shadow: 20px 0 60px rgba(0, 0, 0, .45); }
  .sidebar.open { transform: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30; padding: 10px 14px;
    background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); }
  .main { padding: 18px 16px 100px; }
  h1 { font-size: 22px; }
  .page-head { align-items: flex-start; margin-bottom: 18px; }
  .page-head .actions { width: 100%; }
  .page-head .actions > .btn, .page-head .actions > form .btn { flex: 1 1 auto; }
  .grid { gap: 14px; }
  .g2, .g3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span2, .g3 > .span2 { grid-column: auto; }
  .card-pad { padding: 15px 16px; } .card-head { padding: 13px 16px; } .list-item { padding: 12px 16px; }
  .stat { padding: 15px 16px; } .stat .value { font-size: 24px; }
  .btn { height: 40px; } .btn.sm { height: 34px; }
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], select { height: 44px; font-size: 16px; }
  textarea { font-size: 16px; }
  .filters { padding: 12px; } .filters input[type=search] { max-width: none; flex-basis: 100%; } .filters select { flex: 1 1 140px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; } .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; } .kv dd { margin-bottom: 10px; }
  .hide-sm { display: none; }
  table.t th, table.t td { padding: 10px 12px; }
  .lead-side { order: -1; }
  .live-grid { grid-template-columns: minmax(0, 1fr); }
  .live-side { border-right: 0; border-bottom: 1px solid var(--border); }
  .live-feed, .live-grid.tall .live-feed { height: 60vh; min-height: 320px; border-radius: 0 0 var(--radius) var(--radius); }
  .live-line { grid-template-columns: 58px minmax(0, 1fr); } .live-line .j { display: none; }
  .live-toolbar input[type=search] { max-width: none; flex: 1 1 100%; }
  .mail-row { grid-template-columns: minmax(0, 1fr) auto; } .mail-row .mr-from { grid-column: 1 / -1; }
  .mail-body { padding-left: 20px; }
  .funnel-row { grid-template-columns: 92px minmax(0, 1fr) 46px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid var(--border); }
  .bottom-nav a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; color: var(--muted); font-size: 11px; font-weight: 600; }
  .bottom-nav a.active { color: var(--accent-text); }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav i { position: absolute; top: 0; left: 55%; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--grad); color: #fff;
    font: 700 10px/16px var(--font); font-style: normal; }
  /* the leads table becomes stacked cards */
  table.t.cards thead { display: none; }
  table.t.cards, table.t.cards tbody, table.t.cards tr, table.t.cards td { display: block; width: 100%; }
  table.t.cards tr { position: relative; padding: 13px 16px; border-bottom: 1px solid var(--border); }
  table.t.cards td { padding: 2px 0; border: 0; }
  table.t.cards td.check-cell { position: absolute; top: 13px; right: 16px; width: auto; }
  table.t.cards td.num { text-align: left; }
  table.t.cards tbody tr:hover td { background: transparent; }
}
@media (max-width: 380px) {
  .g4 { grid-template-columns: minmax(0, 1fr); }
}
