/* ============================================================
   Verqal — Operations Console
   Theme: Verqal design system (see verqal_website/DESIGN.md)
   Warm-neutral ground, one electric cobalt voice.
   Type: Spectral (display) / Hanken Grotesk (UI) / JetBrains Mono (data)
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  --font-display: "Spectral", "Iowan Old Style", "Apple Garamond", Georgia, serif;
  --font-ui: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --row-h: 36px;
  --pad-x: 16px;
  --pad-y: 12px;
  --gap: 14px;
  --topbar-h: 56px;
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  /* brand primitives (from the Verqal logo) */
  --paper: #fbf8f3;
  --sand: #f1ebe1;
  --ink-navy: #001a45;
  --near-black: #15120e;
  --cobalt: #1e3eff;
  --cobalt-deep: #1730d6;
  --accent: var(--cobalt);
  --accent-fg: var(--paper);
  --accent-soft: #e9ecff;
  --accent-line: #bcc7ff;
  --accent-ink: var(--cobalt-deep);
}

/* ---------- light theme (default): warm paper ground, ink-navy text ---------- */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: var(--paper);
  --surface: #fffdf9;
  --surface-2: #f7f2e9;
  --surface-3: var(--sand);
  --surface-sunken: #f5efe5;
  --ink: var(--ink-navy);
  --ink-2: #2a3350;
  --muted: #565d76;
  --muted-2: #7c829a;
  --faint: #a0a5b8;
  --line: #e6dfd2;
  --line-2: #ddd5c4;
  --line-strong: #cdc3ac;
  --green: #2c7a4b;
  --green-soft: #e8f2e9;
  --green-line: #bcd9c3;
  --amber: #9a6b15;
  --amber-soft: #f8efdb;
  --amber-line: #e3cf9d;
  --red: #cf4738;
  --red-soft: #f9e9e4;
  --red-line: #ecc0b5;
  --blue: var(--cobalt-deep);
  --blue-soft: var(--accent-soft);
  --shadow-sm: 0 1px 2px rgb(21 18 14 / 0.05), 0 0 0 1px rgb(21 18 14 / 0.04);
  --shadow-md: 0 8px 24px -8px rgb(21 18 14 / 0.10), 0 2px 6px -2px rgb(21 18 14 / 0.06);
  --shadow-lg: 0 24px 56px -16px rgb(21 18 14 / 0.18), 0 6px 14px -6px rgb(21 18 14 / 0.10);
  --shadow-pop: 0 16px 40px -12px rgb(21 18 14 / 0.22), 0 4px 10px -4px rgb(21 18 14 / 0.12);
}
:root[data-theme="light"] {
  --accent: var(--cobalt);
  --accent-soft: #e9ecff;
  --accent-line: #bcc7ff;
  --accent-ink: var(--cobalt-deep);
}

/* ---------- dark theme: warm near-black ground, paper text ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--near-black);
  --surface: #1d1a14;
  --surface-2: #211d16;
  --surface-3: #2a251c;
  --surface-sunken: #181510;
  --ink: var(--paper);
  --ink-2: #e9e3d6;
  --muted: #a59e8e;
  --muted-2: #847d6d;
  --faint: #5f594c;
  --line: #322c22;
  --line-2: #3b3427;
  --line-strong: #4a4232;
  --green: #7fc296;
  --green-soft: #1e2e23;
  --green-line: #2f4a38;
  --amber: #d8ad62;
  --amber-soft: #322a18;
  --amber-line: #514323;
  --red: #ff6a54;
  --red-soft: #381e18;
  --red-line: #5c2e23;
  --blue: #6f86ff;
  --blue-soft: #1b2040;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4), 0 0 0 1px rgb(251 248 243 / 0.04);
  --shadow-md: 0 8px 24px -8px rgb(0 0 0 / 0.5), 0 2px 6px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 24px 56px -16px rgb(0 0 0 / 0.6), 0 6px 14px -6px rgb(0 0 0 / 0.4);
  --shadow-pop: 0 16px 40px -12px rgb(0 0 0 / 0.55), 0 4px 10px -4px rgb(0 0 0 / 0.35);
  --accent: #3a57ff;
  --accent-fg: #f7f9ff;
  --accent-soft: #1b2040;
  --accent-line: #2c3c8f;
  --accent-ink: #6f86ff;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  font-feature-settings: "ss01", "ss02", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .5; }
input, textarea, select { background: none; border: 0; outline: 0; }
::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- auth gate ---------- */
body.auth-required .app { display: none; }
body.authenticated .signin-page { display: none; }

/* ---------- sign-in page ---------- */
.signin-page {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 480px at 20% 30%, color-mix(in srgb, var(--accent-soft) 80%, transparent), transparent 70%),
    radial-gradient(700px 460px at 80% 75%, color-mix(in srgb, var(--green-soft) 50%, transparent), transparent 70%),
    var(--bg);
}
.signin-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 28px 24px;
  display: grid;
  gap: 18px;
}
.signin-mark {
  width: 56px; height: 56px;
  border-radius: 12px;
  background: var(--ink-navy);
  display: grid; place-items: center;
  overflow: hidden;
}
.signin-mark img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}
.signin-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.1;
}
.signin-card h1 em {
  font-style: italic;
  font-family: var(--font-display);
}
.signin-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}
.signin-restricted {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--red-line);
  background: var(--red-soft);
  color: var(--red);
}
.signin-restricted[hidden] { display: none; }
.signin-restricted strong {
  font-size: 13px;
  line-height: 1.2;
}
.signin-restricted span {
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.35;
}
.signin-form,
.signin-password-panel { display: grid; gap: 14px; }
.signin-password-panel[hidden] { display: none; }
.btn.google-signin {
  justify-content: center;
  gap: 10px;
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.btn.google-signin:hover {
  background: var(--surface-2);
  border-color: var(--accent-line);
}
.btn.google-signin svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}
.signin-secondary {
  justify-self: start;
  color: var(--accent-ink);
  font-size: 12.5px;
  font-weight: 650;
}
.signin-secondary:hover { text-decoration: underline; }
.field-label {
  display: grid;
  gap: 6px;
}
.field-label > span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.field-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.text-input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.text-input:focus {
  background: var(--surface);
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.text-input[aria-invalid="true"] {
  border-color: var(--red-line);
  box-shadow: 0 0 0 3px var(--red-soft);
}
.signin-error {
  min-height: 18px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--red);
  font-family: var(--font-mono);
}
.signin-error:not(:empty) {
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--red-soft);
  border: 1px solid var(--red-line);
}
.signin-foot {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.signin-foot::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent);
}
.signin-foot[data-state="checking"]::before {
  background: var(--amber);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 25%, transparent);
}
.signin-foot[data-state="error"] {
  color: var(--red);
}
.signin-foot[data-state="error"]::before {
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app {
  height: 100dvh;
  min-height: 600px;
  display: grid;
  grid-template-columns: var(--rail-w, 58px) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  background: var(--bg);
}
.app > .nav-rail { grid-column: 1; grid-row: 1 / -1; }
.app > .topbar { grid-column: 2; grid-row: 1; }
.app > .workspace,
.app > .page-view { grid-column: 2; grid-row: 2; }
:root[data-theme="light"] .app {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent-soft) 34%, var(--bg)) 0%,
      var(--bg) 34%,
      color-mix(in srgb, var(--green-soft) 18%, var(--bg)) 100%);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent-soft) 28%, var(--surface-2)) 0%,
      var(--surface-2) 55%,
      var(--surface-2) 100%),
    var(--surface-2);
  box-shadow: 0 1px 0 var(--line), 0 6px 18px -10px rgba(15, 18, 26, 0.08);
}
:root[data-theme="dark"] .topbar {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent-soft) 35%, var(--surface-2)) 0%,
      var(--surface-2) 50%,
      color-mix(in srgb, var(--surface) 50%, var(--surface-2)) 100%),
    var(--surface-2);
  box-shadow: 0 1px 0 var(--line), 0 10px 22px -10px rgba(0, 0, 0, 0.55);
}
:root[data-theme="light"] .topbar {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent-soft) 48%, var(--surface-2)) 0%,
      color-mix(in srgb, var(--surface) 64%, var(--surface-2)) 58%,
      color-mix(in srgb, var(--green-soft) 14%, var(--surface-2)) 100%),
    linear-gradient(90deg,
      color-mix(in srgb, var(--accent-soft) 42%, transparent) 0%,
      color-mix(in srgb, var(--green-soft) 34%, transparent) 100%),
    var(--surface-2);
  box-shadow: 0 1px 0 var(--line), 0 8px 22px -14px rgba(15, 18, 26, 0.14);
}
.workspace-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px 0 8px;
  margin-left: 4px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
  min-width: 0;
  cursor: pointer;
}
.workspace-menu:hover { background: var(--surface-2); border-color: var(--line); }
.workspace-menu .ws-mark {
  width: 30px; height: 30px;
  border-radius: 7px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--ink-navy) 0%, color-mix(in srgb, var(--ink-navy) 80%, var(--cobalt)) 100%);
  overflow: hidden;
  flex: 0 0 auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 1px 2px rgba(0,0,0,0.18);
}
.workspace-menu .ws-mark img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.workspace-menu .ws-meta {
  min-width: 0;
  display: grid;
  gap: 2px;
  line-height: 1.15;
}
.workspace-menu .ws-name {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}
.workspace-menu .ws-role {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.workspace-menu .ws-caret {
  width: 14px; height: 14px;
  color: var(--muted-2);
  margin-left: auto;
  flex: 0 0 auto;
}
.workspace-menu .ws-caret svg { width: 14px; height: 14px; }

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--muted);
  transition: border-color .15s, background .15s;
}
.topbar-search:focus-within {
  background: var(--surface);
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.topbar-search svg { width: 15px; height: 15px; color: var(--muted); flex: 0 0 auto; }
.topbar-search input {
  flex: 1; min-width: 0; height: 100%;
  font-size: 13px;
  color: var(--ink);
  background: none;
  border: 0;
  outline: 0;
}
.topbar-search input::placeholder { color: var(--muted-2); }
.topbar-search .kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-actions .divider {
  width: 1px; height: 22px;
  background: var(--line);
  margin: 0 4px;
}

/* icon button */
.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.active { background: var(--surface-3); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-2); }
.btn:active { background: var(--surface-3); }
.btn.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: color-mix(in srgb, var(--accent) 88%, black);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 1px 2px rgba(15,18,26,0.08);
}
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 92%, black); }
.btn.primary.google-signin {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.btn.primary.google-signin:hover {
  background: var(--surface-2);
  border-color: var(--accent-line);
}
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { color: var(--red); border-color: var(--red-line); background: var(--surface); }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 38px; padding: 0 16px; font-size: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }
.btn.refreshing svg {
  animation: refresh-spin .7s cubic-bezier(.4, 0, .2, 1);
}

/* eyebrow */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  padding: 4px 8px 4px 7px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  white-space: nowrap;
  line-height: 1;
}
.pill .dot {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--muted);
  flex: 0 0 auto;
}
.pill.danger { color: var(--red); background: var(--red-soft); border-color: var(--red-line); }
.pill.danger .dot { background: var(--red); }
.pill.review { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }
.pill.review .dot { background: var(--amber); }
.pill.ready { color: var(--green); background: var(--green-soft); border-color: var(--green-line); }
.pill.ready .dot { background: var(--green); }
.pill.active { color: var(--blue); background: var(--blue-soft); border-color: color-mix(in srgb, var(--blue) 30%, var(--line)); }
.pill.active .dot { background: var(--blue); }
.pill.collecting { color: var(--accent-ink); background: var(--accent-soft); border-color: var(--accent-line); }
.pill.collecting .dot { background: var(--accent); }
.pill.error { color: var(--red); background: var(--red-soft); border-color: var(--red-line); }
.pill.error .dot { background: var(--red); }
.pill.neutral { color: var(--ink-2); background: var(--surface-2); border-color: var(--line); }

/* ============================================================
   WORKSPACE — 3 panels
   ============================================================ */
.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 360px;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}
.workspace > .panel {
  min-height: 0;
  min-width: 0;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.workspace > .panel + .panel { border-left: 1px solid var(--line); }

.panel-head {
  height: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex: 0 0 auto;
}
:root[data-theme="dark"] .panel-head {
  background: var(--surface-2);
}
:root[data-theme="light"] .panel-head,
:root[data-theme="light"] .chat-head,
:root[data-theme="light"] .queue-tabs,
:root[data-theme="light"] .inspector-tabs {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent-soft) 24%, var(--surface)) 0%,
      var(--surface) 62%,
      color-mix(in srgb, var(--green-soft) 10%, var(--surface-2)) 100%);
}
.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1;
}
.panel-head .head-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   QUEUE PANEL
   ============================================================ */
.queue-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--accent-soft) 35%, var(--surface)) 0%,
    var(--surface) 220px,
    var(--surface) 100%);
}
:root[data-theme="light"] .queue-panel {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent-soft) 44%, var(--surface)) 0%,
      color-mix(in srgb, var(--surface) 82%, var(--green-soft)) 260px,
      var(--surface) 100%);
}
.queue-panel > .panel-head,
.queue-panel > .queue-search,
.queue-panel > .queue-tabs { flex: 0 0 auto; }
.queue-panel > .case-list { flex: 1 1 0; min-height: 0; }

.queue-search {
  padding: 8px 12px 10px;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.search-input {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
.search-input:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-input input {
  flex: 1; min-width: 0; height: 100%;
  font-size: 13px; color: var(--ink);
}
.search-input input::placeholder { color: var(--muted-2); }

.queue-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  padding: 0 8px;
  height: 38px;
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 18px), transparent);
          mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 18px), transparent);
}
.queue-tabs::-webkit-scrollbar { display: none; }
.queue-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0 9px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: color .12s;
}
.queue-tab:hover { color: var(--ink-2); }
.queue-tab.active { color: var(--ink); }
.queue-tab.active::after {
  content: "";
  position: absolute;
  left: 7px; right: 7px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}
.queue-tab .tab-count {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  letter-spacing: 0.04em;
  line-height: 1;
}
.queue-tab.active .tab-count { background: var(--ink); color: var(--bg); }

/* queue toolbar trigger */
.queue-toolbar {
  padding: 8px 12px 10px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  flex: 0 0 auto;
}
.queue-search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  padding: 0 8px 0 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  text-align: left;
  color: var(--ink);
  transition: border-color .12s, background .12s;
  min-width: 0;
}
.queue-search-trigger:hover { border-color: var(--line-2); background: var(--surface-2); }
.qst-placeholder { color: var(--muted-2); font-size: 13px; flex: 1; min-width: 0; }
.qst-query { color: var(--ink); font-size: 13px; flex: 1; min-width: 0; }
.qst-kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  flex: 0 0 auto;
}

/* spotlight palette */
.spotlight {
  position: fixed;
  z-index: 95;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: spotlight-in .14s cubic-bezier(.4,0,.2,1);
  max-height: 70vh;
}
@keyframes spotlight-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.995); }
  to { opacity: 1; transform: none; }
}
.spotlight-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.spotlight-input svg { width: 17px; height: 17px; color: var(--muted); flex: 0 0 auto; }
.spotlight-input input {
  flex: 1; min-width: 0; height: 28px;
  font-size: 15px; color: var(--ink);
  background: none; border: 0; outline: 0;
}
.spotlight-input input::placeholder { color: var(--muted-2); }
.spotlight-esc {
  font-family: var(--font-mono);
  font-size: 9.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}
.spotlight-section { padding: 8px 6px; }
.spotlight-section-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 4px 10px 6px;
}
.spotlight-list { display: flex; flex-direction: column; gap: 1px; }
.spotlight-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px 8px 8px;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  color: var(--ink-2);
  transition: background .1s, color .1s;
}
.spotlight-item:hover, .spotlight-item.highlighted {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
:root[data-theme="dark"] .spotlight-item:hover,
:root[data-theme="dark"] .spotlight-item.highlighted { color: var(--ink); }
.spotlight-item-icon {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  color: var(--muted-2);
  margin-left: 6px;
}
.spotlight-item-icon svg { width: 14px; height: 14px; }
.spotlight-item.current .spotlight-item-icon { color: var(--accent); }
.spotlight-item-label {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.spotlight-item.current .spotlight-item-label { font-weight: 600; }
.spotlight-item-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  letter-spacing: 0.04em;
  line-height: 1;
}
.spotlight-item.current .spotlight-item-count {
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 80%, black);
  color: var(--accent-fg);
}
.spotlight-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.spotlight-foot kbd {
  font-family: var(--font-mono);
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  margin-right: 4px;
}

.case-list {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0 30px;
}
.case-list:empty::after {
  content: "No cases match this filter.";
  display: block;
  padding: 30px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.case-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  padding: 12px 14px 12px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background .1s;
  text-align: left;
  width: 100%;
}
.case-card::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: transparent;
  transition: background .15s;
}
.case-card:hover { background: var(--surface-2); }
.case-card.active { background: var(--accent-soft); }
.case-card.active::before { background: var(--accent); }
.case-card .case-top {
  display: flex; align-items: center;
  gap: 8px; min-width: 0;
  grid-column: 1 / -1;
}
.case-card .case-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.case-card .case-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted-2);
  flex: 0 0 auto;
}
.case-card .case-preview {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  grid-column: 1 / -1;
}
.case-card .case-tags {
  display: flex; align-items: center;
  gap: 6px; flex-wrap: wrap;
  margin-top: 2px;
  grid-column: 1 / -1;
}
.case-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 18px;
  padding: 3px 6px;
  border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1;
}
.case-tag-icon { display: inline-flex; align-items: center; }
.case-tag-icon svg { width: 11px; height: 11px; }
.case-tag.channel-telegram { color: oklch(0.55 0.15 235); }
.case-tag.channel-whatsapp { color: oklch(0.55 0.14 145); }
.case-tag.channel-web { color: var(--muted); }
:root[data-theme="dark"] .case-tag.channel-telegram { color: oklch(0.82 0.15 235); }
:root[data-theme="dark"] .case-tag.channel-whatsapp { color: oklch(0.82 0.14 145); }

/* ============================================================
   CHAT PANEL
   ============================================================ */
.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
}
.chat-panel > .chat-head,
.chat-panel > .banner,
.chat-panel > .composer { flex: 0 0 auto; }
.chat-panel > .transcript { flex: 1 1 0; min-height: 0; }

.chat-head {
  min-height: 64px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
:root[data-theme="dark"] .chat-head {
  background: var(--surface-2);
}
.chat-head .h-title { display: grid; gap: 4px; min-width: 0; }
.chat-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-head .h-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  flex-wrap: wrap;
}
.chat-head .h-meta #sessionLine {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.chat-head .h-meta .sep {
  width: 3px; height: 3px;
  border-radius: 999px;
  background: var(--muted-2);
  flex: 0 0 auto;
  margin: 0 2px;
}
.chat-head .h-meta .channel-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
}
.chat-head .h-meta .channel-icon { display: inline-flex; align-items: center; }
.chat-head .h-meta .channel-icon svg { width: 11px; height: 11px; }
.channel-chip.channel-whatsapp {
  color: oklch(0.46 0.14 145);
  background: color-mix(in srgb, var(--green-soft) 58%, var(--surface));
  border-color: var(--green-line);
}
.channel-chip.channel-telegram {
  color: oklch(0.48 0.16 235);
  background: color-mix(in srgb, var(--blue-soft) 62%, var(--surface));
  border-color: color-mix(in srgb, var(--blue) 28%, var(--line));
}
.channel-chip.channel-web {
  color: var(--ink-2);
  background: var(--surface-2);
}
:root[data-theme="dark"] .channel-chip.channel-whatsapp {
  color: oklch(0.82 0.15 145);
  background: color-mix(in srgb, var(--green-soft) 52%, var(--surface));
  border-color: var(--green-line);
}
:root[data-theme="dark"] .channel-chip.channel-telegram {
  color: oklch(0.82 0.15 235);
  background: color-mix(in srgb, var(--blue-soft) 55%, var(--surface));
  border-color: color-mix(in srgb, var(--blue) 36%, var(--line));
}
:root[data-theme="dark"] .channel-chip.channel-web { color: var(--ink); }

.handle-chip {
  display: inline-block;
  min-height: 22px;
  max-width: min(260px, 100%);
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.handle-chip.channel-whatsapp {
  color: oklch(0.46 0.14 145);
  border-color: var(--green-line);
}
.handle-chip.channel-telegram {
  color: oklch(0.48 0.16 235);
  border-color: color-mix(in srgb, var(--blue) 30%, var(--line));
}
.handle-chip.channel-web { color: var(--ink-2); }
:root[data-theme="dark"] .handle-chip.channel-whatsapp { color: oklch(0.82 0.15 145); }
:root[data-theme="dark"] .handle-chip.channel-telegram { color: oklch(0.82 0.15 235); }

.conv-id {
  display: inline-block;
  min-height: 22px;
  max-width: min(200px, 100%);
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.chat-head .h-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.banner {
  margin: 0;
  padding: 10px 16px;
  border: 0;
  border-bottom: 1px solid var(--amber-line);
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--amber-soft) 90%, var(--surface)) 0%,
    color-mix(in srgb, var(--amber-soft) 70%, var(--surface)) 100%);
  color: oklch(0.35 0.1 70);
  display: none;
  gap: 10px;
  align-items: center;
  font-size: 12.5px;
  line-height: 1.4;
}
.banner.show { display: flex; }
.banner.danger {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--red-soft) 90%, var(--surface)) 0%,
    color-mix(in srgb, var(--red-soft) 70%, var(--surface)) 100%);
  border-bottom-color: var(--red-line);
  color: oklch(0.4 0.13 25);
}
.banner.info {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--accent-soft) 90%, var(--surface)) 0%,
    color-mix(in srgb, var(--accent-soft) 70%, var(--surface)) 100%);
  border-bottom-color: var(--accent-line);
  color: var(--accent-ink);
}
:root[data-theme="dark"] .banner { color: oklch(0.92 0.1 75); }
:root[data-theme="dark"] .banner.danger { color: oklch(0.94 0.13 25); }
:root[data-theme="dark"] .banner.info { color: var(--ink); }
.banner strong { font-weight: 600; }

/* transcript */
.transcript {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 16px 16px;
  display: grid;
  align-content: start;
  gap: 4px;
  background: var(--surface);
}
:root[data-theme="dark"] .transcript {
  background:
    linear-gradient(180deg, var(--surface-sunken) 0%, transparent 80px),
    var(--surface-sunken);
}
:root[data-theme="light"] .transcript {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent-soft) 38%, var(--surface-sunken)) 0%,
      transparent 92px),
    linear-gradient(135deg,
      color-mix(in srgb, var(--surface) 92%, var(--accent-soft)) 0%,
      var(--surface) 54%,
      color-mix(in srgb, var(--surface) 90%, var(--green-soft)) 100%);
}
.empty-state {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.empty-state strong {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  font-style: italic;
  color: var(--ink);
  margin-bottom: 6px;
  font-weight: 400;
}

/* messages — customer on the left, our side (AI + operators) on the right */
.msg {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  max-width: 560px;
  padding: 3px 0;
}
.msg.from-me { justify-self: end; }
.msg .msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}
.msg .msg-head .actor {
  color: var(--ink-2);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.msg .role-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-family: var(--font-mono);
  font-weight: 500;
}
.msg .role-badge.assistant { color: var(--accent-ink); background: var(--accent-soft); border-color: var(--accent-line); }
.msg .role-badge.human { color: var(--green); background: var(--green-soft); border-color: var(--green-line); }
.msg .role-badge.note-badge { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }
.msg .bubble {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 8px 12px 7px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.msg .bubble-sender {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 1px 0 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-text, var(--accent-ink));
}
.msg.from-human .bubble-sender { color: var(--green); }
.msg .bubble-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg .bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
}
.msg .bubble-meta .ticks { display: inline-flex; align-items: center; color: var(--muted-2); }
.msg .bubble-meta .ticks svg { width: 15px; height: 15px; }
.msg .bubble-meta .ticks.read { color: var(--accent-text, var(--accent)); }
.msg .bubble-meta .ticks.failed { color: var(--red); }
.msg.from-customer .bubble {
  border-top-left-radius: 4px;
}
.msg.from-assistant .bubble {
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface));
  border-color: var(--accent-line);
  border-top-right-radius: 4px;
}
.msg.from-human .bubble {
  background: color-mix(in srgb, var(--green-soft) 75%, var(--surface));
  border-color: var(--green-line);
  border-top-right-radius: 4px;
}
:root[data-theme="dark"] .msg.from-assistant .bubble {
  background: color-mix(in srgb, var(--accent-soft) 80%, var(--surface));
}
:root[data-theme="dark"] .msg.from-human .bubble {
  background: color-mix(in srgb, var(--green-soft) 80%, var(--surface));
}
.msg.note-msg {
  max-width: 540px;
  justify-self: center;
}
.msg.note-msg .bubble {
  background: var(--amber-soft);
  border-color: var(--amber-line);
  border-style: dashed;
  color: oklch(0.4 0.1 75);
  font-size: 13px;
  text-align: center;
}
:root[data-theme="dark"] .msg.note-msg .bubble { color: oklch(0.85 0.1 75); }
.msg.error-msg .bubble {
  color: var(--red);
  border-color: var(--red-line);
  background: var(--red-soft);
}

.msg-assets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 6px;
}
.asset-card {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface);
}
.asset-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--surface-2);
}
.asset-card .asset-label {
  display: block;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* composer */
.composer {
  border-top: 1px solid var(--line);
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent-soft) 18%, var(--surface-2)) 0%,
      var(--surface-2) 50%,
      var(--surface-sunken) 100%);
  padding: 12px 16px 14px;
  box-shadow: inset 0 1px 0 var(--line), inset 0 8px 14px -10px rgba(0,0,0,0.06);
}
:root[data-theme="dark"] .composer {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent-soft) 35%, var(--bg)) 0%,
      var(--bg) 55%,
      color-mix(in srgb, var(--surface-sunken) 40%, var(--bg)) 100%);
  box-shadow: inset 0 1px 0 var(--line), inset 0 12px 18px -10px rgba(0,0,0,0.45);
}
:root[data-theme="light"] .composer {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent-soft) 34%, var(--surface-2)) 0%,
      color-mix(in srgb, var(--surface-2) 82%, var(--green-soft)) 55%,
      color-mix(in srgb, var(--surface-sunken) 88%, var(--accent-soft)) 100%);
  box-shadow: inset 0 1px 0 var(--line), inset 0 12px 18px -14px rgba(15,18,26,0.12);
}
.composer-mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.role-switch {
  display: none;
  padding: 3px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  gap: 2px;
}
.role-switch.enabled { display: inline-flex; }
.role-switch button {
  height: 26px;
  padding: 0 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.role-switch button .dot { width: 5px; height: 5px; border-radius: 999px; background: var(--muted-2); }
.role-switch button:hover { color: var(--ink-2); }
.role-switch button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.role-switch button.active[data-role="customer"] .dot { background: var(--blue); }
.role-switch button.active[data-role="operator"] .dot { background: var(--green); }

.composer-status {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.composer-box {
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  transition: border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
}
.composer-box:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.composer-box.mode-operator {
  background: color-mix(in srgb, var(--green-soft) 50%, var(--surface));
  border-color: var(--green-line);
}
.composer-box.mode-operator:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent);
}
.composer-box textarea {
  resize: none;
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
  min-height: 60px;
  max-height: 200px;
  font-family: var(--font-ui);
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}
.composer-box textarea::placeholder { color: var(--muted-2); }
.composer-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 10px;
  border-top: 1px solid var(--line);
}
.composer-bottom .media-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}
.composer-bottom .spacer { flex: 1; }
.composer-bottom .hint {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted-2);
  margin-right: 4px;
}

/* media chip */
.media-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  max-width: min(520px, 100%);
}
.media-chip-item {
  position: relative;
  display: block;
  width: 74px;
  height: 74px;
  padding: 0;
  overflow: hidden;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-ink);
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
}
.media-chip-preview {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.media-chip-label {
  position: absolute;
  inset: auto 0 0;
  height: 22px;
  padding: 5px 6px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: white;
  font-size: 10.5px;
  line-height: 1;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.7));
}
.media-chip-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  color: white;
  background: rgba(12, 15, 24, 0.72);
  box-shadow: 0 5px 14px rgba(12, 15, 24, 0.24);
}
.media-chip-remove svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}
.media-chip-remove:hover {
  background: rgba(12, 15, 24, 0.88);
}

/* ============================================================
   DETAILS PANEL
   ============================================================ */
.inspector-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
}
.inspector-panel > .panel-head,
.inspector-panel > .inspector-tabs { flex: 0 0 auto; }
.inspector-panel > .inspector-body { flex: 1 1 0; min-height: 0; }

.inspector-tabs {
  display: flex;
  align-items: center;
  padding: 0 4px 0 12px;
  border-bottom: 1px solid var(--line);
  gap: 2px;
  height: var(--topbar-h);
  background: var(--surface);
}
.inspector-tab {
  position: relative;
  height: 100%;
  padding: 0 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: -0.005em;
  background: none;
  border: 0;
}
.inspector-tab:hover { color: var(--ink-2); }
.inspector-tab.active { color: var(--ink); }
.inspector-tab.active::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}
.inspector-tabs .details-refresh {
  margin-left: auto;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--muted);
  border: 0;
  background: transparent;
  transition: background .12s, color .12s;
}
.inspector-tabs .details-refresh:hover { background: var(--surface-2); color: var(--ink); }
.inspector-tabs .details-refresh svg {
  width: 15px; height: 15px;
  transition: transform .15s;
}
.inspector-tabs .details-refresh:active svg { transform: rotate(30deg) scale(0.92); }
.inspector-tabs .details-refresh.spinning svg {
  animation: refresh-spin .7s cubic-bezier(.4, 0, .2, 1);
}
@keyframes refresh-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.inspector-body {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
}
:root[data-theme="light"] .inspector-body {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent-soft) 18%, var(--surface)) 0%,
      var(--surface) 180px,
      color-mix(in srgb, var(--green-soft) 12%, var(--surface)) 100%);
}
.section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
}
.section:last-child { border-bottom: 0; }
.section .section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.section .section-head h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* summary block */
.summary-block { display: grid; gap: 10px; }
.summary-tag {
  align-self: start;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 6px 10px 6px 12px;
  border-radius: 6px;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent-soft) 80%, var(--surface)) 0%,
    color-mix(in srgb, var(--accent-soft) 40%, var(--surface)) 100%);
  border: 1px solid var(--accent-line);
  border-left: 3px solid var(--accent);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px;
  font-weight: 400;
  color: var(--accent-ink);
  line-height: 1.25;
  word-break: break-word;
}
.summary-tag.danger {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--red-soft) 80%, var(--surface)) 0%,
    color-mix(in srgb, var(--red-soft) 40%, var(--surface)) 100%);
  border-color: var(--red-line);
  border-left-color: var(--red);
  color: var(--red);
}
:root[data-theme="dark"] .summary-tag { color: var(--ink); }
:root[data-theme="dark"] .summary-tag.danger { color: var(--ink); }
.summary-body {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.field-grid.cols-1 { grid-template-columns: 1fr; }
.field { display: grid; gap: 4px; }
.field label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.field .value {
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.field .value.mono { font-family: var(--font-mono); font-size: 12.5px; }
.field .value.empty { color: var(--muted-2); font-style: italic; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.chip.ok { color: var(--green); background: var(--green-soft); border-color: var(--green-line); }
.chip.warn { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }
.chip.fail { color: var(--red); background: var(--red-soft); border-color: var(--red-line); }

.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.danger-alert {
  border: 1px solid var(--red-line);
  border-radius: var(--r-md);
  background: var(--red-soft);
  color: var(--red);
  padding: 10px 11px;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.assignment-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}
.select-shell {
  display: flex;
  height: 32px;
  align-items: center;
  padding: 0 10px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  gap: 8px;
  cursor: pointer;
  min-width: 0;
}
.select-shell:hover { background: var(--surface-2); }
.select-shell select {
  flex: 1; min-width: 0;
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0; outline: 0;
  color: var(--ink);
}
.select-shell select:disabled { opacity: .5; cursor: not-allowed; }
.select-shell select option { background: var(--surface); color: var(--ink); }

.mini-list {
  list-style: none;
  margin: 0; padding: 0;
  display: grid; gap: 6px;
}
.mini-list li {
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.agent-entry { display: grid; gap: 8px; }
.agent-entry textarea {
  width: 100%;
  min-height: 80px;
  max-height: 180px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  color: var(--ink);
  font-size: 13px;
  outline: 0;
}
.agent-entry textarea:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.agent-entry-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  display: none; place-items: center;
  padding: 24px;
  background: rgb(15 18 26 / 0.45);
  backdrop-filter: blur(2px);
  animation: backdrop-in .15s ease;
}
.modal-backdrop.open { display: grid; }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(520px, 100%);
  max-height: min(720px, 92dvh);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  animation: modal-in .2s cubic-bezier(.4,0,.2,1);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.modal-head, .modal-foot {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.modal-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}
.modal-head h2 {
  margin: 0; flex: 1;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.modal-body {
  overflow-y: auto;
  padding: 18px;
  display: grid;
  gap: 14px;
}

/* settings rows */
.setting-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.setting-row strong {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
}
.setting-row > div > span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}
.switch {
  position: relative;
  display: inline-block;
  width: 38px; height: 22px;
  flex: 0 0 auto;
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; inset: 0; }
.switch span {
  position: absolute; inset: 0;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background .15s;
}
.switch span::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform .15s, background .15s;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); background: #fff; }
.switch input:disabled + span { opacity: .55; }

/* workspace menu dropdown */
.ws-menu-dropdown {
  position: fixed;
  z-index: 90;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  display: none;
  gap: 2px;
  animation: modal-in .12s ease;
}
.ws-menu-dropdown.open { display: grid; }
.ws-menu-dropdown .menu-header {
  padding: 10px 10px 8px;
  display: grid;
  gap: 2px;
}
.ws-menu-dropdown .menu-header strong {
  font-size: 13.5px;
  font-weight: 600;
}
.ws-menu-dropdown .menu-header span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.ws-menu-dropdown .menu-divider { height: 1px; background: var(--line); margin: 4px 2px; }
.ws-menu-dropdown .menu-section-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 8px 8px 4px;
}
.ws-menu-dropdown .menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-xs);
  font-size: 13px;
  color: var(--ink-2);
  width: 100%;
  text-align: left;
}
.ws-menu-dropdown .menu-item:hover { background: var(--surface-2); color: var(--ink); }
.ws-menu-dropdown .menu-item.danger { color: var(--red); }
.ws-menu-dropdown .menu-item.danger:hover { background: var(--red-soft); }
.ws-menu-dropdown .menu-item svg { width: 14px; height: 14px; color: var(--muted); }
.ws-menu-dropdown .menu-item.danger svg { color: var(--red); }

/* role preview (in dropdown) */
.role-preview {
  padding: 4px 8px 8px;
  display: none;
  gap: 5px;
}
.role-preview.enabled { display: grid; }
.role-preview label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.role-preview select {
  width: 100%;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}

/* ---------- density variants ---------- */
:root[data-density="compact"] {
  --row-h: 30px;
  --pad-x: 12px;
  --pad-y: 8px;
  --gap: 10px;
  --topbar-h: 50px;
}

/* ---------- appearance modal ---------- */
.appearance-section {
  display: grid;
  gap: 8px;
}
.appearance-radios {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.appearance-option {
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: background .12s, border-color .12s, color .12s;
}
.appearance-option:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.appearance-option.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-ink);
  font-weight: 600;
}

/* ============================================================
   NOTIFICATIONS
   ============================================================ */
.bell-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  display: grid; place-items: center;
  pointer-events: none;
  border: 2px solid var(--surface-2);
  box-sizing: content-box;
  line-height: 1;
}
.notif-dropdown {
  position: absolute;
  z-index: 90;
  right: 0; top: 42px;
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: 480px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  display: none;
  animation: modal-in .12s ease;
}
.notif-dropdown.open { display: block; }
.notif-header {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
}
.notif-mark-all {
  font-size: 11px;
  color: var(--accent-ink);
  font-weight: 500;
  background: none;
  border: 0;
}
.notif-mark-all:hover { text-decoration: underline; }
.notif-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.notif-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  position: relative;
  background: transparent;
}
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: color-mix(in srgb, var(--accent-soft) 35%, transparent); }
.notif-item.unread::before {
  content: "";
  position: absolute;
  left: 4px; top: 50%;
  width: 5px; height: 5px;
  border-radius: 999px;
  background: var(--accent);
  transform: translateY(-50%);
}
.notif-body {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.notif-body strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-body span {
  font-size: 12.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.notif-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted-2);
  white-space: nowrap;
  align-self: start;
  margin-top: 3px;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  left: 50%; bottom: 22px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.toast.show { opacity: 1; animation: toast-in .2s ease; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================================
   SCROLLBARS
   ============================================================ */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border: 2px solid var(--surface);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1240px) {
  .workspace { grid-template-columns: 300px minmax(0, 1fr) 340px; }
}
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 280px minmax(0, 1fr) 320px; }
  .topbar-search { max-width: 320px; }
  .topbar-actions .btn > span:not(.dot) { display: none; }
}
@media (max-width: 980px) {
  .workspace { grid-template-columns: 260px minmax(0, 1fr) 300px; }
  .topbar-search { max-width: 220px; }
  .topbar-search .kbd { display: none; }
}
@media (max-width: 900px) {
  html, body { overflow-x: hidden; }
  body { overflow-y: auto; }
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  .topbar-search { display: none; }
  .app {
    min-height: 100dvh;
    height: auto;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
    gap: 0;
  }
  .workspace > .panel + .panel { border-left: 0; border-top: 1px solid var(--line); }
  .workspace > .panel { min-height: 520px; }
  .mobile-tabs {
    display: flex !important;
    align-items: center;
    gap: 0;
    height: 42px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .mobile-tabs::-webkit-scrollbar { display: none; }
  .mobile-tab {
    position: relative;
    height: 100%;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    background: none;
    border: 0;
    white-space: nowrap;
  }
  .mobile-tab.active { color: var(--ink); }
  .mobile-tab.active::after {
    content: "";
    position: absolute;
    left: 10px; right: 10px;
    bottom: -1px;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
  }
  .workspace > .panel:not(.mobile-active) { display: none; }
  .workspace > .panel.mobile-active { display: flex; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar-actions .btn > span:not(.dot) { display: none; }
  .workspace-menu .ws-meta { display: none; }
  .field-grid { grid-template-columns: 1fr; }
  .chat-head { grid-template-columns: 1fr; }
  .chat-head .h-actions { justify-content: flex-start; }
}

.mobile-tabs { display: none; }

/* ============================================================
   Console views — Inbox / Customers / Templates
   ============================================================ */
/* far-left icon rail (reference: contact-center consoles) */
.nav-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  border-right: 1px solid var(--line);
  background: var(--ink);
}
:root[data-theme="dark"] .nav-rail {
  background: var(--surface-sunken);
}
.rail-brand {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--ink-navy) 70%, var(--cobalt)) 0%, var(--ink-navy) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.rail-brand img { width: 26px; height: 26px; object-fit: contain; }
.nav-rail .view-tab {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: none;
  color: rgba(251, 248, 243, 0.55);
  cursor: pointer;
  transition: color .12s, background .12s;
}
:root[data-theme="dark"] .nav-rail .view-tab { color: var(--muted); }
.nav-rail .view-tab svg { width: 19px; height: 19px; }
.nav-rail .view-tab .rail-label {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 9px;
  border-radius: var(--r-sm);
  background: var(--ink-navy);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
  box-shadow: var(--shadow-md);
  z-index: 60;
}
.nav-rail .view-tab:hover .rail-label { opacity: 1; }
.nav-rail .view-tab:hover { color: var(--paper); background: rgba(251, 248, 243, 0.08); }
:root[data-theme="dark"] .nav-rail .view-tab:hover { color: var(--ink); background: var(--surface-2); }
.nav-rail .view-tab.active {
  color: #ffffff;
  background: var(--accent);
}
.nav-rail .view-tab.active::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
}
:root[data-theme="dark"] .nav-rail .view-tab.active { color: var(--accent-fg); }
.view-tab[hidden] { display: none; }

.workspace[hidden],
.page-view[hidden] { display: none !important; }

.page-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 22px clamp(16px, 4vw, 40px) 14px;
}
.page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.page-sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.page-actions { display: flex; gap: 8px; }

.stage-filter {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 clamp(16px, 4vw, 40px) 12px;
}
.stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.stage-chip:hover { color: var(--ink-2); border-color: var(--line-strong); }
.stage-chip.active {
  color: var(--accent-ink);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.stage-chip .count { color: var(--muted-2); }
.stage-chip.active .count { color: var(--accent-ink); }

.page-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 0;
  flex: 1;
}
.page-body.single { grid-template-columns: minmax(0, 1fr); }
.data-table-wrap {
  min-height: 0;
  overflow: auto;
  padding: 0 clamp(16px, 4vw, 40px) 28px;
}
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  font-size: 13px;
}
.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink-2);
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { cursor: pointer; transition: background .1s; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr.selected { background: var(--accent-soft); }
.data-table .cell-strong { color: var(--ink); font-weight: 600; }
.data-table .cell-sub { display: block; color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.data-table .cell-mono { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.data-table .cell-body {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-table select.inline-select { cursor: pointer; }

.inline-select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  color: var(--ink);
  font-size: 12px;
}
.inline-select:disabled { opacity: 0.6; cursor: default; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.status-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); }
.status-badge.ok { color: var(--green); background: var(--green-soft); border-color: var(--green-line); }
.status-badge.ok .dot { background: var(--green); }
.status-badge.warn { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }
.status-badge.warn .dot { background: var(--amber); }
.status-badge.bad { color: var(--red); background: var(--red-soft); border-color: var(--red-line); }
.status-badge.bad .dot { background: var(--red); }
.status-badge.brand { color: var(--accent-ink); background: var(--accent-soft); border-color: var(--accent-line); }
.status-badge.brand .dot { background: var(--accent); }

.record-drawer {
  width: min(360px, 40vw);
  min-height: 0;
  overflow: auto;
  margin: 0 clamp(16px, 4vw, 40px) 28px 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 18px;
}
.record-drawer[hidden] { display: none !important; }
.record-drawer h3 {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
}
.record-drawer .drawer-sub {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.record-drawer .drawer-section { margin-top: 16px; }
.record-drawer .drawer-section > h4 {
  margin: 0 0 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.drawer-close { float: right; }
.drawer-tags-input { width: 100%; margin-top: 6px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
select.text-input { cursor: pointer; }
textarea.text-input { resize: vertical; min-height: 90px; }
.template-submit-row { margin-top: 6px; }

.setting-row .num-input {
  width: 84px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12.5px;
  text-align: right;
}

.msg .context-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 18px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.page-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 24px;
}

@media (max-width: 900px) {
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; }
  .topbar-search { display: none; }
  .page-body { grid-template-columns: minmax(0, 1fr); }
  .record-drawer {
    position: fixed;
    right: 12px;
    top: calc(var(--topbar-h) + 12px);
    bottom: 12px;
    width: min(360px, calc(100vw - 24px));
    margin: 0;
    box-shadow: var(--shadow-pop);
    z-index: 40;
  }
}

/* ============================================================
   View transitions, queue channel filter, composer actions, emoji
   ============================================================ */
.app > .workspace:not([hidden]),
.app > .page-view:not([hidden]) {
  animation: view-in var(--vt-dur, 240ms) cubic-bezier(0.25, 1, 0.5, 1);
}
@keyframes view-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}
.nav-rail .view-tab { transition: color .16s, background .16s, transform .12s; }
.nav-rail .view-tab:active { transform: scale(0.94); }
@media (prefers-reduced-motion: reduce) {
  .app > .workspace:not([hidden]),
  .app > .page-view:not([hidden]) { animation: none; }
  .nav-rail .view-tab { transition: none; }
}

.queue-tabs { scroll-behavior: smooth; }

.queue-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.queue-toolbar .queue-search-trigger { width: 100%; }
.channel-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.channel-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.channel-chip svg { width: 12px; height: 12px; }
.channel-chip:hover { color: var(--ink-2); border-color: var(--line-strong); }
.channel-chip.active {
  color: var(--accent-ink);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.case-card .unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.case-card.unread .case-name { font-weight: 700; color: var(--ink); }

.composer-box { position: relative; }
.composer-end {
  color: var(--muted);
}
.composer-end:hover { color: var(--red); border-color: var(--red-line); background: var(--red-soft); }
.composer-passback {
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.composer-passback:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); }
.composer-end svg, .composer-passback svg { width: 13px; height: 13px; }

.emoji-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 8px;
  width: 312px;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  padding: 10px;
  z-index: 50;
}
.emoji-popover[hidden] { display: none !important; }
.emoji-group-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 8px 2px 4px;
}
.emoji-group-label:first-child { margin-top: 0; }
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}
.emoji-grid button {
  border: 0;
  background: none;
  border-radius: var(--r-sm);
  font-size: 19px;
  line-height: 1;
  padding: 5px 0;
  cursor: pointer;
  transition: background .1s, transform .1s;
}
.emoji-grid button:hover { background: var(--surface-2); transform: scale(1.15); }

.case-preview mark, .qst-query mark {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 2px;
  padding: 0 1px;
}

/* ---------- contacts: search, avatars, selection, row actions ---------- */
.page-search {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  min-width: 210px;
}
.page-search svg { width: 13px; height: 13px; color: var(--muted); flex: 0 0 auto; }
.page-search input {
  border: 0;
  background: none;
  outline: none;
  font-size: 12.5px;
  width: 100%;
  color: var(--ink);
}
.page-search:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
  user-select: none;
}
.cell-customer { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-customer > div { min-width: 0; }

.data-table .row-check { width: 30px; }
.data-table .row-check input { cursor: pointer; accent-color: var(--accent); }
.data-table .row-actions { white-space: nowrap; text-align: right; }
.row-action {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--muted-2);
  cursor: pointer;
  transition: color .12s, background .12s;
}
.row-action svg { width: 14px; height: 14px; }
.row-action:hover { color: var(--ink); background: var(--surface-2); }
.row-action.danger:hover { color: var(--red); background: var(--red-soft); }

.selection-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  padding: 7px 12px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12.5px;
}
.selection-bar .spacer { flex: 1; }

/* ---------- chat avatars ---------- */
.msg.chat-row {
  display: flex;
  align-items: flex-end;
  gap: 7px;
}
.msg.chat-row.from-me { flex-direction: row-reverse; }
.msg-stack { min-width: 0; display: grid; gap: 4px; }
.msg-avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  flex: 0 0 auto;
  overflow: hidden;
  margin-bottom: 2px;
}
.msg-avatar.ai {
  background: var(--ink-navy);
  border-color: var(--ink-navy);
}
.msg-avatar.ai img { width: 17px; height: 17px; object-fit: contain; }
.msg-avatar.operator {
  background: var(--green-soft);
  border-color: var(--green-line);
  color: var(--green);
}

/* ---------- inspector: identity card, handling, collapse ---------- */
.inspector-identity {
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.identity-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 10px;
}
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.identity-text { min-width: 0; display: grid; }
.identity-text strong {
  font-size: 14px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.identity-text span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.handling-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.handling-row > span {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 0 0 auto;
}
.handling-row .inline-select { flex: 1; height: 32px; }

.title-edit .text-input { width: 100%; }

.workspace { transition: grid-template-columns var(--vt-dur, 240ms) cubic-bezier(0.25, 1, 0.5, 1); }
.workspace.details-collapsed { grid-template-columns: 320px minmax(0, 1fr) 0; }
.workspace.details-collapsed .inspector-panel { display: none; }
@media (max-width: 1100px) {
  .workspace.details-collapsed { grid-template-columns: 300px minmax(0, 1fr) 0; }
}
#detailsToggle.active { color: var(--accent-ink); }

/* ---------- inspector polish: flat identity, facts, chat events ---------- */
.inspector-identity {
  margin: -2px -2px 14px;
  padding: 2px 2px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: none;
}
.identity-name {
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: none;
  padding: 1px 6px;
  margin-left: -7px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  width: 100%;
  min-width: 0;
  transition: border-color .12s, background .12s;
}
.identity-name:hover:not(:disabled) { border-color: var(--line); background: var(--surface); }
.identity-name:focus { border-color: var(--accent-line); background: var(--surface); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.identity-name:disabled { color: var(--ink); opacity: 1; }
.identity-facts { display: grid; gap: 5px; margin-top: 10px; }
.identity-fact {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 12.5px;
}
.identity-fact label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
  width: 52px;
  flex: 0 0 auto;
}
.identity-fact span {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
.panel-close { margin-left: auto; }
.inspector-panel .panel-head { display: flex; align-items: center; }

.chat-event {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  max-width: 560px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  text-align: center;
}
.chat-event::before,
.chat-event::after {
  content: "";
  height: 1px;
  width: 34px;
  background: var(--line-strong);
  flex: 0 0 auto;
}

/* ---------- inspector identity v2: breathing room, consistent type ---------- */
.inspector-identity {
  margin: 4px 0 16px;
  padding: 6px 2px 16px;
}
.identity-head {
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.identity-text { gap: 2px; }
.identity-name { font-size: 15px; }
.identity-text span { font-size: 11px; }
.identity-facts {
  gap: 8px;
  margin: 0 0 14px;
}
.identity-fact { align-items: center; }
.identity-fact label { width: 56px; }
.identity-fact span,
.identity-fact-input {
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: var(--ink-2);
}
.identity-fact-input {
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: none;
  padding: 2px 6px;
  margin-left: -7px;
  width: 100%;
  min-width: 0;
  transition: border-color .12s, background .12s;
}
.identity-fact-input:hover:not(:disabled) { border-color: var(--line); background: var(--surface); }
.identity-fact-input:focus { border-color: var(--accent-line); background: var(--surface); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.handling-row {
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.drawer-edit-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

/* identity sits above the tabs, padded off the panel border */
.inspector-identity-host {
  flex: 0 0 auto;
  background: var(--surface);
}
.inspector-identity-host:empty { display: none; }
.inspector-identity-host .inspector-identity {
  margin: 0;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
}
.inspector-identity-host .identity-facts { margin-bottom: 12px; }

/* ---------- automations ---------- */
.kill-switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
}
.modal-wide { width: min(620px, calc(100vw - 32px)); }
.rule-steps-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 8px;
}
.rule-steps-head > span {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.rule-step {
  display: grid;
  grid-template-columns: 64px 86px minmax(0, 1fr) 28px;
  gap: 8px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  margin-bottom: 8px;
}
.rule-step .text-input { height: 32px; padding: 0 8px; font-size: 12.5px; }
.rule-step .step-fields { display: grid; gap: 6px; }
.rule-step textarea.text-input { height: auto; min-height: 34px; padding: 6px 8px; }
.ladder-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent-ink);
}
.ladder-chip + .ladder-chip::before {
  content: "→";
  color: var(--muted-2);
  margin-right: 4px;
}
.upcoming-section { margin-top: 22px; }
.upcoming-title {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
