/* ═══════════════════════════════════════════════════════════════════════════
   JarvisChat Dashboard — Design System (matched to JarvisBook V2)
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Surfaces */
  --bg-base:        #0a0a0f;
  --bg-surface:     #111118;
  --bg-elevated:    #1a1a24;
  --bg-hover:       #1e1e2c;

  /* Borders */
  --border-subtle:  rgba(255,255,255,0.06);
  --border-default: rgba(255,255,255,0.10);
  --border-strong:  rgba(255,255,255,0.18);

  /* Text */
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-disabled:  #334155;

  /* Brand accent — green (chat-native, swaps to per-property in some contexts) */
  --accent:         #4ade80;
  --accent-rgb:     74, 222, 128;
  --accent-dim:     rgba(74,222,128,0.15);
  --accent-hover:   rgba(74,222,128,0.25);
  --accent-strong:  rgba(74,222,128,0.55);

  /* Status / semantic */
  --status-open:       #4ade80;
  --status-closed:     #64748b;
  --status-takeover:   #fbbf24;
  --success:           #22c55e;
  --warning:           #f59e0b;
  --error:             #ef4444;
  --info:              #3b82f6;

  /* Spacing */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;

  /* Radii */
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 16px; --radius-xl: 20px; --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 20px rgba(74,222,128,0.18);

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(.2,.8,.2,1);
  --transition-base: 200ms cubic-bezier(.2,.8,.2,1);
  --transition-slow: 300ms cubic-bezier(.2,.8,.2,1);

  /* Layout */
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 56px;

  --bg-topbar:   rgba(10,10,15,0.7);
  --bg-backdrop: rgba(0,0,0,0.6);
}

/* Light theme override */
[data-theme="light"] {
  --bg-base:        #f6f7fb;
  --bg-surface:     #ffffff;
  --bg-elevated:    #f1f5f9;
  --bg-hover:       #e2e8f0;

  --border-subtle:  rgba(15,23,42,0.06);
  --border-default: rgba(15,23,42,0.12);
  --border-strong:  rgba(15,23,42,0.22);

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #64748b;
  --text-disabled:  #cbd5e1;

  --shadow-sm:   0 1px 3px rgba(15,23,42,0.06);
  --shadow-md:   0 4px 16px rgba(15,23,42,0.08);
  --shadow-lg:   0 12px 36px rgba(15,23,42,0.14);

  --bg-topbar:   rgba(255,255,255,0.85);
  --bg-backdrop: rgba(15,23,42,0.45);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Focus rings */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
button:focus-visible { outline-offset: 1px; }

/* Screen-reader-only */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  background: var(--bg-base);
  color: var(--text-primary);
  font: 14px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02','cv03','cv04','cv11';
  overflow: hidden;
}

button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, textarea, select { font: inherit; color: var(--text-primary); }

/* Autofill defeats */
input:-webkit-autofill, input:-webkit-autofill:hover,
input:-webkit-autofill:focus, input:-webkit-autofill:active,
textarea:-webkit-autofill, select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-elevated) inset !important;
  -webkit-text-fill-color: var(--text-primary) !important;
  caret-color: var(--text-primary);
  transition: background-color 600000s 0s, color 600000s 0s;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 14px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast), transform var(--transition-fast);
  white-space: nowrap; line-height: 1; user-select: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); color: #07140d; font-weight: 600;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); box-shadow: var(--shadow-glow); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-secondary {
  background: var(--bg-elevated); color: var(--text-primary);
  border: 1px solid var(--border-default);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-strong); }
.btn-ghost { color: var(--text-secondary); padding: 8px 12px; }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: rgba(239,68,68,0.12); color: #fca5a5; border: 1px solid rgba(239,68,68,0.25); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.2); color: #fecaca; }
.btn-icon {
  width: 32px; height: 32px; padding: 0; border-radius: var(--radius-md);
  color: var(--text-secondary);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.btn-icon:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon > svg { display: block; }
.btn-icon.warn { color: var(--warning); }
.btn-icon.on   { color: var(--accent); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ─── Form controls ─── */
.input,
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
select, textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
  width: 100%;
}
select {
  padding-right: 30px; appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
}
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--accent-strong);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input[type="color"] {
  width: 44px; height: 32px; padding: 2px; border-radius: var(--radius-md);
  background: var(--bg-elevated); border: 1px solid var(--border-default); cursor: pointer;
}
.field-label {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin-bottom: 6px; font-weight: 500;
}
.field-help { font-size: 11px; color: var(--text-muted); margin-top: 5px; font-style: italic; }

/* ═══ Shell layout ═══ */
.app { display: flex; height: 100vh; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column;
  transition: width var(--transition-base);
  height: 100vh;
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar-brand {
  height: var(--topbar-h);
  display: flex; align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 10px;
  flex-shrink: 0;
}
.sidebar-brand .logo-mark {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #16a34a);
  display: flex; align-items: center; justify-content: center;
  color: #07140d; font-weight: 700; font-size: 14px;
  box-shadow: 0 4px 14px rgba(74,222,128,0.35);
}
.sidebar-brand .logo-text {
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
  opacity: 1; transition: opacity var(--transition-base);
  white-space: nowrap;
}
.sidebar.collapsed .logo-text { opacity: 0; }

.sidebar-nav {
  padding: 8px;
  display: flex; flex-direction: column; gap: 2px;
  flex: 1; overflow-y: auto;
  min-height: 0;
}
.sidebar-section-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); padding: 12px 12px 6px; font-weight: 600;
}
.sidebar.collapsed .sidebar-section-label { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  height: 38px; padding: 0 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
  white-space: nowrap; overflow: hidden;
  border: 0;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}
.nav-item.active::before {
  content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item .nav-icon {
  width: 20px; height: 20px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.nav-item .nav-label { opacity: 1; transition: opacity var(--transition-fast); flex: 1; }
.sidebar.collapsed .nav-item .nav-label { opacity: 0; }
.nav-item .nav-badge {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 10px; font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  min-width: 18px; text-align: center;
}
.nav-item.active .nav-badge { background: var(--accent); color: #07140d; }
.sidebar.collapsed .nav-item .nav-badge { display: none; }
.nav-item .nav-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  flex-shrink: 0;
}
.nav-section-divider {
  height: 1px; background: var(--border-subtle);
  margin: 6px 8px;
}
.sidebar-footer {
  padding: 8px; border-top: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; gap: 2px;
  flex-shrink: 0;
}

/* ─── Topbar ─── */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-topbar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; z-index: 30;
  gap: 12px;
  flex-shrink: 0;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-title {
  font-size: 16px; font-weight: 600; letter-spacing: -0.01em;
}
.topbar-status {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 12px; color: var(--text-secondary);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,222,128,0.18);
}
.status-dot.off { background: var(--text-muted); box-shadow: none; }
.topbar-ai-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 12px; color: var(--text-muted);
}
.topbar-ai-pill .ai-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted);
}
.topbar-ai-pill .ai-dot.on {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,222,128,0.16);
}

/* Audio blocked banner */
.audio-blocked-banner {
  background: linear-gradient(90deg, rgba(245,158,11,0.18), rgba(245,158,11,0.08));
  border-bottom: 1px solid rgba(245,158,11,0.4);
  color: #fbbf24;
  padding: 8px 20px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.audio-blocked-banner:hover {
  background: linear-gradient(90deg, rgba(245,158,11,0.28), rgba(245,158,11,0.14));
}

/* ─── Content ─── */
.main-content {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--bg-base);
}
.view-scroll {
  flex: 1; overflow-y: auto;
  padding: 24px 28px;
}

/* Section headers */
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-title h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.section-title .meta { font-size: 12px; color: var(--text-muted); }
.view-title {
  font-size: 22px; font-weight: 600; letter-spacing: -0.01em;
  margin: 0 0 4px 0;
}
.view-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.panel-tight { padding: 0; overflow: hidden; }
.panel-title {
  margin: 0;
  font-size: 14px; font-weight: 600;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; justify-content: space-between; align-items: center;
}

/* ─── KPI cards ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .kpi-grid { grid-template-columns: 1fr; } }
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: border-color var(--transition-base), transform var(--transition-base),
              box-shadow var(--transition-base);
}
.kpi-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.kpi-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); font-weight: 500;
}
.kpi-value {
  font-size: 32px; font-weight: 700; margin-top: 8px;
  letter-spacing: -0.02em; line-height: 1;
  color: var(--text-primary);
}
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ─── Overview two-column ─── */
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 16px;
}
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

/* Active convo row in overview */
.active-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.active-row:last-child { border-bottom: 0; }
.active-row:hover { background: var(--bg-hover); }
.active-row .ar-dot { width: 8px; height: 8px; border-radius: 50%; }
.active-row .ar-name { font-size: 13px; font-weight: 500; }
.active-row .ar-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.active-row .ar-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* Property health card row */
.health-row {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.health-row:last-child { border-bottom: 0; }
.health-name-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500;
}
.health-stripe {
  width: 4px; height: 18px; border-radius: 2px;
  flex-shrink: 0;
}
.health-meta {
  display: flex; gap: 14px; margin-top: 6px;
  font-size: 11px; color: var(--text-muted);
}
.health-meta strong { color: var(--text-secondary); font-weight: 500; }

/* ═══ Conversations view ═══ */
.convs-split {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 320px 1fr;
}

.conv-pane {
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex; flex-direction: column;
  min-height: 0;
}
.conv-pane-header {
  padding: 12px 16px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.conv-pane-title {
  font-size: 13px; font-weight: 600;
  margin-right: auto;
}
.filter-tabs { display: inline-flex; gap: 2px; padding: 2px;
  background: var(--bg-elevated); border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
}
.filter-tabs button {
  background: transparent; border: 0; color: var(--text-muted);
  padding: 4px 10px; font-size: 11px; font-weight: 500;
  border-radius: var(--radius-sm);
  text-transform: uppercase; letter-spacing: 0.04em;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.filter-tabs button:hover { color: var(--text-primary); }
.filter-tabs button.on { background: var(--bg-hover); color: var(--text-primary); }

.conv-list { flex: 1; overflow-y: auto; min-height: 0; }
.conv-empty {
  padding: 48px 24px; text-align: center; color: var(--text-muted); font-size: 13px;
}

.conv-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  display: grid; grid-template-columns: 10px 1fr auto;
  gap: 10px; align-items: flex-start;
  position: relative;
  transition: background var(--transition-fast);
}
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--accent-dim); }
.conv-item.active::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent);
}
.conv-item.takeover { background: linear-gradient(90deg, rgba(251,191,36,0.10), transparent 50%); }
.conv-item.takeover.active { background: linear-gradient(90deg, rgba(251,191,36,0.18), var(--accent-dim) 70%); }
.conv-pill {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  margin-top: 4px;
  box-shadow: 0 0 0 3px rgba(74,222,128,0.18);
}
.conv-pill.read { background: var(--text-muted); box-shadow: none; }
.conv-meta { min-width: 0; }
.conv-prop {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.conv-prop-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.conv-name {
  font-size: 13px; font-weight: 500; margin: 3px 0 1px;
  color: var(--text-primary);
}
.conv-preview {
  font-size: 12px; color: var(--text-secondary);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.conv-time {
  font-size: 11px; color: var(--text-muted); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.conv-takeover-tag {
  position: absolute; top: 8px; right: 10px;
  font-size: 9px; color: var(--status-takeover);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.conv-tier-star { margin-left: 4px; font-size: 11px; }

/* Conv tags */
.conv-tags-row { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.conv-tag {
  font-size: 10px;
  background: rgba(99,102,241,0.12); color: #a5b4fc;
  border: 1px solid rgba(99,102,241,0.25);
  padding: 1px 6px; border-radius: 10px;
  font-weight: 500;
}

/* ─── Thread pane ─── */
.thread-panel {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  background: var(--bg-base);
}
.thread-header {
  padding: 14px 22px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
.thread-title-block { flex: 1; min-width: 0; }
.thread-title {
  font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--text-primary);
}
.thread-sub {
  font-size: 12px; color: var(--text-muted);
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 2px;
}
.thread-sub a { color: var(--text-secondary); text-decoration: none; }
.thread-sub a:hover { color: var(--text-primary); text-decoration: underline; }
.thread-actions { display: flex; gap: 6px; align-items: center; }

.thread-takeover-banner {
  background: linear-gradient(90deg, rgba(251,191,36,0.16), rgba(251,191,36,0.06));
  border-bottom: 1px solid rgba(251,191,36,0.35);
  padding: 10px 22px;
  font-size: 13px;
  color: #fbbf24;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.thread-takeover-banner button {
  margin-left: auto;
  background: rgba(251,191,36,0.18);
  border: 1px solid rgba(251,191,36,0.45);
  color: #fef3c7;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500;
  transition: background var(--transition-fast);
}
.thread-takeover-banner button:hover { background: rgba(251,191,36,0.28); }

.thread-empty {
  margin: auto; color: var(--text-muted); text-align: center; padding: 24px;
}
.thread-empty-icon {
  font-size: 48px; opacity: 0.4;
  margin-bottom: 16px;
}
.thread-empty-title {
  font-size: 16px; color: var(--text-secondary);
  margin-bottom: 4px; font-weight: 500;
}

.thread {
  flex: 1; overflow-y: auto;
  padding: 24px 22px;
  display: flex; flex-direction: column;
  gap: 8px;
  min-height: 0;
}

/* Tags */
.thread-tags { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.thread-tag {
  font-size: 11px;
  background: rgba(99,102,241,0.15); color: #c7d2fe;
  border: 1px solid rgba(99,102,241,0.35);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.thread-tag:hover {
  background: rgba(239,68,68,0.16); border-color: rgba(239,68,68,0.45); color: #fca5a5;
}
.thread-tag .tag-x { opacity: 0.55; font-size: 13px; line-height: 1; }
.thread-tag:hover .tag-x { opacity: 1; }
.thread-tag-add {
  font-size: 11px;
  background: transparent; color: var(--text-muted);
  border: 1px dashed var(--border-default);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.thread-tag-add:hover { color: var(--text-primary); border-color: var(--accent-strong); }

/* Messages */
.msg-row {
  display: flex; flex-direction: column; max-width: 72%;
  position: relative;
}
.msg-row.visitor { align-self: flex-end; align-items: flex-end; }
.msg-row.agent { align-self: flex-start; }
.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px; line-height: 1.5;
  word-wrap: break-word; white-space: pre-wrap;
  box-shadow: var(--shadow-sm);
}
.msg-row.visitor .msg-bubble {
  background: var(--msg-visitor-bg, var(--accent));
  color: var(--msg-visitor-text, #07140d);
  border-bottom-right-radius: 4px;
}
.msg-row.agent .msg-bubble {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-bottom-left-radius: 4px;
}
.msg-row.agent.ai-suggested .msg-bubble::after {
  content: '✦';
  position: absolute; bottom: 6px; right: -22px;
  font-size: 12px; color: var(--accent);
  opacity: 0.6;
}
.msg-time {
  font-size: 11px; color: var(--text-muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.msg-time .msg-ai-tag {
  display: inline-block; font-size: 10px;
  padding: 1px 5px; margin-left: 6px;
  background: rgba(74,222,128,0.18); color: #86efac;
  border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600;
}

/* Time gap label */
.time-gap {
  align-self: center;
  font-size: 11px; color: var(--text-muted);
  font-weight: 500;
  padding: 6px 0;
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* System line */
.system-line {
  align-self: center;
  font-size: 11px; color: var(--text-muted);
  padding: 6px 0;
  font-style: italic;
}

/* Typing dots */
.typing-row {
  align-self: flex-start;
  display: inline-flex; gap: 4px;
  background: var(--bg-elevated);
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border-default);
  border-bottom-left-radius: 4px;
}
.typing-row span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted);
  display: inline-block;
  animation: dot 1.2s infinite;
}
.typing-row span:nth-child(2) { animation-delay: 0.15s; }
.typing-row span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* AI suggestion card */
.ai-card {
  margin: 0 22px 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(74,222,128,0.10), rgba(74,222,128,0.03));
  border: 1px solid rgba(74,222,128,0.30);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.ai-card-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: #86efac;
  margin-bottom: 8px;
  font-weight: 600;
}
.ai-card-body {
  font-size: 13.5px; line-height: 1.5;
  color: var(--text-primary);
  white-space: pre-wrap;
}
.ai-card-actions {
  display: flex; gap: 8px; margin-top: 10px;
}
.ai-card-actions button {
  padding: 6px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated); color: var(--text-secondary);
  font-size: 12px; font-weight: 500;
  transition: background var(--transition-fast);
}
.ai-card-actions button:hover { background: var(--bg-hover); color: var(--text-primary); }
.ai-card-actions .use {
  background: var(--accent); color: #07140d;
  border-color: transparent;
}
.ai-card-actions .use:hover { filter: brightness(1.08); color: #07140d; }
.ai-spinner {
  font-size: 13px; color: var(--text-muted); font-style: italic;
}

/* Composer */
.composer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  padding: 12px 22px 16px;
  display: flex; flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.composer-row {
  display: flex; gap: 10px; align-items: flex-end;
}
.composer textarea {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  resize: none;
  min-height: 42px; max-height: 200px;
  outline: none;
  line-height: 1.5;
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.composer textarea:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.composer-send {
  background: var(--accent); color: #07140d;
  padding: 11px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: filter var(--transition-fast), transform var(--transition-fast);
}
.composer-send:disabled { opacity: 0.4; cursor: not-allowed; }
.composer-send:not(:disabled):hover { filter: brightness(1.08); box-shadow: var(--shadow-glow); }
.composer-send:not(:disabled):active { transform: translateY(1px); }
.composer-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--text-muted);
}
.composer-meta .composer-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
}
.composer-char-count.warn { color: var(--warning); }

/* ═══ Properties view ═══ */
.props-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.props-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 18px;
}
.prop-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-base), transform var(--transition-base), box-shadow var(--transition-base);
  display: flex;
}
.prop-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.prop-stripe {
  width: 4px;
  flex-shrink: 0;
}
.prop-body { padding: 18px 20px; flex: 1; min-width: 0; }
.prop-name-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.prop-name {
  font-size: 16px; font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.tier-badge, .mode-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid;
}
.tier-badge.tier-paid {
  color: #fbbf24;
  background: rgba(251,191,36,0.10);
  border-color: rgba(251,191,36,0.4);
}
.tier-badge.tier-prospect {
  color: #38bdf8;
  background: rgba(56,189,248,0.10);
  border-color: rgba(56,189,248,0.4);
}
.tier-badge.tier-demo {
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border-color: var(--border-default);
}

/* ─── Clients toolbar (search + sort reset) ─── */
.props-toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.props-search {
  position: relative; flex: 1; max-width: 420px;
  display: flex; align-items: center;
}
.props-search-icon {
  position: absolute; left: 12px; font-size: 13px; opacity: 0.6; pointer-events: none;
}
.props-search input {
  width: 100%;
  padding: 9px 32px 9px 34px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--transition-base);
}
.props-search input:focus { outline: none; border-color: var(--accent); }
.props-search-clear {
  position: absolute; right: 8px;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 13px; padding: 4px 6px; border-radius: var(--radius-full);
}
.props-search-clear:hover { color: var(--text-primary); background: var(--bg-elevated); }

/* ─── Clients table ─── */
.props-table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.props-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.props-table thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 600; color: var(--text-muted);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-elevated);
  white-space: nowrap;
}
.props-table th.col-num { text-align: right; }
.props-table th.col-portal, .props-table th.col-tier { text-align: center; }
.props-table th.sortable { cursor: pointer; user-select: none; }
.props-table th.sortable:hover { color: var(--text-secondary); }
.props-table th.sorted { color: var(--accent); }
.sort-caret { font-size: 9px; }

.tier-group-header td {
  padding: 10px 14px 6px;
  border-bottom: 1px solid var(--border-subtle);
}
.tier-group-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-secondary);
}
.tier-group-count {
  margin-left: 8px; font-size: 11px; color: var(--text-muted);
  background: var(--bg-elevated); border-radius: var(--radius-full); padding: 1px 7px;
}
.tier-group-demo .tier-group-title, .tier-group-archived .tier-group-title { color: var(--text-muted); }

.prop-row { cursor: pointer; transition: background var(--transition-base); }
.prop-row:hover { background: var(--bg-elevated); }
.prop-row td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.props-table tbody:last-child .prop-row:last-child td { border-bottom: none; }
.col-client { width: 40%; }
.col-client .prop-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 10px; flex-shrink: 0; vertical-align: middle;
}
.prop-client-text { display: inline-flex; flex-direction: column; vertical-align: middle; }
.prop-row-name { font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; }
.prop-row-sub { font-size: 12px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.props-table td.col-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.props-table td.col-num.muted { color: var(--text-muted); }
.props-table td.col-num.warn { color: #f59e0b; font-size: 12px; }
.props-table td.col-tier, .props-table td.col-portal { text-align: center; white-space: nowrap; }
.portal-pill { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: var(--radius-full); }
.portal-pill.on { color: var(--accent); background: var(--bg-elevated); border: 1px solid var(--border-default); }
.portal-pill.off { color: var(--text-muted); }
.col-actions { text-align: right; white-space: nowrap; }
.col-actions .btn { margin-left: 6px; }

.prop-embed-float {
  margin-top: 14px; padding: 14px 16px;
  background: var(--bg-surface); border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}
.prop-embed-float .prop-embed-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.prop-embed-float code {
  display: block; font-size: 12px; word-break: break-all;
  color: var(--text-secondary); font-family: 'JetBrains Mono', monospace;
}

/* sidebar tier sub-labels */
.sidebar-tier-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); font-weight: 600;
  padding: 8px 12px 3px;
}

@media (max-width: 768px) {
  .props-table td.col-tier, .props-table th.col-tier,
  .props-table td.col-portal, .props-table th.col-portal { display: none; }
  .col-client { width: auto; }
  .props-table thead th, .prop-row td { padding-left: 10px; padding-right: 10px; }
}
.tier-badge.tier-archived {
  color: var(--text-muted);
  background: rgba(0,0,0,0.12);
  border-color: var(--border-subtle);
  opacity: 0.7;
}
.mode-badge.mode-off {
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-color: var(--border-default);
}
.mode-badge.mode-when_away {
  color: #fbbf24;
  background: rgba(251,191,36,0.08);
  border-color: rgba(251,191,36,0.3);
}
.mode-badge.mode-always {
  color: var(--accent);
  background: rgba(74,222,128,0.10);
  border-color: rgba(74,222,128,0.35);
}
.prop-id {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-muted);
}
.prop-greeting {
  font-size: 13px; color: var(--text-secondary);
  font-style: italic; margin: 12px 0;
  border-left: 2px solid var(--border-default);
  padding-left: 10px;
}
.prop-voice {
  font-size: 12px; color: var(--text-secondary);
  background: rgba(74,222,128,0.06);
  border: 1px solid rgba(74,222,128,0.18);
  padding: 7px 10px; border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.prop-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; margin: 14px 0;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}
.prop-stats > div { text-align: center; }
.stat-num {
  font-size: 18px; font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.stat-lbl {
  font-size: 10px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-top: 2px;
}
.prop-kb-status {
  font-size: 11px; color: var(--text-muted);
  margin-bottom: 12px;
}
.prop-kb-status.warn { color: var(--warning); }
.prop-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.prop-embed {
  margin-top: 12px;
  padding: 10px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  word-break: break-all;
}

/* Client Access section */
.client-access-section {
  margin-top: 16px;
  padding: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.client-access-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
}
.client-access-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  margin-bottom: 8px;
}
.client-access-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.client-access-status.on .dot { background: var(--accent); }
.client-access-status.off .dot { background: var(--text-muted); }
.client-access-url {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-bottom: 8px;
  word-break: break-all;
}
.client-access-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
}

/* Avatar field */
.avatar-field {
  display: flex; align-items: center; gap: 14px;
  text-transform: none; letter-spacing: normal;
}
.avatar-preview {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  overflow: hidden;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-preview-empty { color: var(--text-muted); font-size: 18px; }
.avatar-actions {
  display: flex; gap: 6px; flex: 1 1 auto;
  flex-wrap: wrap; align-items: center;
}

/* ═══ Modal ═══ */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--bg-backdrop);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn 150ms ease;
}
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  width: 540px;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 200ms cubic-bezier(.2,.8,.2,1);
}
.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-subtle);
}
.modal-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.modal-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.modal-body {
  padding: 18px 22px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  flex: 1;
}
.modal-body label.field, .modal-body > label {
  display: flex; flex-direction: column; gap: 6px;
}
.modal-body > label > span:first-child,
.modal-body label.field > span:first-child {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); font-weight: 500;
}
.form-row { display: flex; gap: 12px; align-items: flex-end; }
.form-row > label { flex: 0 0 auto; }
.form-row > label.grow { flex: 1 1 auto; }
.form-error { color: var(--error); font-size: 12px; }
.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 14px 22px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-base);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes shimmer { 0% { background-position: -800px 0; } 100% { background-position: 800px 0; } }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 1600px 100%;
  animation: shimmer 1.6s infinite linear;
  border-radius: var(--radius-sm);
}
.skel-row {
  display: grid; grid-template-columns: 10px 1fr 50px;
  gap: 10px; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.skel-block { height: 12px; }
.skel-block.lg { height: 16px; }
.skel-block.sm { height: 10px; }
.skel-block.pill { width: 10px; height: 10px; border-radius: 50%; }

/* Toast stack */
.toast-stack {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  display: flex; flex-direction: column-reverse; gap: 8px;
  max-width: 380px;
  pointer-events: none;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  font-size: 13px;
  color: var(--text-primary);
  animation: slideUp 220ms cubic-bezier(.2,.8,.2,1);
  min-width: 240px;
  pointer-events: auto;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--error); }
.toast.info    { border-left: 3px solid var(--info); }
.toast .toast-icon { font-size: 16px; line-height: 1; }
.toast .toast-close {
  margin-left: 8px; padding: 2px 6px; border-radius: 4px;
  color: var(--text-muted);
}
.toast .toast-close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Empty state */
.empty {
  padding: 48px 24px;
  text-align: center; color: var(--text-muted);
}
.empty-icon { font-size: 40px; opacity: 0.5; margin-bottom: 14px; }
.empty-title { font-size: 14px; color: var(--text-secondary); font-weight: 500; margin-bottom: 4px; }
.empty-sub { font-size: 13px; margin-bottom: 16px; }

/* Search overlay (K shortcut) */
.search-overlay {
  position: fixed; inset: 0;
  background: var(--bg-backdrop);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 110;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 96px;
  animation: fadeIn 150ms ease;
}
.search-panel {
  width: 560px; max-width: calc(100vw - 32px);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: scaleIn 200ms cubic-bezier(.2,.8,.2,1);
  overflow: hidden;
}
.search-input-row {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.search-input-row input {
  border: 0; background: transparent;
  padding: 0; font-size: 15px;
  box-shadow: none !important;
}
.search-results { max-height: 50vh; overflow-y: auto; }
.search-result-row {
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}
.search-result-row:hover, .search-result-row.focused {
  background: var(--bg-hover);
}
.search-result-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ═══ Auth gate ═══ */
.gate {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, rgba(74,222,128,0.08) 0%, var(--bg-base) 55%);
}
.gate-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 380px; max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
}
.gate-brand {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px;
}
.gate-brand .logo-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #16a34a);
  display: flex; align-items: center; justify-content: center;
  color: #07140d;
  box-shadow: 0 4px 14px rgba(74,222,128,0.35);
}
.gate-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.gate-sub { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }
.gate input { margin-bottom: 12px; }
.gate button {
  width: 100%; padding: 11px;
  background: var(--accent); color: #07140d;
  border: 0; border-radius: var(--radius-md);
  font-weight: 600; font-size: 14px;
  transition: filter var(--transition-fast);
}
.gate button:hover { filter: brightness(1.08); }
.gate-error { color: var(--error); font-size: 12px; margin-top: 8px; }

/* ═══ Mobile / responsive ═══ */
@media (max-width: 900px) {
  :root { --sidebar-w: 220px; }
}

@media (max-width: 768px) {
  /* Sidebar slides over as drawer */
  .app { position: relative; }
  .sidebar {
    position: fixed; top: 0; left: 0;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-scrim {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 49;
    display: none;
  }
  .app.sidebar-open .sidebar-scrim { display: block; }
  .main-col { width: 100%; }

  /* Convs split → mobile stack */
  .convs-split {
    grid-template-columns: 1fr;
    position: relative;
    overflow: hidden;
  }
  .conv-pane {
    grid-column: 1 / -1;
    border-right: 0;
  }
  .thread-panel {
    position: absolute;
    inset: 0;
    background: var(--bg-base);
    transform: translateX(100%);
    transition: transform 220ms ease;
    z-index: 5;
  }
  .convs-split[data-mobile-thread="open"] .thread-panel {
    transform: translateX(0);
  }
  .mobile-back-btn {
    display: inline-flex;
    align-items: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin-right: 8px;
    cursor: pointer;
    gap: 4px;
  }
  .mobile-back-btn:hover { color: var(--text-primary); }
  .topbar { padding: 0 12px; gap: 6px; }
  .view-scroll { padding: 16px 14px; }
  .props-grid { grid-template-columns: 1fr; }
  .props-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .modal-overlay { padding: 0; }
  .modal { width: 100%; height: 100%; max-height: 100vh; border-radius: 0; border: 0; }
  .composer textarea { font-size: 16px; min-height: 44px; }
  .composer-send { min-height: 44px; }
}
@media (min-width: 769px) {
  .mobile-back-btn { display: none; }
  .sidebar-scrim { display: none !important; }
}

/* ─── Train the Agent: knowledge sources panel ─────────────────────────── */
.train-agent {
  margin-top: 8px;
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.train-agent-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px;
}
.train-busy { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--accent); }
.src-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.src-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; background: var(--bg-elevated);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
}
.src-name {
  flex: 1; min-width: 0; font-size: 12px; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.src-meta { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.src-del {
  flex-shrink: 0; width: 22px; height: 22px; line-height: 1; padding: 0;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  cursor: pointer; font-size: 15px;
}
.src-del:hover { color: var(--error); border-color: var(--error); background: rgba(239,68,68,0.12); }
.upload-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; font-size: 13px; font-weight: 500;
  color: var(--accent); background: var(--accent-dim);
  border: 1px dashed var(--accent-strong); border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.15s;
}
.upload-btn:hover { background: var(--accent-hover); }
.upload-btn.disabled { opacity: 0.5; pointer-events: none; }
