:root {
  /* Stratagile's own mark is a dark "Strat" + red "agile" wordmark, so the
     brand colour here is that red, not the platform-tool navy the console
     used before. Reserved for interactive/emphasis elements — active nav,
     primary buttons, badges, the logo — headings stay dark ink, matching
     the reference dashboard's mostly-black type with red used sparingly. */
  --brand: #dc2626;
  --accent: #dc2626;
  --accent-dark: #b91c1c;
  --bg: #f5f7fb;
  --card: #ffffff;
  --border: #e3e8f0;
  /* Neutral near-black rather than the old navy-tinted ink — that tint
     was a holdover from the previous blue/navy brand and read as faintly
     blue text next to the new red accent. */
  --text: #1a1c22;
  --muted: #6b7688;
  --green: #1f8a4c;
  --red: #b91c1c;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
header.topbar {
  background: #fff;
  color: var(--text);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
header.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
/* "Strat" stays ink-dark, "agile" carries the brand red — the same split
   used on the sign-in screen's wordmark, so the two pages read as one
   product rather than a login page and a separate admin tool. */
.brand-strat { color: var(--text); }
.brand-agile { color: var(--brand); }
header.topbar .tag { font-size: 12px; opacity: 0.75; }
.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; } }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; color: var(--text); }  /* dark, not brand red — the reference reserves red for active/interactive elements, not section titles */
.card h3 { margin: 16px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
button {
  font: inherit;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
}
button.secondary { background: #e8edf5; color: var(--brand); }
button.danger { background: var(--red); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:hover:not(:disabled) { filter: brightness(0.94); }
button.small { padding: 5px 10px; font-size: 12.5px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.bot-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.bot-item:hover, .bot-item.active { border-color: var(--accent); background: #fdf1f1; }
.pill {
  font-size: 11px;
  background: #eef2f8;
  color: var(--muted);
  border-radius: 20px;
  padding: 2px 10px;
}
.doc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.muted { color: var(--muted); font-size: 12.5px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 13px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.stat .stat-top { display: flex; align-items: center; gap: 8px; }
/* Fixed, decorative categorical badge colors — icon only, always paired
   with a text label, so no reader depends on the hue to tell tiles apart. */
.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.stat-icon svg { width: 16px; height: 16px; }
.stat-icon.purple { background: #efe9fe; color: #7c5cfc; }
.stat-icon.blue   { background: #e6f0fe; color: #3b82f6; }
.stat-icon.green  { background: #e3f7ec; color: #16a34a; }
.stat-icon.orange { background: #fdf1de; color: #d97706; }
.stat-icon.red    { background: #fde8e8; color: var(--brand); }
.stat .lbl {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat .num { font-size: 21px; font-weight: 700; color: var(--text); line-height: 1.1; }
.embed-code {
  background: #0f1a2e;
  color: #cfe3ff;
  border-radius: 8px;
  padding: 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--brand);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  z-index: 99;
}
.toast.show { opacity: 1; }

/* ── Widget ─────────────────────────────────────────────────────── */
/* Mobile-first: avatar on top, chat below. On desktop (Windows) the
   layout switches to two panels: large avatar left, chat right. */
.widget-wrap {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--card);
}
.avatar-panel {
  display: flex;
  flex-direction: column;
}
.chat-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--card);
}
.avatar-stage {
  position: relative;
  background: #0d1524;
  aspect-ratio: 16/10;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
/* Desktop / Windows layout */
@media (min-width: 900px) {
  .widget-wrap {
    flex-direction: row;
    background: #0a111f;
  }
  .avatar-panel {
    flex: 1;
    min-width: 0;
    height: 100dvh;
  }
  .avatar-stage {
    flex: 1;
    aspect-ratio: auto;
    height: 100%;
  }
  .chat-panel {
    flex: none;
    width: 420px;
    height: 100dvh;
    border-left: 1px solid var(--border);
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.25);
  }
  .avatar-overlay button#start-avatar-btn {
    font-size: 17px;
    padding: 12px 26px;
  }
}
/* Comfortable scrollbars on Windows (Chromium/Edge) */
.chat-log::-webkit-scrollbar { width: 10px; }
.chat-log::-webkit-scrollbar-track { background: transparent; }
.chat-log::-webkit-scrollbar-thumb {
  background: #c9d4e5;
  border-radius: 6px;
  border: 2px solid var(--card);
}
.chat-log::-webkit-scrollbar-thumb:hover { background: #9fb0c9; }
.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: 12px;
  color: #cfe3ff;
  background: rgba(13, 21, 36, 0.85);
  text-align: center;
  padding: 20px;
}
.avatar-overlay.hidden { display: none; }
.status-bar {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}
.chat-log { flex: 1; overflow-y: auto; padding: 14px; }
.msg { margin-bottom: 10px; max-width: 85%; padding: 9px 12px; border-radius: 12px; font-size: 14px; line-height: 1.45; }
.msg.user { background: var(--accent); color: #fff; margin-left: auto; border-bottom-right-radius: 3px; }
.msg.bot { background: #eef2f8; border-bottom-left-radius: 3px; }
.msg .src { display: block; margin-top: 5px; font-size: 11px; opacity: 0.65; }
.input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.input-bar input { flex: 1; }
.mic-btn {
  width: 46px;
  height: 42px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
}
.mic-btn:hover { background: var(--accent-dark); }  /* brand now equals accent, so this needs its own darker step to still read as a hover */
.mic-btn.listening { background: var(--red); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.gate {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gate .card { width: 320px; }

/* ── Language picker (widget status bar) ────────────────────────── */
.lang-select {
  width: auto;
  padding: 2px 6px;
  font-size: 11.5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.status-bar .row { gap: 8px; }
.msg .src.specialists { opacity: 0.8; }
/* RTL is set per message, so a mixed-language conversation keeps each
   bubble in its own direction instead of flipping the whole log. */
.msg[dir="rtl"] { text-align: right; }
.msg[dir="rtl"] .src { text-align: right; }

/* ── Specialist roster (console) ────────────────────────────────── */
.spec-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
}
.spec-item:hover, .spec-item.active { border-color: var(--accent); background: #fdf1f1; }
.spec-item .spec-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.spec-item .spec-name { font-weight: 600; font-size: 13.5px; }
.spec-item .spec-desc {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pill.spec { background: #fde8e8; color: var(--brand); }  /* same fix as .pill.admin — accent is red now */
.pill.warn { background: #fdf0e6; color: #b35c00; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab {
  padding: 6px 12px;
  border-radius: 6px;
  background: #eef2f8;
  color: var(--muted);
  cursor: pointer;
  font-size: 12.5px;
  border: 1px solid transparent;
}
.tab.active { background: #fff; color: var(--brand); border-color: var(--accent); font-weight: 600; }
.scroll-list { max-height: 320px; overflow-y: auto; }

/* ── Sign-in screen ─────────────────────────────────────────────── */
.login-body {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #16233d 0%, #1f3864 55%, #24406f 100%);
  padding: 24px;
}
.login-panel { width: 100%; max-width: 380px; }
.login-brand {
  text-align: center;
  margin-bottom: 22px;
  color: #fff;
}
.login-mark { display: block; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.login-mark em { font-style: normal; color: #ff6b5e; }
.login-product {
  display: block;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-top: 4px;
}
.login-card { margin-bottom: 14px; box-shadow: 0 18px 48px -20px rgba(0, 0, 0, 0.55); }
.login-card h1 { margin: 0 0 4px; font-size: 19px; color: var(--brand); }
.login-sub { margin: 0 0 6px; }
.login-error {
  margin: 12px 0 0;
  padding: 9px 11px;
  border-radius: 6px;
  background: #fdecea;
  color: var(--red);
  font-size: 13px;
}
.login-foot { text-align: center; color: #b9c9e2; }
/* The gradient ground needs light text, which the shared .muted colour
   is too dark for. */
.login-body .muted { color: #b9c9e2; }
.login-card .muted { color: var(--muted); }

/* ── Signed-in identity in the top bar ──────────────────────────── */
header.topbar .tag {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  opacity: 1;
}
/* Initials bubble — the reference product shows a colored avatar circle
   next to the signed-in name; there is no photo to show, so this is the
   honest equivalent rather than a placeholder image. */
.identity-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
header.topbar .who { font-weight: 600; color: var(--text); }
header.topbar .org { opacity: 0.8; color: var(--muted); }
header.topbar .mode { opacity: 0.7; font-size: 11px; color: var(--muted); }
header.topbar .pill.role {
  background: #fde8e8;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  font-weight: 600;
}
button.linkish {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 5px;
}
button.linkish:hover { background: #f4f5f7; border-color: #d0d5dd; }

/* ── Avatar picker ──────────────────────────────────────────────── */
.avatar-chosen {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfd;
  margin-bottom: 10px;
}
.avatar-chosen img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: #e8edf5;
  flex: none;
}
.avatar-chosen img:not([src]), .avatar-chosen img[src=""] { visibility: hidden; }
.avatar-chosen > div { flex: 1; min-width: 0; }
.avatar-chosen-name { font-weight: 600; font-size: 14px; }

.avatar-picker {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
  background: #fff;
}
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
  padding: 2px;
}
.avatar-card {
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 0;
  background: #eef2f8;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  display: block;
  width: 100%;
}
.avatar-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  background: #dde5f0;
}
.avatar-card .cap {
  display: block;
  padding: 5px 7px;
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--text);
  background: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.avatar-card:hover { border-color: var(--accent); }
.avatar-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18); }  /* was a hardcoded blue glow left over from the old accent color */
.avatar-card.selected .cap { background: var(--accent); color: #fff; font-weight: 600; }
.avatar-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

details.advanced { margin-top: 14px; }
details.advanced summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--muted);
  padding: 4px 0;
}
details.advanced summary:hover { color: var(--accent); }

/* ── Dashboard & charts ─────────────────────────────────────────── */
/* Chart roles, so hexes live in one place. The console is a
   single-theme light application; these are its light steps, validated
   against the white card surface (CVD ΔE 18.6 between the two series).
   On :root rather than scoped to a specific element id: it was previously
   scoped to `#dashboard`, an id the multi-screen rewrite renamed to
   `#view-dashboard` without updating this rule — every var() reference
   silently resolved to nothing, and SVG `fill` fell back to its CSS-spec
   default of black, so every chart bar rendered solid black. */
:root {
  --series-answered: #2e74b5;
  --series-unanswered: #d03b3b;
  --chart-grid: #e8edf4;
  --chart-axis: #97a3b6;
}
.chart-wrap { overflow-x: auto; }
.chart-wrap svg { display: block; }
.chart-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
@media (max-width: 720px) { .chart-pair { grid-template-columns: 1fr; } }

.chart-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.chart-legend span.key { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i {
  width: 10px; height: 10px; border-radius: 2px; display: inline-block;
}
.chart-empty { color: var(--muted); font-size: 13px; padding: 18px 0; }

/* Horizontal bar rows — direct-labelled, so identity never rests on colour */
.hbar { margin-bottom: 7px; }
.hbar-top {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12.5px; margin-bottom: 3px;
}
.hbar-top .n { font-variant-numeric: tabular-nums; color: var(--muted); }
.hbar-track { background: #eef2f8; border-radius: 4px; height: 8px; overflow: hidden; }
.hbar-fill { background: var(--series-answered); height: 100%; border-radius: 4px; }

.q-item {
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.q-item .q-text { flex: 1; min-width: 0; }
.q-item .q-meta {
  color: var(--muted); font-size: 11.5px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.q-item .pill.times { background: #fdecea; color: var(--red); font-weight: 600; }

.chart-tip {
  position: fixed;
  background: #16233d;
  color: #fff;
  font-size: 12px;
  padding: 6px 9px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.chart-tip b { font-variant-numeric: tabular-nums; }

.avatar-card { position: relative; }
.avatar-badge {
  position: absolute;
  top: 5px;
  left: 5px;
  background: var(--brand);
  color: #fff;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
}

/* ── Clients & team ─────────────────────────────────────────────── */
.org-item, .user-item {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 7px;
}
.org-item .row, .user-item .row { justify-content: space-between; gap: 8px; }
.org-item .name, .user-item .email { font-weight: 600; font-size: 13.5px; }
.org-item .meta, .user-item .meta { color: var(--muted); font-size: 11.5px; }
.pill.owner  { background: #efe3fb; color: #6b2fb3; }
.pill.admin  { background: #fde8e8; color: var(--brand); }  /* was light-blue bg with red text once accent became red — a real clash */
.pill.viewer { background: #eef2f8; color: var(--muted); }
.pill.you    { background: var(--green); color: #fff; }
.form-note.ok  { color: var(--green); }
.form-note.bad { color: var(--red); }

/* ═══ Multi-screen admin shell ══════════════════════════════════ */
body.app { background: var(--bg); }

.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  align-items: start;
  min-height: calc(100dvh - 51px);
}

.topbar .topbar-sub { font-weight: 400; opacity: 0.65; font-size: 14px; }
.nav-toggle {
  display: none;
  background: #f4f5f7;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 16px;
  padding: 4px 10px;
  border-radius: 6px;
}

.sidenav {
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 16px 10px 40px;
  position: sticky;
  top: 0;
  align-self: stretch;
}
.nav-group { margin-bottom: 20px; }
.nav-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  margin-bottom: 1px;
}
.nav-item .nav-ico {
  width: 17px;
  height: 17px;
  flex: none;
  color: var(--muted);
}
.nav-item:hover { background: #f6eeee; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-item.active .nav-ico { color: #fff; }
.nav-item[hidden] { display: none; }
.nav-item.disabled { opacity: 0.4; pointer-events: none; }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.main {
  padding: 20px 24px 60px;
  max-width: 980px;
  min-width: 0;
}
.view-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.view-head h2 { margin: 0; font-size: 20px; color: var(--text); font-weight: 700; }

.agent-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  margin-bottom: 16px;
}
.agent-bar label {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.agent-bar select { flex: 1; min-width: 120px; }

.empty-state { text-align: center; padding: 40px 20px; }
.empty-state h3 { margin-top: 0; color: var(--brand); text-transform: none;
  font-size: 16px; letter-spacing: 0; }

.card h3:first-child { margin-top: 0; }
.chart-pair .card { margin-bottom: 0; }
.chart-pair { margin-bottom: 18px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .nav-toggle { display: block; }
  .sidenav {
    display: none;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidenav.open { display: block; }
  .main { padding: 16px; }
}
