/* BonnieOS — tokens mirror the design pack (BonnieShell.dc.html + BonnieOS Onboarding.dc.html).
   Every value below is lifted from the mocks; don't hand-tune without updating the mocks. */
:root {
  /* Explicitly declares this page as light-themed by default — without this,
     some browsers' own automatic dark-mode/"force dark" heuristics can
     re-invert form controls and text independently of our [data-theme]
     system, which is exactly what a white-text-on-white-background report
     looks like even when every rule below is authored correctly. */
  color-scheme: light;
  --sidebar-width: 228px;
  --topbar-height: 58px;
  --sidebar-bg: #ffffff;
  --sidebar-hover: #f4f4f5;
  --sidebar-active: #c026d3;
  --sidebar-text: #52525b;
  --sidebar-text-active: #ffffff;
  --primary: #c026d3;
  --primary-hover: #a21caf;
  --primary-light: #fdf4ff;
  --primary-border: #f5d0fe;
  --primary-deep: #86198f;
  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --success: #047857;
  --success-bg: #ecfdf5;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --bg: #fafafa;
  --card-bg: #ffffff;
  --text: #18181b;
  --text-strong: #27272a;
  --text-secondary: #52525b;
  --text-tertiary: #71717a;
  --text-muted: #a1a1aa;
  --border: #e4e4ea;
  --border-card: #ececf1;
  --border-light: #f0f0f4;
  --fill-subtle: #f4f4f5;
  --radius: 12px;
  --radius-sm: 9px;
  --radius-nav: 10px;
  --shadow: 0 1px 3px rgba(24,24,27,0.06);
  --shadow-md: 0 6px 18px rgba(192,38,211,0.07);
  --shadow-lg: 0 14px 36px rgba(24,24,27,0.16);
  --transition: 150ms ease;
  --accent: #c026d3;
  --accent-hover: #a21caf;
  --hover-bg: var(--fill-subtle);
  --bg-card: #ffffff;
  --gradient-brand: linear-gradient(135deg, #ec4899 0%, #a855f7 100%);
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ─── Dark Mode (OPTION B.2) ─── */
[data-theme="dark"] {
  color-scheme: dark;
  --sidebar-bg: #18181b;
  --sidebar-hover: #27272a;
  --sidebar-active: #d946ef;
  --sidebar-text: #a1a1aa;
  --sidebar-text-active: #ffffff;
  --bg: #09090b;
  --bg-card: #18181b;
  --card-bg: #18181b;
  --text: #fafafa;
  --text-strong: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-tertiary: #a1a1aa;
  --text-muted: #71717a;
  --border: #27272a;
  --border-card: #27272a;
  --border-light: #232326;
  --fill-subtle: #27272a;
  --accent: #d946ef;
  --accent-hover: #e879f9;
  --hover-bg: #27272a;
  --hover: #27272a;
  --primary: #d946ef;
  --primary-hover: #e879f9;
  --primary-light: #2d1132;
  --primary-border: #4a1d52;
  --primary-deep: #f0abfc;
  --info: #60a5fa;
  --info-bg: #17233d;
  --danger: #f87171;
  --danger-hover: #fca5a5;
  --danger-bg: #2a1416;
  --danger-border: #4c1d1d;
  --success: #34d399;
  --success-bg: #0c2a20;
  --warning: #fbbf24;
  --warning-bg: #2c1e05;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 14px 36px rgba(0,0,0,0.55);
}

[data-theme="dark"] .logout-btn:hover { background: #3b1a1a; border-color: var(--danger); color: #fca5a5; }
[data-theme="dark"] thead th { background: #1e1f28; }
[data-theme="dark"] tbody tr:hover { background: #22232b; }
[data-theme="dark"] .badge-default { background: #2a2b33; color: #c0c0cc; }
[data-theme="dark"] .badge-primary { background: #252a4a; color: #8ba3ff; }
[data-theme="dark"] .error-msg { background: #3b1a1a; color: #fca5a5; }
[data-theme="dark"] .sr-snippet mark { background: #554400; color: #fef08a; }
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea { background: #1a1b23; color: #e1e1e6; }
[data-theme="dark"] .search-input-container input { background: #1a1b23; color: #e1e1e6; border-color: #2a2b33; }
[data-theme="dark"] .settings-section { border: 1px solid #2a2b33; }
[data-theme="dark"] table th { background: #1e1f2e; color: #c8c8d4; }
[data-theme="dark"] table td { background: #181923; color: #d4d4dc; }
[data-theme="dark"] table tr:hover td { background: #232438; }
[data-theme="dark"] .empty-state { color: #8b8b96; }
[data-theme="dark"] .modal-content { background: #1a1b23; color: #e1e1e6; }
[data-theme="dark"] .sidebar-link { color: #b0b0ba; }
[data-theme="dark"] .sidebar-link:hover { background: #22232b; color: #e1e1e6; }
[data-theme="dark"] .btn-outline { border-color: #3a3b45; color: #d4d4dc; }
[data-theme="dark"] .btn-outline:hover { background: #2a2b35; }
[data-theme="dark"] .btn-ghost { color: #b0b0ba; }
[data-theme="dark"] .btn-ghost:hover { background: #22232b; color: #e1e1e6; }
[data-theme="dark"] .tab { color: #b0b0ba; }
[data-theme="dark"] .tab.active { color: var(--text); border-bottom-color: var(--primary); }
[data-theme="dark"] .page-header,
[data-theme="dark"] .subtitle { color: #8b8b96; }
[data-theme="dark"] .mini-stat { background: var(--bg-card); border: 1px solid #2a2b33; }

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font-ui);
  font-size: 13.5px; font-feature-settings: 'cv11';
  background: var(--bg); color: var(--text); line-height: 1.55;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Sidebar — 228px flush rail, per BonnieShell ─── */
#sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-width);
  background: var(--sidebar-bg); border-right: 1px solid var(--border-light);
  display: flex; flex-direction: column; padding: 16px 12px; gap: 14px;
  z-index: 102; overflow: hidden;
}
.sidebar-brand { display: flex; align-items: center; gap: 9px; padding: 0 6px; flex: none; }
.sidebar-brand .logo-icon { display: block; width: 26px; height: 26px; border-radius: 8px; object-fit: contain; flex: none; }
.sidebar-brand .logo-text {
  font-size: 16px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); white-space: nowrap;
}
.sidebar-new-chat-btn {
  display: flex; align-items: center; gap: 8px; flex: none;
  margin: 0; padding: 9px 12px; border: none; border-radius: var(--radius-nav);
  background: var(--fill-subtle); color: #3f3f46; font-size: 13px; font-weight: 600;
  font-family: inherit; text-align: left; cursor: pointer; transition: all var(--transition);
}
.sidebar-new-chat-btn > span:first-child { font-size: 14px; line-height: 1; }
.sidebar-new-chat-btn:hover { background: var(--primary-light); color: var(--primary); }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0; flex: none; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  color: var(--sidebar-text); text-decoration: none; border-radius: var(--radius-nav);
  font-size: 13.5px; font-weight: 500; transition: all var(--transition);
  margin-bottom: 0;
}
.sidebar-nav a:hover { background: var(--fill-subtle); color: var(--text); }
.sidebar-nav a.active {
  background: var(--gradient-brand); color: var(--sidebar-text-active);
  font-weight: 600; box-shadow: none;
}
.sidebar-nav .nav-icon { display: flex; align-items: center; justify-content: center; width: 15px; height: 15px; flex-shrink: 0; }
.sidebar-nav .nav-icon svg { width: 15px; height: 15px; }
.sidebar-subnav { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 6px; padding-left: 22px; }
.sidebar-subnav a {
  display: flex; align-items: center; padding: 7px 10px;
  color: var(--sidebar-text); text-decoration: none; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 400; transition: all var(--transition);
}
.sidebar-subnav a:hover { background: var(--fill-subtle); color: var(--text); }
.sidebar-subnav a.active { background: var(--gradient-brand); color: var(--sidebar-text-active); font-weight: 600; }
.sidebar-recent-chats {
  flex: 1; min-height: 0; overflow-y: auto; padding: 12px 0 0;
  border-top: 1px solid var(--border-light);
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar-recent-chats-label {
  display: flex; align-items: center; gap: 8px; padding: 0 8px 3px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted);
}
.sidebar-recent-chats-label .chats-product {
  margin-left: auto; flex: none; font-weight: 600; text-transform: none; letter-spacing: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 96px;
}
.sidebar-recent-chat-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 12px; font-weight: 400; cursor: pointer;
  border: 1px solid transparent; transition: background var(--transition);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-recent-chat-item:hover { background: var(--fill-subtle); }
.sidebar-recent-chat-item.unread {
  background: var(--primary-light); border-color: var(--primary-border);
  color: var(--text); font-weight: 700;
}
.sidebar-recent-chat-item.active { background: var(--primary-light); border-color: var(--primary-border); color: var(--text); font-weight: 600; }
.sidebar-recent-chat-item span:last-child { overflow: hidden; text-overflow: ellipsis; }
.sidebar-chat-unread {
  margin-left: auto; flex: none; min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 999px; background: var(--gradient-brand); color: #fff;
  font-size: 9.5px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.sidebar-footer {
  margin-top: auto; flex: none; padding: 0 8px; border-top: none;
  font-size: 11px; font-weight: 400; color: var(--text-muted); text-align: left;
}

/* ─── Header (topbar: product switcher + page title + actions) ─── */
.os-gradient {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}
.sidebar-selector { flex: none; }
.sidebar-selector select {
  width: 100%;
  padding: 6px 26px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: all 150ms ease;
}
.sidebar-selector select:hover {
  border-color: var(--primary);
  background: var(--card-bg);
}
.sidebar-selector select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}
.sidebar-selector select option {
  background: var(--card-bg);
  color: var(--text);
}

/* ─── Custom Product Dropdown ─── */
.product-selector { position: relative; }
.product-select-trigger {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; cursor: pointer;
  transition: all 150ms ease;
}
.product-select-trigger:hover {
  border-color: var(--primary-border);
  background: var(--primary-light);
}
.product-select-icon {
  width: 16px; height: 16px; flex: none; border-radius: 5px; background: #fae8ff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 10px; line-height: 1;
}
.product-select-name { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.product-select-caret { font-size: 10px; color: var(--text-muted); transition: transform 150ms ease; flex-shrink: 0; }
.product-select-menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 240px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 300;
  animation: fadeIn 120ms ease;
}
.product-select-menu.open { display: block; }
.product-select-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.product-select-empty { padding: 14px; text-align: center; color: var(--text-muted); font-size: 12px; }
.product-select-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 8px 10px;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text);
  font-size: 13px; cursor: pointer;
  transition: background 120ms ease;
}
.product-select-item:hover { background: var(--sidebar-hover); }
.product-select-item.active { background: var(--primary-light); }
.product-select-item-icon {
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.product-select-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-select-check { color: var(--primary); font-weight: 700; flex-shrink: 0; }
.product-select-footer { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
.product-select-add {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; border: 1px dashed var(--border); border-radius: var(--radius-sm);
  background: transparent; color: var(--primary); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 120ms ease;
}
.product-select-add:hover { background: var(--primary-light); border-color: var(--primary); }

/* ─── Top Bar — 58px, starts right of the rail, per BonnieShell ─── */
#topbar {
  position: fixed; left: var(--sidebar-width); top: 0; right: 0; height: var(--topbar-height);
  background: var(--card-bg); border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: flex-start; gap: 14px;
  padding: 0 22px; z-index: 101; min-width: 0;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
#topbar h1 {
  font-size: 13.5px; font-weight: 600; color: #3f3f46;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.topbar-search {
  display: flex; align-items: center; gap: 8px; flex: none;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0 10px; width: 190px; height: 32px; cursor: pointer;
  color: var(--text-muted); font-size: 12px; font-weight: 400; transition: all var(--transition);
}
.topbar-search:hover { border-color: var(--primary-border); background: var(--primary-light); }
.topbar-search .shortcut-hint { margin-left: auto; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; margin-left: auto; }
.topbar-user { position: relative; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.topbar-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: #ec4899;
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex: none;
}
#user-name { display: none; }
.logout-btn {
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  height: 32px; padding: 0 12px; cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  transition: all var(--transition);
}
.logout-btn:hover { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }

/* Icon buttons in the topbar (bell, theme, install) */
.theme-toggle-btn {
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  width: 32px; height: 32px; cursor: pointer; font-size: 14px; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center; flex: none;
  transition: all var(--transition);
}
.theme-toggle-btn:hover { background: var(--fill-subtle); }

/* Finish-setup pill */
.setup-pill {
  display: none; align-items: center; gap: 8px; flex: none; white-space: nowrap;
  width: auto; height: auto; border: 1px solid var(--primary-border);
  background: var(--primary-light); border-radius: 999px; padding: 5px 11px 5px 5px;
  font-family: inherit; cursor: pointer;
}
.setup-pill:hover { background: #fae8ff; }
.setup-pill .setup-frac {
  width: 22px; height: 22px; flex: none; border-radius: 50%; background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--primary-hover);
}
.setup-pill .setup-label { font-size: 11.5px; font-weight: 600; color: var(--primary-deep); }

/* Notification badge on the bell */
#notif-badge {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--gradient-brand); color: #fff;
  font-size: 10px; font-weight: 700; align-items: center; justify-content: center;
  border: 1.5px solid #fff;
}

/* ─── Content ─── */
#app-content {
  margin-left: var(--sidebar-width); min-height: 100vh;
  padding: calc(var(--topbar-height) + 24px) 26px 24px;
}

/* ─── Login Page ─── */
.login-page {
  margin: 0 !important; padding: 0; min-height: 100vh;
  display: flex; align-items: flex-start; justify-content: center; background: var(--bg);
  position: fixed; inset: 0; z-index: 1;
}
.login-container {
  display: flex; flex-direction: column; align-items: center;
  max-width: 440px; width: 100%; padding: 120px 40px 40px;
}
.login-brand-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.login-logo {
  display: block; width: 32px; height: 32px;
  object-fit: contain; flex-shrink: 0;
}
.login-brand {
  font-size: 24px; font-weight: 700; color: var(--text); line-height: 1;
}
.login-subtitle {
  font-size: 14px; color: var(--text-muted); margin-bottom: 32px;
}
.login-page .form-group { margin-bottom: 20px; width: 100%; }
.login-page .form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: var(--text-secondary); }
.login-page .form-group input { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 15px; transition: all var(--transition); background: var(--card-bg); }
.login-page .form-group input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.login-btn {
  width: 100%; justify-content: center; padding: 11px; font-size: 15px;
}
.login-footer {
  text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-muted);
}
.login-page #login-form {
  width: 100%; display: flex; flex-direction: column;
}
.login-page #login-error { width: 100%; }
.login-page #login-error .error-msg { margin-bottom: 16px; }
.back-home {
  position: absolute; top: 24px; left: 24px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 500; color: var(--text-secondary);
  text-decoration: none; z-index: 10;
}
.back-home:hover { color: var(--primary); }

/* ─── Components ─── */
.container { max-width: 1200px; margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.page-header h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.page-header .subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 6px; }
.page-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 4px; }

/* Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; margin-bottom: 32px; }
.stat-card {
  background: var(--card-bg); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 16px;
  transition: all var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card-top { display: flex; align-items: center; justify-content: space-between; }
.stat-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm); display: flex;
  align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.orange { background: var(--warning-bg); color: var(--warning); }
.stat-icon.purple { background: var(--primary-light); color: var(--primary); }
.stat-info h3 { font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; color: var(--text); }
.stat-info p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.stat-trend {
  display: inline-flex; align-items: center; gap: 3px; padding: 3px 10px;
  border-radius: 9999px; font-size: 12px; font-weight: 500;
}
.stat-trend.positive { background: var(--success-bg); color: var(--success); }
.stat-trend.negative { background: rgba(239,68,68,0.1); color: var(--danger); }

/* Product Grid */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.product-card {
  background: var(--card-bg); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); cursor: pointer; transition: all var(--transition);
  border: 1px solid var(--border);
}
.product-card:hover { box-shadow: var(--shadow-md); border-color: var(--primary); transform: translateY(-2px); }
.product-icon {
  width: 48px; height: 48px; border-radius: 14px; display: flex;
  align-items: center; justify-content: center; font-size: 24px; margin-bottom: 12px;
}
.product-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.product-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.product-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); }
.product-meta span { display: flex; align-items: center; gap: 4px; }

/* AI Models view — Settings → AI models cards */
.model-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.model-card {
  background: #fff; border-radius: 12px; padding: 22px 22px 18px;
  box-shadow: none; border: 1px solid #ececf1; transition: opacity var(--transition);
  position: relative; display: flex; flex-direction: column; min-width: 0;
}
.model-card.is-enabled { border-color: #ececf1; }
.model-card.is-off { background: #f7f7f8; opacity: 1; }
.model-card-head { display: flex; align-items: center; gap: 12px; }
.model-icon {
  width: 36px; height: 36px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.model-icon svg { width: 18px; height: 18px; }
.model-card.tint-fast .model-icon { background: #ecfdf5; color: #059669; }
.model-card.tint-deep .model-icon { background: #eef2ff; color: #4f46e5; }
.model-card.tint-experimental .model-icon { background: #ececf1; color: #71717a; }
.model-card.is-off .model-icon { background: #ececf1; color: #a1a1aa; }
.model-card.is-off .stat-value { color: var(--text-tertiary); }
.model-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.model-title h3 { font-size: 15.5px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.model-card.is-off .model-title h3 { color: var(--text-tertiary); }
.model-provider { font-size: 12px; color: var(--text-muted); }
.model-when { font-size: 13px; color: var(--text-tertiary); margin: 14px 0 18px; line-height: 1.55; flex: 1; }
.model-card.is-off .model-when { color: var(--text-muted); }
.model-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; border-top: 1px solid #f0f0f4; padding-top: 14px; margin-top: auto; }
.model-stat { display: flex; flex-direction: column; min-width: 0; }
.model-stat .stat-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; }
.model-stat .stat-value { font-size: 15px; font-weight: 700; margin-top: 3px; color: var(--text); letter-spacing: -0.02em; }
.model-stat-beta { font-size: 13.5px !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
.model-badge {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a21caf;
  background: #fae8ff;
  padding: 3px 8px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 0;
}
.model-card .switch { margin-left: auto; flex-shrink: 0; width: 36px; height: 20px; }
.model-card .slider:before { height: 16px; width: 16px; left: 2px; bottom: 2px; }
.model-card .switch input:checked + .slider { background: var(--gradient-brand); }
.model-card .switch input:checked + .slider:before { transform: translateX(16px); }

/* Dashboard content cards (AI Usage / Integrations / Quick Actions / Recent Activity row) */
.dashboard-row { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-top: 24px; }
.dashboard-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; min-width: 0;
}
.dashboard-card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.dashboard-card-head h3 { font-size: 16px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.bar-chart-horizontal .bar-label { width: 70px; text-transform: capitalize; }
.dashboard-card-head p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.dashboard-card-link { font-size: 13px; color: var(--primary); text-decoration: none; white-space: nowrap; }
.dashboard-card-link:hover { text-decoration: underline; }

/* Quick Actions */
.quick-actions-list { display: flex; flex-direction: column; gap: 10px; }
.quick-action-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all var(--transition);
}
.quick-action-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.quick-action-icon {
  display: flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: var(--radius-sm); background: var(--info-bg); font-size: 15px; flex-shrink: 0;
}

/* Integrations donut chart */
#integrations-donut { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.donut-chart { width: 150px; height: 150px; border-radius: 50%; position: relative; }
.donut-hole { position: absolute; inset: 20px; background: var(--card-bg); border-radius: 50%; }
.donut-legend { display: flex; gap: 18px; font-size: 13px; color: var(--text-secondary); }
.donut-legend span { display: flex; align-items: center; gap: 6px; }
.donut-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* Integrations */
.integrations-toolbar { display: flex; gap: 16px; margin-bottom: 24px; }
.form-select-inline {
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text); font-size: 14px; cursor: pointer;
}
.integration-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }

/* Document Cards Grid */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.doc-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; cursor: pointer;
  display: flex; flex-direction: column; gap: 16px;
  transition: all var(--transition);
}
.doc-card:hover { box-shadow: var(--shadow-md); border-color: var(--primary); transform: translateY(-2px); }
.doc-card-head { display: flex; align-items: flex-start; gap: 12px; }
.doc-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--border-light);
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.doc-card-head h3 { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-product { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.doc-meta-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.doc-size { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.integration-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; display: flex; flex-direction: column; gap: 14px;
}
.integration-card-head { display: flex; align-items: flex-start; gap: 12px; }
.integration-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--border-light);
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.integration-card-head h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.integration-category { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.connector-type {
  display: inline-block; padding: 2px 8px; border-radius: 9999px; font-size: 10px; font-weight: 600;
  letter-spacing: 0.02em; vertical-align: middle; white-space: nowrap;
}
.connector-type-full { background: rgba(59,130,246,0.12); color: #2563eb; }
[data-theme="dark"] .connector-type-full { background: rgba(96,165,250,0.16); color: #93c5fd; }
.connector-type-mcp { background: rgba(139,92,246,0.12); color: #7c3aed; }
[data-theme="dark"] .connector-type-mcp { background: rgba(167,139,250,0.16); color: #c4b5fd; }
.connector-tier {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 9999px;
  font-size: 10px; font-weight: 600; vertical-align: middle; white-space: nowrap;
  background: rgba(217,119,6,0.14); color: #b45309;
}
.connector-tier-verified { background: rgba(16,185,129,0.14); color: #059669; }
.integration-badge {
  padding: 3px 10px; border-radius: 9999px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.integration-badge.connected { background: var(--primary-light); color: var(--primary); }
.integration-badge.available { background: var(--border-light); color: var(--text-secondary); }
.integration-badge.coming-soon { background: rgba(217,119,6,0.12); color: #b45309; }
[data-theme="dark"] .integration-badge.coming-soon { background: rgba(251,191,36,0.15); color: #fbbf24; }
.integration-badge.needs-attention { background: rgba(239,68,68,0.12); color: var(--danger); }
.integration-badge.health-live { background: var(--success-bg); color: var(--success); }
.integration-badge.health-partial { background: var(--warning-bg); color: var(--warning); }
.integration-badge.health-expiring { background: var(--warning-bg); color: var(--warning); }
.integration-badge.health-revoked { background: rgba(239,68,68,0.12); color: var(--danger); }
.integration-badge.health-unverified { background: var(--border-light); color: var(--text-secondary); }
.integration-meta.integration-meta-error { color: var(--danger); }
.integration-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; flex: 1; }

/* Phase 3 — analysis-depth banner + security posture */
.page-header-depth { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.depth-banner {
  background: var(--card-bg); border: 1px solid var(--border-light); border-radius: var(--radius);
  padding: 14px 18px; min-width: 260px; max-width: 380px; flex: 1;
}
.depth-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.depth-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.depth-pct { font-size: 18px; font-weight: 700; color: var(--text); }
.depth-bar { height: 8px; background: var(--border-light); border-radius: 9999px; overflow: hidden; margin-bottom: 10px; }
.depth-fill { height: 100%; background: var(--gradient-brand); border-radius: 9999px; transition: width 0.4s ease; }
.depth-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.depth-cat { font-size: 11px; padding: 2px 8px; border-radius: 9999px; background: var(--border-light); color: var(--text-muted); }
.depth-cat-on { background: var(--success-bg); color: var(--success); }
.depth-gate { margin-top: 10px; font-size: 12px; color: var(--warning); font-weight: 500; }
.security-posture { margin-top: 12px; font-size: 12px; color: var(--text-muted); text-align: center; line-height: 1.5; }
.integration-meta { font-size: 12px; color: var(--text-muted); }
.integration-actions { display: flex; align-items: center; gap: 8px; }
.integration-disconnect {
  background: none; border: none; color: var(--danger); font-size: 13px; font-weight: 500;
  cursor: pointer; margin-left: auto; padding: 5px 8px;
}
.integration-disconnect:hover { text-decoration: underline; }
.btn-connect {
  background: var(--gradient-brand); color: white; border: none; border-radius: var(--radius-sm);
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity var(--transition);
}
.btn-connect:hover { opacity: 0.9; }
.btn-connect:disabled {
  background: var(--border-light); color: var(--text-muted); cursor: not-allowed; opacity: 1;
}
.integration-card-disabled { opacity: 0.7; }

/* Tables */
.table-container {
  background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 12px 16px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted);
  background: var(--border-light); border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--border-light); }
tbody tr:hover { background: var(--border-light); }
tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px;
  border-radius: 100px; font-size: 12px; font-weight: 500;
}
.badge-healthy { background: var(--success-bg); color: var(--success); }
.badge-invalid { background: #fef2f2; color: var(--danger); }
.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-default { background: var(--border-light); color: var(--text-secondary); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.badge-healthy::before { background: var(--success); }
.badge-invalid::before { background: var(--danger); }
.badge-pending::before { background: var(--warning); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  border: 1px solid var(--border); background: var(--card-bg); color: var(--text);
  cursor: pointer; transition: all var(--transition); text-decoration: none;
}
.btn:hover { background: var(--border-light); }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-ghost { background: transparent; border: none; color: var(--text-muted); }
.btn-ghost:hover { background: var(--border-light); color: var(--text); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text-secondary); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; transition: all var(--transition);
  background: var(--card-bg);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 20px; font-size: 14px; font-weight: 500; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; transition: all var(--transition);
  background: none; border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 150ms ease;
}
.modal,
.modal-content {
  background: var(--card-bg); border-radius: var(--radius); padding: 0;
  box-shadow: var(--shadow-lg); max-width: 520px; width: 90%;
  max-height: 85vh; overflow-y: auto; animation: slideUp 200ms ease;
}
.modal.modal-wide { max-width: 880px; }

/* Connect-integration popup: form on one side, step-by-step "where do I get
   this" guide on the other. Wraps to stacked (guide above form) on narrow
   viewports rather than squeezing two columns into no space. */
.connect-split {
  display: flex; flex-wrap: wrap-reverse; gap: 20px;
}
.connect-form-panel { flex: 1 1 280px; min-width: 260px; }
.connect-guide-panel {
  flex: 1 1 260px; min-width: 240px;
  background: rgba(139,54,217,0.05); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
}
[data-theme="dark"] .connect-guide-panel { background: rgba(216,180,254,0.05); }
.connect-guide-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.connect-guide-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.connect-guide-steps li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.guide-step-num {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); color: white; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.connect-guide-steps a { color: var(--primary); text-decoration: underline; }

.modal-header { padding: 20px 24px 0; display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-body { padding: 16px 24px 24px; }
.modal-footer { padding: 0 24px 20px; display: flex; justify-content: flex-end; gap: 8px; }

/* Document viewer modal */
.doc-viewer { max-width: 720px; }
.doc-viewer .doc-title { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.doc-viewer .doc-meta { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.doc-viewer .doc-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.doc-tag { padding: 2px 8px; border-radius: 4px; background: var(--border-light); font-size: 11px; color: var(--text-muted); }
.doc-viewer .doc-content {
  background: var(--border-light); padding: 16px; border-radius: 8px;
  font-size: 13px; white-space: normal; word-break: break-word;
  max-height: 50vh; overflow-y: auto; line-height: 1.6;
}
.doc-viewer .doc-content h2, .doc-viewer .doc-content h3, .doc-viewer .doc-content h4 { margin: 12px 0 6px; color: var(--text); font-weight: 600; }
.doc-viewer .doc-content h2 { font-size: 17px; } .doc-viewer .doc-content h3 { font-size: 15px; } .doc-viewer .doc-content h4 { font-size: 14px; }
.doc-viewer .doc-content pre { background: rgba(0,0,0,0.05); padding: 10px 12px; border-radius: 6px; overflow-x: auto; font-size: 12px; }
.doc-viewer .doc-content code { font-family: var(--mono, monospace); font-size: 12px; }
.doc-viewer .doc-content ul, .doc-viewer .doc-content ol { margin: 8px 0; padding-left: 22px; }
.doc-viewer .doc-content a { color: var(--primary); }

/* Search */
.search-page { max-width: 640px; margin: 0 auto; padding-top: 40px; }
.search-input-container {
  position: relative; margin-bottom: 24px;
}
.search-input-container input {
  width: 100%; padding: 14px 20px; font-size: 18px;
  border: 2px solid var(--border); border-radius: var(--radius);
  transition: all var(--transition);
}
.search-input-container input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }
.search-results { margin-top: 8px; }
.search-result {
  padding: 16px; border-radius: var(--radius-sm); cursor: pointer;
  transition: all var(--transition); border-bottom: 1px solid var(--border-light);
}
.search-result:hover { background: var(--border-light); }
.search-result h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.search-result p { font-size: 13px; color: var(--text-muted); }
.search-result .sr-meta { display: flex; gap: 8px; margin-top: 6px; }

/* Settings */
.settings-section { background: var(--card-bg); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
.settings-section h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border-light); }
.settings-row { display: flex; padding: 12px 0; border-bottom: 1px solid var(--border-light); }
.settings-row:last-child { border-bottom: none; }
.settings-label { width: 140px; font-size: 13px; color: var(--text-muted); flex-shrink: 0; }
.settings-value { font-size: 14px; }

/* Loading & Empty */
.loading { display: flex; align-items: center; justify-content: center; padding: 60px; }
.spinner { 
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 600ms linear infinite;
}
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.error-msg { padding: 12px 16px; background: #fef2f2; color: var(--danger); border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.success-msg { padding: 12px 16px; background: var(--success-bg); color: var(--success); border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }

/* User Management */
.users-table-container { overflow-x: auto; }
.users-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.users-table th { text-align: left; padding: 12px 10px; font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--border); cursor: pointer; user-select: none; }
.users-table th:hover { color: var(--text); background: rgba(79,110,247,0.05); }
.users-table td { padding: 12px 10px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.users-table tbody tr:hover { background: var(--hover-bg); }
.inactive-row { opacity: 0.5; }
/* Skeleton Loading */
.skeleton-stats { display:grid;grid-template-columns:repeat(4,1fr);gap:20px; }
.skeleton-card { height:100px;background:var(--border-light);border-radius:var(--radius);animation:pulse 1.5s ease-in-out infinite; }
.skeleton-grid { display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:20px; }
.skeleton-product { height:160px;background:var(--border-light);border-radius:var(--radius);animation:pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:0.5; } 50% { opacity:1; } }

/* Activity List */
.activity-list { max-height: 400px; overflow-y: auto; }
.activity-item { display: flex; align-items: flex-start; gap: 12px; padding: 10px; border-radius: var(--radius-sm); transition: background var(--transition); }
.activity-item:hover { background: var(--border-light); }
.activity-icon {
  font-size: 15px; flex-shrink: 0; width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: var(--border-light); display: flex; align-items: center; justify-content: center;
}
.activity-body { flex: 1; }
.activity-title { font-size: 14px; color: var(--text); }
.activity-time { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* Bar Chart */
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-item { display: flex; align-items: center; gap: 12px; }
.bar-label { width: 40px; font-size: 12px; color: var(--text-muted); text-align: right; flex-shrink: 0; }
.bar-track { flex: 1; height: 24px; background: var(--border-light); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width 0.5s; min-width: 4px; }
.bar-value { font-size: 13px; font-weight: 600; color: var(--text); width: 30px; text-align: right; }

/* Search result snippet with highlights */
.sr-snippet { font-size: 13px; color: var(--text-muted); margin: 4px 0; line-height: 1.5; }
.sr-snippet mark { background: #fef08a; color: #333; padding: 1px 3px; border-radius: 2px; }

/* Inactive row */
.inactive-row { opacity: 0.6; }

/* Success card */
.success-card { background: var(--success-bg,#ecfdf5); border-radius: var(--radius); padding: 24px; }

/* Agent Activity */
.agent-widget { background: var(--card-bg); border-radius: var(--radius); padding: 20px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.mini-stat { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--bg); transition: background 0.2s; }
.mini-stat:hover { background: var(--border-light); }
.mini-stat-icon { font-size: 24px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); }
.progress-bar-track { display: inline-block; width: 80px; height: 6px; background: var(--border-light); border-radius: 4px; overflow: hidden; vertical-align: middle; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.5s; }

/* Trend chart for user activity */
.trend-chart {
  padding: 16px; background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.trend-chart .bar-fill { background: var(--accent); }

.offline-banner {
  background: #ff6b35;
  color: white;
  text-align: center;
  padding: 6px;
  font-size: 12px;
  font-weight: 600;
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}
[data-theme="dark"] .offline-banner {
  background: #cc5500;
}

/* Keyboard shortcut hint badge */
.shortcut-hint {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-muted); padding: 3px 8px;
  background: var(--border-light); border-radius: 4px;
  cursor: help;
}
.shortcut-hint kbd {
  font-family: monospace; background: var(--bg-card);
  padding: 1px 4px; border-radius: 3px; font-size: 11px;
  border: 1px solid var(--border);
}

/* Agent task type badges */
#agent-list-container .badge { font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; }


.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.status-dot.active { background: var(--success); }
.status-dot.inactive { background: var(--text-muted); }
.btn-sm { padding: 5px 10px; font-size: 12px; margin-left: 6px; }
.btn-danger { background: var(--danger); color: #fff; border: none; }
.btn-danger:hover { opacity: 0.85; }
.form-error { padding: 8px 12px; background: #fef2f2; color: var(--danger); border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13px; }

/* Toggle Switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: var(--border); transition: .3s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; transition: .3s; border-radius: 50%; }
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider:before { transform: translateX(20px); }
.success-msg { padding: 12px 16px; background: var(--success-bg); color: var(--success); border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }

/* Audit logs specific */
#audit-content .badge-healthy { background: var(--success-bg); color: var(--success); }

/* Animations */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive */
@media (max-width: 768px) {
  #sidebar { left: 8px; width: 52px; }
  .sidebar-nav a { justify-content: center; padding: 12px; }
  .sidebar-nav .nav-text, .sidebar-footer, .sidebar-new-chat-btn, .sidebar-recent-chats { display: none; }
  .header-brand .logo-text, .header-brand .sidebar-selector, #topbar h1 { display: none; }
  #topbar { padding: 0 16px; }
  #app-content { margin-left: 60px; padding: 96px 16px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-row { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .login-left { display: none; }
  .login-right { flex: none; width: 100%; }
}

/* ══════════════════════════════════════════════════════════
   Chat Module Styles
   ══════════════════════════════════════════════════════════ */

/* Connection Status Dot */
.ws-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 8px;
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}
.ws-status-connected {
  background: #22c55e;
  box-shadow: 0 0 6px 2px rgba(34, 197, 94, 0.5);
}
.ws-status-reconnecting {
  background: #f59e0b;
  box-shadow: 0 0 6px 2px rgba(245, 158, 11, 0.5);
  animation: wsPulse 1.5s ease-in-out infinite;
}
.ws-status-disconnected {
  background: #ef4444;
  box-shadow: 0 0 6px 2px rgba(239, 68, 68, 0.3);
}

@keyframes wsPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Chat Nav Badge */
.chat-nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #ef4444;
  border-radius: 9px;
  margin-left: auto;
  line-height: 1;
}

/* Chat Layout — message column + 262px members pane (design pack, screen 12) */
.chat-layout {
  display: grid;
  grid-template-columns: 1fr 262px;
  gap: 18px;
  height: calc(100vh - var(--topbar-height) - 48px);
  min-height: 0;
  overflow: hidden;
  background: transparent;
}

.chat-layout:has(.chat-member-panel.is-collapsed) { grid-template-columns: 1fr 44px; }

@media (max-width: 1100px) {
  .chat-layout { grid-template-columns: 1fr; }
}

.chat-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border-radius: 10px;
  flex-shrink: 0;
}

/* Main Chat Area */
.chat-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

.chat-thread-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border-bottom: none;
  background: transparent;
  min-height: 0;
  flex-shrink: 0;
}

.chat-thread-icon { display: none; }

.chat-thread-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-thread-scope {
  margin-left: auto;
  flex: none;
  white-space: nowrap;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--fill-subtle);
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 600;
}

.chat-group-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Messages Area */
.chat-messages-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.chat-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 14px;
  padding: 40px;
  text-align: center;
}

/* Individual Message */
.chat-message {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  max-width: 100%;
  animation: fadeInMsg 0.2s ease;
}

.chat-message.mine {
  align-self: flex-end;
  max-width: 74%;
}

.chat-message.system {
  align-self: center;
  max-width: 100%;
}

.chat-message.agent-reply {
  align-self: flex-start;
}

@keyframes fadeInMsg {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #60a5fa;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0;
}

/* Bonnie reads as a product mark, not a person — squircle, not a circle. */
.chat-msg-avatar.agent-avatar {
  border-radius: 8px;
  background: var(--gradient-brand);
  font-size: 11px;
}

.chat-msg-bubble {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border-card);
  border-radius: 4px 12px 12px 12px;
  padding: 12px 15px;
  min-width: 60px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-message.mine .chat-msg-bubble {
  background: var(--gradient-brand);
  border-color: transparent;
  border-radius: 12px 12px 4px 12px;
  color: #fff;
}

.chat-message.mine .chat-msg-content { color: #fff; }

.chat-message.agent-reply .chat-msg-bubble {
  background: var(--card-bg);
  border-color: var(--border-card);
  padding: 14px 16px;
  gap: 10px;
}

.chat-msg-header {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 0;
}

.chat-msg-user {
  font-size: 12px;
  font-weight: 600;
}

/* Source chips — every substantive AI claim names the tools behind it. */
.chat-source-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-source-chip {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--fill-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
}
.chat-source-chip.is-document { background: var(--primary-light); color: var(--primary-deep); }

.chat-msg-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 3px;
  border-top: 1px solid var(--fill-subtle);
}

.chat-action-btn {
  flex: none;
  white-space: nowrap;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: #3f3f46;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.chat-action-btn:hover { background: var(--fill-subtle); }
.chat-action-btn:disabled { opacity: 0.5; cursor: default; }

.chat-msg-foot {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.chat-mention {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary-deep);
  font-weight: 600;
}
.chat-message.mine .chat-mention { background: rgba(255,255,255,0.22); color: #fff; }

.chat-msg-time {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--text-muted);
}

.chat-msg-content {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  color: var(--text);
}

/* AI reply formatting — headers/bold/code/lists rendered from markdown
   (see renderAgentMarkdown in chat.js). Newlines are real <br> tags here,
   so this overrides the plain-text pre-wrap above. */
.chat-msg-content.ai-formatted {
  white-space: normal;
}

/* Generic catch-all: every element (and the container itself, for bare text
   nodes not wrapped in any tag — e.g. plain paragraph lines joined by <br>)
   gets an explicit text color instead of relying on inheritance. This is
   the pattern every specific fix above already followed one element at a
   time (headers, strong, list items, markers, table cells) — this closes
   the rest in one shot instead of chasing each remaining tag individually.
   Safe against the intentional code/inline-code colors below: those
   selectors are more specific (3 classes vs. 2 here) and win regardless. */
.chat-msg-content.ai-formatted,
.chat-msg-content.ai-formatted * {
  color: var(--text);
}

.chat-msg-content.ai-formatted .msg-h2,
.chat-msg-content.ai-formatted .msg-h3,
.chat-msg-content.ai-formatted .msg-h4 {
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin: 10px 0 4px;
}
.chat-msg-content.ai-formatted .msg-h2 { font-size: 16px; }
.chat-msg-content.ai-formatted .msg-h3 { font-size: 15px; }
.chat-msg-content.ai-formatted .msg-h4 { font-size: 14px; }
.chat-msg-content.ai-formatted .msg-h2:first-child,
.chat-msg-content.ai-formatted .msg-h3:first-child,
.chat-msg-content.ai-formatted .msg-h4:first-child {
  margin-top: 0;
}

.chat-msg-content.ai-formatted strong {
  font-weight: 700;
  color: var(--text);
}

.chat-msg-content.ai-formatted .msg-inline-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: rgba(139,54,217,0.08);
  color: #6b21a8;
  padding: 1px 5px;
  border-radius: 4px;
}

.chat-msg-content.ai-formatted .msg-code-block {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  background: #1e1330;
  color: #e9d5ff;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 6px 0;
}
.chat-msg-content.ai-formatted .msg-code-block code {
  background: none;
  padding: 0;
  color: inherit;
}

.chat-msg-content.ai-formatted .msg-list {
  margin: 4px 0 8px;
  padding-left: 20px;
  color: var(--text);
}
.chat-msg-content.ai-formatted .msg-list li {
  margin-bottom: 3px;
  color: var(--text);
}
.chat-msg-content.ai-formatted .msg-list li::marker {
  color: var(--text);
}
/* Numbered items render as one <ol> per line (see renderAgentMarkdown) so
   consecutive items stay visually tight instead of reading as separate lists. */
.chat-msg-content.ai-formatted ol.msg-list {
  margin: 1px 0;
}
.chat-msg-content.ai-formatted ol.msg-list + ol.msg-list {
  margin-top: 0;
}

[data-theme="dark"] .chat-msg-content.ai-formatted .msg-inline-code {
  background: rgba(216,180,254,0.12);
  color: #d8b4fe;
}

/* Markdown tables (e.g. ClickUp task lists) — were rendering as literal
   "| a | b |" pipe text before (see convertMarkdownTables in chat.js). Wide
   tables scroll inside their own box rather than the whole message. */
.chat-msg-content.ai-formatted .msg-table-wrap {
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.chat-msg-content.ai-formatted .msg-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  white-space: nowrap;
}
.chat-msg-content.ai-formatted .msg-table th,
.chat-msg-content.ai-formatted .msg-table td {
  padding: 7px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: normal;
}
.chat-msg-content.ai-formatted .msg-table th {
  background: rgba(139,54,217,0.08);
  color: var(--text);
  font-weight: 600;
}
.chat-msg-content.ai-formatted .msg-table td {
  color: var(--text);
}
.chat-msg-content.ai-formatted .msg-table tbody tr:last-child td {
  border-bottom: none;
}
[data-theme="dark"] .chat-msg-content.ai-formatted .msg-table th {
  background: rgba(216,180,254,0.1);
}
.chat-msg-content.ai-formatted .msg-chart {
  width: 100%;
  margin: 10px 0 4px;
  background: #ffffff;
  border: 1px solid #ece8f5;
  border-radius: 12px;
  padding: 8px;
  box-sizing: border-box;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] .chat-msg-content.ai-formatted .msg-chart {
  background: #1c1626;
  border-color: #2a2b33;
  box-shadow: none;
}

.chat-system-msg {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 6px 12px;
  background: var(--hover-bg);
  border-radius: 20px;
  max-width: 500px;
}

/* Input Area — a single bordered card holding the field and its tools */
.chat-input-container {
  position: relative;
  padding: 0;
  border-top: none;
  background: transparent;
  flex-shrink: 0;
}

.chat-composer {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  transition: border-color var(--transition);
}

.chat-composer:focus-within { border-color: var(--primary-border); }

.chat-input {
  width: 100%;
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: 13.5px;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  background: transparent;
  color: var(--text);
  max-height: 160px;
  outline: none;
}

.chat-input::placeholder { color: var(--text-muted); }

.chat-composer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-tool-btn {
  flex: none;
  white-space: nowrap;
  width: auto;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: #3f3f46;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.chat-tool-btn:hover { background: var(--fill-subtle); }

/* Model choice sits in the composer, where it is used. */
.chat-model-pill {
  flex: none;
  height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px 0 12px;
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  background: var(--primary-light);
}
.chat-model-pill select {
  border: none;
  background: transparent;
  color: var(--primary-deep);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  outline: none;
}

.chat-composer-hint {
  font-size: 11px;
  line-height: 1.4;
  font-weight: 400;
  color: var(--text-muted);
}

.chat-send-btn {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--gradient-brand);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: filter 0.15s, transform 0.1s;
}

.chat-send-btn:hover { filter: brightness(1.06); }
.chat-send-btn:active { transform: scale(0.95); }

.chat-send-btn:disabled,
.chat-send-btn.is-busy {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chat-mention-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 20;
}

/* Pending-attachment preview chips (above the compose row) */
.chat-attachment-previews {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 10px;
}

.chat-attach-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.chat-attach-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
}

.chat-attach-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-attach-thumb-icon {
  font-size: 18px;
}

.chat-attach-chip-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.chat-attach-chip-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.chat-attach-chip-size {
  font-size: 11px;
  color: var(--text-muted, #6b7280);
}

.chat-attach-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--danger, #ef4444);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Rendered attachments inside a message bubble */
.chat-attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.chat-image-wrap {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: zoom-in;
  background: var(--card-bg);
}

.chat-image-wrap img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.chat-video-wrap {
  margin-top: 8px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  max-width: 360px;
}

.chat-video-wrap video {
  width: 100%;
  display: block;
  max-height: 260px;
}

.chat-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.chat-file-card:hover {
  border-color: var(--primary);
  background: var(--card-bg);
}

.chat-file-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.chat-file-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  line-height: 1.3;
}

.chat-file-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-file-size {
  font-size: 11px;
  color: var(--text-muted, #6b7280);
}

.chat-file-dl {
  flex-shrink: 0;
  color: var(--text-muted, #6b7280);
  font-size: 16px;
}

/* Image lightbox */
.chat-lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.chat-lightbox-inner {
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chat-lightbox-inner > img {
  max-width: 100%;
  max-height: calc(92vh - 64px);
  object-fit: contain;
  border-radius: 8px;
}

.chat-lightbox-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  color: #fff;
}

.chat-lightbox-name {
  font-size: 13px;
  max-width: 40vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-lightbox-bar .btn {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.chat-lightbox-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

/* AI thinking / processing indicator */
.chat-thinking .chat-msg-bubble {
  min-width: 140px;
}

.chat-thinking-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 24px;
}

.chat-thinking-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.chat-thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chat-thinking-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: chatDotBounce 1.15s ease-in-out infinite;
}

.chat-thinking-dots span:nth-child(2) { animation-delay: 0.16s; }
.chat-thinking-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes chatDotBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* Typing Indicator */
.chat-typing-indicator {
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 4px 6px;
  font-style: italic;
  animation: typingPulse 1.5s ease-in-out infinite;
}

@keyframes typingPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Load More */
.chat-load-more {
  text-align: center;
  padding: 8px 0;
}

/* Members Panel — the chat's roster, collapsible to an avatar rail */
.chat-member-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--border-light);
  padding-left: 16px;
  background: transparent;
}

.chat-member-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border-bottom: none;
  flex: none;
}

.chat-member-heading {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.chat-member-count {
  flex: none;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--fill-subtle);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
}

.chat-member-collapse {
  margin-left: auto;
  flex: none;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}
.chat-member-collapse:hover { color: var(--text); }

.chat-member-list {
  flex: none;
  overflow-y: visible;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.chat-member-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0;
  border-radius: 8px;
  font-size: 12.5px;
  transition: background 0.15s;
}

.chat-member-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #60a5fa;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.chat-member-avatar.agent { background: var(--gradient-brand); border-radius: 50%; }

.chat-member-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }

.chat-member-name {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-member-you { font-weight: 400; color: var(--text-muted); }

.chat-member-sub {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Add someone */
.chat-member-add {
  flex: none;
  border: 1px dashed var(--primary-border);
  background: #fdf7fd;
  border-radius: var(--radius-nav);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
[data-theme="dark"] .chat-member-add { background: var(--primary-light); }
.chat-member-add[hidden] { display: none; }
.chat-member-add-title { font-size: 12px; font-weight: 600; color: var(--primary-deep); }
.chat-member-add-input {
  width: 100%;
  text-align: left;
  background: var(--card-bg);
  border: 1px solid var(--primary-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
}
.chat-member-add-input:hover { color: var(--text); }
.chat-member-add-hint { font-size: 10.5px; line-height: 1.5; color: var(--text-tertiary); }

/* Recently mentioned */
.chat-member-mentioned { flex: none; display: flex; flex-direction: column; gap: 6px; }
.chat-member-mentioned[hidden] { display: none; }
.chat-member-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-mention-chip {
  flex: none;
  padding: 5px 9px;
  border: none;
  border-radius: 999px;
  background: var(--fill-subtle);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.chat-mention-chip.is-active { background: var(--primary-light); color: var(--primary-deep); }
.chat-mention-chip:hover { background: var(--primary-light); color: var(--primary-deep); }

.chat-member-note {
  margin-top: auto;
  flex: none;
  font-size: 10.5px;
  line-height: 1.5;
  font-weight: 400;
  color: var(--text-muted);
}

/* Collapsed: an avatar rail, but unread/presence stays legible */
.chat-member-panel.is-collapsed { padding-left: 10px; align-items: center; }
.chat-member-panel.is-collapsed .chat-member-heading,
.chat-member-panel.is-collapsed .chat-member-count,
.chat-member-panel.is-collapsed .chat-member-info,
.chat-member-panel.is-collapsed .chat-member-add,
.chat-member-panel.is-collapsed .chat-member-mentioned,
.chat-member-panel.is-collapsed .chat-member-note { display: none; }
.chat-member-panel.is-collapsed .chat-member-collapse { margin: 0; transform: rotate(180deg); }

/* Online Dots */
.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s;
}
.online-dot.online { background: #10b981; }
.online-dot.offline { background: transparent; }

/* Responsive Chat */
@media (max-width: 1100px) {
  .chat-member-panel { display: none; }
}
@media (max-width: 768px) {
  .chat-message { max-width: 95%; }
}

/* Danger button variant */
.btn-danger {
  background: var(--danger);
  color: #fff;
  border: 1px solid var(--danger);
}
.btn-danger:hover {
  background: var(--danger-hover);
}

/* Extra small button */
.btn-xs {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
}
.btn-ghost:hover {
  background: var(--hover-bg);
  color: var(--text);
}

/* ─── Chat UI ─────────────────────────────────────────────── */


/* ─── Settings sub-nav (BonnieOS redesign — Screen 11: Settings → Team & access) ─── */
.settings-layout { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
.settings-sidebar { position: sticky; top: 24px; }
.settings-subnav { display: flex; flex-direction: column; gap: 2px; }
.settings-subnav-kicker {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-muted); padding: 0 12px 8px;
}
.settings-subnav-item { display: block; padding: 9px 12px; border-radius: 999px; font-size: 14px; color: var(--text-muted); cursor: pointer; text-decoration: none; transition: background var(--transition), color var(--transition); }
.settings-subnav-item:hover { background: var(--hover-bg); color: var(--text); }
.settings-subnav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.settings-subnav-note { margin-top: 14px; padding: 12px; border: 1px solid var(--border-light); border-radius: 8px; font-size: 12px; color: var(--text-muted); line-height: 1.5; background: var(--card-bg); }

.settings-content { background: var(--card-bg); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); min-height: 420px; }
.settings-pane-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.settings-pane-header.row { align-items: center; }
.settings-pane-header h2 { font-size: 20px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; color: var(--text); }
.settings-lede { font-size: 14px; color: var(--text-muted); margin: 0; line-height: 1.55; }
.settings-pane-section { margin-bottom: 28px; }
.settings-pane-section:last-child { margin-bottom: 0; }
.settings-pane-section-title { font-size: 12.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }

.role-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 28px; }
.role-card { border: 1px solid var(--border-light); border-radius: 10px; padding: 16px; background: var(--card-bg); }
.role-card p { font-size: 13px; color: var(--text-muted); margin: 10px 0 0; line-height: 1.5; }
.role-card-badge { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; padding: 3px 8px; border-radius: 4px; }
.role-card-badge.role-admin { background: var(--primary-light); color: var(--primary); }
.role-card-badge.role-member { background: var(--border-light); color: var(--text-secondary); }

.radio-row { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--border-light); border-radius: 10px; margin-bottom: 10px; cursor: pointer; }
.radio-row input { margin-top: 3px; accent-color: var(--primary); }
.radio-title { display: block; font-size: 14px; font-weight: 600; color: var(--text); }
.radio-sub { display: block; font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.radio-control { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; margin-top: 2px; transition: border-color 120ms, box-shadow 120ms; }
.radio-row input:checked ~ .radio-control { border-color: var(--primary); box-shadow: inset 0 0 0 4px var(--primary); }

.product-access-list { display: flex; flex-wrap: wrap; gap: 10px; padding: 2px 2px 4px 28px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); padding: 8px 12px; border: 1px solid var(--border-light); border-radius: 8px; cursor: pointer; }
.checkbox-row input { accent-color: var(--primary); }

.team-search { max-width: 220px; font-size: 13px; }
.team-table-wrap { overflow-x: auto; }
.team-table td { padding: 12px 10px; }
.team-member-cell { display: flex; align-items: center; gap: 10px; }
.team-member-name { font-weight: 600; font-size: 14px; color: var(--text); }
.team-member-email { font-size: 12.5px; color: var(--text-muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex-shrink: 0; }
.avatar-sm { width: 30px; height: 30px; font-size: 13px; }

.team-status { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; padding: 3px 8px; border-radius: 4px; }
.team-status-active { background: var(--success-bg); color: var(--success); }
.team-status-pending { background: var(--warning-bg); color: var(--warning); }
.team-status-hint { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

.count-pill { display: inline-block; min-width: 22px; text-align: center; font-size: 12px; font-weight: 600; color: var(--text-muted); background: var(--border-light); border-radius: 10px; padding: 1px 8px; margin-left: 6px; }

.member-note { margin-top: 8px; padding: 16px 18px; border: 1px solid var(--border-light); border-radius: 10px; background: var(--hover-bg); }
.member-note-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.member-note p { font-size: 13px; color: var(--text-muted); margin: 0; line-height: 1.55; }

.role-radio-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-radio { cursor: pointer; position: relative; }
.role-radio input { position: absolute; opacity: 0; pointer-events: none; }
.role-radio-card { display: flex; flex-direction: column; gap: 8px; border: 1.5px solid var(--border-light); border-radius: 10px; padding: 14px; transition: border-color 120ms, background 120ms; }
.role-radio input:checked + .role-radio-card { border-color: var(--primary); background: var(--primary-light); }
.role-radio-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.45; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.text-muted { color: var(--text-muted); }

@media (max-width: 900px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-sidebar { position: static; }
  .role-cards, .role-radio-group { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════════════
   Design-pack parity layer
   Measurements below come straight from BonnieOS Onboarding.dc.html /
   BonnieShell.dc.html. This block is loaded last so it settles the
   primitives the older rules above disagree with.
   ══════════════════════════════════════════════════════════════════ */

/* — account menu (holds theme / install / logout so the topbar matches) — */
.user-menu {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 178px;
  display: none; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 300;
}
.user-menu.open { display: flex; }
.user-menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: none; border-radius: 8px; background: none;
  font-family: inherit; font-size: 12.5px; font-weight: 500; color: var(--text-secondary);
  text-align: left; cursor: pointer; transition: background var(--transition);
}
.user-menu-item:hover { background: var(--fill-subtle); color: var(--text); }
.user-menu .logout-btn { height: auto; border: none; }
.user-menu .logout-btn:hover { background: var(--danger-bg); color: var(--danger); }

/* — page headers — */
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 23px; font-weight: 700; line-height: 1.25; letter-spacing: -0.025em; }
.page-header .subtitle { font-size: 13.5px; font-weight: 400; color: var(--text-tertiary); margin-top: 4px; }
.page-eyebrow {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 6px;
}

/* — buttons — */
.btn {
  padding: 9px 14px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border); background: var(--card-bg); color: var(--text);
}
.btn:hover { background: var(--fill-subtle); }
.btn-primary { background: var(--gradient-brand); color: #fff; border-color: transparent; }
.btn-primary:hover { background: var(--gradient-brand); filter: brightness(1.06); }
.btn-secondary { background: var(--card-bg); color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 6px 11px; font-size: 11.5px; border-radius: 8px; }
.btn-xs { padding: 4px 9px; font-size: 11px; border-radius: 6px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--fill-subtle); color: var(--text); }
.btn-connect {
  background: var(--gradient-brand); border: none; border-radius: var(--radius-sm);
  padding: 9px 14px; font-size: 12.5px; font-weight: 600;
}
.btn-connect:disabled { background: var(--fill-subtle); color: var(--text-muted); }

/* — surfaces — */
.stat-card, .table-container, .depth-banner {
  border: 1px solid var(--border-card); border-radius: var(--radius);
  background: var(--card-bg); box-shadow: none;
}
.stat-card { padding: 14px 16px; gap: 12px; }
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon { width: 32px; height: 32px; border-radius: 8px; font-size: 15px; }
.stat-info h3 { font-size: 24px; font-weight: 700; letter-spacing: -0.025em; }
.stat-info p { font-size: 11.5px; color: var(--text-tertiary); margin-top: 2px; }
.stats-grid { gap: 12px; margin-bottom: 20px; }

/* — depth banner — */
.depth-banner { padding: 12px 16px; min-width: 238px; max-width: 300px; }
.depth-label { font-size: 12px; font-weight: 600; color: var(--text); text-transform: none; letter-spacing: 0; }
.depth-pct { font-size: 15px; font-weight: 700; color: var(--primary); }
.depth-bar { height: 6px; background: var(--fill-subtle); margin-bottom: 0; }
.depth-cats { margin-top: 7px; }
.depth-cat { font-size: 11px; padding: 3px 8px; }
.depth-gate { margin-top: 7px; font-size: 11px; color: var(--text-muted); font-weight: 400; }

/* — badges — */
.badge { padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; gap: 5px; }
.badge-invalid { background: var(--danger-bg); color: var(--danger); }
.badge-default { background: var(--fill-subtle); color: var(--text-secondary); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* — forms — */
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea,
.form-input, .form-select, .form-textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 12.5px; color: var(--text); background: var(--card-bg);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus,
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-muted); }

/* — tables — */
thead th {
  padding: 10px 14px; font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.08em; color: var(--text-muted);
  background: var(--card-bg); border-bottom: 1px solid var(--border-card);
}
tbody td { padding: 11px 14px; font-size: 12.5px; border-bottom: 1px solid var(--border-light); }
tbody tr:hover { background: var(--fill-subtle); }

/* — tabs — */
.tabs { border-bottom: 1px solid var(--border-card); margin-bottom: 16px; }
.tab { padding: 9px 14px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* — modals — */
.modal, .modal-content { border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.modal-overlay { background: rgba(24,24,27,0.42); }

/* ─── Screen 10 — product context panel ─── */
.ctx-grid { display: grid; grid-template-columns: 1fr 1.25fr; gap: 18px; align-items: start; }
.ctx-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ctx-title h1 { font-size: 23px; font-weight: 700; line-height: 1.25; letter-spacing: -0.025em; color: var(--text); }
.ctx-subtitle { font-size: 13.5px; color: var(--text-tertiary); margin-top: 4px; line-height: 1.5; }
.ctx-card {
  background: var(--card-bg); border: 1px solid var(--border-card); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 11px;
}
.ctx-card-head { display: flex; align-items: center; gap: 9px; }
.ctx-card-head h3 { font-size: 14.5px; font-weight: 600; color: var(--text); margin: 0; }
.ctx-count {
  font-size: 10.5px; font-weight: 600; background: var(--fill-subtle); color: var(--text-secondary);
  padding: 4px 9px; border-radius: 999px; flex: none;
}
.ctx-link {
  margin-left: auto; flex: none; white-space: nowrap; border: none; background: none; padding: 0;
  font-family: inherit; font-size: 12px; font-weight: 600; color: var(--primary); cursor: pointer;
}
.ctx-link:hover { color: var(--primary-hover); text-decoration: underline; }
.ctx-link-block { margin-left: 0; align-self: flex-start; }
.ctx-rows { display: flex; flex-direction: column; gap: 8px; }
.ctx-row {
  border: 1px solid var(--border-light); border-radius: 9px; padding: 11px 13px;
  display: flex; gap: 10px; align-items: flex-start;
}
.ctx-row-file, .ctx-row-schedule { align-items: center; padding: 12px 13px; }
.ctx-row-text { font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); min-width: 0; }
.ctx-row-title { font-size: 12.5px; font-weight: 600; color: var(--text); }
.ctx-row-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.ctx-file-name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-row-remove {
  margin-left: auto; flex: none; border: none; background: none; padding: 0 2px; line-height: 1;
  font-size: 15px; color: var(--text-muted); cursor: pointer;
}
.ctx-row-remove:hover { color: var(--danger); }
.ctx-scope { font-size: 11px; color: var(--text-muted); }
.ctx-empty { font-size: 12.5px; color: var(--text-muted); margin: 0; }
.ctx-foot { font-size: 11.5px; line-height: 1.5; color: var(--text-muted); }
.ctx-foot-lead { margin-top: -2px; }
.ctx-instruction { font-size: 12.5px; line-height: 1.65; color: var(--text-secondary); margin: 0 0 6px; }
.ctx-instruction:last-child { margin-bottom: 0; }

.ctx-chip { font-size: 10px; font-weight: 600; padding: 3px 7px; border-radius: 5px; flex: none; letter-spacing: 0.02em; }
.ctx-chip-decision { background: var(--info-bg); color: var(--info); }
.ctx-chip-fact { background: var(--primary-light); color: var(--primary-hover); }
.ctx-chip-neutral { background: var(--fill-subtle); color: var(--text-secondary); }

.ctx-file-square { width: 28px; height: 28px; border-radius: 8px; flex: none; }
.ctx-tint-read { background: #dcfce7; }
.ctx-tint-linked { background: #e0e7ff; }
.ctx-tint-stored { background: #fef3c7; }
.ctx-badge { margin-left: auto; flex: none; font-size: 10.5px; font-weight: 600; padding: 4px 9px; border-radius: 999px; }
.ctx-badge-read { background: var(--success-bg); color: var(--success); }
.ctx-badge-linked { background: var(--info-bg); color: var(--info); }
.ctx-badge-stored { background: var(--warning-bg); color: var(--warning); }

.ctx-card-grow { flex: 1; }
.ctx-drop {
  border: 1.5px dashed var(--primary-border); background: #fdf7fd; border-radius: 10px;
  padding: 18px; font-size: 12.5px; color: var(--primary); text-align: left; cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.ctx-drop:hover, .ctx-drop.is-over { background: var(--primary-light); border-color: var(--primary); }

.ctx-toggle {
  margin-left: auto; flex: none; width: 34px; height: 19px; border: none; border-radius: 999px;
  background: var(--border); padding: 2px; cursor: pointer;
  display: flex; align-items: center; justify-content: flex-start; transition: background var(--transition);
}
.ctx-toggle.is-on { background: var(--gradient-brand); justify-content: flex-end; }
.ctx-toggle-knob { width: 15px; height: 15px; border-radius: 50%; background: #fff; }

.ctx-edit-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.ctx-edit-input { flex: 1; resize: vertical; line-height: 1.55; }
.ctx-edit-actions { display: flex; gap: 8px; }

@media (max-width: 900px) { .ctx-grid { grid-template-columns: 1fr; } }
[data-theme="dark"] .ctx-drop { background: var(--primary-light); }
[data-theme="dark"] .ctx-tint-read { background: #14532d; }
[data-theme="dark"] .ctx-tint-linked { background: #1e2a5a; }
[data-theme="dark"] .ctx-tint-stored { background: #452a05; }

/* ─── Screen 11 — invite / team & access ─── */
.settings-layout { grid-template-columns: 168px 1fr; gap: 18px; }
.settings-content-flush { background: none; padding: 0; box-shadow: none; min-height: 0; }
.team-access-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; align-items: start; }
.team-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.invite-card {
  background: var(--card-bg); border: 1px solid var(--border-card); border-radius: var(--radius);
  padding: 22px; display: flex; flex-direction: column; gap: 16px;
}
.invite-card .form-group { margin-bottom: 0; }
.invite-head h2 { font-size: 21px; font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; margin: 0 0 4px; color: var(--text); }
.invite-actions { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.invite-actions .btn { padding: 11px 17px; font-size: 13.5px; border-radius: 10px; flex: none; white-space: nowrap; }
.modal .invite-head { display: none; }

.team-card {
  background: var(--card-bg); border: 1px solid var(--border-card); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 11px;
}
.team-card-head { display: flex; align-items: center; gap: 9px; }
.team-card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.team-card .team-search { margin-left: auto; max-width: 130px; font-size: 12px; padding: 6px 9px; }
.team-rows { display: flex; flex-direction: column; gap: 8px; }
.team-row {
  border: 1px solid var(--border-light); border-radius: 10px; padding: 12px 13px;
  display: flex; align-items: center; gap: 11px;
}
.team-avatar {
  width: 28px; height: 28px; flex: none; border-radius: 50%; color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.team-avatar-pending { background: var(--fill-subtle); color: var(--text-muted); }
.team-row-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.team-row .team-member-name { font-size: 12.5px; font-weight: 600; color: var(--text); }
.team-member-sub { font-size: 11px; color: var(--text-muted); }
.team-row .team-status { margin-left: auto; flex: none; font-size: 10.5px; padding: 4px 9px; border-radius: 999px; letter-spacing: 0.04em; }
.team-status-admin { background: var(--primary-light); color: var(--primary-hover); }
.team-status-member { background: var(--fill-subtle); color: var(--text-secondary); }
.team-status-pending { background: var(--warning-bg); color: var(--warning); }
.team-row-edit {
  flex: none; border: none; background: none; padding: 0; font-family: inherit;
  font-size: 11px; font-weight: 600; color: var(--primary); cursor: pointer; opacity: 0;
  transition: opacity var(--transition);
}
.team-row:hover .team-row-edit, .team-row-edit:focus { opacity: 1; }

.member-note { margin-top: 0; padding: 16px; border-radius: var(--radius); background: #fdf7fd; border-color: #f7dcf6; }
.member-note-title { font-size: 13px; color: var(--primary-deep); }
.member-note p { font-size: 12.5px; line-height: 1.65; color: var(--text-secondary); }
[data-theme="dark"] .member-note { background: var(--primary-light); border-color: var(--primary-border); }

/* the pack's product-access rows use a square gradient tick, not a radio dot */
.product-access { display: flex; flex-direction: column; gap: 9px; }
.product-access .radio-row { position: relative; margin-bottom: 0; align-items: center; padding: 13px 14px; border-radius: 11px; }
.product-access .radio-row-compact { padding: 9px 14px; }
.product-access .radio-row input { position: absolute; opacity: 0; pointer-events: none; }
.product-access .radio-control {
  width: 17px; height: 17px; border-radius: 5px; border: 1.5px solid var(--border);
  margin-top: 0; display: flex; align-items: center; justify-content: center;
}
.product-access .radio-row input:checked ~ .radio-control {
  border-color: transparent; box-shadow: none; background: var(--gradient-brand);
}
.product-access .radio-row input:checked ~ .radio-control::after {
  content: '✓'; color: #fff; font-size: 10px; font-weight: 700; line-height: 1;
}
.product-access .radio-row:has(input:checked) { border-color: var(--primary); border-width: 1.5px; background: #fdf7fd; }
.product-access .radio-title { font-size: 13px; }
.product-access .radio-sub { font-size: 11.5px; color: var(--text-tertiary); }
.product-access-list { padding: 0; gap: 10px; transition: opacity var(--transition); }
.product-access-list.is-dimmed { opacity: 0.55; }
.product-access-list .checkbox-row { flex: 1; padding: 13px 14px; border-radius: 11px; font-size: 13px; font-weight: 600; }
[data-theme="dark"] .product-access .radio-row:has(input:checked) { background: var(--primary-light); }

@media (max-width: 1100px) { .team-access-grid { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .settings-layout { grid-template-columns: 1fr; } }

/* ─── Screen 13 — notification centre ─── */
#notif-scrim { position: fixed; inset: 0; background: rgba(24,24,27,0.14); z-index: 200; }
#notif-panel {
  position: fixed; right: 22px; top: calc(var(--topbar-height) + 8px); width: 372px;
  max-height: min(560px, calc(100vh - var(--topbar-height) - 32px));
  background: var(--card-bg); border: 1px solid #e8e8ee; border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(24,24,27,0.16); z-index: 201;
  display: flex; flex-direction: column; overflow: hidden;
}
.notif-head { padding: 13px 16px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; gap: 9px; }
.notif-head strong { font-size: 14px; font-weight: 700; color: var(--text); }
.notif-new {
  font-size: 10px; font-weight: 600; background: var(--gradient-brand); color: #fff;
  padding: 3px 8px; border-radius: 999px; flex: none;
}
.notif-link {
  margin-left: auto; flex: none; white-space: nowrap; border: none; background: none; padding: 0;
  font-family: inherit; font-size: 11.5px; font-weight: 600; color: var(--primary); cursor: pointer;
}
.notif-link:hover { color: var(--primary-hover); text-decoration: underline; }
.notif-tabs { display: flex; gap: 5px; padding: 10px 16px; border-bottom: 1px solid var(--border-light); }
.notif-tab {
  border: none; background: none; padding: 5px 10px; border-radius: 7px; flex: none; white-space: nowrap;
  font-family: inherit; font-size: 11.5px; font-weight: 600; color: var(--text-tertiary); cursor: pointer;
}
.notif-tab:hover { background: var(--fill-subtle); }
.notif-tab.active { background: var(--primary-light); color: var(--primary-deep); }
.notif-rows { overflow-y: auto; flex: 1; min-height: 0; }
.notif-row {
  padding: 13px 16px; border-bottom: 1px solid var(--border-light); text-decoration: none;
  display: flex; gap: 11px; align-items: flex-start;
}
.notif-row:hover { background: var(--fill-subtle); }
.notif-row.unread { background: #fdf7fd; }
.notif-row.unread:hover { background: var(--primary-light); }
.notif-avatar, .notif-square { width: 28px; height: 28px; flex: none; }
.notif-avatar {
  border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.notif-square { border-radius: 8px; }
.notif-square-report { background: #dcfce7; }
.notif-square-connector { background: #fffbeb; }
.notif-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.notif-title { font-size: 12.5px; font-weight: 400; line-height: 1.55; color: var(--text-strong); }
.notif-row .notif-title strong { font-weight: 700; }
.notif-row:not(.unread) .notif-title { color: var(--text-secondary); }
.notif-sub { font-size: 11px; color: var(--text-muted); }
.notif-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--primary); margin-top: 6px; }
.notif-foot {
  padding: 11px 16px; display: flex; align-items: center; gap: 9px;
  font-size: 11px; line-height: 1.5; color: var(--text-muted);
}
.notif-empty { padding: 16px; font-size: 12.5px; color: var(--text-muted); margin: 0; }
[data-theme="dark"] #notif-panel { border-color: var(--border); }
[data-theme="dark"] .notif-row.unread { background: var(--primary-light); }
[data-theme="dark"] .notif-square-report { background: #14532d; }
[data-theme="dark"] .notif-square-connector { background: #452a05; }

/* ─── Screens 05 / 07 — connector ladder + health stack ─── */
.conn-page {
  display: flex; flex-direction: column; gap: 15px;
  min-height: calc(100vh - var(--topbar-height) - 48px);
}
.conn-head { display: flex; align-items: flex-end; gap: 16px; }
.conn-head-copy { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.conn-head-copy h1 {
  font-size: 23px; font-weight: 700; line-height: 1.25; letter-spacing: -0.025em;
  color: var(--text); margin: 0;
}
.conn-sub { font-size: 13.5px; font-weight: 400; color: var(--text-tertiary); }
.conn-head-actions { margin-left: auto; display: flex; gap: 8px; flex: none; }

.conn-depth {
  margin-left: auto; width: 238px; flex: none;
  background: var(--card-bg); border: 1px solid var(--border-card); border-radius: 11px;
  padding: 12px 16px; display: flex; flex-direction: column; gap: 7px;
}
.conn-depth-head { display: flex; align-items: baseline; gap: 8px; }
.conn-depth-label { font-size: 12px; font-weight: 600; color: var(--text); }
.conn-depth-pct { margin-left: auto; font-size: 15px; font-weight: 700; color: var(--primary); }
.conn-depth-bar { height: 6px; border-radius: 999px; background: var(--fill-subtle); overflow: hidden; }
.conn-depth-fill { height: 100%; background: var(--gradient-brand); border-radius: 999px; }
.conn-depth-gate { font-size: 11px; font-weight: 400; color: var(--text-muted); }

.conn-body { display: flex; flex-direction: column; gap: 11px; flex: 1; min-height: 0; }
.conn-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; padding: 10px 14px; flex: none; white-space: nowrap;
  font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; line-height: 1.2;
}
.conn-btn-primary { background: var(--gradient-brand); color: #fff; border-color: transparent; }
.conn-btn-primary:hover { opacity: 0.94; }
.conn-btn-ghost { background: #fff; color: #3f3f46; border-color: var(--border); }
.conn-btn-ghost:hover { background: var(--fill-subtle); }
.conn-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.conn-swatch { flex: none; border-radius: 8px; }
.conn-swatch-lg { width: 38px; height: 38px; border-radius: 10px; }
.conn-swatch-md { width: 34px; height: 34px; border-radius: 9px; }
.conn-swatch-sm { width: 30px; height: 30px; border-radius: 8px; }

.conn-required {
  background: var(--card-bg); border: 1.5px solid var(--primary); border-radius: 12px;
  padding: 18px; display: flex; gap: 18px; align-items: center;
  box-shadow: 0 6px 18px rgba(192, 38, 211, 0.09);
}
.conn-required-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.conn-required-title {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  font-size: 15px; font-weight: 700; color: var(--text);
}
.conn-required-pill {
  font-size: 10.5px; font-weight: 600; background: var(--gradient-brand); color: #fff;
  padding: 3px 8px; border-radius: 999px;
}
.conn-required-blurb { font-size: 12.5px; font-weight: 400; color: var(--text-tertiary); }
.conn-required-actions { margin-left: auto; display: flex; gap: 8px; flex: none; flex-wrap: wrap; justify-content: flex-end; }

.conn-payoff-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); margin-top: 2px;
}
.conn-payoff { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; flex: 1; min-height: 0; }
.conn-rung {
  background: var(--card-bg); border: 1px solid var(--border-card); border-radius: 12px;
  padding: 17px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.conn-rung-top { display: flex; align-items: center; gap: 9px; }
.conn-rung-top .conn-swatch { width: 30px; height: 30px; }
.conn-gain {
  margin-left: auto; font-size: 11px; font-weight: 700; background: var(--fill-subtle);
  color: #3f3f46; padding: 4px 9px; border-radius: 999px;
}
.conn-rung-title { font-size: 14.5px; font-weight: 600; color: var(--text); }
.conn-rung-blurb { font-size: 12.5px; line-height: 1.55; font-weight: 400; color: var(--text-tertiary); }
.conn-rung-actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 7px; }
.conn-rung-actions .conn-btn { padding: 9px 13px; }

.conn-live-chip {
  font-size: 10.5px; font-weight: 600; background: var(--success-bg); color: var(--success);
  padding: 4px 9px; border-radius: 999px;
}

.conn-help {
  background: var(--card-bg); border: 1px dashed var(--primary-border); border-radius: 12px;
  padding: 15px 17px; display: flex; align-items: center; gap: 14px;
}
.conn-help-title { font-size: 13.5px; font-weight: 600; color: var(--text); flex: none; }
.conn-help-copy { font-size: 12.5px; font-weight: 400; color: var(--text-tertiary); }
.conn-help-actions { margin-left: auto; display: flex; gap: 8px; flex: none; }
.conn-help-actions .conn-btn { padding: 9px 14px; }
.conn-back {
  align-self: flex-start; border: none; background: none; padding: 0;
  font-family: inherit; font-size: 12px; font-weight: 600; color: var(--primary); cursor: pointer;
}

.conn-stack { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.conn-issue {
  background: var(--card-bg); border-radius: 12px; padding: 17px;
  display: flex; align-items: center; gap: 16px;
}
.conn-issue-revoked { border: 1.5px solid var(--danger-border); }
.conn-issue-expiring { border: 1px solid #fde68a; }
.conn-issue-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.conn-issue-title { display: flex; align-items: center; gap: 9px; font-size: 14.5px; font-weight: 600; color: var(--text); }
.conn-issue-sub { font-size: 12.5px; font-weight: 400; color: var(--text-tertiary); }
.conn-issue-actions { margin-left: auto; display: flex; gap: 8px; flex: none; }
.conn-issue-actions .conn-btn { padding: 9px 14px; }

.conn-live-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.conn-live {
  background: var(--card-bg); border: 1px solid var(--border-card); border-radius: 12px;
  padding: 15px; display: flex; align-items: center; gap: 12px; text-align: left;
  font-family: inherit; font-size: inherit; color: var(--text);
  cursor: pointer; width: 100%; -webkit-appearance: none; appearance: none;
}
.conn-live:hover { border-color: var(--primary-border); }
.conn-live-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.conn-live-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.conn-live-sub { font-size: 11.5px; font-weight: 400; color: var(--text-muted); }
.conn-live .conn-pill { margin-left: auto; }

.conn-pill {
  flex: none; font-size: 10.5px; font-weight: 600; padding: 4px 9px; border-radius: 999px;
  letter-spacing: 0.02em; white-space: nowrap;
}
.conn-pill-live { background: var(--success-bg); color: var(--success); }
.conn-pill-revoked { background: var(--danger-bg); color: var(--danger); }
.conn-pill-expiring { background: var(--warning-bg); color: var(--warning); }
.conn-pill-partial { background: var(--info-bg); color: var(--info); }
.conn-pill-unverified { background: var(--fill-subtle); color: var(--text-secondary); }

.conn-mcp-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.conn-foot {
  background: #fdf7fd; border: 1px solid #f7dcf6; border-radius: 12px;
  padding: 14px 16px; font-size: 12.5px; line-height: 1.6; color: var(--primary-deep);
  margin-top: auto;
}

@media (max-width: 1100px) {
  .conn-payoff, .conn-live-grid, .conn-mcp-grid { grid-template-columns: 1fr; }
  .conn-required, .conn-issue, .conn-help, .conn-head { flex-wrap: wrap; }
  .conn-required-actions, .conn-issue-actions, .conn-help-actions, .conn-depth, .conn-head-actions {
    margin-left: 0; width: 100%;
  }
}
[data-theme="dark"] .conn-foot { background: var(--primary-light); border-color: var(--primary-border); }
[data-theme="dark"] .conn-btn-ghost { background: var(--card-bg); color: var(--text); }

/* ─── Auth split (screen 01) ─── */
.auth-split-page { align-items: stretch; justify-content: stretch; }
.auth-split { display: flex; width: 100%; height: 100%; background: #fff; }
.auth-main {
  width: 52%; padding: 56px 60px; display: flex; flex-direction: column; gap: 22px;
  overflow: auto; box-sizing: border-box;
}
.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--gradient-brand);
  color: #fff; font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.auth-wordmark { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.auth-hero { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.auth-hero h1 { font-size: 32px; font-weight: 700; line-height: 1.2; letter-spacing: -0.03em; margin: 0; }
.auth-hero p { font-size: 14.5px; line-height: 1.6; font-weight: 400; color: #71717a; max-width: 420px; margin: 0; }
.auth-stack { display: flex; flex-direction: column; gap: 10px; max-width: 420px; margin-top: 6px; }
.auth-social {
  display: flex; align-items: center; gap: 11px; width: 100%;
  border: 1px solid #e4e4ea; border-radius: 10px; padding: 13px 15px;
  background: #fff; font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--text);
  cursor: pointer; text-align: left;
}
.auth-social:hover { border-color: var(--primary-border); background: #fdf7fd; }
.auth-social-chip { width: 18px; height: 18px; border-radius: 5px; opacity: 0.85; flex: none; }
.auth-or { display: flex; align-items: center; gap: 12px; margin: 4px 0; }
.auth-or span { flex: 1; height: 1px; background: #ececf1; }
.auth-or em { font-style: normal; font-size: 11.5px; font-weight: 500; color: #a1a1aa; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field label { font-size: 11.5px; font-weight: 600; color: #3f3f46; display: flex; align-items: baseline; gap: 8px; }
.auth-field-hint { font-size: 11.5px; font-weight: 400; color: #a1a1aa; }
.auth-field input {
  border: 1px solid #e4e4ea; border-radius: 10px; padding: 12px 14px;
  font-family: inherit; font-size: 13px; color: var(--text); background: #fff;
}
.auth-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.auth-cta { display: flex; align-items: center; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.auth-continue {
  background: var(--gradient-brand); color: #fff; border: none; border-radius: 10px;
  padding: 12px 18px; font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.auth-alt { font-size: 12.5px; font-weight: 400; color: #a1a1aa; }
.auth-alt a { color: var(--primary); font-weight: 600; }
.auth-foot { margin-top: auto; font-size: 12px; line-height: 1.6; font-weight: 400; color: #a1a1aa; max-width: 420px; }
.auth-preview {
  flex: 1; background: #fdf7fd; border-left: 1px solid #f0f0f4; padding: 56px 48px;
  display: flex; flex-direction: column; gap: 16px; justify-content: center;
}
.auth-preview-kicker { font-size: 10.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: #a1a1aa; }
.auth-preview-steps { display: flex; flex-direction: column; gap: 12px; }
.auth-preview-card {
  background: #fff; border: 1px solid #ececf1; border-radius: 12px; padding: 16px 18px;
  display: flex; gap: 13px; align-items: flex-start;
}
.auth-step-num {
  width: 24px; height: 24px; flex: none; border-radius: 7px; background: #fae8ff; color: #a21caf;
  font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.auth-step-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.auth-step-copy { font-size: 12.5px; line-height: 1.5; font-weight: 400; color: #71717a; }
.auth-preview-book { display: flex; align-items: center; gap: 9px; margin-top: 8px; font-size: 12.5px; font-weight: 500; color: #52525b; }
.auth-preview-dot { width: 7px; height: 7px; border-radius: 50%; background: #10b981; flex: none; }

/* ─── Dashboard pills + Insights (screen 09) ─── */
.dash-pills { display: flex; gap: 5px; margin-bottom: 16px; }
.dash-pill {
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: #71717a;
  padding: 6px 11px; border-radius: 8px; border: none; background: transparent; cursor: pointer;
}
.dash-pill.active { color: #86198f; background: #fdf4ff; }
.ins-page { display: flex; flex-direction: column; gap: 15px; min-height: 0; }
.ins-head { display: flex; align-items: flex-end; gap: 16px; }
.ins-head-copy { display: flex; flex-direction: column; gap: 4px; }
.ins-title { font-size: 23px; font-weight: 700; line-height: 1.25; letter-spacing: -0.025em; color: var(--text); }
.ins-sub { font-size: 13.5px; font-weight: 400; color: #71717a; }
.ins-head-actions { margin-left: auto; display: flex; gap: 8px; flex: none; }
.ins-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ins-card {
  background: #fff; border: 1px solid #ececf1; border-radius: 12px; padding: 18px;
  display: flex; flex-direction: column; gap: 9px;
}
.ins-card-attn { border: 1.5px solid #fecaca; padding: 19px; gap: 11px; }
.ins-card-top { display: flex; align-items: center; gap: 9px; }
.ins-conf { margin-left: auto; font-size: 11.5px; font-weight: 400; color: #a1a1aa; }
.ins-h-attn { font-size: 17px; font-weight: 700; line-height: 1.35; letter-spacing: -0.01em; }
.ins-h { font-size: 15.5px; font-weight: 600; line-height: 1.4; }
.ins-body { font-size: 13px; line-height: 1.65; font-weight: 400; color: #52525b; }
.ins-card-attn .ins-body { font-size: 13px; }
.ins-card:not(.ins-card-attn) .ins-body { font-size: 12.5px; line-height: 1.6; }
.ins-sources { display: flex; flex-wrap: wrap; gap: 7px; }
.ins-chip {
  font-size: 11px; font-weight: 600; background: #f4f4f5; color: #52525b;
  padding: 5px 10px; border-radius: 999px;
}
.ins-sev {
  font-size: 10.5px; font-weight: 600; padding: 4px 9px; border-radius: 999px; letter-spacing: 0.02em;
}
.ins-sev-attention { background: #fef2f2; color: #b91c1c; }
.ins-sev-trend { background: #fffbeb; color: #b45309; }
.ins-sev-working { background: #ecfdf5; color: #047857; }
.ins-actions { margin-top: auto; display: flex; gap: 8px; }
.ins-col { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.ins-blind {
  margin-top: auto; background: #fdf7fd; border: 1px solid #f7dcf6; border-radius: 12px;
  padding: 15px 16px; display: flex; align-items: center; gap: 12px;
  font-size: 12.5px; line-height: 1.6; color: #86198f;
}
.ins-empty { padding: 48px 24px; text-align: center; color: #71717a; }

/* ─── Shared outline / gradient buttons used across revamp screens ─── */
.pack-btn {
  font-family: inherit; font-size: 12.5px; font-weight: 600; border-radius: 9px;
  padding: 9px 14px; cursor: pointer; white-space: nowrap; flex: none;
}
.pack-btn-primary { background: var(--gradient-brand); color: #fff; border: none; }
.pack-btn-ghost { border: 1px solid #e4e4ea; background: #fff; color: #3f3f46; }
.pack-btn-pink { border: 1px solid #f5d0fe; background: #fff; color: #a21caf; }
.pack-btn-lg { font-size: 13.5px; padding: 11px 17px; border-radius: 10px; }

.product-select-note {
  padding: 2px 11px 6px; font-size: 11.5px; line-height: 1.5; font-weight: 400; color: #a1a1aa;
}

/* ─── Credential page (screen 06) ─── */
.cred-page { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; min-height: calc(100vh - var(--topbar-height) - 48px); }
.cred-left {
  background: #fff; border: 1px solid #ececf1; border-radius: 12px; padding: 22px;
  display: flex; flex-direction: column; gap: 15px; min-height: 0;
}
.cred-right { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.cred-ident { display: flex; align-items: center; gap: 12px; }
.cred-swatch { width: 36px; height: 36px; border-radius: 10px; flex: none; }
.cred-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.cred-scope { font-size: 12px; font-weight: 400; color: #a1a1aa; }
.cred-step {
  margin-left: auto; font-size: 11px; font-weight: 600; background: #f4f4f5; color: #52525b;
  padding: 5px 10px; border-radius: 999px;
}
.cred-find {
  background: #fdf7fd; border: 1px solid #f7dcf6; border-radius: 10px; padding: 14px;
  display: flex; flex-direction: column; gap: 7px;
}
.cred-find-title { font-size: 12.5px; font-weight: 600; color: #86198f; }
.cred-find-copy { font-size: 12.5px; line-height: 1.6; color: #52525b; }
.cred-find-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cred-guide { display: none; }
.cred-guide.open { display: block; }
.cred-field label, .cred-left .form-group label {
  font-size: 11.5px; font-weight: 600; color: #3f3f46; display: flex; align-items: baseline; gap: 8px;
}
.cred-hint { font-size: 11.5px; font-weight: 400; color: #a1a1aa; }
.cred-cta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cred-reassure { font-size: 12.5px; font-weight: 400; color: #71717a; }
.cred-sec {
  margin-top: auto; background: #f8fafc; border: 1px solid #eef2f6; border-radius: 10px;
  padding: 13px; display: flex; gap: 10px; align-items: flex-start;
  font-size: 12px; line-height: 1.6; color: #52525b;
}
.cred-sec-dot { width: 20px; height: 20px; flex: none; border-radius: 6px; background: #dcfce7; }
.cred-panel {
  background: #fff; border: 1px solid #ececf1; border-radius: 12px; padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.cred-panel h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.cred-hs { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: #3f3f46; }
.cred-hs-dot {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
}
.cred-hs-wait { background: #fae8ff; border: 2px solid #e879f9; }
.cred-hs-ok { background: #dcfce7; color: #047857; }
.cred-hs-fail { background: #fef2f2; color: #b91c1c; }
.cred-unlock { font-size: 12.5px; line-height: 1.7; color: #52525b; }
.cred-depth { margin-top: 4px; font-size: 12px; font-weight: 600; color: #c026d3; }
.cred-stuck {
  margin-top: auto; background: #fff; border: 1px dashed #f5d0fe; border-radius: 12px;
  padding: 15px; display: flex; flex-direction: column; gap: 8px;
}
.cred-stuck h3 { margin: 0; font-size: 13px; font-weight: 600; }
.cred-stuck-title { font-size: 12px; font-weight: 600; color: #3f3f46; }
.cred-stuck p { margin: 0; font-size: 12px; line-height: 1.55; color: #71717a; }
.cred-rule { height: 1px; background: #f0f0f4; }

/* ─── Search overlay (screen 16) ─── */
.search-scrim {
  position: fixed; inset: 0; background: rgba(24,24,27,.14); z-index: 240;
}
.search-overlay {
  position: fixed; top: var(--topbar-height); left: calc(var(--sidebar-width) + 22px);
  width: 520px; background: #fff; border: 1px solid #e8e8ee; border-radius: 12px;
  box-shadow: 0 14px 36px rgba(24,24,27,.16); overflow: hidden; z-index: 241;
}
.search-overlay-head {
  padding: 13px 16px; border-bottom: 1px solid #f0f0f4;
  display: flex; align-items: center; gap: 9px;
}
.search-overlay-head input {
  flex: 1; border: none; outline: none; font-family: inherit; font-size: 14px; color: #27272a; background: transparent;
}
.search-esc { font-size: 11px; font-weight: 400; color: #a1a1aa; flex: none; }
.search-overlay-body { max-height: 420px; overflow: auto; display: flex; flex-direction: column; }
.search-sec-label {
  padding: 8px 16px 4px; font-size: 10px; font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: #a1a1aa;
}
.search-hit {
  padding: 10px 16px; display: flex; align-items: center; gap: 11px;
  width: 100%; border: none; background: transparent; text-align: left; cursor: pointer;
  font-family: inherit; color: inherit;
}
.search-hit:hover, .search-hit.active { background: #fdf7fd; }
.search-hit-title { font-size: 12.5px; font-weight: 500; color: #27272a; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-hit-title mark { background: #fae8ff; color: #86198f; padding: 0 1px; }
.search-hit-dest { margin-left: auto; font-size: 10.5px; font-weight: 400; color: #a1a1aa; flex: none; }
.search-hit-swatch { width: 22px; height: 22px; flex: none; border-radius: 6px; background: #fdf4ff; }
.search-overlay-foot {
  padding: 10px 16px; border-top: 1px solid #f0f0f4;
  font-size: 12px; font-weight: 600; color: #c026d3; cursor: pointer; background: #fff;
  width: 100%; text-align: left; border-left: none; border-right: none; border-bottom: none; font-family: inherit;
}

/* ─── Add-product wizard (screens 03–04) ─── */
.wiz-page { display: flex; gap: 20px; min-height: calc(100vh - var(--topbar-height) - 48px); }
.wiz-rail { width: 196px; flex: none; display: flex; flex-direction: column; gap: 8px; }
.wiz-rail-kicker { font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: #a1a1aa; }
.wiz-rail-item {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 9px;
  font-size: 12.5px; font-weight: 500; color: #71717a; border: none; background: transparent;
  font-family: inherit; text-align: left; cursor: pointer; width: 100%;
}
.wiz-rail-item.is-on { background: #fdf4ff; font-weight: 600; color: #86198f; }
.wiz-rail-num {
  width: 17px; height: 17px; border-radius: 50%; flex: none;
  font-size: 9.5px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  border: 1.5px solid #d4d4d8; color: #a1a1aa;
}
.wiz-rail-item.is-on .wiz-rail-num { border: none; background: var(--gradient-brand); color: #fff; }
.wiz-rail-item.is-done .wiz-rail-num { border: none; background: #dcfce7; color: #047857; }
.wiz-rail-note {
  margin-top: 12px; background: #fff; border: 1px solid #ececf1; border-radius: 11px;
  padding: 13px; font-size: 12px; line-height: 1.55; color: #71717a;
}
.wiz-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.wiz-h { font-size: 23px; font-weight: 700; line-height: 1.25; letter-spacing: -0.025em; margin: 0; }
.wiz-sub { font-size: 13.5px; font-weight: 400; color: #71717a; }
.wiz-card {
  background: #fff; border: 1px solid #ececf1; border-radius: 12px; padding: 20px;
  display: flex; flex-direction: column; gap: 15px; flex: 1; min-height: 0;
}
.wiz-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.wiz-field { display: flex; flex-direction: column; gap: 6px; }
.wiz-field label { font-size: 11.5px; font-weight: 600; color: #3f3f46; display: flex; align-items: baseline; gap: 8px; }
.wiz-field input, .wiz-field textarea {
  border: 1px solid #e4e4ea; border-radius: 9px; padding: 10px 12px;
  font-family: inherit; font-size: 13px; color: var(--text); background: #fff;
}
.wiz-field textarea { min-height: 62px; line-height: 1.6; resize: vertical; }
.wiz-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.wiz-chip {
  border: 1px solid #e4e4ea; border-radius: 8px; padding: 9px 13px;
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: #52525b;
  background: #fff; cursor: pointer;
}
.wiz-chip.is-on { background: var(--gradient-brand); color: #fff; border-color: transparent; }
.wiz-note {
  background: #fdf7fd; border: 1px solid #f7dcf6; border-radius: 10px; padding: 12px 14px;
  font-size: 12.5px; line-height: 1.55; color: #86198f;
}
.wiz-actions { margin-top: auto; display: flex; align-items: center; gap: 10px; }
.wiz-drop {
  border: 1.5px dashed #f5d0fe; background: #fdf7fd; border-radius: 12px; padding: 26px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; cursor: pointer;
}
.wiz-drop.is-over { background: #fae8ff; }
.wiz-drop-icons { display: flex; gap: 6px; }
.wiz-drop-icons span {
  width: 34px; height: 42px; border-radius: 6px; background: #fff; border: 1px solid #f7dcf6;
}
.wiz-drop-icons span:last-child { background: #fdf4ff; border: 1px dashed #e879f9; }
.wiz-file {
  background: #fff; border: 1px solid #ececf1; border-radius: 11px; padding: 14px;
  display: flex; align-items: center; gap: 12px;
}
.wiz-file-swatch { width: 32px; height: 32px; border-radius: 8px; flex: none; }
.wiz-file-name { font-size: 13px; font-weight: 600; }
.wiz-file-meta { font-size: 11.5px; font-weight: 400; color: #a1a1aa; }
.wiz-file-badge { margin-left: auto; font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 999px; }
.wiz-badge-read { background: #ecfdf5; color: #047857; }
.wiz-badge-linked { background: #eff6ff; color: #1d4ed8; }
.wiz-badge-stored { background: #fffbeb; color: #b45309; }
.wiz-cat { display: flex; flex-wrap: wrap; gap: 7px; }
.wiz-cat .wiz-chip { padding: 8px 12px; font-size: 12px; }

/* ─── First-read payoff (screen 08) ─── */
.fr-page { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; min-height: calc(100vh - var(--topbar-height) - 48px); }
.fr-left, .fr-right { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.fr-ident { display: flex; align-items: center; gap: 12px; }
.fr-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--gradient-brand); color: #fff;
  font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.fr-title { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.fr-sub { font-size: 12.5px; font-weight: 400; color: #a1a1aa; }
.fr-claim {
  background: #fff; border: 1.5px solid #f5d0fe; border-radius: 12px; padding: 20px;
  display: flex; flex-direction: column; gap: 13px; box-shadow: 0 6px 18px rgba(192,38,211,.07);
  font-size: 14.5px; line-height: 1.7; color: #27272a;
}
.fr-ask-kicker { font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: #a1a1aa; }
.fr-ask {
  background: #fff; border: 1px solid #ececf1; border-radius: 11px; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  font-family: inherit; font-size: 13.5px; font-weight: 500; color: var(--text); cursor: pointer;
}
.fr-ask span { margin-left: auto; font-size: 11px; font-weight: 600; color: #c026d3; flex: none; }
.fr-free {
  margin-top: auto; background: #fff; border: 1px solid #ececf1; border-radius: 11px;
  padding: 13px 15px; display: flex; align-items: center; gap: 10px; color: #a1a1aa; font-size: 13px;
}
.fr-panel {
  background: #fff; border: 1px solid #ececf1; border-radius: 12px; padding: 18px;
  display: flex; flex-direction: column; gap: 11px;
}
.fr-panel h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.fr-depth { font-size: 17px; font-weight: 700; color: #c026d3; }
.fr-bar { height: 7px; border-radius: 999px; background: #f4f4f5; overflow: hidden; }
.fr-bar > span { display: block; height: 100%; background: var(--gradient-brand); }
.fr-gap { display: flex; flex-direction: column; gap: 5px; }
.fr-gap-q { font-size: 12.5px; font-weight: 500; color: #3f3f46; }
.fr-setup { margin-top: auto; padding: 16px; gap: 10px; }
.fr-setup-row { display: flex; align-items: center; gap: 9px; font-size: 12px; color: #71717a; }
.fr-setup-num {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700;
}
.fr-setup-done { background: #dcfce7; color: #047857; }
.fr-setup-now { border: 1.5px solid #c026d3; color: #c026d3; }
.fr-setup-todo { border: 1.5px solid #d4d4d8; color: #a1a1aa; }
.fr-setup-current { font-weight: 600; color: #27272a; }

/* ─── Schedule drawer (screen 14) ─── */
.drawer-scrim { position: fixed; inset: 0; background: rgba(24,24,27,.2); z-index: 260; }
.sched-drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: 474px; background: #fff;
  border-left: 1px solid #e8e8ee; box-shadow: -14px 0 40px rgba(24,24,27,.14);
  z-index: 261; display: flex; flex-direction: column;
}
.sched-head {
  padding: 20px 24px 15px; border-bottom: 1px solid #f0f0f4;
  display: flex; align-items: flex-start; gap: 12px;
}
.sched-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.sched-head p { margin: 3px 0 0; font-size: 12px; font-weight: 400; color: #a1a1aa; }
.sched-x { margin-left: auto; border: none; background: none; font-size: 15px; font-weight: 600; color: #a1a1aa; cursor: pointer; }
.sched-body { flex: 1; min-height: 0; overflow: auto; padding: 18px 24px; display: flex; flex-direction: column; gap: 17px; }
.sched-step { display: flex; flex-direction: column; gap: 8px; }
.sched-step-h { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; }
.sched-n {
  width: 18px; height: 18px; flex: none; border-radius: 50%; background: var(--gradient-brand); color: #fff;
  font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.sched-foot {
  padding: 15px 24px; border-top: 1px solid #f0f0f4;
  display: flex; align-items: center; gap: 10px;
}
.sched-dest {
  border: 1.5px solid #e4e4ea; border-radius: 9px; padding: 11px 12px;
  display: flex; flex-direction: column; gap: 7px; cursor: pointer; background: #fff; text-align: left;
  font-family: inherit; width: 100%;
}
.sched-dest.is-on { border-color: #c026d3; background: #fdf7fd; }
.sched-tick {
  width: 16px; height: 16px; flex: none; border-radius: 4px; border: 1px solid #d4d4d8;
  display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: #fff;
}
.sched-dest.is-on .sched-tick { background: #c026d3; border-color: #c026d3; }
.sched-ok { background: #f0fdf4; border: 1px solid #dcfce7; border-radius: 9px; padding: 10px 12px; font-size: 11.5px; line-height: 1.55; color: #166534; }

@media (max-width: 1100px) {
  .auth-split { flex-direction: column; overflow: auto; }
  .auth-main, .auth-preview { width: 100%; }
  .ins-grid, .cred-page, .fr-page, .wiz-grid { grid-template-columns: 1fr; }
  .wiz-page { flex-direction: column; }
  .wiz-rail { width: 100%; }
  .search-overlay { left: 16px; right: 16px; width: auto; }
  .sched-drawer { width: min(474px, 100%); }
}
[data-theme="dark"] .auth-preview, [data-theme="dark"] .ins-blind, [data-theme="dark"] .cred-find,
[data-theme="dark"] .wiz-note, [data-theme="dark"] .wiz-drop { background: var(--primary-light); }
[data-theme="dark"] .auth-split, [data-theme="dark"] .cred-left, [data-theme="dark"] .ins-card,
[data-theme="dark"] .wiz-card, [data-theme="dark"] .fr-claim, [data-theme="dark"] .fr-panel,
[data-theme="dark"] .sched-drawer, [data-theme="dark"] .search-overlay { background: var(--card-bg); }

/* Dark-mode coverage for revamp surfaces that hardcode light colors */
[data-theme="dark"] .auth-preview-card,
[data-theme="dark"] .cred-panel,
[data-theme="dark"] .cred-stuck,
[data-theme="dark"] .wiz-rail-note,
[data-theme="dark"] .wiz-file,
[data-theme="dark"] .fr-ask,
[data-theme="dark"] .fr-free,
[data-theme="dark"] .sched-dest {
  background: var(--card-bg);
  border-color: var(--border-card);
}
[data-theme="dark"] .wiz-field input,
[data-theme="dark"] .wiz-field textarea,
[data-theme="dark"] .wiz-chip,
[data-theme="dark"] .pack-btn-ghost,
[data-theme="dark"] .pack-btn-pink,
[data-theme="dark"] .conn-btn-ghost {
  background: var(--card-bg);
  border-color: var(--border-card);
  color: var(--text-secondary);
}
[data-theme="dark"] .wiz-drop-icons span { background: var(--card-bg); border-color: var(--border-card); }
[data-theme="dark"] .fr-claim,
[data-theme="dark"] .fr-setup-current,
[data-theme="dark"] .search-hit-title { color: var(--text); }
[data-theme="dark"] .cred-hs,
[data-theme="dark"] .cred-stuck-title,
[data-theme="dark"] .cred-field label,
[data-theme="dark"] .wiz-field label,
[data-theme="dark"] .fr-gap-q,
[data-theme="dark"] .dash-pill,
[data-theme="dark"] .ins-body,
[data-theme="dark"] .ins-chip,
[data-theme="dark"] .auth-preview-book,
[data-theme="dark"] .cred-sec,
[data-theme="dark"] .cred-unlock { color: var(--text-secondary); }
[data-theme="dark"] .auth-step-copy,
[data-theme="dark"] .cred-reassure,
[data-theme="dark"] .cred-stuck p,
[data-theme="dark"] .ins-sub,
[data-theme="dark"] .wiz-sub,
[data-theme="dark"] .wiz-rail-note,
[data-theme="dark"] .fr-setup-row,
[data-theme="dark"] .cred-scope,
[data-theme="dark"] .cred-hint,
[data-theme="dark"] .ins-conf,
[data-theme="dark"] .fr-sub,
[data-theme="dark"] .fr-free,
[data-theme="dark"] .wiz-rail-kicker,
[data-theme="dark"] .wiz-file-meta,
[data-theme="dark"] .sched-head p,
[data-theme="dark"] .search-hit-dest,
[data-theme="dark"] .search-esc,
[data-theme="dark"] .search-sec-label,
[data-theme="dark"] .product-select-note { color: var(--text-muted); }
[data-theme="dark"] .search-overlay-head input { color: var(--text); }
[data-theme="dark"] .sched-tick { border-color: var(--border-card); }
[data-theme="dark"] .sched-ok { background: var(--success-bg); color: var(--success); }

/* ─── Screen — Settings → AI models ─── */
.models-page-head { margin-bottom: 20px; }
.models-page-head h2 {
  font-size: 23px; font-weight: 700; letter-spacing: -0.025em;
  line-height: 1.25; color: var(--text); margin: 0;
}
.models-page-head p {
  margin: 5px 0 0; font-size: 13.5px; font-weight: 400; color: var(--text-tertiary);
}
.model-plan-note {
  margin-top: 18px; padding: 16px 18px;
  background: #fdf7fd; border: 1px solid #f7dcf6; border-radius: 12px;
  font-size: 12.5px; line-height: 1.65; color: #86198f;
}
@media (max-width: 1100px) {
  .model-grid { grid-template-columns: 1fr; }
}
[data-theme="dark"] .model-card { background: var(--card-bg); border-color: var(--border-card); }
[data-theme="dark"] .model-card.is-off { background: var(--fill-subtle); }
[data-theme="dark"] .model-plan-note {
  background: var(--primary-light); border-color: var(--primary-border); color: var(--primary-deep);
}
