/* Lead agent dashboard. No framework, no build step. Dark first, with a light theme. */

/* ── Tokens ──────────────────────────────────────────────────────────────────────────────── */
:root {
  color-scheme: dark;
  --bg: #0a0c11;
  --bg-2: #0e1118;
  --surface: #12151d;
  --surface-2: #171b25;
  --surface-3: #1e2330;
  --line: #222838;
  --line-2: #2d3447;
  --ink: #e9ebf2;
  --ink-2: #c4c9d6;
  --muted: #8a92a8;
  --faint: #5f6780;
  --accent: #8b7bff;
  --accent-2: #5ee6d0;
  --accent-ink: #0b0a1a;
  --accent-soft: rgba(139, 123, 255, 0.14);
  --accent-line: rgba(139, 123, 255, 0.45);
  --ok: #3ddc97;
  --ok-soft: rgba(61, 220, 151, 0.13);
  --warn: #f6c35b;
  --warn-soft: rgba(246, 195, 91, 0.13);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.13);
  --info: #6cb6ff;
  --info-soft: rgba(108, 182, 255, 0.13);
  --off: #7d8599;
  --off-soft: rgba(125, 133, 153, 0.14);
  --wa-bg: #0b141a;
  --wa-in: #202c33;
  --wa-ink: #e9edef;
  --wa-meta: #8696a0;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--line);
  --r: 14px;
  --r-sm: 9px;
  --r-xs: 6px;
  --sidebar: 248px;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", -apple-system, system-ui, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f9;
  --bg-2: #eceef4;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eff1f6;
  --line: #e4e7ef;
  --line-2: #d3d8e3;
  --ink: #141722;
  --ink-2: #353b4d;
  --muted: #687089;
  --faint: #9aa1b5;
  --accent: #5a48e8;
  --accent-2: #0ea5a0;
  --accent-ink: #ffffff;
  --accent-soft: rgba(90, 72, 232, 0.09);
  --accent-line: rgba(90, 72, 232, 0.4);
  --ok: #0c8f5c;
  --ok-soft: rgba(12, 143, 92, 0.1);
  --warn: #a86a00;
  --warn-soft: rgba(214, 145, 0, 0.12);
  --danger: #d63c3c;
  --danger-soft: rgba(214, 60, 60, 0.09);
  --info: #1f6fd1;
  --info-soft: rgba(31, 111, 209, 0.09);
  --off: #727a8f;
  --off-soft: rgba(114, 122, 143, 0.1);
  --wa-bg: #efeae2;
  --wa-in: #ffffff;
  --wa-ink: #111b21;
  --wa-meta: #667781;
  --shadow: 0 1px 2px rgba(20, 23, 34, 0.04), 0 8px 24px -12px rgba(20, 23, 34, 0.12);
  --shadow-lg: 0 24px 64px -16px rgba(20, 23, 34, 0.25), 0 0 0 1px var(--line);
}

/* ── Base ────────────────────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.015em; }
p { margin: 0; }
code, kbd, .mono { font-family: var(--mono); font-size: 0.92em; }
code { background: var(--surface-3); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; }
kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--surface-2);
  color: var(--muted); font-size: 11px; line-height: 1;
}
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid var(--bg); }

/* ── Controls ────────────────────────────────────────────────────────────────────────────── */
.btn {
  --b: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: var(--r-sm);
  border: 1px solid var(--b); background: var(--surface-2); color: var(--ink);
  font: 550 13px/1 var(--font); cursor: pointer; white-space: nowrap; user-select: none;
  transition: background 0.15s, border-color 0.15s, transform 0.08s, box-shadow 0.15s;
}
.btn:hover { background: var(--surface-3); --b: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn.xs { height: 24px; padding: 0 8px; font-size: 12px; border-radius: 6px; gap: 5px; }
.btn.lg { height: 42px; padding: 0 18px; font-size: 14px; }
.btn.icon { width: 34px; padding: 0; }
.btn.sm.icon { width: 28px; }
.btn.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, white), var(--accent));
  --b: transparent; color: var(--accent-ink);
  box-shadow: 0 6px 20px -8px var(--accent), 0 0 0 1px color-mix(in srgb, var(--accent) 70%, black) inset;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; --b: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn.danger { color: var(--danger); --b: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); }
.btn.danger:hover { --b: var(--danger); }
.btn.ok { color: var(--ok); --b: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--muted); border-top-color: transparent; animation: spin 0.7s linear infinite;
}
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.muted { color: var(--muted); }

.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 11px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--ink);
  font: 13.5px/1.4 var(--font); transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface);
}
.input[readonly] { color: var(--muted); background: var(--surface-2); cursor: default; }
.input.invalid, .textarea.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.input.mono, .textarea.mono { font-family: var(--mono); font-size: 12.5px; }
.textarea { height: auto; min-height: 64px; padding: 9px 11px; resize: vertical; line-height: 1.55; }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 15px, calc(100% - 12px) 15px; background-size: 5px 5px; background-repeat: no-repeat;
}
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-right: 46px; }
.input-wrap .suffix { position: absolute; right: 11px; color: var(--faint); font-size: 12px; pointer-events: none; }
.input-wrap .prefix-icon { position: absolute; left: 10px; color: var(--faint); display: flex; pointer-events: none; }
.input-wrap .prefix-icon + .input { padding-left: 32px; }
.input-wrap .prefix-icon svg { width: 15px; height: 15px; }
.input.sm { height: 30px; font-size: 13px; }

/* switch */
.sw {
  --w: 38px; --h: 22px;
  position: relative; flex: none; width: var(--w); height: var(--h); border-radius: 99px; padding: 0;
  border: 1px solid var(--line-2); background: var(--surface-3); cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s;
}
.sw::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: calc(var(--h) - 6px); height: calc(var(--h) - 6px);
  border-radius: 50%; background: var(--muted); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.22s var(--ease), background 0.2s;
}
.sw[aria-checked="true"] { background: var(--accent); border-color: transparent; }
.sw[aria-checked="true"]::after { transform: translateX(calc(var(--w) - var(--h))); background: #fff; }
.sw.danger[aria-checked="false"] { background: var(--danger); border-color: transparent; }
.sw.danger[aria-checked="false"]::after { background: #fff; }
.sw.sm { --w: 32px; --h: 18px; }
.sw:disabled { opacity: 0.45; cursor: not-allowed; }

/* segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.seg button {
  height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted);
  font: 550 12.5px/1 var(--font); cursor: pointer; white-space: nowrap; transition: background 0.15s, color 0.15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--line-2); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 99px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink-2);
  font: 550 12.5px/1 var(--font); cursor: pointer; transition: all 0.15s;
}
.chip:hover { border-color: var(--faint); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--ink); }
.chip .n { color: var(--faint); font-weight: 500; }
.chip .dot { width: 7px; height: 7px; }

/* tags and pills */
.tag {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 6px;
  font: 600 11px/1 var(--font); letter-spacing: 0.01em; background: var(--off-soft); color: var(--off); white-space: nowrap;
}
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag svg { width: 11px; height: 11px; }
.st, .st-sent, .st-partial, .st-held, .st-dry_run, .st-skipped, .st-failed, .st-duplicate {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 99px;
  font: 600 11.5px/1 var(--font); white-space: nowrap; text-transform: capitalize;
}
.st::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-sent { background: var(--ok-soft); color: var(--ok); }
.st-partial { background: var(--warn-soft); color: var(--warn); }
.st-held { background: var(--warn-soft); color: var(--warn); }
.st-dry_run { background: var(--info-soft); color: var(--info); }
.st-skipped { background: var(--off-soft); color: var(--off); }
.st-failed { background: var(--danger-soft); color: var(--danger); }
.st-duplicate { background: var(--off-soft); color: var(--off); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--off); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.danger { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.dot.info { background: var(--info); box-shadow: 0 0 0 3px var(--info-soft); }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }

/* ── App shell ───────────────────────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  padding: 16px 12px; border-right: 1px solid var(--line); background: var(--bg-2); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 6px 18px -6px var(--accent);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand b { display: block; font-size: 14.5px; letter-spacing: -0.01em; }
.brand span { display: block; font-size: 11.5px; color: var(--muted); }
.nav-label { padding: 14px 10px 6px; font: 650 10.5px/1 var(--font); text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); }
.nav a {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 8px;
  color: var(--ink-2); font-weight: 520; font-size: 13.5px; text-decoration: none; position: relative;
  transition: background 0.12s, color 0.12s;
}
.nav a svg { width: 17px; height: 17px; color: var(--muted); flex: none; transition: color 0.12s; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface-3); color: var(--ink); }
.nav a[aria-current="page"] svg { color: var(--accent); }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav a .badge { margin-left: auto; font-size: 11px; font-weight: 650; color: var(--muted); }
.nav a .badge.hot { color: var(--accent); }
.sidebar-foot { margin-top: auto; padding: 12px 6px 2px; display: flex; flex-direction: column; gap: 10px; }
.mode-card {
  padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: center; gap: 10px;
}
.mode-card b { display: block; font-size: 13px; }
.mode-card span { display: block; font-size: 11.5px; color: var(--muted); }
.mode-card.live { border-color: color-mix(in srgb, var(--danger) 50%, transparent); background: var(--danger-soft); }
.mode-card.live b { color: var(--danger); }

.main { min-width: 0; display: flex; flex-direction: column; }
.livebar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: center; gap: 12px;
  height: 38px; padding: 0 16px; background: linear-gradient(90deg, #b3261e, #e5484d, #b3261e); background-size: 200% 100%;
  color: #fff; font-weight: 650; font-size: 13px; animation: slide 6s linear infinite;
}
.livebar .btn { height: 26px; background: rgba(0, 0, 0, 0.22); --b: rgba(255, 255, 255, 0.35); color: #fff; font-size: 12px; }
.livebar .btn:hover { background: rgba(0, 0, 0, 0.35); }
.livebar .dot { background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3); }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
body.is-live .topbar { top: 38px; }
.topbar h1 { font-size: 16.5px; }
.topbar .crumb { color: var(--muted); font-size: 13px; }
.search-btn {
  display: flex; align-items: center; gap: 9px; width: 280px; height: 34px; padding: 0 8px 0 11px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--faint); font: 13px var(--font); cursor: pointer;
  transition: border-color 0.15s;
}
.search-btn:hover { border-color: var(--line-2); color: var(--muted); }
.search-btn svg { width: 15px; height: 15px; }
.search-btn kbd { margin-left: auto; }
.chan-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 11px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; color: var(--ink-2); cursor: pointer;
}
.chan-pill:hover { border-color: var(--line-2); }
.content { padding: 26px 28px 80px; max-width: 1240px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h2 { font-size: 24px; letter-spacing: -0.025em; }
.page-head p { color: var(--muted); margin-top: 4px; max-width: 680px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.view { animation: fadein 0.22s var(--ease); }

/* ── Cards and layout ────────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 14.5px; }
.card-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 18px; }
.card-body.tight { padding: 8px 0; }
.card.flush .card-head { border-bottom: 0; }
.card.glow { position: relative; overflow: hidden; }
.card.glow::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(135deg, var(--accent-line), transparent 40%, transparent 60%, color-mix(in srgb, var(--accent-2) 40%, transparent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; }
.grid.side-l { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
.sticky { position: sticky; top: 84px; }
body.is-live .sticky { top: 122px; }
.stack > * + * { margin-top: 16px; }

/* stats */
.stat {
  padding: 16px 18px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative; overflow: hidden;
}
.stat .k { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 550; }
.stat .k svg { width: 14px; height: 14px; }
.stat .v { font-size: 26px; font-weight: 680; letter-spacing: -0.03em; line-height: 1.1; }
.stat .v small { font-size: 13px; color: var(--muted); font-weight: 550; letter-spacing: 0; margin-left: 6px; }
.stat .s { color: var(--faint); font-size: 12px; }
.stat.click { cursor: pointer; transition: border-color 0.15s, transform 0.15s; }
.stat.click:hover { border-color: var(--line-2); transform: translateY(-1px); }
.spark { position: absolute; right: 12px; bottom: 12px; opacity: 0.9; }

/* hero */
.hero {
  position: relative; overflow: hidden; padding: 22px 24px; border-radius: 18px; border: 1px solid var(--line);
  background:
    radial-gradient(600px 200px at 0% 0%, var(--accent-soft), transparent 70%),
    radial-gradient(500px 220px at 100% 100%, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent 70%),
    var(--surface);
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
}
.hero.live {
  background: radial-gradient(600px 220px at 0% 0%, var(--danger-soft), transparent 70%), var(--surface);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}
.hero h3 { font-size: 20px; letter-spacing: -0.02em; }
.hero p { color: var(--muted); margin-top: 3px; }
.hero .big-sw { --w: 58px; --h: 32px; }
.hero-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.hero.live .hero-icon { background: var(--danger-soft); color: var(--danger); }
.hero-icon svg { width: 26px; height: 26px; }

/* ── Settings fields ─────────────────────────────────────────────────────────────────────── */
.fields { display: flex; flex-direction: column; }
.field {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 8px 28px; padding: 16px 18px;
  border-top: 1px solid var(--line); align-items: start; transition: background 0.4s;
}
.field:first-child { border-top: 0; }
.field.wide { grid-template-columns: 1fr; }
.field.disabled { opacity: 0.5; }
.field.flash { background: var(--accent-soft); }
.field .meta { min-width: 0; }
.field .label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; font-size: 13.5px; }
.field .help { color: var(--muted); font-size: 12.5px; margin-top: 3px; line-height: 1.45; }
.field .env { margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--faint); font-size: 11.5px; }
.field .env code { font-size: 11px; padding: 0 4px; }
.field .control { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.field .control.inline { flex-direction: row; align-items: center; justify-content: flex-end; }
.field .err { color: var(--danger); font-size: 12px; }
.field .saved-tick { color: var(--ok); font-size: 12px; display: inline-flex; gap: 4px; align-items: center; opacity: 0; transition: opacity 0.3s; }
.field .saved-tick.on { opacity: 1; }
.src { font-size: 10.5px; font-weight: 650; letter-spacing: 0.02em; padding: 2px 6px; border-radius: 5px; text-transform: uppercase; }
.src.dashboard { background: var(--accent-soft); color: var(--accent); }
.src.env { background: var(--info-soft); color: var(--info); }
.src.default { background: var(--off-soft); color: var(--off); }
.placeholders { display: flex; gap: 6px; flex-wrap: wrap; }
.ph { height: 22px; padding: 0 7px; border-radius: 6px; border: 1px dashed var(--line-2); background: transparent; color: var(--accent); font: 12px var(--mono); cursor: pointer; }
.ph:hover { border-color: var(--accent); background: var(--accent-soft); }
.map-rows { display: flex; flex-direction: column; gap: 6px; }
.map-row { display: grid; grid-template-columns: 1fr 1fr 28px; gap: 6px; }
.secret-state { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.adv-toggle { padding: 12px 18px; border-top: 1px solid var(--line); }

/* ── Tables ──────────────────────────────────────────────────────────────────────────────── */
.table-wrap { overflow: auto; border-radius: 0 0 var(--r) var(--r); }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.t th {
  position: sticky; top: 0; z-index: 1; text-align: left; font: 650 11px/1 var(--font); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--faint); padding: 11px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.t th.sortable { cursor: pointer; user-select: none; }
.t th.sortable:hover { color: var(--ink); }
.t th .arrow { opacity: 0.8; margin-left: 4px; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr { transition: background 0.12s; }
.t tbody tr:hover { background: var(--surface-2); }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.new { animation: rowin 1.6s var(--ease); }
.t td.num, .t th.num { text-align: right; }
.t .cell-edit {
  display: block; min-height: 22px; padding: 2px 6px; margin: -2px -6px; border-radius: 6px; border: 1px solid transparent; cursor: text;
}
.t .cell-edit:hover { border-color: var(--line-2); background: var(--bg-2); }
.t .cell-edit.empty::before { content: "—"; color: var(--faint); }
.t td .cell-edit:not(.empty) { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.table-wrap > table.t.wide { min-width: 1080px; }
.t input.cell-input { width: 100%; min-width: 60px; height: 28px; padding: 0 7px; margin: -4px -7px; font-size: 13px; }
.t .row-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; transition: opacity 0.12s; }
.t tr:hover .row-actions, .t tr:focus-within .row-actions { opacity: 1; }
.t .prod b { font-weight: 600; }
.t .sub { color: var(--faint); font-size: 11.5px; margin-top: 2px; }

/* ── Products grid ───────────────────────────────────────────────────────────────────────── */
.cat { overflow: hidden; }
.cat-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.cat-head h3 { font-size: 13.5px; }
.cat-head .n { color: var(--muted); font-size: 12px; }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.prod {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  margin: 0 -1px -1px 0; transition: background 0.12s; cursor: pointer; min-width: 0;
}
.prod:hover { background: var(--surface-2); }
.prod.off .nm { color: var(--muted); }
.prod .nm { font-weight: 600; font-size: 13.5px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.prod .meta { color: var(--faint); font-size: 12px; margin-top: 2px; }

/* ── Chat preview (WhatsApp-like) ────────────────────────────────────────────────────────── */
.phone {
  border-radius: 28px; padding: 10px; background: linear-gradient(160deg, #23262f, #0f1116); border: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg);
}
:root[data-theme="light"] .phone { background: linear-gradient(160deg, #2b2f3a, #14161c); }
.phone-screen { border-radius: 20px; overflow: hidden; background: var(--wa-bg); display: flex; flex-direction: column; min-height: 440px; }
.phone-top { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: color-mix(in srgb, var(--wa-in) 85%, black 0%); color: var(--wa-ink); }
:root[data-theme="light"] .phone-top { background: #008069; color: #fff; }
.phone-top .av { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; }
.phone-top b { font-size: 14px; display: block; }
.phone-top span { font-size: 11.5px; opacity: 0.75; display: block; }
.chat {
  flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  background-image: radial-gradient(color-mix(in srgb, var(--wa-meta) 18%, transparent) 1px, transparent 1px); background-size: 18px 18px;
}
.bubble {
  position: relative; max-width: 86%; min-width: 92px; padding: 7px 10px 18px; border-radius: 10px 2px 10px 10px; background: #005c4b; color: #e9edef;
  font: 14px/1.42 var(--font); white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
  animation: pop 0.28s var(--ease);
}
:root[data-theme="light"] .bubble { background: #d9fdd3; color: #111b21; }
.bubble .time { position: absolute; right: 8px; bottom: 3px; font-size: 10.5px; opacity: 0.65; display: flex; gap: 3px; align-items: center; }
.bubble .time svg { width: 14px; height: 14px; color: #53bdeb; }
.typing { align-self: flex-end; display: flex; align-items: center; gap: 8px; color: var(--wa-meta); font-size: 11.5px; }
.typing .dots { display: inline-flex; gap: 3px; padding: 9px 11px; border-radius: 10px; background: #005c4b; }
:root[data-theme="light"] .typing .dots { background: #d9fdd3; }
.typing .dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; }
.typing .dots i:nth-child(2) { animation-delay: 0.15s; }
.typing .dots i:nth-child(3) { animation-delay: 0.3s; }
.chat .empty { align-self: center; margin: auto; color: var(--wa-meta); font-size: 13px; }
.msg-block {
  white-space: pre-wrap; font: 12.5px/1.5 var(--mono); background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px;
}

/* ── Drawer, modal, palette, toasts ──────────────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(4, 6, 10, 0.55); backdrop-filter: blur(3px); animation: fadein 0.18s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61; width: min(620px, 100vw); display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); animation: slidein 0.26s var(--ease);
}
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { font-size: 15.5px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; word-break: break-word; }
.section-title { font: 650 11px/1 var(--font); text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }
.trace { list-style: none; margin: 0; padding: 0; font: 12px/1.55 var(--mono); border-left: 2px solid var(--line-2); }
.trace li { position: relative; padding: 3px 0 3px 16px; color: var(--ink-2); word-break: break-word; }
.trace li::before { content: ""; position: absolute; left: -5px; top: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-2); }
.trace li.sub { color: var(--faint); padding-left: 28px; }
.trace li.sub::before { display: none; }
.trace li.bad { color: var(--danger); }
.trace li.web::before { border-color: var(--info); }
.trace li.pl::before { border-color: var(--accent); }

.modal-wrap { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.palette {
  width: min(640px, calc(100vw - 32px)); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-lg); overflow: hidden;
  animation: pop 0.18s var(--ease);
}
.palette-in { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette-in svg { width: 18px; height: 18px; color: var(--muted); }
.palette-in input { flex: 1; height: 54px; border: 0; background: transparent; color: var(--ink); font: 16px var(--font); outline: none; }
.palette-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette-group { padding: 10px 10px 4px; font: 650 10.5px/1 var(--font); text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.palette-item svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.palette-item .t { font-weight: 550; }
.palette-item .d { color: var(--faint); font-size: 12px; }
.palette-item .where { margin-left: auto; color: var(--faint); font-size: 11.5px; white-space: nowrap; }
.palette-item[aria-selected="true"] { background: var(--accent-soft); }
.palette-item[aria-selected="true"] svg { color: var(--accent); }
.palette-item mark { background: none; color: var(--accent); font-weight: 700; }
.palette-foot { display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11.5px; }
.palette-foot span { display: inline-flex; gap: 5px; align-items: center; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  display: flex; align-items: center; gap: 12px; min-width: 260px; max-width: 440px; padding: 11px 12px 11px 14px; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg); font-size: 13px; animation: toastin 0.3s var(--ease);
  position: relative; overflow: hidden;
}
.toast.out { animation: toastout 0.25s var(--ease) forwards; }
.toast .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--ok-soft); color: var(--ok); }
.toast.err .ic { background: var(--danger-soft); color: var(--danger); }
.toast.warn .ic { background: var(--warn-soft); color: var(--warn); }
.toast .ic svg { width: 13px; height: 13px; }
.toast .msg { flex: 1; }
.toast .bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--accent); animation: shrink linear forwards; }

/* ── Misc ────────────────────────────────────────────────────────────────────────────────── */
.empty-state { padding: 46px 20px; text-align: center; color: var(--muted); }
.empty-state > svg { width: 36px; height: 36px; color: var(--faint); margin-bottom: 10px; }
.empty-state b { display: block; color: var(--ink); font-size: 14.5px; margin-bottom: 4px; }
.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--info-soft); color: var(--ink-2); font-size: 13px; border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.callout.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.callout.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.callout svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.callout.warn svg { color: var(--warn); } .callout.danger svg { color: var(--danger); } .callout svg { color: var(--info); } .callout.ok svg { color: var(--ok); }
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.bar-viz { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; min-width: 80px; }
.bar-viz i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.qr { display: grid; place-items: center; padding: 14px; border-radius: 14px; background: #fff; width: 240px; height: 240px; }
.qr img { width: 100%; height: 100%; image-rendering: pixelated; }
.breakdown { display: flex; flex-direction: column; gap: 0; }
.breakdown .step { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.breakdown .step:last-child { border-bottom: 0; }
.breakdown .step .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 700; flex: none; }
.breakdown .step .v { margin-left: auto; font-weight: 650; font-family: var(--mono); font-size: 13px; }
.big-price { font-size: 40px; font-weight: 720; letter-spacing: -0.04em; line-height: 1; }
.big-price small { font-size: 15px; color: var(--muted); font-weight: 550; letter-spacing: 0; margin-left: 6px; }
.slider { width: 100%; accent-color: var(--accent); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; }
.tabs button { height: 42px; padding: 0 12px; border: 0; background: none; color: var(--muted); font: 550 13px var(--font); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.editor { width: 100%; min-height: 460px; border: 0; border-radius: 0 0 var(--r) var(--r); background: var(--bg-2); color: var(--ink); font: 12.5px/1.6 var(--mono); padding: 16px 18px; resize: vertical; outline: none; tab-size: 2; }
.feed-item { display: flex; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); cursor: pointer; transition: background 0.12s; align-items: flex-start; }
.feed-item:first-child { border-top: 0; }
.feed-item:hover { background: var(--surface-2); }
.feed-item.new { animation: rowin 1.6s var(--ease); }
.feed-item .when { color: var(--faint); font-size: 12px; white-space: nowrap; min-width: 64px; }
.kbd-hint { display: inline-flex; gap: 4px; align-items: center; color: var(--faint); font-size: 12px; }
.progress { height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; position: relative; }
.progress::after { content: ""; position: absolute; inset: 0; width: 40%; background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: indet 1.1s ease-in-out infinite; }

/* ── Login ───────────────────────────────────────────────────────────────────────────────── */
.login-body {
  display: grid; place-items: center; min-height: 100vh;
  background:
    radial-gradient(800px 400px at 20% 0%, var(--accent-soft), transparent 70%),
    radial-gradient(700px 400px at 90% 100%, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent 70%),
    var(--bg);
}
.login {
  width: min(380px, calc(100vw - 32px)); padding: 34px 30px 26px; border-radius: 20px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); animation: pop 0.35s var(--ease);
}
.login-mark { display: grid; place-items: center; margin-bottom: 14px; }
.login-mark img { border-radius: 12px; box-shadow: 0 10px 30px -8px var(--accent); }
.login h1 { font-size: 21px; }
.login p { margin-top: 4px; }
.login-form { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.login-form input {
  height: 44px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--ink);
  text-align: center; font: 15px var(--font); letter-spacing: 0.08em;
}
.login-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-err { color: var(--danger); font-size: 13px; min-height: 20px; margin-top: 12px; }

/* ── Motion ──────────────────────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastin { from { transform: translateY(12px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastout { to { transform: translateX(20px); opacity: 0; } }
@keyframes shrink { from { width: 100%; } to { width: 0; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes pulse { 50% { opacity: 0.45; } }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@keyframes rowin { from { background: var(--accent-soft); } to { background: transparent; } }
@keyframes slide { to { background-position: -200% 0; } }
@keyframes indet { from { left: -40%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ── Responsive ──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid.side, .grid.side-l { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: 62px; z-index: 40; flex-direction: row; padding: 6px 8px;
    border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; gap: 2px;
  }
  .brand, .nav-label, .sidebar-foot { display: none; }
  .nav { display: contents; }
  .nav a { flex-direction: column; height: 50px; min-width: 64px; padding: 6px 4px; gap: 3px; font-size: 10.5px; justify-content: center; }
  .nav a[aria-current="page"]::before { display: none; }
  .nav a .badge { display: none; }
  .topbar { padding: 0 14px; }
  .search-btn { width: auto; }
  .search-btn .lbl, .search-btn kbd, .topbar .crumb { display: none; }
  .content { padding: 18px 14px 100px; }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }
  .field { grid-template-columns: 1fr; gap: 10px; }
  .field .control.inline { justify-content: flex-start; }
  .page-head h2 { font-size: 20px; }
  .toasts { left: 12px; right: 12px; bottom: 74px; align-items: stretch; }
}
