/* ═══ Stratagile Avatar Platform — design system ═════════════════════
   One accent (Stratagile red) on a neutral slate ground. Red is reserved
   for what the eye should go to — primary actions, the active page,
   focus — so it keeps meaning something. Everything else is ink, grey
   and white, with depth from soft shadows rather than heavy borders. */

:root {
  --brand: #dc2626;
  /* Derived from --brand, so a client's brand colour (set on a widget)
     recolours hovers, tints and focus rings too. */
  --brand-hover: color-mix(in srgb, var(--brand) 84%, black);
  --brand-tint: color-mix(in srgb, var(--brand) 6%, white);
  --brand-ring: color-mix(in srgb, var(--brand) 18%, transparent);
  --brand-light: color-mix(in srgb, var(--brand) 78%, white);
  --brand-border: color-mix(in srgb, var(--brand) 22%, white);
  --brand-grad: linear-gradient(145deg, color-mix(in srgb, var(--brand) 80%, white), var(--brand-hover));
  /* On a dark background (sign-in page): a lighter shade of the brand */
  --brand-on-dark: color-mix(in srgb, var(--brand) 72%, white);
  /* Text on a brand background, and the brand colour as text on white.
     Same as the defaults for a strong colour like red; brandColor.js picks
     dark text and a darker shade when the brand colour is light. */
  --on-brand: #fff;
  --brand-text: var(--brand);
  /* Kept as aliases: JS-built markup and older rules still refer to them. */
  --accent: var(--brand);
  --accent-dark: var(--brand-hover);

  --ink: #0f172a;
  --text: #1e293b;
  --text-2: #334155;
  --muted: #64748b;
  --subtle: #94a3b8;

  --bg: #f4f6f9;
  --card: #ffffff;
  --surface: #f8fafc;
  --border: #e5e8ee;
  --border-strong: #d4d9e1;

  --green: #15803d;
  --red: #b91c1c;

  --side-bg: #0c0f16;
  --side-text: #a3aab8;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px -6px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 48px -16px rgba(15, 23, 42, 0.25);
  --font: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Chart roles. On :root so every chart finds them — scoped to a view id
     once, a rename left them unresolved and every bar rendered black. */
  --series-answered: #2e74b5;
  --series-unanswered: #d03b3b;
  --chart-grid: #edf0f5;
  --chart-axis: #94a3b8;
}

*, *::before, *::after { box-sizing: border-box; }
/* `hidden` must always win. Any rule that sets `display` (every button
   here is inline-flex) otherwise beats the browser's own [hidden] rule and
   the element shows anyway — the bug behind the stray avatar bar and the
   empty filter chip. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--brand-ring); }

/* ── Type ─────────────────────────────────────────────────────────── */
h1, h2, h3 { color: var(--ink); letter-spacing: -0.015em; }
.muted { color: var(--muted); font-size: 13px; }
.brand-strat { color: inherit; }
.brand-agile { color: var(--brand-text); }

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; font-weight: 650; }
/* A card's headings are its section titles; a later one starts a new
   section, so it gets a hairline above it instead of a separate card. */
.card h3 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
}
.card > label:first-child { margin-top: 0; }
.card h3:not(:first-child) {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

/* ── Form controls ────────────────────────────────────────────────── */
label {
  display: block;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-2);
  margin: 16px 0 6px;
}
input[type="text"], input[type="password"], input[type="email"], input[type="search"],
input[type="number"], input[type="url"], textarea, select {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  min-height: 40px;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath d='M5.2 7.6a.75.75 0 0 1 1.06 0L10 11.34l3.74-3.74a.75.75 0 1 1 1.06 1.06l-4.27 4.27a.75.75 0 0 1-1.06 0L5.2 8.66a.75.75 0 0 1 0-1.06Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  cursor: pointer;
}
input::placeholder, textarea::placeholder { color: var(--subtle); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-ring);
}
input:disabled, textarea:disabled, select:disabled { background: var(--surface); color: var(--muted); cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); width: 16px; height: 16px; }
input[type="file"] {
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  padding: 5px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-width: 0;
}
input[type="file"]::file-selector-button {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px 12px;
  margin-right: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
}
input[type="file"]::file-selector-button:hover { background: var(--surface); }

/* ── Buttons ──────────────────────────────────────────────────────── */
button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--on-brand);
  background: var(--brand);
  box-shadow: 0 1px 2px rgba(185, 28, 28, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
  white-space: nowrap;
}
button:hover:not(:disabled) { background: var(--brand-hover); }
button:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--brand-ring); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  color: var(--ink);
  background: #fff;
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
button.secondary:hover:not(:disabled) { background: var(--surface); border-color: #c3cad5; }

button.danger {
  color: var(--red);
  background: #fff;
  border-color: #f3c4c4;
  box-shadow: var(--shadow-xs);
}
button.danger:hover:not(:disabled) { background: var(--brand-tint); border-color: #eea5a5; }

button.small { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
button.linkish {
  color: var(--text-2);
  background: transparent;
  border-color: var(--border-strong);
  box-shadow: none;
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}
button.linkish:hover:not(:disabled) { background: var(--surface); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── Pills ────────────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 550;
  line-height: 1;
  color: var(--text-2);
  background: #f1f4f8;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
.pill.spec   { color: var(--brand-text); background: var(--brand-tint); border-color: var(--brand-border); }
.pill.warn   { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.pill.owner  { color: #6d28d9; background: #f5f3ff; border-color: #ddd6fe; }
.pill.admin  { color: var(--brand-text); background: var(--brand-tint); border-color: var(--brand-border); }
.pill.viewer { color: var(--muted); background: #f1f4f8; }
.pill.you    { color: #fff; background: var(--green); border-color: var(--green); }
.pill.public { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
.pill.locked { color: #92400e; background: #fffbeb; border-color: #fde68a; }
.form-note.ok  { color: var(--green); }
.form-note.bad { color: var(--red); }

/* ── Toast ────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 12px;
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  background: var(--ink);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e; flex: none;
}
.toast.show { opacity: 1; transform: none; }

/* ═══ Console shell ══════════════════════════════════════════════════ */
body.app { background: var(--bg); }
.shell { min-height: 100dvh; display: flex; flex-direction: column; }

.side-mark {
  width: 34px; height: 34px; flex: none;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--brand-grad);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--brand) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  color: var(--on-brand);
}
.side-mark svg { width: 19px; height: 19px; }
.side-name { font-size: 17px; font-weight: 750; color: var(--ink); letter-spacing: -0.02em; line-height: 1.15; }
.side-product { font-size: 11.5px; color: var(--muted); letter-spacing: 0.02em; }

/* Top bar: brand, the menus, the account */
header.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topnav-row {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 64px;
  padding: 0 24px;
}
.top-brand { display: flex; align-items: center; gap: 10px; flex: none; text-decoration: none; }
.top-brand:hover { text-decoration: none; }

.topnav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }
.tn-link, .tn-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 38px;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  color: #475569;
  font: 600 14px var(--font);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tn-link:hover, .tn-btn:hover:not(:disabled) { background: #f1f4f8; color: var(--ink); text-decoration: none; }
.tn-link.active, .tn-group.active > .tn-btn { background: var(--brand-tint); color: var(--brand-text); }
.tn-link:focus-visible, .tn-btn:focus-visible { outline: 2px solid var(--brand-ring); outline-offset: 1px; }
.tn-link.disabled { opacity: 0.4; pointer-events: none; }
.tn-chev { width: 14px; height: 14px; transition: transform 0.15s; }
.tn-group.open > .tn-btn .tn-chev { transform: rotate(180deg); }

/* A red dot on a menu when something inside it is waiting */
.tn-group:has(.nav-badge:not([hidden])) > .tn-btn::after {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand); animation: hf-pulse 1.6s infinite;
}

.tn-group { position: relative; }
.tn-group[hidden] { display: none; }
.tn-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  min-width: 232px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 44px -12px rgba(15, 23, 42, 0.22);
}
/* The gap between button and panel still counts as the menu, so hover holds */
.tn-menu::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; }
.tn-group.open > .tn-menu { display: block; }
@media (hover: hover) and (min-width: 961px) {
  .topnav .tn-group:hover:not(.hush) > .tn-menu { display: block; }
}

.tn-menu .nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  color: #334155;
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-item .nav-ico { width: 18px; height: 18px; flex: none; color: var(--subtle); transition: color 0.15s; }
.tn-menu .nav-item:hover { background: var(--brand-tint); color: var(--brand-text); text-decoration: none; }
.tn-menu .nav-item:hover .nav-ico, .tn-menu .nav-item.active .nav-ico { color: var(--brand-text); }
.tn-menu .nav-item.active { color: var(--brand-text); font-weight: 650; background: var(--brand-tint); }
.nav-item[hidden] { display: none; }
.nav-item.disabled { opacity: 0.4; pointer-events: none; }
.nav-item:focus-visible { outline: 2px solid var(--brand-ring); outline-offset: -2px; }

/* Account, top right */
.top-right { display: flex; align-items: center; gap: 8px; flex: none; margin-left: auto; }
.user-btn { padding: 0 4px; }
.user-btn:hover:not(:disabled) { background: transparent; }
.user-menu .tn-menu { left: auto; right: 0; min-width: 280px; padding: 10px; }
.user-head { display: flex; align-items: center; gap: 12px; padding: 6px 6px 12px; }
.user-head .who { font-weight: 650; color: var(--ink); font-size: 13.5px; word-break: break-all; }
.user-head .org { color: var(--muted); font-size: 12.5px; }
.user-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 6px 10px; margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.user-meta .mode {
  font-size: 11.5px; color: var(--muted);
  background: #f1f4f8; border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 10px;
}
.user-meta .pill.role {
  color: var(--brand-text); background: var(--brand-tint); border-color: var(--brand-border);
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 10px; font-weight: 700;
}
.menu-action {
  display: block; width: 100%; min-height: 0;
  padding: 9px 12px; border: 0; border-radius: 10px;
  background: transparent; box-shadow: none;
  color: #334155; font: 550 14px var(--font); text-align: left;
}
.menu-action:hover:not(:disabled) { background: var(--brand-tint); color: var(--brand-text); }
.identity-avatar {
  width: 36px; height: 36px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700; color: var(--on-brand);
  background: var(--brand-grad);
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--border);
}

.nav-toggle {
  display: none;
  min-height: 38px;
  width: 38px;
  padding: 0;
  font-size: 18px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.nav-toggle:hover:not(:disabled) { background: var(--surface); }

/* Which training the screens are about — a slim strip under the menus */
.agent-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.agent-bar[hidden] { display: none; }
.agent-bar label {
  margin: 0;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.agent-bar select { width: auto; min-width: 220px; max-width: 420px; min-height: 36px; font-weight: 550; background-color: #fff; }
.agent-bar button { flex: none; }

/* ── Home: one box per area ─────────────────────────────────────── */
.home { max-width: 1120px; margin: 0 auto; padding-top: 18px; }
.home-eyebrow {
  font-size: 12px; font-weight: 800; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--brand-text); margin-bottom: 8px;
}
.home-title { margin: 0 0 6px; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.home .view-sub { margin-bottom: 30px; }
.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.module-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.2s, transform 0.2s;
}
.module-card:hover { box-shadow: 0 14px 32px -10px rgba(15, 23, 42, 0.16); transform: translateY(-2px); }
.module-top { height: 112px; display: flex; align-items: center; padding: 0 24px; }
.module-ico {
  width: 58px; height: 58px; border-radius: 16px;
  display: grid; place-items: center;
  background: #fff; box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1);
}
.module-ico svg { width: 26px; height: 26px; }
.tone-purple { background: #f1edff; color: #6d4aff; }
.tone-blue   { background: #e8f0fe; color: #2563eb; }
.tone-red    { background: color-mix(in srgb, var(--brand) 10%, white); color: var(--brand-text); }
.tone-orange { background: #fff1e3; color: #ea580c; }
.tone-slate  { background: #eef1f6; color: #475569; }
.tone-green  { background: #e3f6ec; color: #059669; }
.module-body { padding: 20px 24px 24px; }
.module-title { font-size: 18px; font-weight: 800; color: var(--ink); margin-bottom: 4px; }
.module-sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; min-height: 18px; }
.module-btn {
  display: inline-flex; align-items: center;
  height: 38px; padding: 0 20px; border-radius: 10px;
  background: var(--brand); color: var(--on-brand);
  font-size: 13.5px; font-weight: 700; text-decoration: none;
  box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--brand) 60%, transparent);
  transition: background 0.15s;
}
.module-btn:hover { background: var(--brand-hover); color: var(--on-brand); text-decoration: none; }
.module-btn.disabled { background: #e2e8f0; color: var(--muted); box-shadow: none; cursor: not-allowed; }
@media (max-width: 960px) { .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .module-grid { grid-template-columns: 1fr; gap: 16px; }
  .home-title { font-size: 24px; }
  .module-top { height: 88px; }
}

.main {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px 32px 64px;
  min-width: 0;
}

/* Page header */
.view-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.view-head h2 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.025em; }
.view-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.view { animation: view-in 0.25s ease-out; }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Lists ────────────────────────────────────────────────────────── */
.bot-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  margin: 0 -10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.bot-item + .bot-item { margin-top: 2px; }
.bot-item:hover { background: var(--surface); }
.bot-item.active { background: var(--brand-tint); border-color: var(--brand-border); }
.bot-avatar {
  width: 42px; height: 42px; flex: none;
  border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: #fff;
  background: linear-gradient(145deg, #334155, #0f172a);
}
.bot-item.active .bot-avatar { background: var(--brand-grad); color: var(--on-brand); }
.bot-body { flex: 1; min-width: 0; }
.bot-name { font-weight: 600; color: var(--ink); font-size: 14.5px; }
.bot-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-chev { color: var(--subtle); flex: none; }
.bot-item:hover .bot-chev { color: var(--muted); }

.doc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.doc-item:last-child { border-bottom: none; }
.doc-item > span { min-width: 0; }
.doc-item > .doc-actions { display: flex; gap: 6px; flex-shrink: 0; }
.scroll-list { max-height: 380px; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }

.spec-item, .org-item, .user-item, .deck-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.spec-item:hover, .org-item:hover, .user-item:hover, .deck-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
@media (min-width: 1180px) {
  #spec-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  #spec-list > .spec-item { margin-bottom: 0; }
  #spec-list > .muted, #spec-list > .list-empty { grid-column: 1 / -1; }
}
.spec-item .spec-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.spec-item .spec-name { font-weight: 650; font-size: 14.5px; color: var(--ink); }
.spec-item .spec-desc {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.org-item .row, .user-item .row { justify-content: space-between; gap: 8px; }
.org-item .name, .user-item .email { font-weight: 650; font-size: 14.5px; color: var(--ink); }
.org-item .meta, .user-item .meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.deck-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.deck-item.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.deck-item .name { font-weight: 650; color: var(--ink); }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab {
  padding: 7px 12px; border-radius: 8px; font-size: 13px; cursor: pointer;
  background: #f1f4f8; color: var(--muted); border: 1px solid transparent;
}
.tab.active { background: #fff; color: var(--brand-text); border-color: var(--brand); font-weight: 600; }

/* Empty states */
.empty-state { text-align: center; padding: 56px 24px; }
.empty-state h3 { margin: 14px 0 6px; font-size: 17px; }
.empty-state h3:not(:first-child) { border-top: none; padding-top: 0; }
.empty-state .muted { font-size: 14px; }
.empty-ico {
  width: 56px; height: 56px; margin: 0 auto;
  border-radius: 16px;
  display: grid; place-items: center;
  color: var(--brand-text);
  background: var(--brand-tint);
}
.empty-ico svg { width: 26px; height: 26px; }
.list-empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  font-size: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
}

/* ── Stats ────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}
.stat:hover { box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 24px -10px rgba(15, 23, 42, 0.16); transform: translateY(-1px); }
.stat .stat-top { display: flex; align-items: center; gap: 10px; }
.stat-icon {
  width: 38px; height: 38px; flex: none;
  border-radius: 11px;
  display: grid; place-items: center;
}
.stat-icon svg { width: 18px; height: 18px; }
/* Decorative only: every tile keeps its text label. */
.stat-icon.purple { background: #f3f0ff; color: #6d4aff; }
.stat-icon.blue   { background: #eff6ff; color: #2563eb; }
.stat-icon.green  { background: #ecfdf5; color: #059669; }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }
.stat-icon.red    { background: var(--brand-tint); color: var(--brand-text); }
.stat .lbl {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat .num {
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Dashboard tiles stand on the page, not inside another card, and sit as
   an even 4-across grid — two rows of four, never six and two. */
.card:has(> #dash-tiles) { background: none; border: none; box-shadow: none; padding: 0; }
#dash-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 980px) { #dash-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ── Charts ───────────────────────────────────────────────────────── */
.chart-wrap { overflow-x: auto; }
.chart-wrap svg { display: block; }
.chart-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.chart-pair .card { margin-bottom: 0; }
/* Grid items never shrink below their content by default; a wide table
   would push the page sideways. Its own wrapper scrolls instead. */
.chart-pair > * { min-width: 0; }
@media (max-width: 820px) { .chart-pair { grid-template-columns: 1fr; } }
.chart-legend {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--muted); margin-bottom: 8px;
}
.chart-legend span.key { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-empty {
  color: var(--muted); font-size: 13.5px; padding: 28px 0; text-align: center;
}
.hbar { margin-bottom: 12px; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 5px; color: var(--text-2); }
.hbar-top .n { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.hbar-track { background: #eef1f6; border-radius: 999px; height: 8px; overflow: hidden; }
.hbar-fill { background: var(--series-answered); height: 100%; border-radius: 999px; }
.chart-tip {
  position: fixed; z-index: 200; pointer-events: none; white-space: nowrap;
  font-size: 12px; color: #fff; background: var(--ink);
  padding: 7px 10px; border-radius: 8px; box-shadow: var(--shadow-lg);
}
.chart-tip b { font-variant-numeric: tabular-nums; }

.q-item {
  display: flex; gap: 12px; align-items: baseline;
  padding: 11px 4px; border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.q-item:last-child { border-bottom: none; }
.q-item .q-text { flex: 1; min-width: 0; color: var(--text); }
.q-item .q-meta { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.q-item .pill.times { color: var(--red); background: var(--brand-tint); border-color: var(--brand-border); font-weight: 650; }

/* ── Embed code ───────────────────────────────────────────────────── */
.embed-code {
  position: relative;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  color: #e2e8f0;
  background: linear-gradient(180deg, #111827, #0b1220);
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 18px 20px;
  white-space: pre-wrap;
  word-break: break-all;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* ── Appearance: avatar picker ────────────────────────────────────── */
.avatar-chosen {
  display: flex; align-items: center; gap: 16px;
  padding: 14px; margin-bottom: 6px;
  border: 1px solid var(--border); border-radius: 14px;
  background: linear-gradient(180deg, #fff, var(--surface));
}
.avatar-chosen img {
  width: 72px; height: 72px; flex: none;
  border-radius: 14px; object-fit: cover;
  background: #e8edf5; box-shadow: var(--shadow);
}
.avatar-chosen img:not([src]), .avatar-chosen img[src=""] { visibility: hidden; }
.avatar-chosen > div { flex: 1; min-width: 0; }
.avatar-chosen-name { font-weight: 650; font-size: 15px; color: var(--ink); }
.avatar-picker {
  border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; margin: 10px 0 4px; background: var(--surface);
}
.avatar-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 12px; max-height: 380px; overflow-y: auto; padding: 4px;
}
.avatar-card {
  position: relative; display: block; width: 100%; min-height: 0;
  padding: 0; overflow: hidden; text-align: left; line-height: normal;
  color: var(--ink); background: #fff;
  border: 2px solid transparent; border-radius: 12px;
  box-shadow: var(--shadow); cursor: pointer;
}
.avatar-card:hover:not(:disabled) { background: #fff; border-color: #fca5a5; }
.avatar-card img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; background: #dde5f0; }
.avatar-card .cap {
  display: block; padding: 7px 9px; font-size: 12px; font-weight: 550;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.avatar-card.selected { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
.avatar-card.selected .cap { background: var(--brand); color: var(--on-brand); }
.avatar-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.avatar-badge {
  position: absolute; top: 7px; left: 7px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--on-brand); background: var(--brand); padding: 3px 7px; border-radius: 6px;
}
details.advanced { margin-top: 18px; }
details.advanced summary { cursor: pointer; font-size: 13px; font-weight: 550; color: var(--muted); padding: 4px 0; }
details.advanced summary:hover { color: var(--brand-text); }
.voice-row { flex-wrap: nowrap; align-items: center; }
.voice-row select { flex: 1; min-width: 0; margin: 0; }
.voice-row button { flex: none; }
.voice-note { margin: 8px 0 0; font-size: 12.5px; }

/* ── Knowledge base: upload progress ──────────────────────────────── */
.media-progress { margin: 6px 0 14px; }
.media-bar { height: 6px; background: #eef1f6; border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.media-bar > div { height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width 0.3s; }
.media-bar.working > div { width: 100% !important; animation: media-pulse 1.4s ease-in-out infinite; }
@keyframes media-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ── Presentations (console) ──────────────────────────────────────── */
.deck-editor-head { align-items: flex-start; margin-bottom: 8px; }
.slide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; margin-top: 14px; }
.slide-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px; background: #fff;
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.slide-card.skipped { opacity: 0.5; }
.slide-card.working { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
.slide-thumb {
  aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #eef1f6; border: 1px solid var(--border);
}
.slide-thumb canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.slide-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.slide-meta button { min-height: 28px; padding: 0 10px; font-size: 12px; }
.slide-badge {
  margin-right: auto; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--brand-text); background: var(--brand-tint); padding: 4px 9px; border-radius: 999px;
}
.slide-label { margin: 2px 0 0; font-size: 12px; }
.slide-narration { font-size: 13px; line-height: 1.5; min-height: 100px; }
.slide-saved { font-size: 11.5px; min-height: 14px; color: var(--green); }

/* ── Conversations: insights ──────────────────────────────────────── */
.insight-grid { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 20px; margin-bottom: 20px; }
.insight-grid .card { margin-bottom: 0; min-width: 0; }
@media (max-width: 1180px) { .insight-grid { grid-template-columns: 1fr 1fr; } .insight-grid .card:last-child { grid-column: 1 / -1; } }
@media (max-width: 760px) { .insight-grid { grid-template-columns: 1fr; } }
.scroll-list.short { max-height: 250px; }

.mood-bar { display: flex; gap: 3px; height: 14px; border-radius: 999px; overflow: hidden; margin: 6px 0 14px; }
.mood-seg.positive { background: #16a34a; }
.mood-seg.neutral  { background: #94a3b8; }
.mood-seg.negative { background: #dc2626; }
.mood-legend { display: grid; gap: 6px; }
.mood-key {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  min-height: 38px; padding: 0 12px; border-radius: 10px; font-weight: 500;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); box-shadow: none;
}
.mood-key:hover:not(:disabled) { background: #fff; border-color: var(--border-strong); }
.mood-key b { font-variant-numeric: tabular-nums; }
.mood-key.positive b { color: #15803d; }
.mood-key.negative b { color: var(--red); }

.topic-row {
  display: block; width: 100%; min-height: 0; padding: 6px 8px; margin: 0 -8px 4px;
  width: calc(100% + 16px); text-align: left; font-weight: 500; line-height: 1.3;
  color: var(--text); background: transparent; border: none; box-shadow: none; border-radius: 8px;
}
.topic-row:hover:not(:disabled) { background: var(--surface); }
.topic-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.topic-top .n { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.topic-row .hbar-track, .topic-row .hbar-fill { display: block; }

.conv-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.conv-filters input[type="search"] { width: 260px; }
.conv-row {
  display: flex; align-items: flex-start; gap: 14px; width: 100%; min-height: 0;
  padding: 14px 12px; margin: 0; text-align: left; line-height: 1.4; white-space: normal;
  color: var(--text); background: #fff; border: none; border-bottom: 1px solid var(--border);
  border-radius: 0; box-shadow: none; font-weight: 400;
}
.conv-row:hover:not(:disabled) { background: var(--surface); }
.conv-row:last-child { border-bottom: none; }
.conv-mood {
  width: 36px; height: 36px; flex: none; border-radius: 10px;
  display: grid; place-items: center; font-size: 18px; background: #f1f4f8;
}
.conv-mood.positive { background: #ecfdf5; }
.conv-mood.negative { background: var(--brand-tint); }
.conv-mood.pending { color: var(--subtle); font-size: 14px; }
.conv-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.conv-title { font-size: 14px; font-weight: 550; color: var(--ink); }
.conv-meta { font-size: 12.5px; color: var(--muted); }
.conv-miss { color: var(--red); font-weight: 600; }
.conv-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.conv-row .bot-chev { margin-top: 9px; }
.conv-pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }

/* Side panel for one conversation */
.drawer { position: fixed; inset: 0; z-index: 120; }
.drawer[hidden] { display: none; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); animation: fade-in 0.2s; }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  display: flex; flex-direction: column; background: #fff;
  box-shadow: -24px 0 48px -16px rgba(15, 23, 42, 0.35); animation: slide-in 0.25s ease-out;
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.drawer-insight { padding: 0 22px; }
.di-summary { display: flex; gap: 12px; padding: 16px; margin: 16px 0 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.di-summary p { margin: 2px 0 8px; font-size: 14px; }
.di-label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 22px 28px; background: #fbfcfd; }
.tmsg { max-width: 88%; margin-bottom: 14px; }
.tmsg.visitor { margin-left: auto; }
.tmsg-who { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tmsg.visitor .tmsg-who { justify-content: flex-end; }
.tmsg-text { padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.tmsg.avatar .tmsg-text { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.tmsg.visitor .tmsg-text { background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.tmsg.missed .tmsg-text { border-color: #fde68a; background: #fffbeb; }
.tmsg-src { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ── Integrations ─────────────────────────────────────────────────── */
.check-list { display: grid; gap: 8px; }
.check-card {
  display: flex; gap: 12px; align-items: flex-start; margin: 0; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 12px; font-weight: 400; background: #fff;
}
.check-card:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); }
.check-card input { margin-top: 2px; flex: none; }
.check-card b { display: block; color: var(--ink); font-size: 14px; font-weight: 600; }
.check-card .muted { display: block; margin-top: 2px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); margin-top: 16px; cursor: pointer; }
.hook-item { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.hook-item.paused { opacity: 0.65; }
.hook-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.hook-url { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; font-size: 13px; color: var(--ink); word-break: break-all; }
.hook-events { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.hook-error { font-size: 12.5px; color: var(--red); margin-bottom: 8px; }
.hook-secret { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; margin-bottom: 10px; }
.secret-value { font-size: 12.5px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; word-break: break-all; }
.hook-actions { gap: 8px; }
code { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; font-size: 0.92em; }
pre.embed-code { margin: 0; max-height: 360px; overflow: auto; white-space: pre; word-break: normal; }

/* ── Brand kit ────────────────────────────────────────────────────── */
.brand-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
@media (max-width: 980px) { .brand-grid { grid-template-columns: 1fr; } }
input[type="color"] {
  width: 44px; height: 40px; padding: 3px; border: 1px solid var(--border-strong);
  border-radius: 10px; background: #fff; cursor: pointer;
}
.brand-logo-box {
  width: 48px; height: 48px; flex: none; border-radius: 12px; overflow: hidden;
  display: grid; place-items: center; font-weight: 700; color: #fff;
  background: linear-gradient(145deg, #334155, #0f172a);
}
.brand-logo-box.has-logo, .bp-avatar.has-logo { background: #fff; border: 1px solid var(--border); }
.brand-logo-box img, .bp-avatar img { width: 100%; height: 100%; object-fit: contain; }

/* A miniature of the visitor widget, recoloured live as the colour changes */
.brand-preview {
  --brand-hover: color-mix(in srgb, var(--brand) 82%, black);
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  background: #f6f7f9; box-shadow: var(--shadow); font-size: 13px;
}
.bp-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #fff; border-bottom: 1px solid var(--border); }
.bp-avatar {
  width: 34px; height: 34px; border-radius: 50%; overflow: hidden; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--on-brand);
  background: linear-gradient(145deg, color-mix(in srgb, var(--brand) 78%, white), var(--brand-hover));
}
.bp-name { font-weight: 650; color: var(--ink); }
.bp-status { font-size: 11px; color: #16a34a; }
.bp-body { padding: 14px; display: grid; gap: 8px; }
.bp-msg { max-width: 85%; padding: 8px 11px; border-radius: 12px; line-height: 1.4; }
.bp-msg.bot { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bp-msg.user {
  margin-left: auto; color: var(--on-brand); border-bottom-right-radius: 4px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--brand) 85%, white), var(--brand-hover));
}
.bp-composer {
  display: flex; justify-content: space-between; align-items: center; margin: 0 10px 8px;
  padding: 6px 6px 6px 14px; background: #fff; border: 1px solid var(--border-strong); border-radius: 999px; color: var(--subtle);
}
.bp-send { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--on-brand); background: var(--brand); }
.bp-foot { text-align: center; font-size: 10.5px; color: var(--subtle); padding-bottom: 8px; }
.bp-foot[hidden] { display: none; }

/* ── Training (console) ───────────────────────────────────────────── */
.scn-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 18px; align-items: center;
  padding: 16px 18px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 14px; background: #fff;
}
.scn-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.scn-name { font-size: 15px; font-weight: 650; color: var(--ink); }
.scn-brief { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.scn-meta { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.scn-score {
  grid-row: span 2; display: grid; place-items: center; min-width: 76px; padding: 8px 10px;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
}
.scn-score b { font-size: 24px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1; }
.scn-score span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.scn-score.great { background: #ecfdf5; border-color: #a7f3d0; } .scn-score.great b { color: #15803d; }
.scn-score.ok { background: #fffbeb; border-color: #fde68a; } .scn-score.ok b { color: #b45309; }
.scn-score.low { background: var(--brand-tint); border-color: var(--brand-border); } .scn-score.low b { color: var(--red); }
.scn-actions { gap: 8px; }
.crit-list { display: grid; gap: 8px; margin-bottom: 10px; }
.crit-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 8px; align-items: center; }
@media (max-width: 760px) { .crit-row { grid-template-columns: 1fr auto; } .crit-row .crit-desc { grid-column: 1; } }
.att-score {
  width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; background: #f1f4f8; color: var(--muted);
}
.att-score.great { background: #ecfdf5; color: #15803d; }
.att-score.ok { background: #fffbeb; color: #b45309; }
.att-score.low { background: var(--brand-tint); color: var(--red); }
.att-sub { margin: 18px 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ── Mobile console ───────────────────────────────────────────────── */
@media (max-width: 960px) {
  .topnav-row { padding: 0 16px; }
  .nav-toggle { display: inline-flex; }
  .topnav {
    display: none;
    position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    max-height: calc(100dvh - 64px); overflow-y: auto;
    padding: 12px 16px 18px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 24px 40px -16px rgba(15, 23, 42, 0.3);
  }
  .topnav.open { display: flex; }
  .topnav .tn-link { width: 100%; }
  .topnav .tn-btn {
    width: 100%; height: auto; min-height: 0; padding: 14px 12px 6px;
    font-size: 11px; font-weight: 650; letter-spacing: 0.09em; text-transform: uppercase;
    color: var(--subtle); background: transparent; pointer-events: none;
  }
  .topnav .tn-btn .tn-chev { display: none; }
  .topnav .tn-menu { display: block; position: static; min-width: 0; padding: 0; border: 0; box-shadow: none; }
  .topnav .tn-menu::before { display: none; }
  .agent-bar { padding: 8px 16px; }
  .agent-bar label, .agent-bar button { display: none; }
  .agent-bar select { flex: 1; min-width: 0; max-width: none; }
  .main { padding: 20px 16px 48px; }
  .card { padding: 18px; }
  .view-head h2 { font-size: 21px; }
}

/* ═══ Sign-in ══════════════════════════════════════════════════════ */
.login-body {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  background: #fff;
}
.login-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px 56px;
  color: #fff;
  background:
    radial-gradient(70% 55% at 85% 10%, color-mix(in srgb, var(--brand) 35%, transparent), transparent 70%),
    radial-gradient(60% 50% at 0% 100%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 70%),
    linear-gradient(160deg, #111623 0%, #0b0e15 100%);
}
.login-hero::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.8), transparent 75%);
  pointer-events: none;
}
.login-hero > * { position: relative; z-index: 1; }
.login-logo { display: flex; align-items: center; gap: 12px; }
.login-logo .side-name { font-size: 20px; color: #fff; }
.login-logo .side-name .brand-agile { color: var(--brand-on-dark); }
.login-logo .side-product { color: var(--side-text); }
.login-pitch h2 { color: #fff; font-size: 38px; line-height: 1.12; letter-spacing: -0.035em; margin: 0 0 16px; max-width: 520px; }
.login-pitch h2 em { font-style: normal; color: var(--brand-on-dark); }
.login-pitch p { color: #a8b0bf; font-size: 16px; max-width: 460px; margin: 0 0 30px; }
.login-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.login-points li { display: flex; align-items: center; gap: 12px; color: #d4d9e2; font-size: 14.5px; }
.login-points .dot {
  width: 30px; height: 30px; flex: none; border-radius: 9px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.1); color: var(--brand-on-dark);
}
.login-points .dot svg { width: 16px; height: 16px; }
.login-copy { color: #6b7280; font-size: 12.5px; }

.login-side { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.login-panel { width: 100%; max-width: 400px; }
.login-brand { display: none; text-align: center; margin-bottom: 24px; }
.login-mark { display: block; font-size: 26px; font-weight: 750; letter-spacing: -0.02em; color: var(--ink); }
.login-mark em { font-style: normal; color: var(--brand-text); }
.login-product { display: block; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.login-card { padding: 32px; margin-bottom: 16px; box-shadow: var(--shadow-lg); border-radius: 18px; }
.login-card h1 { margin: 0 0 6px; font-size: 24px; font-weight: 700; letter-spacing: -0.025em; }
.login-sub { margin: 0 0 8px; font-size: 14px; }
.login-card button[type="submit"] { width: 100%; min-height: 44px; margin-top: 22px; font-size: 15px; }
.login-error {
  margin: 14px 0 0; padding: 10px 12px; border-radius: 10px;
  font-size: 13px; color: var(--red); background: var(--brand-tint); border: 1px solid var(--brand-border);
}
.login-error[hidden] { display: none; }
.login-foot { text-align: center; font-size: 13px; }
@media (max-width: 960px) {
  .login-body { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-brand { display: block; }
}

/* ═══ Visitor widget ═══════════════════════════════════════════════
   Mobile first: avatar on top, chat below. Desktop: the avatar fills the
   left, the conversation is a panel on the right. */
.widget-wrap {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.avatar-panel { display: flex; flex-direction: column; }
.avatar-stage {
  position: relative;
  aspect-ratio: 16 / 10;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(60% 50% at 50% 38%, color-mix(in srgb, var(--brand) 16%, transparent), transparent 70%),
    radial-gradient(90% 70% at 50% 110%, rgba(255, 255, 255, 0.06), transparent 60%),
    linear-gradient(180deg, #121722 0%, #0a0d14 100%);
}
.avatar-stage video { width: 100%; height: 100%; object-fit: cover; }
.avatar-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center;
  color: #cbd2de;
}
.avatar-overlay.hidden { display: none; }
.avatar-portrait {
  width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 34px; font-weight: 700; color: var(--on-brand);
  background: linear-gradient(145deg, var(--brand-light), color-mix(in srgb, var(--brand) 70%, black));
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.05), 0 0 0 12px rgba(255, 255, 255, 0.03), 0 20px 40px -12px color-mix(in srgb, var(--brand) 55%, transparent);
  margin-bottom: 6px;
  animation: portrait-breathe 3.2s ease-in-out infinite;
}
@keyframes portrait-breathe { 50% { box-shadow: 0 0 0 9px rgba(255, 255, 255, 0.06), 0 0 0 18px rgba(255, 255, 255, 0.025), 0 20px 44px -12px color-mix(in srgb, var(--brand) 65%, transparent); } }
#bot-title { font-size: 24px !important; font-weight: 700 !important; color: #fff; letter-spacing: -0.02em; }
#avatar-status { color: #9aa3b2 !important; font-size: 14px; max-width: 340px; }
.avatar-overlay button#start-avatar-btn {
  min-height: 48px; padding: 0 26px; font-size: 15.5px; border-radius: 999px; margin-top: 6px;
  box-shadow: 0 10px 30px -10px color-mix(in srgb, var(--brand) 80%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.avatar-overlay button#text-only-btn {
  min-height: 34px; color: #cbd2de; background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12); box-shadow: none; border-radius: 999px;
}
.avatar-overlay button#text-only-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); color: #fff; }

.chat-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #f6f7f9; }

/* Chat header: who you are talking to, and what they are doing */
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.chat-head-avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; color: var(--on-brand); font-size: 15px;
  background: linear-gradient(145deg, var(--brand-light), var(--brand-hover));
}
/* A client's logo replaces the initials: shown whole on white. */
.chat-head-avatar.has-logo, .avatar-portrait.has-logo { background: #fff; overflow: hidden; }
.chat-head-avatar.has-logo { border: 1px solid var(--border); }
.chat-head-avatar img, .avatar-portrait img { width: 100%; height: 100%; object-fit: contain; }
.avatar-portrait.has-logo img { padding: 14%; }
.chat-head-text { flex: 1; min-width: 0; }
.chat-head-name { font-weight: 650; color: var(--ink); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-bar { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.status-bar::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}
.status-bar.busy::before { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2); animation: status-blink 1s ease-in-out infinite; }
.status-bar.error::before { background: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
@keyframes status-blink { 50% { opacity: 0.4; } }
#status-right { color: var(--subtle); font-variant-numeric: tabular-nums; }
#status-right:not(:empty)::before { content: "· "; }
.lang-select {
  /* Sized to "Auto", not its longest language name, so it never crowds
     out the avatar's name beside it. */
  flex: none; width: auto; max-width: 118px; min-height: 34px; padding: 0 30px 0 10px;
  font-size: 12.5px; font-weight: 550; color: var(--text-2);
  border-radius: 999px; background-position: right 8px center; background-size: 16px;
}

.chat-log { flex: 1; overflow-y: auto; padding: 20px 16px; }
.chat-log::-webkit-scrollbar { width: 8px; }
.chat-log::-webkit-scrollbar-thumb { background: #d4d9e1; border-radius: 4px; }
.msg {
  max-width: 86%;
  margin-bottom: 12px;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  animation: msg-in 0.2s ease-out;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg.bot {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
  box-shadow: var(--shadow-xs);
}
.msg.user {
  margin-left: auto;
  color: var(--on-brand);
  background: linear-gradient(145deg, var(--brand-light), color-mix(in srgb, var(--brand) 92%, black));
  border-bottom-right-radius: 5px;
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--brand) 60%, transparent);
}
.msg:empty::after { content: "…"; color: var(--subtle); }
.msg .src {
  display: block; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11.5px; line-height: 1.45; color: var(--muted); white-space: normal;
}
.msg .src + .src { border-top: none; padding-top: 0; margin-top: 4px; }
.msg[dir="rtl"], .msg[dir="rtl"] .src { text-align: right; }

.input-bar {
  display: flex; align-items: center; gap: 8px;
  margin: 0 12px 12px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-bar:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
.input-bar input {
  flex: 1; min-width: 0; min-height: 40px;
  border: none; box-shadow: none; background: transparent; padding: 0 6px;
}
.input-bar input:focus { box-shadow: none; }
.mic-btn, #send-btn {
  width: 42px; min-height: 42px; height: 42px; padding: 0; flex: none; border-radius: 50%;
}
.mic-btn {
  color: var(--text-2); background: #f1f4f8; border: 1px solid var(--border); box-shadow: none;
}
.mic-btn:hover:not(:disabled) { background: #e7ebf1; }
.mic-btn.listening { color: var(--on-brand); background: var(--brand); border-color: var(--brand); animation: mic-pulse 1.4s infinite; }
@keyframes mic-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 45%, transparent); }
  70% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--brand) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 0%, transparent); }
}
#send-btn svg, .mic-btn svg { width: 19px; height: 19px; }
/* Hands-free toggle: a pill beside the mic; filled while it is on. */
.hf-btn {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  min-height: 42px; height: 42px; padding: 0 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-2); background: #f1f4f8; border: 1px solid var(--border); box-shadow: none;
}
.hf-btn svg { width: 17px; height: 17px; }
.hf-btn:hover:not(:disabled) { background: #e7ebf1; }
.hf-btn.on { color: var(--brand-text); background: color-mix(in srgb, var(--brand) 12%, #fff); border-color: var(--brand); }
@media (max-width: 420px) {
  .hf-btn span { display: none; }
  .hf-btn { width: 42px; padding: 0; justify-content: center; }
}
.widget-foot { text-align: center; font-size: 11px; color: var(--subtle); padding: 0 0 10px; }
.widget-foot b { color: var(--muted); font-weight: 650; }

/* Password gate */
.gate {
  height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(60% 50% at 50% 30%, color-mix(in srgb, var(--brand) 18%, transparent), transparent 70%),
    linear-gradient(180deg, #121722, #0a0d14);
}
.gate .card { width: 100%; max-width: 360px; padding: 30px; border-radius: 18px; box-shadow: var(--shadow-lg); }
.gate h2 { margin: 0 0 16px; font-size: 20px; }
.gate button { width: 100%; }

/* Phone widget: the avatar area is short, so the start panel is compact
   enough to fit inside it rather than being clipped at the top. */
@media (max-width: 899px) {
  .avatar-overlay { gap: 8px; padding: 14px; }
  .avatar-portrait { width: 56px; height: 56px; font-size: 20px; margin-bottom: 0; }
  #bot-title { font-size: 18px !important; }
  #avatar-status { font-size: 13px; }
  .avatar-overlay button#start-avatar-btn { min-height: 40px; font-size: 14px; margin-top: 2px; }
  .avatar-overlay button#text-only-btn { min-height: 30px; }
}

/* Desktop widget */
@media (min-width: 900px) {
  .widget-wrap { flex-direction: row; background: #0a0d14; }
  .avatar-panel { flex: 1; min-width: 0; height: 100dvh; }
  .avatar-stage { flex: 1; aspect-ratio: auto; height: 100%; }
  .chat-panel {
    flex: none; width: 440px; height: 100dvh;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: -18px 0 40px rgba(0, 0, 0, 0.35);
  }
}

/* ── Widget: presentation mode ─────────────────────────────────────
   The slide is the main event; the avatar becomes a presenter tile
   beside it, with the caption and Q&A underneath. Phones stack slide,
   a short presenter strip, then caption and chat. */
.deck-panel { display: flex; flex-direction: column; min-height: 0; background: #eceff4; }
.deck-panel[hidden], .deck-caption[hidden], .deck-start[hidden] { display: none; }
.deck-stage {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; overflow: hidden;
}
.deck-stage canvas {
  display: block; max-width: 100%; max-height: 100%;
  background: #fff; border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 24px 48px -20px rgba(15, 23, 42, 0.35);
}
.deck-fullscreen {
  position: absolute; top: 14px; right: 14px;
  width: 38px; min-height: 38px; padding: 0; font-size: 16px;
  color: var(--ink); background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.deck-fullscreen:hover:not(:disabled) { background: #fff; }
.deck-start {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center; color: #fff;
  background:
    radial-gradient(60% 50% at 50% 35%, color-mix(in srgb, var(--brand) 25%, transparent), transparent 70%),
    rgba(10, 13, 20, 0.92);
  backdrop-filter: blur(6px);
}
.deck-start-title { font-size: 26px; font-weight: 700; letter-spacing: -0.025em; max-width: 80%; }
.deck-start #deck-start-btn {
  min-height: 50px; padding: 0 28px; font-size: 16px; border-radius: 999px;
  box-shadow: 0 12px 30px -10px color-mix(in srgb, var(--brand) 80%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.deck-start #deck-textonly-btn {
  color: #d4d9e2; background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14); box-shadow: none; border-radius: 999px;
}
.deck-start-note { font-size: 13.5px; color: #cbd2de; min-height: 18px; }
.deck-controls { padding: 0 18px 14px; }
.deck-progress { height: 4px; background: #d6dce6; border-radius: 999px; overflow: hidden; }
.deck-progress > div { height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width 0.35s; }
.deck-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 13px; font-weight: 550; color: var(--muted); }
.deck-bar button { min-width: 40px; min-height: 36px; padding: 0 12px; border-radius: 999px; }
.deck-caption {
  flex: none; max-height: 34%; overflow-y: auto;
  padding: 14px 16px; background: #fff; border-bottom: 1px solid var(--border);
  box-shadow: 0 6px 12px -10px rgba(15, 23, 42, 0.25);
  position: relative; z-index: 1;
}
.deck-caption-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; min-height: 28px; }
.deck-caption-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand-text); }
.deck-caption p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--text); }
.deck-caption button[hidden] { display: none; }

.widget-wrap.presenting .avatar-overlay button { display: none; }
.widget-wrap.presenting .avatar-portrait { width: 64px; height: 64px; font-size: 24px; }
.widget-wrap.presenting #bot-title { font-size: 17px !important; }
.widget-wrap.presenting .deck-panel { order: -1; height: 42dvh; flex: none; }
.widget-wrap.presenting .avatar-stage { aspect-ratio: auto; height: 20dvh; flex: none; }
.widget-wrap.presenting .deck-stage { padding: 10px; }
.widget-wrap.presenting .deck-caption { max-height: 28%; }
@media (min-width: 900px) {
  .widget-wrap.presenting {
    display: grid;
    grid-template-columns: 360px 1fr;
    grid-template-rows: auto 1fr;
    background: #eceff4;
  }
  .widget-wrap.presenting .avatar-panel { grid-column: 1; grid-row: 1; height: auto; }
  .widget-wrap.presenting .avatar-stage { aspect-ratio: 4 / 3; height: auto; }
  .widget-wrap.presenting .chat-panel {
    grid-column: 1; grid-row: 2; width: auto; height: auto; min-height: 0;
    border-left: none; border-right: 1px solid var(--border); box-shadow: none;
  }
  .widget-wrap.presenting .deck-panel { grid-column: 2; grid-row: 1 / span 2; height: 100dvh; }
  .widget-wrap.presenting .deck-stage { padding: 28px; }
  .widget-wrap.presenting .deck-caption { max-height: 34%; }
}

/* ── Widget: training (roleplay) mode ──────────────────────────────── */
.widget-wrap.training .avatar-overlay > button { display: none; }
.train-start { display: grid; gap: 10px; width: min(320px, 100%); margin-top: 6px; }
.train-start input { background: rgba(255, 255, 255, 0.96); }
.train-start #train-start-avatar {
  min-height: 46px; border-radius: 999px; font-size: 15px;
  box-shadow: 0 10px 30px -10px color-mix(in srgb, var(--brand) 80%, transparent);
}
.train-start #train-start-text {
  justify-self: center; color: #cbd2de; background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12); box-shadow: none; border-radius: 999px;
}
.train-error { color: #fca5a5; font-size: 13px; min-height: 16px; }

/* Scoring and the scorecard take the chat's place */
.widget-wrap.scoring .chat-log, .widget-wrap.scoring .input-bar { display: none; }
.train-result { flex: 1; overflow-y: auto; padding: 20px 18px 28px; background: #f6f7f9; }
/* "View conversation": the chat comes back, and the feedback shrinks to
   its buttons so "Back to feedback" stays in reach. */
.widget-wrap.scoring:has(.train-result.peek) .chat-log { display: block; }
.train-result.peek { flex: none; padding: 10px 18px; border-top: 1px solid var(--border); background: #fff; }
.train-result.peek > :not(.tr-actions) { display: none; }
.train-result.peek .tr-actions { margin-top: 0; }
.tr-wait { display: flex; gap: 14px; align-items: center; padding: 28px 8px; font-size: 14px; }
.tr-spinner {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--brand); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tr-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.tr-ring {
  --c: #dc2626;
  width: 84px; height: 84px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--pct) * 1%), #e5e8ee 0);
}
.tr-ring.great { --c: #16a34a; }
.tr-ring.ok { --c: #d97706; }
.tr-ring span {
  width: 66px; height: 66px; border-radius: 50%; background: #fff; display: grid; place-items: center;
  font-size: 26px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums;
}
.tr-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tr-summary { margin: 4px 0 0; font-size: 14px; line-height: 1.5; }
.tr-criteria { display: grid; gap: 10px; margin-bottom: 16px; }
.tr-crit { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.tr-crit-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.tr-crit-name { font-weight: 600; font-size: 14px; color: var(--ink); }
.tr-dots { display: inline-flex; gap: 4px; flex: none; }
.tr-dots i { width: 10px; height: 10px; border-radius: 50%; background: #e5e8ee; }
.tr-dots i.on.great { background: #16a34a; }
.tr-dots i.on.ok { background: #d97706; }
.tr-dots i.on.low { background: #dc2626; }
.tr-evidence { margin-top: 6px; font-size: 13px; color: var(--text-2); font-style: italic; }
.tr-evidence em { color: var(--subtle); }
.tr-advice { margin-top: 6px; font-size: 13px; color: var(--text); }
.tr-list { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.tr-list h4 { margin: 0 0 6px; font-size: 13px; color: var(--ink); }
.tr-list ul { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.55; }
.tr-list.good { border-left: 3px solid #16a34a; }
.tr-list.work { border-left: 3px solid #d97706; }
.tr-list.facts { border-left: 3px solid #dc2626; }
.tr-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ── Legacy / shared bits ─────────────────────────────────────────── */
.container { max-width: 1100px; margin: 24px auto; padding: 0 20px; }
.grid { display: grid; grid-template-columns: 320px 1fr; gap: 20px; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── Leads ─────────────────────────────────────────────────────────── */
.lead-fields { display: flex; flex-wrap: wrap; gap: 8px; }
.lead-field {
  display: inline-flex; align-items: center; gap: 7px; margin: 0;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px;
  font-size: 13.5px; font-weight: 500; color: var(--text); background: #fff; cursor: pointer;
}
.lead-field:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); }
.lead-field input { margin: 0; }
#lead-options { transition: opacity 0.15s; }
#lead-options.dim { opacity: 0.45; }

.lead-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 12px; border-bottom: 1px solid var(--border);
}
.lead-row:last-child { border-bottom: none; }
.lead-avatar {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  color: var(--brand-text); background: var(--brand-tint);
}
.lead-main { flex: 1; min-width: 0; }
.lead-name { font-weight: 650; color: var(--ink); }
.lead-contact { font-size: 13.5px; margin-top: 2px; overflow-wrap: anywhere; }
.lead-contact a { color: var(--text); }
.lead-interest { font-size: 13.5px; color: var(--text-2); margin-top: 4px; }
.lead-meta { font-size: 12px; color: var(--subtle); margin-top: 4px; }
.lead-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.lead-actions select { width: auto; min-height: 34px; padding: 4px 30px 4px 10px; font-size: 13px; font-weight: 600; }
.lead-status.new       { color: var(--brand-text); }
.lead-status.contacted { color: #b45309; }
.lead-status.won       { color: #047857; }
.lead-status.lost      { color: var(--muted); }
@media (max-width: 700px) {
  .lead-row { flex-wrap: wrap; }
  .lead-actions { width: 100%; padding-left: 52px; flex-wrap: wrap; }
}

/* ── Widget consent notice ─────────────────────────────────────────── */
.consent-card { max-width: 420px !important; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.consent-card h2 { margin: 4px 0 0 !important; }
.consent-card p { margin: 0; line-height: 1.55; color: var(--text-2); font-size: 14.5px; }
.consent-card a { font-size: 14px; font-weight: 600; color: var(--brand-text); }
.consent-card button { margin-top: 4px; }
.consent-ico {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  color: var(--brand-text); background: var(--brand-tint);
}

/* ── Privacy ───────────────────────────────────────────────────────── */
.privacy-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.privacy-grid .card { margin-bottom: 18px; }
#consent-options { transition: opacity 0.15s; }
#consent-options.dim { opacity: 0.45; }
@media (max-width: 900px) { .privacy-grid { grid-template-columns: 1fr; gap: 0; } }

#dsr-results { margin-top: 14px; }
.dsr-row {
  display: flex; align-items: center; gap: 12px; margin: 0; padding: 12px;
  border-bottom: 1px solid var(--border); font-weight: 400; cursor: pointer;
}
.dsr-row:last-child { border-bottom: none; }
.dsr-row:hover { background: var(--surface); }
.dsr-row input { flex: none; margin: 0; }
.dsr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dsr-title { color: var(--ink); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dsr-meta { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.dsr-meta b { color: var(--text); font-weight: 600; }
.dsr-actions { justify-content: flex-end; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.dsr-actions .muted { margin-right: auto; }

/* ── Audit log ─────────────────────────────────────────────────────── */
.audit-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 6px; border-bottom: 1px solid var(--border); }
.audit-row:last-child { border-bottom: none; }
.audit-dot { width: 9px; height: 9px; flex: none; margin-top: 6px; border-radius: 50%; background: #94a3b8; }
.audit-dot.bad { background: var(--brand); }
.audit-main { flex: 1; min-width: 0; }
.audit-action { font-weight: 600; color: var(--ink); }
.audit-detail { font-size: 13px; color: var(--text-2); margin-top: 2px; overflow-wrap: anywhere; }
.audit-meta { font-size: 12px; color: var(--subtle); margin-top: 3px; overflow-wrap: anywhere; }
.audit-time { flex: none; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
@media (max-width: 600px) {
  .audit-row { flex-wrap: wrap; }
  .audit-time { width: 100%; padding-left: 21px; }
}

/* ── Widget: talking to a person ───────────────────────────────────── */
.person-btn { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 34px; padding: 0 12px; font-size: 12.5px; white-space: nowrap; }
.person-btn svg { width: 15px; height: 15px; }
@media (max-width: 480px) {
  .person-btn span { display: none; }
  .person-btn { width: 36px; padding: 0; justify-content: center; }
}
.msg.human { background: #f0fdf4; border-color: #bbf7d0; }
.msg.human .who { display: block; margin-bottom: 3px; font-size: 11.5px; font-weight: 650; color: #047857; white-space: normal; }
.msg-note {
  margin: 4px auto 14px; max-width: 90%; text-align: center;
  font-size: 12.5px; line-height: 1.5; color: var(--muted);
}
.handoff-bar {
  display: flex; align-items: center; gap: 10px;
  margin: 0 12px 8px; padding: 9px 10px 9px 14px;
  font-size: 13px; font-weight: 550; color: #92400e;
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px;
}
.handoff-bar.connected { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
.handoff-bar #handoff-text { flex: 1; min-width: 0; }
.handoff-bar button { flex: none; min-height: 30px; font-size: 12px; }
.handoff-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: currentColor; animation: hf-pulse 1.4s infinite; }
.handoff-bar.connected .handoff-dot { animation: none; }
@keyframes hf-pulse { 50% { opacity: 0.3; } }

/* ── Live chats (console) ──────────────────────────────────────────── */
.nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: inline-grid; place-items: center; font-size: 11.5px; font-weight: 700;
  color: var(--on-brand); background: var(--brand); animation: hf-pulse 1.6s infinite;
}
.tmsg.staff .tmsg-text { background: #f0fdf4; border: 1px solid #bbf7d0; border-bottom-left-radius: 4px; }
.tmsg.staff .tmsg-who { color: #047857; font-weight: 600; }

.live-layout { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: stretch; margin-bottom: 18px; }
.live-layout .card { margin-bottom: 0; }
.live-list-card { max-height: 620px; overflow-y: auto; }
#live-list { display: flex; flex-direction: column; gap: 6px; }
.live-item {
  display: flex; flex-direction: column; align-items: stretch; gap: 4px; width: 100%; min-height: 0; padding: 11px 12px;
  text-align: left; white-space: normal; font-weight: 400; line-height: 1.4;
  color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: none;
}
.live-item:hover:not(:disabled) { background: var(--surface); }
.live-item.selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.live-item.waiting { border-left: 3px solid #f59e0b; }
.live-item.active { border-left: 3px solid #10b981; }
.live-item-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; }
.live-status { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.live-status.waiting { color: #b45309; }
.live-status.active { color: #047857; }
.live-age { font-size: 12px; color: var(--subtle); }
.live-item-msg { color: var(--ink); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.live-item-meta { font-size: 12px; color: var(--muted); }

.live-panel { display: flex; flex-direction: column; min-height: 520px; padding: 0 !important; overflow: hidden; }
.live-empty { margin: auto; padding: 40px 24px; text-align: center; max-width: 360px; }
.live-empty .empty-ico { margin: 0 auto 10px; }
.live-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.live-chat[hidden] { display: none; }
.live-chat-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.live-messages { flex: 1; min-height: 280px; max-height: 480px; overflow-y: auto; padding: 18px; background: var(--surface); }
.live-compose { display: flex; gap: 10px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--border); }
.live-compose textarea { flex: 1; min-height: 44px; resize: vertical; }
.live-compose button { flex: none; }
#live-options { transition: opacity 0.15s; }
#live-options.dim { opacity: 0.45; }
@media (max-width: 900px) {
  .live-layout { grid-template-columns: 1fr; }
  .live-list-card { max-height: 320px; }
}

/* ── Custom avatars ────────────────────────────────────────────────── */
.car-form { margin-top: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 4px 16px 16px; }
.car-form summary { cursor: pointer; padding: 12px 0 8px; font-weight: 600; color: var(--brand-text); }
.car-form[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.car-kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.car-kinds .check-card { margin: 0; }
.car-kinds .check-card > span { display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 700px) { .car-kinds { grid-template-columns: 1fr; } }

.car-item, .car-req, .car-av { display: flex; align-items: flex-start; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.car-item:last-child, .car-req:last-child, .car-av:last-child { border-bottom: none; }
.car-thumb { width: 52px; height: 52px; flex: none; border-radius: 12px; object-fit: cover; background: #f1f4f8; }
.car-photo { width: 96px; height: 96px; flex: none; border-radius: 14px; object-fit: cover; background: #f1f4f8; display: block; }
.car-thumb-video { display: grid; place-items: center; color: var(--muted); font-size: 18px; }
.car-main { flex: 1; min-width: 0; }
.car-name { font-weight: 650; color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.car-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.car-note { font-size: 13px; color: var(--text-2); margin-top: 5px; }
.car-actions { flex: none; display: flex; gap: 8px; align-items: center; }
.car-status { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; padding: 2px 8px; border-radius: 999px; background: #f1f4f8; color: var(--muted); }
.car-status.requested   { background: #fffbeb; color: #b45309; }
.car-status.in_progress { background: #eff6ff; color: #1d4ed8; }
.car-status.ready       { background: #ecfdf5; color: #047857; }
.car-status.rejected    { background: var(--brand-tint); color: var(--brand-text); }
.car-staff { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.car-staff select { width: auto; max-width: 100%; min-height: 36px; }
.car-staff input { flex: 1 1 180px; min-width: 0; min-height: 36px; }
.car-av img { width: 56px; height: 56px; flex: none; border-radius: 12px; object-fit: cover; background: #f1f4f8; }
.car-av select { width: auto; max-width: 220px; flex: none; }
@media (max-width: 600px) {
  .car-req, .car-av, .car-item { flex-wrap: wrap; }
  .car-actions { width: 100%; padding-left: 66px; }
}

/* ── Modal dialog (change password) ────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.55); animation: fade-in 0.2s; }
.modal-panel { position: relative; width: 100%; max-width: 420px; margin: 0; box-shadow: var(--shadow-lg); }

/* Sign-in: forgot / reset password */
.login-links { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 13px; }
.login-links button { font-size: 13px; }
.login-ok { color: var(--green); font-size: 13.5px; margin: 10px 0 0; }
.login-error.ok { color: var(--green); background: #ecfdf5; border-color: #a7f3d0; }

/* ── Usage & cost ───────────────────────────────────────────────── */
.usage-table-wrap { overflow-x: auto; }
.usage-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.usage-table th { text-align: left; font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.usage-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.usage-table tr:last-child td { border-bottom: 0; }
.usage-table td:not(:first-child) { white-space: nowrap; }
.usage-table td .muted { font-size: 12px; }
.usage-tile-note { margin-top: 4px; font-size: 12px; }
.usage-bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-bottom: 22px; position: relative; }
.usage-bar { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.usage-bar span { display: block; width: 100%; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 0; }
.usage-bar:hover span { background: var(--brand-hover); }
.usage-bar-axis { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; font-size: 11px; color: var(--subtle); }
