/* AdNerve app layer — the marketing site's pastel-glass world, tuned for
   long working sessions: calmer light fields, denser type, solid-enough
   surfaces for data. Shared by dashboard and admin. */

@font-face { font-family: 'Bricolage Grotesque'; src: url('/assets/fonts/bricolage-grotesque.woff2') format('woff2'); font-weight: 400 800; font-stretch: 75% 125%; font-display: swap; }
@font-face { font-family: 'Figtree'; src: url('/assets/fonts/figtree.woff2') format('woff2'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Figtree'; src: url('/assets/fonts/figtree-italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  color-scheme: light;
  --ground: #f3f2fa;
  --ink: #27233f;
  --ink-soft: #504b70;
  --ink-faint: #6d6890;
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(255, 255, 255, 0.85);
  --glass-edge: rgba(122, 108, 240, 0.14);
  --accent: #6f61ec;
  --accent-deep: #5a4be0;
  --accent-soft: rgba(122, 108, 240, 0.12);
  --peach: #f0a878;
  --shadow: 0 24px 48px -28px rgba(84, 74, 160, 0.3);
  --shadow-soft: 0 10px 24px -16px rgba(84, 74, 160, 0.24);
  --field: rgba(255, 255, 255, 0.72);
  --line: rgba(122, 108, 240, 0.13);
  --rule: rgba(39, 35, 63, 0.1);
  --panel: #faf9ff;
  --user-bubble: #ebe8fd;
  --ok: #2c7a4b;
  --ok-bg: rgba(44, 122, 75, 0.1);
  --bad: #a33a48;
  --bad-bg: rgba(163, 58, 72, 0.09);
  --warn: #99561f;
  --warn-bg: rgba(153, 86, 31, 0.1);
  --chart-surface: #fcfcfb;
  --grid: rgba(39, 35, 63, 0.08);
  --s1: #6250d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #2a78d6; --s8: #e34948;
  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --text: 'Figtree', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --ground: #14121e;
  --ink: #f3f1fb;
  --ink-soft: #cdc8e6;
  --ink-faint: #a49fc2;
  --glass: rgba(255, 255, 255, 0.05);
  --glass-strong: rgba(36, 32, 54, 0.92);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-edge: rgba(179, 169, 255, 0.16);
  --accent: #a497f8;
  --accent-deep: #b6acff;
  --accent-soft: rgba(164, 151, 248, 0.16);
  --peach: #f4b78e;
  --shadow: 0 24px 48px -24px rgba(0, 0, 0, 0.7);
  --shadow-soft: 0 12px 28px -16px rgba(0, 0, 0, 0.6);
  --field: rgba(255, 255, 255, 0.07);
  --line: rgba(179, 169, 255, 0.15);
  --rule: rgba(255, 255, 255, 0.1);
  --panel: #1d1a2c;
  --user-bubble: #2e2950;
  --ok: #8fe0b2;
  --ok-bg: rgba(143, 224, 178, 0.12);
  --bad: #ffb0ba;
  --bad-bg: rgba(255, 176, 186, 0.12);
  --warn: #f8c79f;
  --warn-bg: rgba(248, 199, 159, 0.12);
  --chart-surface: #211d32;
  --grid: rgba(255, 255, 255, 0.08);
  --s1: #9085e9; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #3987e5; --s8: #e66767;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 400 15px/1.55 var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-deep); }
::selection { background: rgba(122, 108, 240, 0.25); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.ambient { position: fixed; inset: -20vh -20vw; z-index: -1; pointer-events: none; filter: blur(80px); }
.ambient i { position: absolute; border-radius: 50%; mix-blend-mode: multiply; opacity: 0.38; }
.ambient i:nth-child(1) { width: 60vmax; height: 50vmax; left: -14vmax; top: -18vmax; background: radial-gradient(closest-side, #b9b0f2, transparent 70%); animation: drift1 30s ease-in-out infinite alternate; }
.ambient i:nth-child(2) { width: 50vmax; height: 44vmax; right: -16vmax; top: 6vmax; background: radial-gradient(closest-side, #f6cdae, transparent 70%); animation: drift2 36s ease-in-out infinite alternate; }
.ambient i:nth-child(3) { width: 54vmax; height: 46vmax; left: 18vmax; bottom: -24vmax; background: radial-gradient(closest-side, #b8d9f2, transparent 70%); animation: drift3 42s ease-in-out infinite alternate; }
[data-theme="dark"] .ambient i { mix-blend-mode: screen; opacity: 0.12; }
@keyframes drift1 { to { transform: translate(6vmax, 4vmax) scale(1.06); } }
@keyframes drift2 { to { transform: translate(-5vmax, 6vmax) scale(0.95); } }
@keyframes drift3 { to { transform: translate(4vmax, -5vmax) scale(1.05); } }
@media (prefers-reduced-motion: reduce) { .ambient i { animation: none; } * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; } }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft), inset 0 0 0 1px var(--glass-edge);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
}

/* ---------- controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 9px 18px; cursor: pointer;
  font-weight: 600; font-size: 14px; line-height: 1.2; white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, opacity 0.2s;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #8a7cf4 0%, #6557e8 100%); color: #fff; box-shadow: 0 8px 20px -10px rgba(101, 87, 232, 0.7); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 24px -10px rgba(101, 87, 232, 0.85); }
.btn-glass { background: var(--field); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn-glass:hover:not(:disabled) { background: var(--glass-strong); }
.btn-ghost { background: transparent; color: var(--ink-soft); padding: 8px 12px; }
.btn-ghost:hover:not(:disabled) { background: var(--accent-soft); color: var(--ink); }
.btn-danger { background: var(--bad-bg); color: var(--bad); }
.btn-danger:hover:not(:disabled) { background: var(--bad); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 26px; font-size: 15px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  border: 0; background: transparent; color: var(--ink-soft); cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--ink); }
.icon-btn svg, .btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field small { color: var(--ink-faint); font-size: 12.5px; }
.input, select.input, textarea.input {
  width: 100%; border: 0; border-radius: var(--r-sm); padding: 10px 13px;
  background: var(--field); box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow 0.15s;
}
.input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.input::placeholder { color: var(--ink-faint); opacity: 0.8; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; background: var(--accent-soft); color: var(--accent-deep);
  white-space: nowrap;
}
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.muted { background: var(--rule); color: var(--ink-soft); }

.label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint); }
.muted { color: var(--ink-faint); }
.error-text { color: var(--bad); font-size: 13.5px; }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  background: rgba(30, 26, 52, 0.28); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade 0.18s ease;
}
[data-theme="dark"] .modal-backdrop { background: rgba(5, 4, 12, 0.55); }
.modal {
  width: min(560px, 100%); max-height: calc(100dvh - 40px); overflow: auto;
  border-radius: var(--r-lg); padding: 26px; background: var(--glass-strong);
  animation: rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal h2 { font: 700 22px/1.2 var(--display); letter-spacing: -0.015em; margin: 0 0 6px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-head p { margin: 0; color: var(--ink-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(0.98); } }

.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 10px 18px; border-radius: 999px; background: #27233f; color: #fff; font-size: 14px; box-shadow: var(--shadow); animation: rise 0.2s ease; pointer-events: auto; }
.toast.bad { background: #a33a48; }
[data-theme="dark"] .toast { background: #f3f1fb; color: #27233f; }

.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- markdown ---------- */

.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol { margin: 0 0 0.75em; }
.md ul, .md ol { padding-left: 1.3em; }
.md li { margin: 0.2em 0; }
.md li::marker { color: var(--ink-faint); }
.md h1, .md h2, .md h3 { font-family: var(--display); letter-spacing: -0.01em; line-height: 1.25; margin: 1.1em 0 0.45em; }
.md h1 { font-size: 1.3em; } .md h2 { font-size: 1.16em; } .md h3 { font-size: 1.04em; }
.md strong { font-weight: 650; color: var(--ink); }
.md code { font-family: var(--mono); font-size: 0.88em; background: var(--accent-soft); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--panel); border-radius: var(--r-sm); padding: 12px 14px; overflow: auto; box-shadow: inset 0 0 0 1px var(--line); }
.md pre code { background: none; padding: 0; }
.md hr { border: 0; border-top: 1px solid var(--rule); margin: 1em 0; }
.md blockquote { margin: 0 0 0.75em; padding-left: 12px; border-left: 3px solid var(--line); color: var(--ink-soft); }
.md .table-wrap { overflow-x: auto; margin: 0 0 0.85em; border-radius: var(--r-sm); box-shadow: inset 0 0 0 1px var(--line); }
.md table { border-collapse: collapse; width: 100%; font-size: 0.93em; font-variant-numeric: tabular-nums; }
.md th, .md td { padding: 7px 12px; text-align: left; border-bottom: 1px solid var(--rule); }
.md th { font-weight: 650; color: var(--ink-soft); background: var(--accent-soft); white-space: nowrap; }
.md tr:last-child td { border-bottom: 0; }
.md td.num, .md th.num { text-align: right; }

/* ---------- charts ---------- */

.viz { border-radius: var(--r-md); padding: 16px 16px 12px; background: var(--chart-surface); box-shadow: inset 0 0 0 1px var(--line); margin: 10px 0 14px; position: relative; }
.viz-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.viz-title { font: 650 15px/1.3 var(--display); margin: 0; letter-spacing: -0.005em; }
.viz-sub { font-size: 12.5px; color: var(--ink-faint); margin: 2px 0 0; }
.viz-tools { display: flex; gap: 2px; flex: none; }
.viz-tools button { border: 0; background: transparent; color: var(--ink-faint); font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 7px; cursor: pointer; }
.viz-tools button:hover, .viz-tools button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); }
.viz-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 2px 0 6px; font-size: 12.5px; color: var(--ink-soft); }
.viz-legend span { display: inline-flex; align-items: center; gap: 6px; }
.viz-legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.viz svg { display: block; width: 100%; overflow: visible; }
.viz svg text { fill: var(--ink-faint); font: 11px var(--text); font-variant-numeric: tabular-nums; }
.viz .grid line { stroke: var(--grid); }
.viz .axis-base { stroke: var(--rule); }
.viz-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 140px; max-width: 260px;
  background: var(--glass-strong); border-radius: 10px; padding: 8px 11px; font-size: 12.5px;
  box-shadow: var(--shadow), inset 0 0 0 1px var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  transition: opacity 0.12s; font-variant-numeric: tabular-nums;
}
.viz-tip b { display: block; font-weight: 650; margin-bottom: 4px; color: var(--ink); }
.viz-tip div { display: flex; align-items: center; gap: 7px; justify-content: space-between; color: var(--ink-soft); }
.viz-tip div span { display: inline-flex; align-items: center; gap: 6px; }
.viz-tip i { width: 8px; height: 8px; border-radius: 2px; }
.viz-tip div strong { color: var(--ink); font-weight: 650; }
.viz-table { max-height: 320px; overflow: auto; }
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut-wrap svg { width: 190px; height: 190px; flex: none; }
.donut-list { flex: 1; min-width: 180px; display: grid; gap: 6px; font-size: 13.5px; }
.donut-list div { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 8px; align-items: center; }
.donut-list i { width: 10px; height: 10px; border-radius: 3px; }
.donut-list strong { font-weight: 650; font-variant-numeric: tabular-nums; }
.donut-list em { font-style: normal; color: var(--ink-faint); font-variant-numeric: tabular-nums; min-width: 46px; text-align: right; }
