:root {
  --bg: #0B0D10;
  --bg-secondary: #111318;
  --bg-tertiary: #181B21;
  --bg-hover: #1C1F26;
  --bg-active: #24272F;
  --surface: #111318;
  --surface-hover: #181B21;
  --text: #F4F6F8;
  --text-secondary: #9BA3AF;
  --text-muted: #6B7280;
  --text-faint: #4B5563;
  --border: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.10);
  --border-glow: rgba(75, 123, 245, 0.12);
  --accent: #4B7BF5;
  --accent-hover: #3d6de0;
  --accent-subtle: rgba(75, 123, 245, 0.08);
  --accent-glow: rgba(75, 123, 245, 0.15);
  --accent-purple: #8b5cf6;
  --accent-purple-subtle: rgba(139, 92, 246, 0.08);
  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.08);
  --warn: #f59e0b;
  --warn-subtle: rgba(245, 158, 11, 0.08);
  --ok: #10b981;
  --ok-subtle: rgba(16, 185, 129, 0.08);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 10px;
  --radius-xl: 16px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition: 160ms ease;
  --sidebar-width: 260px;
  --rail-width: 340px;
  --topbar-height: 64px;
  --bottom-nav-height: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }

html {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
button { font-family: var(--sans); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }

/* ── App Shell ────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--rail-width);
  grid-template-rows: 1fr;
  height: 100%;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--border);
  transition: transform 250ms ease, width var(--transition), opacity var(--transition);
  z-index: 40;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}

.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-width)));
  min-width: 0;
  width: 0;
  border-right: none;
  opacity: 0;
  pointer-events: none;
}

/* ── Sidebar Mobile Backdrop ─────────────────────────── */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 42;
  opacity: 1;
  transition: opacity 250ms ease;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.sidebar-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.sidebar-brand {
  padding: 16px 16px 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.sidebar-brand img {
  height: 20px;
  width: auto;
  opacity: 0.9;
}

.sidebar-top {
  padding: 8px 12px 4px;
  flex-shrink: 0;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  min-height: 44px;
}

.new-chat-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.new-chat-btn:active {
  transform: scale(0.98);
}

.sidebar-nav {
  padding: 4px 12px;
  flex-shrink: 0;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 12px 10px 4px;
  opacity: 0.6;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all 200ms ease;
  margin-bottom: 1px;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.nav-item.active {
  background: var(--accent-subtle);
  color: var(--text);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
}

.nav-item svg { opacity: 0.45; flex-shrink: 0; transition: opacity var(--transition); }
.nav-item:hover svg { opacity: 0.7; }
.nav-item.active svg { opacity: 0.9; color: var(--accent); }

.nav-separator {
  height: 1px;
  background: var(--border);
  margin: 6px 12px;
}

/* ── Conversation History ─────────────────────────────── */
.conv-history {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.04) transparent;
  -webkit-overflow-scrolling: touch;
}

.conv-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 12px 10px 4px;
  opacity: 0.6;
}

.conv-item-wrap {
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  position: relative;
}

.conv-item-wrap:hover {
  background: var(--bg-hover);
}

.conv-item-wrap .conv-item {
  flex: 1;
  min-width: 0;
}

.conv-item-wrap:hover .conv-item {
  background: transparent;
}

.conv-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  text-align: left;
  transition: all var(--transition);
  margin-bottom: 1px;
}

.conv-item:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.conv-item.conv-active {
  background: var(--accent-subtle);
  color: var(--text);
}

.conv-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.conv-item-actions {
  display: none;
  align-items: center;
  gap: 2px;
  padding-right: 6px;
  flex-shrink: 0;
}

.conv-item-wrap:hover .conv-item-actions {
  display: flex;
}

.conv-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: all var(--transition);
}

.conv-action-btn:hover {
  background: var(--bg-active);
  color: var(--text-secondary);
}

.conv-action-delete:hover {
  background: var(--danger-subtle);
  color: var(--danger);
}

.conv-item-deleting {
  opacity: 0.3;
  transform: translateX(-8px);
  transition: all 200ms ease;
}

.conv-rename-form {
  flex: 1;
  padding: 3px 6px;
}

.conv-rename-input {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  outline: none;
}

.conv-empty {
  padding: 20px 10px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}

/* ── Sidebar Bottom ───────────────────────────────────── */
.sidebar-bottom {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.sidebar-profile:hover { background: var(--bg-hover); }

.profile-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}

.profile-info { flex: 1; min-width: 0; }
.profile-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-plan { margin-top: 2px; }

.plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.plan-badge-free { background: var(--bg-tertiary); color: var(--text-muted); }
.plan-badge-pro { background: var(--accent-subtle); color: var(--accent); }
.plan-badge-enterprise { background: var(--accent-purple-subtle); color: var(--accent-purple); }

.profile-settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.profile-settings-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }

/* ── Sidebar Toggle ───────────────────────────────────── */
.sidebar-toggle {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  opacity: 0;
  pointer-events: none;
}

.sidebar-toggle.visible { opacity: 1; pointer-events: auto; }
.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text); }

/* ── Main Area ────────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--topbar-height);
  min-height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-center { display: flex; align-items: center; gap: 6px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

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

.brand-logo {
  height: 18px;
  width: auto;
  opacity: 0.9;
}

.brand-divider {
  width: 1px;
  height: 14px;
  background: var(--border-light);
}

.brand-sub {
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 500;
}

/* ── Context Selectors (Enterprise Topbar) ────────────── */
.context-selector {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 4px 24px 4px 8px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all var(--transition);
  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%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

.context-selector:hover { border-color: var(--border-light); }
.context-selector:focus { border-color: var(--accent); }

.mobile-context-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.mobile-context-toggle:hover { background: var(--bg-hover); color: var(--text); }
.mobile-context-toggle:active { transform: scale(0.95); }

.mobile-context-drawer {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: none;
  flex-direction: column;
  gap: 10px;
}
.mobile-context-drawer.open {
  display: flex;
  animation: slideDown 200ms ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.mobile-context-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mobile-context-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 80px;
  flex-shrink: 0;
}
.mobile-context-select {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  font-family: var(--sans);
  cursor: pointer;
  flex: 1;
  min-height: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.mobile-context-select:focus {
  border-color: var(--accent);
  outline: none;
}

.context-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 2px;
}

/* ── Status & Indicators ──────────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.status-pill.status-ok .status-dot { background: var(--ok); }
.status-pill.status-ok .status-text { color: var(--text-secondary); }
.status-pill.status-bad .status-dot { background: var(--danger); }
.status-pill.status-bad .status-text { color: var(--danger); }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
}

.health-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.health-dot-green { background: var(--ok); }
.health-dot-amber { background: var(--warn); }
.health-dot-red { background: var(--danger); }

.topbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.topbar-icon-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }

.topbar-icon-btn .notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.topbar-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: #fff;
  cursor: pointer;
  transition: opacity var(--transition);
}

.topbar-user-avatar:hover { opacity: 0.8; }

/* ── Main Content ─────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow: auto;
  padding: 24px;
  -webkit-overflow-scrolling: touch;
  animation: viewFadeIn 200ms ease;
}

@keyframes viewFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.main-content-flush {
  padding: 0;
}

/* ── Shared Components ────────────────────────────────── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: clamp(18px, 2vw + 10px, 24px);
  font-weight: 700;
  letter-spacing: -0.025em;
}

.page-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
  line-height: 1.5;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-muted);
}

.pill-ok { border-color: rgba(16, 185, 129, 0.15); background: var(--ok-subtle); color: var(--ok); }
.pill-bad { border-color: rgba(239, 68, 68, 0.15); background: var(--danger-subtle); color: var(--danger); }
.pill-muted { color: var(--text-muted); }
.pill-accent { border-color: rgba(75, 123, 245, 0.15); background: var(--accent-subtle); color: var(--accent); }
.pill-warn { border-color: rgba(245, 158, 11, 0.15); background: var(--warn-subtle); color: var(--warn); }

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: rgba(17, 19, 24, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all var(--transition);
}

.card:hover {
  border-color: var(--border-light);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.card-title {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-weight: 600;
  font-size: 14px;
}

.card-kicker {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.card-body {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:hover {
  border-color: var(--border-light);
  background: var(--surface-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.card-interactive:active {
  transform: scale(0.98);
}

.card-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  appearance: none;
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  transition: all var(--transition);
  min-height: 44px;
}

.btn:hover { background: var(--bg-hover); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover { background: var(--bg-hover); border-color: var(--border); }

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* ── Inputs ───────────────────────────────────────────── */
.input, .select {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text);
  padding: 8px 12px;
  font-family: var(--sans);
  font-size: 13px;
  transition: all var(--transition);
  outline: none;
}

.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(75, 123, 245, 0.1);
}

.input-sm { padding: 5px 8px; font-size: 12px; width: auto; }

/* ── Layout Helpers ───────────────────────────────────── */
.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.row > * { flex: 1 1 180px; }

.section { margin-top: 24px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 24px 0 10px;
}

.section-title { font-weight: 700; font-size: 14px; }
.section-sub { color: var(--text-muted); font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.mono { font-family: var(--mono); }

.code {
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Drawer ───────────────────────────────────────────── */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, calc(100vw - 24px));
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 0;
  z-index: 60;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateX(0);
  transition: transform 250ms ease;
  display: flex;
  flex-direction: column;
}

.drawer.hidden { transform: translateX(100%); display: none; }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-title { font-weight: 700; font-size: 14px; }

.drawer-body {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  flex: 1;
  overflow: auto;
  padding: 16px;
}

.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-tab {
  flex: 1;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border-bottom: 2px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.drawer-tab:hover { color: var(--text-secondary); background: var(--bg-hover); }
.drawer-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.drawer-tab-panel { display: none; }
.drawer-tab-panel.active { display: block; }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 55;
}

.backdrop.hidden { display: none; }

/* ── Chat Container ───────────────────────────────────── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-height, 56px));
  height: calc(100dvh - var(--topbar-height, 56px));
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.04) transparent;
  -webkit-overflow-scrolling: touch;
}

.chat-messages-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Chat Messages ────────────────────────────────────── */
.chat-msg {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  animation: msgFadeIn 160ms ease;
}

.chat-msg:last-child { border-bottom: none; }

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

.chat-msg-inner {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.chat-avatar {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-avatar-user {
  background: var(--bg-active);
  color: var(--text-secondary);
  border-radius: 50%;
}

.chat-avatar-assistant {
  background: var(--accent);
  color: #fff;
}

.chat-msg-body {
  flex: 1;
  min-width: 0;
}

.chat-msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.chat-msg-name {
  font-weight: 600;
  font-size: 13px;
}

.chat-msg-provider {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent-subtle);
  color: var(--accent);
  letter-spacing: 0.02em;
}

.chat-msg-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  word-wrap: break-word;
}

.chat-msg-text p { margin: 0 0 10px; }
.chat-msg-text p:last-child { margin-bottom: 0; }

/* ── Chat Action Bar ──────────────────────────────────── */
.chat-msg-actions-bar {
  display: flex;
  gap: 1px;
  margin-top: 10px;
  opacity: 0;
  transition: opacity var(--transition);
}

.chat-msg:hover .chat-msg-actions-bar {
  opacity: 1;
}

.chat-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: all var(--transition);
}

.chat-action-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }
.chat-action-btn.active { color: var(--accent); }

/* ── Answer Sections ──────────────────────────────────── */
.answer-summary {
  font-size: 14px;
  line-height: 1.65;
  margin-bottom: 14px;
}

.answer-section { margin-top: 14px; }

.answer-label {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.answer-label-know { color: var(--ok); }
.answer-label-infer { color: var(--accent); }
.answer-label-missing { color: var(--warn); }

.answer-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}

.answer-list li { margin-bottom: 4px; }
.answer-list li:last-child { margin-bottom: 0; }
.answer-list.infer { color: var(--text-secondary); }
.answer-list.missing { color: var(--warn); }

/* ── Sources Accordion ────────────────────────────────── */
.sources-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 12px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--sans);
  transition: all var(--transition);
}

.sources-toggle:hover { background: var(--bg-hover); border-color: var(--border-light); }

.sources-toggle svg {
  transition: transform var(--transition);
}

.sources-toggle.open svg { transform: rotate(180deg); }

.sources-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 200ms ease;
}

.sources-panel.open { max-height: 2000px; }

.sources-list {
  padding: 10px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.source-card {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  transition: all var(--transition);
}

.source-card:hover { border-color: var(--border-light); }

.source-tier-badges {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

.source-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
}

.source-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: var(--mono);
}

.source-hash {
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 2px;
  font-family: var(--mono);
}

/* ── Confidence Bar ───────────────────────────────────── */
.confidence-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.confidence-score {
  font-weight: 700;
  font-size: 16px;
  min-width: 42px;
  font-variant-numeric: tabular-nums;
}

.confidence-score.high { color: var(--ok); }
.confidence-score.medium { color: var(--warn); }
.confidence-score.low { color: var(--danger); }

.confidence-track {
  flex: 1;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 400ms ease;
}

.confidence-fill.high { background: var(--ok); }
.confidence-fill.medium { background: var(--warn); }
.confidence-fill.low { background: var(--danger); }

.confidence-details {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--text-muted);
}

.confidence-details span { font-weight: 600; color: var(--text-secondary); }

/* ── Action Pills ─────────────────────────────────────── */
.action-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.action-pill {
  padding: 5px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--sans);
  transition: all var(--transition);
}

.action-pill:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
  color: var(--text);
}

/* ── Chat Input ───────────────────────────────────────── */
.chat-input-area {
  padding: 0 16px 14px;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: var(--bg);
}

.chat-input-wrapper {
  max-width: 820px;
  margin: 0 auto;
}

.chat-input-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: all var(--transition);
}

.chat-input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(75, 123, 245, 0.08);
}

.chat-textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  min-height: 22px;
  max-height: 200px;
  padding: 2px 0;
}

.chat-textarea::placeholder { color: var(--text-faint); }

.chat-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}

.chat-send-btn:hover { background: var(--accent-hover); }
.chat-send-btn:active { transform: scale(0.95); }
.chat-send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.chat-input-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 8px;
}

.chat-prompt-header {
  text-align: center;
  margin-bottom: 8px;
}

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

.chat-example-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 10px;
}

.example-prompt-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.example-prompt-chip:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
  color: var(--text);
}

/* ── Reasoning Panel ──────────────────────────────────── */
.reasoning-panel {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  overflow: hidden;
}

.reasoning-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.reasoning-header svg {
  color: var(--accent);
  flex-shrink: 0;
}

.reasoning-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
}

.reasoning-item {
  padding: 10px 14px;
  background: var(--bg-secondary);
}

.reasoning-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.reasoning-value {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.3;
}

.reasoning-confidence {
  font-weight: 700;
  font-family: var(--mono);
  font-size: 14px;
}

.reasoning-confidence.high { color: var(--ok); }
.reasoning-confidence.medium { color: var(--warn); }
.reasoning-confidence.low { color: var(--danger); }

.reasoning-priority {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.reasoning-priority.high {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.reasoning-priority.medium {
  background: rgba(234, 179, 8, 0.12);
  color: var(--warn);
}

.reasoning-priority.low {
  background: rgba(34, 197, 94, 0.12);
  color: var(--ok);
}

.chat-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 820px;
  margin: 0 auto 6px;
}

.toolbar-select {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 4px 24px 4px 8px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all var(--transition);
  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%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

.toolbar-select:hover { border-color: var(--border-light); }
.toolbar-select:focus { border-color: var(--accent); }

/* ── Model Selector (Topbar) ──────────────────────────── */
.model-selector-wrap {
  position: relative;
}

.model-selector {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text);
  padding: 4px 26px 4px 10px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all var(--transition);
  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%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.model-selector:hover { border-color: var(--border-light); }
.model-selector:focus { border-color: var(--accent); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
}

.topbar-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: all var(--transition);
}

.topbar-action-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }
.topbar-action-btn.active { color: var(--accent); }

/* ── Welcome Screen ───────────────────────────────────── */
.welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 20px;
  text-align: center;
}

.welcome-logo {
  height: 40px;
  width: auto;
  margin-bottom: 20px;
  opacity: 0.8;
}

.welcome-title {
  font-size: clamp(22px, 3vw + 10px, 32px);
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
  color: var(--text);
}

.welcome-sub {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 480px;
  margin-bottom: 32px;
  line-height: 1.5;
}

/* ── Capability Cards ─────────────────────────────────── */
.capability-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-width: 820px;
  width: 100%;
}

.capability-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(17, 19, 24, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  font-family: var(--sans);
  transition: all 200ms ease;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.capability-card:hover {
  border-color: var(--border-light);
  background: var(--surface-hover);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.capability-card:active {
  transform: scale(0.98);
}

.capability-card-icon {
  color: var(--text-faint);
  flex-shrink: 0;
}

.capability-card-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.capability-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Thinking Indicator ───────────────────────────────── */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.thinking-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: thinking-pulse 1.4s infinite ease-in-out both;
}

.thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.thinking-dot:nth-child(2) { animation-delay: -0.16s; }
.thinking-dot:nth-child(3) { animation-delay: 0s; }

@keyframes thinking-pulse {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

.thinking-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 6px;
  font-weight: 500;
}

/* ── Streaming Cursor ─────────────────────────────────── */
.streaming::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--text-faint);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink-cursor 0.8s steps(2) infinite;
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Markdown Rendering ───────────────────────────────── */
.markdown-body {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  word-wrap: break-word;
}

.markdown-body p { margin: 0 0 10px; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body strong { font-weight: 700; }
.markdown-body em { color: var(--text-secondary); }

.md-h2 { font-size: 16px; font-weight: 700; margin: 16px 0 6px; }
.md-h3 { font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
.md-h4 { font-size: 13px; font-weight: 600; margin: 10px 0 4px; text-transform: uppercase; letter-spacing: 0.02em; }

.md-ul, .md-ol { margin: 6px 0 10px; padding-left: 18px; }
.md-li, .md-oli { margin-bottom: 3px; line-height: 1.5; }

.inline-code {
  font-family: var(--mono);
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ── Code Blocks ──────────────────────────────────────── */
.code-block {
  margin: 10px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0A0C0F;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
}

.code-block-lang {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

.code-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  transition: all var(--transition);
}

.code-copy-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }

.code-block-body {
  margin: 0;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  overflow-x: auto;
}

.code-block-body code { font-family: inherit; }

/* ── KPI Cards (Carbon/Data Dense) ────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.kpi-card {
  background: rgba(17, 19, 24, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: all var(--transition);
}

.kpi-card:hover {
  border-color: var(--border-light);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi-unit {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 2px;
}

.kpi-meta {
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 4px;
  font-family: var(--mono);
}

/* ── Data Table ───────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.data-table tr:hover td {
  background: var(--bg-hover);
  transition: background 120ms ease;
}

.data-table td:first-child {
  color: var(--text);
  font-weight: 500;
}

/* ── Hotspot Bar Chart ────────────────────────────────── */
.hotspot-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.hotspot-label {
  width: 160px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hotspot-bar-wrap {
  flex: 1;
  height: 20px;
  background: var(--bg-secondary);
  border-radius: 2px;
  overflow: hidden;
}

.hotspot-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 400ms ease;
}

.hotspot-value {
  width: 70px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ── Verification Tree ────────────────────────────────── */
.verification-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
  min-height: 400px;
}

.scope-tree {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: auto;
}

.scope-tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: all var(--transition);
}

.scope-tree-item:last-child { border-bottom: none; }
.scope-tree-item:hover { background: var(--bg-hover); color: var(--text-secondary); }
.scope-tree-item.active { background: var(--accent-subtle); color: var(--text); }

.scope-tree-indent { padding-left: 24px; }

.status-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-card-title {
  font-weight: 600;
  font-size: 14px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
}

.status-indicator-verified { color: var(--ok); }
.status-indicator-partial { color: var(--warn); }
.status-indicator-gap { color: var(--danger); }

.status-detail-row {
  display: flex;
  gap: 20px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-detail-row strong {
  color: var(--text-secondary);
}

/* ── Supplier Table ───────────────────────────────────── */
.risk-badge {
  display: inline-flex;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
}

.risk-high { background: var(--danger-subtle); color: var(--danger); }
.risk-medium { background: var(--warn-subtle); color: var(--warn); }
.risk-low { background: var(--ok-subtle); color: var(--ok); }

/* ── Report Builder ───────────────────────────────────── */
.report-builder {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  min-height: 500px;
}

.report-form {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px;
}

.report-form-group {
  margin-bottom: 16px;
}

.report-form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.report-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.report-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.report-preview-title {
  font-weight: 700;
  font-size: 14px;
}

.report-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.report-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.report-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.progress-bar {
  width: 100%;
  height: 3px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 200ms ease;
}

/* ── Plans ────────────────────────────────────────────── */
.plans-container {
  max-width: 960px;
  margin: 0 auto;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 24px;
}

.plan-card {
  background: rgba(17, 19, 24, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  transition: all 200ms ease;
}

.plan-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.plan-card.plan-featured {
  border-color: rgba(75, 123, 245, 0.2);
}

.plan-card.plan-enterprise {
  border-color: rgba(139, 92, 246, 0.15);
}

.plan-popular-tag {
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 12px;
  border-radius: 0 0 6px 6px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.plan-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
  margin-top: 6px;
}

.plan-price {
  font-size: 32px;
  font-weight: 800;
  margin: 10px 0 4px;
  letter-spacing: -0.03em;
}

.plan-price-period {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

.plan-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 18px;
  line-height: 1.4;
}

.plan-features {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  flex: 1;
}

.plan-feature {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.plan-feature-icon {
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 1px;
}

.plan-cta {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition: all var(--transition);
}

.plan-cta:hover { background: var(--bg-hover); }
.plan-cta:active { transform: scale(0.98); }

.plan-cta-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.plan-cta-primary:hover { background: var(--accent-hover); }

.plan-cta-enterprise {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: #fff;
}

.plan-cta-enterprise:hover { background: #7c3aed; }

/* ── Settings ─────────────────────────────────────────── */
.settings-container {
  max-width: 600px;
  margin: 0 auto;
}

.settings-section {
  margin-bottom: 28px;
}

.settings-section-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child { border-bottom: none; }

.settings-label { font-size: 13px; font-weight: 500; }
.settings-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--bg-active);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  padding: 0;
}

.toggle-switch.active {
  background: var(--accent);
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--transition);
}

.toggle-switch.active::after { transform: translateX(18px); }

/* ── Blueprint/APIs/Compliance (existing views) ───────── */
.list {
  margin: 6px 0 0;
  padding-left: 16px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.page-head-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.meta-card { border-left: 2px solid var(--accent); }

.meta-grid { display: flex; flex-direction: column; gap: 4px; }
.meta-item { display: flex; align-items: center; gap: 8px; }
.meta-label { font-family: var(--mono); font-size: 11px; color: var(--text-muted); min-width: 68px; }
.meta-value { font-size: 13px; color: var(--text-secondary); }
.meta-source { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); color: var(--text-faint); font-size: 11px; }

.perf-card { display: flex; flex-direction: column; }
.perf-row { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 12px; }
.perf-row:last-child { border-bottom: none; }
.perf-metric { font-weight: 600; color: var(--text); }
.perf-divider { color: var(--text-faint); }
.perf-target { color: var(--accent); font-weight: 600; }
.perf-unit { color: var(--text-secondary); }
.perf-env { color: var(--text-muted); font-size: 11px; }

.flow-list { padding-left: 0; list-style: none; }
.flow-step { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.flow-step-label { color: var(--text-secondary); font-size: 12px; }

.detail-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.detail-section-title { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 6px; }
.detail-list { margin: 0; padding-left: 16px; color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.detail-empty { color: var(--text-faint); font-size: 12px; }
.detail-tier { margin-bottom: 8px; }
.detail-summary { color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.detail-deps { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.detail-status { margin-top: 4px; font-size: 12px; color: var(--text-secondary); }
.detail-note { margin-top: 6px; color: var(--text-faint); font-size: 11px; line-height: 1.4; }

.api-group-card { margin-top: 10px; }
.api-endpoints { margin-top: 6px; display: flex; flex-direction: column; }
.api-endpoint { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.api-endpoint:last-child { border-bottom: none; }
.api-method { font-family: var(--mono); font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 3px; background: var(--bg-tertiary); color: var(--accent); text-transform: uppercase; flex-shrink: 0; }
.api-method-get { color: var(--ok); }
.api-method-post { color: var(--accent); }
.api-method-put { color: var(--warn); }
.api-method-delete { color: var(--danger); }
.api-method-patch { color: var(--accent-purple); }
.api-path { font-family: var(--mono); font-size: 12px; color: var(--text); }
.api-desc { color: var(--text-muted); font-size: 12px; }
.api-groups-list { display: flex; flex-direction: column; }

.filter-bar { max-width: 500px; margin-bottom: 14px; }
.reqs-list { display: flex; flex-direction: column; gap: 6px; }
.req-card { transition: all var(--transition); }
.req-card:hover { border-color: var(--border-light); background: var(--surface-hover); }
.req-status { margin-left: auto; }
.req-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.empty-state { text-align: center; color: var(--text-faint); padding: 18px 0; }

.try-bar { display: flex; gap: 8px; align-items: center; }
.try-bar .input { flex: 1; }
.try-bar .btn { flex-shrink: 0; flex-grow: 0; flex-basis: auto; }
.try-output { margin-top: 10px; min-height: 50px; }
.try-ok { border-color: rgba(16, 185, 129, 0.1); }
.try-error { border-color: rgba(239, 68, 68, 0.1); }

/* ── Mode Switcher ───────────────────────────────────── */
.mode-dropdown {
  position: relative;
  width: 100%;
  margin-bottom: 6px;
}
.mode-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text);
  padding: 8px 12px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}
.mode-dropdown-trigger:hover,
.mode-dropdown.open .mode-dropdown-trigger {
  border-color: var(--accent);
  background: rgba(255,255,255,0.03);
}
.mode-dropdown-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
.mode-dropdown.open .mode-dropdown-chevron {
  transform: rotate(180deg);
}
.mode-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 4px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.mode-dropdown.open .mode-dropdown-menu {
  display: block;
}
.mode-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.mode-dropdown-item:hover {
  background: rgba(255,255,255,0.05);
}
.mode-dropdown-item.active {
  background: rgba(255,255,255,0.06);
  color: var(--accent);
  font-weight: 600;
}
.mode-dropdown-item.locked {
  color: var(--text-muted);
}
.mode-dropdown-item.locked:hover {
  background: rgba(255,255,255,0.03);
}
.mode-dropdown-lock {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  opacity: 0.5;
  margin-left: 8px;
}
.mode-dropdown-lock svg {
  width: 12px;
  height: 12px;
}

/* ── Brief Grid (Investor) ──────────────────────────── */
.brief-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.brief-card {
  background: rgba(17, 19, 24, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 200ms ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brief-card:hover {
  border-color: var(--border-light);
  background: var(--surface-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.brief-card:active {
  transform: scale(0.98);
}

.brief-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brief-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.brief-summary {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Learning Grid ──────────────────────────────────── */
.learning-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.learning-card {
  background: rgba(17, 19, 24, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 200ms ease;
}

.learning-card:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.learning-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.learning-card-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.learning-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}

.learning-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ── Glossary ───────────────────────────────────────── */
.glossary-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.glossary-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: all var(--transition);
}

.glossary-item:hover {
  border-color: var(--border-light);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.glossary-term {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}

.glossary-def {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Signals Feed ───────────────────────────────────── */
.signals-feed {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.signal-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: all var(--transition);
}

.signal-item:hover {
  border-color: var(--border-light);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.signal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.signal-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}

.signal-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Nav Footer Item ────────────────────────────────── */
.nav-item-footer {
  margin-top: auto;
}

/* ── Right Rail ──────────────────────────────────────── */
.right-rail {
  width: var(--rail-width);
  min-width: var(--rail-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

.right-rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.right-rail-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.rail-toggle-btn {
  display: none;
}
.right-rail-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.right-rail-close:hover { background: var(--bg-hover); color: var(--text); }

.right-rail-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  -webkit-overflow-scrolling: touch;
}

.rail-section {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.rail-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.rail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.rail-row-label {
  font-size: 12px;
  color: var(--text-muted);
}

.rail-row-value {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Topbar Search ───────────────────────────────────── */
.topbar-search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 10px;
  height: 32px;
  transition: all var(--transition);
}

.topbar-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(75, 123, 245, 0.08);
}

.topbar-search svg { color: var(--text-faint); flex-shrink: 0; }

.topbar-search-input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  width: 140px;
}

.topbar-search-input::placeholder { color: var(--text-faint); }

.topbar-org-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Bottom Mobile Nav ───────────────────────────────── */
.bottom-mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-mobile-nav a {
  text-decoration: none;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 0 6px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 500;
  flex: 1;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item svg { opacity: 0.5; transition: opacity var(--transition); }
.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item.active svg { opacity: 1; color: var(--accent); }

/* ── Responsive ───────────────────────────────────────── */

/* Desktop large (1440px+) */
@media (min-width: 1440px) {
  .main-content { padding: 32px 40px; }
  .chat-messages-inner { max-width: 900px; }
  .chat-input-wrapper { max-width: 900px; }
  .chat-toolbar { max-width: 900px; }
  .plans-container { max-width: 1080px; }
  .settings-container { max-width: 680px; }
  .welcome-container { padding: 60px 40px; }
  .page-head { margin-bottom: 28px; }
}

/* Tablet — icon-only sidebar + right rail becomes drawer (1024px) */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 60px 1fr;
  }
  .sidebar {
    width: 60px;
    min-width: 60px;
  }
  .sidebar-brand img { height: 20px; }
  .sidebar .nav-item span,
  .sidebar .new-chat-btn span,
  .sidebar .nav-item-footer { font-size: 0; overflow: hidden; }
  .sidebar .nav-item { justify-content: center; padding: 10px; }
  .sidebar .new-chat-btn { justify-content: center; padding: 8px; gap: 0; }
  .sidebar .nav-item svg { margin: 0; }
  .sidebar-bottom,
  .conv-history,
  #conv-separator,
  #mode-switcher,
  .nav-section-label { display: none; }
  .right-rail {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--rail-width);
    z-index: 45;
    transform: translateX(100%);
    transition: transform 250ms ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
    background: var(--bg);
  }
  .right-rail.open {
    transform: translateX(0);
  }
  .right-rail-close {
    display: flex;
  }
  .rail-toggle-btn {
    display: flex;
  }
}

/* Medium desktop / small laptop (1100px) */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .capability-cards { grid-template-columns: repeat(2, 1fr); }
  .verification-grid { grid-template-columns: 1fr; }
  .report-builder { grid-template-columns: 1fr; }
  .learning-grid { grid-template-columns: repeat(2, 1fr); }
  .brief-grid { grid-template-columns: 1fr; }
}

/* Tablet layout adjustments (880px) */
@media (max-width: 880px) {
  .capability-cards { grid-template-columns: 1fr; }
  .plans-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
  .topbar-org-name { display: none; }
  #model-selector-area { display: none; }
  .status-pill { display: none; }
  .sources-toggle { min-height: 44px; padding: 8px 14px; }
  .action-pill { min-height: 44px; padding: 10px 14px; }
  .toolbar-select { min-height: 44px; padding: 10px 12px; }
  .mode-dropdown-trigger { min-height: 44px; padding: 10px 12px; }
  .context-selector { min-height: 44px; padding: 10px 12px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .learning-grid { grid-template-columns: 1fr; }
  .brand-divider { display: none; }
  .brand-sub { display: none; }
  .nav-item { padding: 10px 12px; min-height: 44px; }
  .sidebar-profile { padding: 10px 12px; min-height: 44px; }
  .nav-section-label { padding: 14px 12px 6px; }
  .sidebar-toggle {
    top: calc(14px + env(safe-area-inset-top));
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }
  .chat-container {
    height: calc(100vh - var(--topbar-height) - env(safe-area-inset-top));
    height: calc(100dvh - var(--topbar-height) - env(safe-area-inset-top));
  }
  .main-content { padding: 16px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-head-actions { width: 100%; }
  .action-bar { width: 100%; }
  .action-btn, .action-btn-outline {
    flex: 1;
    text-align: center;
    min-height: 44px;
    padding: 10px 14px;
  }
  .data-table { font-size: 14px; }
  .data-table th, .data-table td { padding: 8px; }
  .hotspot-label { width: 120px; }
  .drawer { width: 100vw; }
}

/* Tablet portrait (768px) */
@media (max-width: 768px) {
  .topbar-right .topbar-icon-btn:not(.rail-toggle-btn) { display: none; }
  .topbar-right .health-dot { display: none; }
  .verification-grid { grid-template-columns: 1fr; min-height: auto; }
  .report-builder { grid-template-columns: 1fr; min-height: auto; }
  .brief-grid { gap: 8px; }
  .reasoning-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Small screens / mobile (640px) */
@media (max-width: 640px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 45;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  }
  .sidebar.collapsed {
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar-toggle { opacity: 1; pointer-events: auto; }
  .right-rail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    min-width: 100%;
    height: 60vh;
    max-height: 80vh;
    z-index: 46;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 300ms ease;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
    background: var(--bg);
  }
  .right-rail.open {
    transform: translateY(0);
  }
  .right-rail-close {
    display: flex;
  }
  .rail-toggle-btn {
    display: flex;
  }
  .topbar {
    padding: 0 12px 0 48px;
    padding-top: env(safe-area-inset-top);
    min-height: calc(48px + env(safe-area-inset-top));
  }
  .topbar-center .context-selector { display: none; }
  .topbar-center .context-divider { display: none; }
  .mobile-context-toggle { display: flex; }
  .icon-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  .conv-action-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  .profile-settings-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  .bottom-mobile-nav { display: flex; }
  .main-content { padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom)); }
  .chat-container {
    height: calc(100vh - var(--topbar-height) - var(--bottom-nav-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    height: calc(100dvh - var(--topbar-height) - var(--bottom-nav-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
  .dashboard-grid { grid-template-columns: 1fr; }
  .recommendation-cards { grid-template-columns: 1fr 1fr; }
  .automation-card { flex-wrap: wrap; gap: 10px; }
  .automation-meta { flex-direction: row; gap: 8px; }
  .chat-input-box { border-radius: var(--radius); }
  .confidence-bar { flex-wrap: wrap; }
  .kpi-grid { grid-template-columns: 1fr; }
  .reasoning-grid { grid-template-columns: repeat(2, 1fr); }
  .chat-example-prompts {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .chat-example-prompts::-webkit-scrollbar { display: none; }
  .example-prompt-chip {
    font-size: 12px;
    padding: 6px 10px;
    flex-shrink: 0;
    min-height: 36px;
    max-width: 200px;
  }
  .chat-msg-inner { gap: 10px; }
  .chat-msg { padding: 16px 0; }
  .chat-msg-text { font-size: 14px; line-height: 1.6; }
  .chat-input-area {
    padding: 0 12px 12px;
    padding-bottom: calc(12px + var(--bottom-nav-height) + env(safe-area-inset-bottom));
  }
  .welcome-container { padding: 16px 14px 8px; height: auto; justify-content: flex-start; min-height: 0; }
  .welcome-logo { display: none; }
  .welcome-title { font-size: 18px; font-weight: 600; margin-bottom: 12px; }
  .welcome-sub { font-size: 13px; margin-bottom: 16px; }
  .capability-cards { grid-template-columns: 1fr 1fr; gap: 6px; }
  .capability-card { min-height: auto; padding: 10px 12px; gap: 3px; }
  .capability-card-icon { display: none; }
  .capability-card-title { font-size: 13px; }
  .capability-card-desc { font-size: 12px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .chat-input-hint { font-size: 10px; }
  .chat-toolbar { display: none; }
  .chat-prompt-header { font-size: 12px; }
  .prompt-header-text { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .main-content { padding: 12px; }
  .section-head { flex-direction: column; gap: 2px; }
  .topbar-user-avatar { width: 44px; height: 44px; font-size: 14px; }
  .chat-msg-actions-bar { opacity: 1; }
  .setup-modal { padding: 36px 28px 30px; }
  .setup-input { font-size: 16px; }
  .setup-btn { font-size: 14px; }
  .setup-subtitle { font-size: 13px; }
}

/* iPhone Pro Max (430px) */
@media (max-width: 430px) {
  .reasoning-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 20px; }
  .hotspot-label { width: 100px; font-size: 14px; }
  .hotspot-value { width: 60px; font-size: 14px; }
  .plan-price { font-size: 28px; }
  .data-table th, .data-table td { padding: 6px 8px; font-size: 14px; }
  .setup-modal { padding: 32px 24px 28px; width: 92%; }
  .capability-cards { grid-template-columns: 1fr 1fr; }
  .welcome-container { padding: 14px 12px 6px; }
  .welcome-title { font-size: 17px; }
}

/* iPhone 14/15 (390px) */
@media (max-width: 390px) {
  .reasoning-grid { grid-template-columns: 1fr; }
  .confidence-details { flex-direction: column; gap: 4px; }
  .topbar { padding: 0 8px 0 48px; }
  .main-content { padding: 10px; }
  .chat-input-area { padding: 0 8px 8px; padding-bottom: calc(8px + var(--bottom-nav-height) + env(safe-area-inset-bottom)); }
  .page-title { font-size: 18px; }
  .capability-card { padding: 10px; min-height: auto; }
  .capability-card-title { font-size: 13px; }
  .capability-card-desc { font-size: 12px; }
  .brief-title { font-size: 14px; }
  .brief-summary { font-size: 14px; }
  .learning-card-title { font-size: 14px; }
  .learning-card-desc { font-size: 14px; }
  .section-title { font-size: 14px; }
  .section-sub { font-size: 14px; }
}

/* iPhone SE (375px) */
@media (max-width: 375px) {
  .sidebar { --sidebar-width: 240px; }
  .chat-messages-inner { padding: 12px 8px; }
  .chat-msg-inner { gap: 8px; }
  .chat-avatar { width: 24px; height: 24px; font-size: 11px; border-radius: 5px; }
  .chat-msg-name { font-size: 14px; }
  .chat-msg-text { font-size: 14px; }
  .answer-list { font-size: 14px; padding-left: 14px; }
  .source-card { padding: 8px; }
  .confidence-bar { padding: 8px 10px; }
  .kpi-card { padding: 10px; }
  .kpi-label { font-size: 14px; }
  .kpi-value { font-size: 18px; }
  .setup-modal { padding: 28px 20px 24px; width: 94%; max-width: none; }
  .setup-logo-img { height: 22px; }
  .setup-title { font-size: 15px; }
  .welcome-container { padding: 12px 10px 4px; }
  .welcome-title { font-size: 16px; }
  .capability-cards { grid-template-columns: 1fr 1fr; gap: 5px; }
  .capability-card { padding: 8px 10px; }
  .capability-card-desc { -webkit-line-clamp: 1; }
  .example-prompt-chip { max-width: 160px; }
  :root { --topbar-height: 44px; }
  .topbar { height: 44px; min-height: calc(44px + env(safe-area-inset-top)); }
  .chat-container {
    height: calc(100vh - var(--topbar-height) - var(--bottom-nav-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    height: calc(100dvh - var(--topbar-height) - var(--bottom-nav-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
  .recommendation-cards { grid-template-columns: 1fr; }
}

.setup-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0, 0, 0, 0.7);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
}
.setup-modal {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 20px; padding: 44px 40px 36px; max-width: 380px; width: 90%;
  box-shadow: 0 24px 80px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.04) inset;
}
.setup-logo-img {
  display: block; height: 24px; width: auto;
  margin: 0 auto 22px; object-fit: contain;
  opacity: 0.85;
}
.setup-title {
  color: var(--text); font-size: 15px; font-weight: 500;
  margin: 0 0 4px; text-align: center; letter-spacing: 0.01em;
}
.setup-subtitle {
  color: var(--text-faint); font-size: 12px; font-weight: 400;
  margin: 0 0 24px; text-align: center;
}
.setup-form { display: flex; flex-direction: column; gap: 10px; }
.setup-input {
  background: var(--bg); border: 1px solid var(--border-light);
  border-radius: 10px; padding: 11px 14px; color: var(--text);
  font-size: 13px; outline: none; width: 100%; box-sizing: border-box;
  min-height: 44px; transition: border 0.15s, box-shadow 0.15s;
}
.setup-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(75, 123, 245, 0.08); }
.setup-input::placeholder { color: var(--text-faint); }
.setup-btn {
  background: var(--accent); color: #fff; border: none;
  border-radius: 10px; padding: 11px 18px; font-size: 13px;
  font-weight: 500; cursor: pointer; transition: all 160ms;
  min-height: 44px; margin-top: 4px;
}
.setup-btn:hover { background: var(--accent-hover); }
.setup-btn:active { transform: scale(0.98); }
.setup-btn:disabled { opacity: 0.6; cursor: default; }
.setup-btn-secondary {
  background: var(--bg-hover); color: var(--text); border: 1px solid var(--border-light);
  border-radius: 8px; padding: 8px 14px; font-size: 13px;
  cursor: pointer; transition: background 160ms; display: block;
  width: 100%; text-align: left; margin-bottom: 6px;
}
.setup-btn-secondary:hover { background: var(--bg-active); }
.setup-error {
  color: #f87171; font-size: 12px; text-align: center; margin-top: 8px;
}
.setup-pw-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: setupPwSlide 0.25s ease-out;
}
@keyframes setupPwSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.setup-pw-field {
  position: relative;
  display: flex;
  align-items: center;
}
.setup-pw-field .setup-input {
  padding-right: 40px;
  width: 100%;
}
.setup-pw-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: opacity var(--transition), color var(--transition);
}
.setup-pw-toggle:hover { opacity: 0.8; }
.setup-pw-toggle.active { opacity: 1; color: var(--accent); }
.setup-pw-hint {
  color: var(--text-muted);
  font-size: 11px;
  margin: -4px 0 0 2px;
}

.upload-zone {
  border: 2px dashed var(--border-light); border-radius: 10px;
  padding: 24px; text-align: center; cursor: pointer;
  transition: border-color 160ms, background 160ms;
  background: var(--bg);
}
.upload-zone:hover { border-color: var(--accent); background: var(--accent-subtle); }
.upload-zone.dragover { border-color: var(--accent); background: var(--accent-subtle); }
.upload-zone-label {
  color: var(--text-secondary); font-size: 13px; margin-top: 6px;
}
.upload-zone-icon {
  font-size: 28px; color: var(--text-muted); margin-bottom: 4px;
}

.data-health-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px;
}
.data-health-green { background: #10b981; }
.data-health-amber { background: #f59e0b; }
.data-health-red { background: #ef4444; }

.action-bar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.action-btn {
  background: var(--accent); color: #fff; border: none;
  border-radius: 6px; padding: 10px 14px; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: all 160ms;
  min-height: 44px;
}
.action-btn:hover { background: var(--accent-hover); }
.action-btn:active { transform: scale(0.97); }
.action-btn:disabled { opacity: 0.6; cursor: default; }
.action-btn-outline {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border-light); border-radius: 6px;
  padding: 10px 14px; font-size: 14px; cursor: pointer;
  transition: all 160ms; min-height: 44px;
}
.action-btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.action-btn-outline:active { transform: scale(0.97); }

.calc-version-tag {
  font-family: var(--mono); font-size: 11px; color: var(--text-faint);
  padding: 2px 8px; border-radius: 4px; background: var(--bg-hover);
}

/* ── Dashboard ───────────────────────────────────────── */
.dashboard-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 24px;
}

.dashboard-header {
  margin-bottom: 28px;
}

.dashboard-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}

.dashboard-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.kpi-strip {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.kpi-strip::-webkit-scrollbar { display: none; }

.kpi-strip-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  min-width: 160px;
  flex: 1;
  transition: all var(--transition);
}

.kpi-strip-card:hover {
  border-color: var(--border-light);
  background: var(--surface-hover);
}

.kpi-strip-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--accent-subtle);
  color: var(--accent);
  flex-shrink: 0;
}

.kpi-strip-icon.kpi-icon-green { background: var(--ok-subtle); color: var(--ok); }
.kpi-strip-icon.kpi-icon-amber { background: var(--warn-subtle); color: var(--warn); }
.kpi-strip-icon.kpi-icon-purple { background: var(--accent-purple-subtle); color: var(--accent-purple); }
.kpi-strip-icon.kpi-icon-blue { background: var(--accent-subtle); color: var(--accent); }

.kpi-strip-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-strip-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.kpi-strip-value-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.kpi-strip-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.kpi-trend {
  font-size: 11px;
  font-weight: 600;
}
.kpi-trend-up { color: var(--ok); }
.kpi-trend-down { color: var(--danger); }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.dashboard-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.dashboard-section-full {
  grid-column: 1 / -1;
}

.dashboard-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.dashboard-section-header .dashboard-section-title {
  margin-bottom: 0;
}

.dashboard-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dashboard-section-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  transition: opacity var(--transition);
}
.dashboard-section-link:hover { opacity: 0.7; }

.dashboard-empty-state {
  text-align: center;
  padding: 24px 0 16px;
}

.dashboard-empty-state .empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--text-faint);
  margin-bottom: 10px;
}

.dashboard-empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 4px;
}

.dashboard-empty-state .empty-hint {
  font-size: 12px;
  color: var(--text-faint);
}

.dashboard-action-link {
  display: inline-block;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  transition: opacity var(--transition);
}

.dashboard-action-link:hover { opacity: 0.8; }

.dash-loading {
  text-align: center;
  padding: 20px 0;
  font-size: 12px;
  color: var(--text-faint);
}

.priority-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.priority-card:last-child { border-bottom: none; }

.priority-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-faint);
}
.priority-high .priority-indicator { background: var(--danger); }
.priority-medium .priority-indicator { background: var(--warn); }
.priority-low .priority-indicator { background: var(--ok); }

.priority-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.priority-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.priority-meta {
  font-size: 11px;
  color: var(--text-faint);
}

.priority-action {
  padding: 4px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.priority-action:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
}

.analysis-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: opacity var(--transition);
}
.analysis-item:last-child { border-bottom: none; }
.analysis-item:hover { opacity: 0.85; }

.analysis-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent);
  flex-shrink: 0;
}

.analysis-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.analysis-snippet {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analysis-time {
  font-size: 11px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.compliance-defaults { display: flex; flex-direction: column; gap: 8px; }

.compliance-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
}

.compliance-border {
  width: 3px;
  min-height: 32px;
  border-radius: 2px;
  flex-shrink: 0;
  align-self: stretch;
}
.compliance-warn .compliance-border { background: var(--warn); }
.compliance-ok .compliance-border { background: var(--ok); }
.compliance-info .compliance-border { background: var(--accent); }
.compliance-danger .compliance-border { background: var(--danger); }

.compliance-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.compliance-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.compliance-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.compliance-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 3px;
  flex-shrink: 0;
  white-space: nowrap;
}
.tag-warn { background: var(--warn-subtle); color: var(--warn); }
.tag-ok { background: var(--ok-subtle); color: var(--ok); }
.tag-info { background: var(--accent-subtle); color: var(--accent); }
.tag-danger { background: var(--danger-subtle); color: var(--danger); }

.recommendation-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.recommendation-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-family: var(--sans);
}

.recommendation-card:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.recommendation-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
  color: var(--accent);
  flex-shrink: 0;
}

.rec-icon-green { background: var(--ok-subtle); color: var(--ok); }
.rec-icon-amber { background: var(--warn-subtle); color: var(--warn); }
.rec-icon-blue { background: var(--accent-subtle); color: var(--accent); }
.rec-icon-purple { background: var(--accent-purple-subtle); color: var(--accent-purple); }

.recommendation-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.recommendation-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.recommendation-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.rail-quick-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.rail-quick-link:hover { color: var(--accent); }
.rail-quick-link svg { opacity: 0.5; flex-shrink: 0; }

.rail-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.rail-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.rail-step-text {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── Data Room ───────────────────────────────────────── */
.dataroom-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.dataroom-tab {
  padding: 10px 20px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}

.dataroom-tab:hover { color: var(--text-secondary); }
.dataroom-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.dataroom-panel { display: none; }
.dataroom-panel.active { display: block; }

.dataroom-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Data Room ──────────────────────────────────────── */
.dr-dropzone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
  margin-bottom: 16px;
  color: var(--text-muted);
}

.dr-dropzone:hover,
.dr-dropzone-active {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.dr-dropzone svg { margin-bottom: 8px; opacity: 0.5; }
.dr-dropzone p { font-size: 13px; margin: 0 0 4px; }
.dr-dropzone-hint { font-size: 11px; color: var(--text-faint); }

.dr-upload-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}

.dr-select {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
}

.dr-upload-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--sans);
}

.dr-upload-btn:hover { background: var(--accent-hover); }

.dr-upload-cancel-btn {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.dr-upload-cancel-btn:hover { background: var(--bg-hover); }

.dr-upload-filename {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 0;
  font-family: var(--mono);
}

.dr-upload-status {
  font-size: 12px;
  margin: 8px 0;
}

.dr-status-info { color: var(--accent); }
.dr-status-ok { color: var(--ok); }
.dr-status-warn { color: var(--warn); }
.dr-status-error { color: var(--danger); }

.dr-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.dr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.dr-table thead { background: var(--bg-secondary); }

.dr-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.dr-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.dr-table tbody tr { transition: background var(--transition); cursor: pointer; }
.dr-table tbody tr:hover { background: var(--bg-hover); }
.dr-table tbody tr:last-child td { border-bottom: none; }

.dr-cell-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--text);
}

.dr-file-icon { color: var(--text-faint); flex-shrink: 0; display: flex; }
.dr-file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }

.dr-cell-mono { font-family: var(--mono); font-size: 11px; }

.dr-cell-hash {
  font-family: var(--mono);
  font-size: 10px;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dr-cell-actions {
  display: flex;
  gap: 4px;
}

.dr-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.dr-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-light);
}

.dataroom-panel .pill { display: inline-block; font-size: 10px; padding: 2px 8px; border-radius: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.pill-type { background: var(--accent-subtle); color: var(--accent); }

.dr-connections-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.dr-connection-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: all var(--transition);
}

.dr-connection-card:hover { border-color: var(--border-light); }

.dr-connection-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.dr-connection-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  flex-shrink: 0;
}

.dr-connection-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dr-connection-name { font-size: 14px; font-weight: 600; color: var(--text); }
.dr-connection-desc { font-size: 12px; color: var(--text-muted); }

.dr-connection-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dr-connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-faint);
}

.dr-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.dr-status-dot-inactive { background: var(--text-faint); }
.dr-status-dot-active { background: var(--ok); }

.dr-connect-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 5px 14px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--sans);
}

.dr-connect-btn:hover { border-color: var(--accent); color: var(--accent); }

.dr-connections-note {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.dr-connections-note p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.dr-entity-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dr-entity-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  transition: all var(--transition);
}

.dr-entity-card:hover { border-color: var(--border-light); }

.dr-entity-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 3px;
}

.dr-badge-category { background: var(--accent-subtle); color: var(--accent); }
.dr-badge-site { background: var(--ok-subtle); color: var(--ok); }
.dr-badge-source { background: var(--warn-subtle); color: var(--warn); }
.dr-badge-company { background: var(--accent-purple-subtle); color: var(--accent-purple); }

.dr-entity-name { font-size: 13px; font-weight: 500; color: var(--text); }

.dr-evidence-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dr-evidence-count { font-size: 12px; color: var(--text-muted); }

.dr-ev-upload-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--sans);
}

.dr-ev-upload-btn:hover { background: var(--accent-hover); }

.dr-ev-modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.dr-ev-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
}

.dr-ev-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}

.dr-ev-modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dr-ev-dropzone {
  padding: 20px;
}

.dr-audit-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 20px;
}

.dr-audit-timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--border);
}

.dr-audit-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  padding: 10px 0;
}

.dr-audit-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
  position: absolute;
  left: -20px;
  top: 14px;
  z-index: 1;
}

.dr-audit-create .dr-audit-dot { background: var(--ok); }
.dr-audit-calc .dr-audit-dot { background: var(--accent); }
.dr-audit-report .dr-audit-dot { background: var(--accent-purple); }
.dr-audit-error .dr-audit-dot { background: var(--danger); }
.dr-audit-info .dr-audit-dot { background: var(--text-faint); }

.dr-audit-content {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.dr-audit-kind {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.dr-audit-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.dr-audit-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--text-faint);
}

.dr-audit-time {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
}

.dr-audit-user { font-family: var(--mono); }

.rail-hash {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  word-break: break-all;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-top: 4px;
}

.dr-setup-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.dr-setup-icon { color: var(--accent); flex-shrink: 0; }
.dr-setup-text { flex: 1; }
.dr-setup-text strong { color: var(--text); font-size: 14px; }
.dr-setup-text p { color: var(--text-muted); font-size: 12px; margin: 4px 0 0; }
.dr-setup-action {
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.dr-setup-action:hover { opacity: 0.9; }

.dr-badge-org { background: var(--accent-subtle); color: var(--accent); }
.dr-badge-site { background: var(--ok-subtle); color: var(--ok); }
.dr-badge-source { background: var(--accent-purple-subtle); color: var(--accent-purple); }

.dr-delete-btn { color: var(--text-faint); }
.dr-delete-btn:hover { color: var(--danger); }

.dr-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.dr-sortable:hover { color: var(--accent); }
.dr-sort-icon { font-size: 10px; margin-left: 4px; color: var(--text-faint); }
.dr-sort-active { color: var(--accent); }

.dr-entity-selectable { cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.dr-entity-selectable:hover { border-color: var(--border-light); }
.dr-entity-active { border-color: var(--accent); background: var(--accent-subtle); }

@media (max-width: 640px) {
  .dr-connections-grid { grid-template-columns: 1fr; }
  .dr-file-name { max-width: 160px; }
  .dr-cell-hash { display: none; }
  .dr-setup-banner { flex-direction: column; text-align: center; }
}

/* ── Automations ─────────────────────────────────────── */
.automations-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.automation-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  transition: all var(--transition);
}

.automation-card:hover { border-color: var(--border-light); }

.automation-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--accent-subtle);
  color: var(--accent);
  flex-shrink: 0;
}

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

.automation-title { font-size: 14px; font-weight: 600; color: var(--text); }
.automation-desc { font-size: 12px; color: var(--text-muted); }

.automation-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.automation-schedule {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.automation-status {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 3px;
}

.automation-status-active { background: var(--ok-subtle); color: var(--ok); }
.automation-status-paused { background: var(--bg-hover); color: var(--text-faint); }

.automation-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.automation-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.automation-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-hover);
  border-radius: 11px;
  cursor: pointer;
  transition: background 200ms;
}

.automation-toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 200ms, background 200ms;
}

.automation-toggle input:checked + .automation-toggle-slider {
  background: var(--accent);
}

.automation-toggle input:checked + .automation-toggle-slider::before {
  transform: translateX(18px);
  background: #fff;
}

.automation-runs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
}

.automation-run-label {
  font-size: 11px;
  color: var(--text-faint);
}

.automation-run-value {
  color: var(--text-muted);
  font-weight: 500;
}

.aut-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.aut-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.aut-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.aut-stat-label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* ── Reports Library ──────────────────────────────────── */
.rpt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.rpt-categories {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.rpt-cat-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--sans);
}

.rpt-cat-btn:hover {
  border-color: var(--border-light);
  color: var(--text-secondary);
}

.rpt-cat-btn.rpt-cat-active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}

.rpt-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-faint);
  min-width: 200px;
}

.rpt-search {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: var(--sans);
  outline: none;
  width: 100%;
}

.rpt-search::placeholder { color: var(--text-faint); }

.rpt-count-row {
  margin-bottom: 12px;
}

.rpt-count {
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 500;
}

.rpt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.rpt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all var(--transition);
  cursor: default;
}

.rpt-card:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.rpt-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rpt-card-icon {
  color: var(--text-faint);
}

.rpt-card-body { flex: 1; }

.rpt-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px;
  line-height: 1.4;
}

.rpt-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-faint);
}

.rpt-card-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-faint);
}

.rpt-card-actions {
  display: flex;
  gap: 4px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.rpt-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: all var(--transition);
}

.rpt-action-btn:hover {
  border-color: var(--border-light);
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.rpt-action-danger:hover {
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
  background: var(--danger-subtle);
}

.rpt-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  text-align: center;
}

.rpt-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0;
}

.rpt-empty-desc {
  font-size: 13px;
  color: var(--text-faint);
  max-width: 360px;
  margin: 0;
}

.rpt-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rpt-modal.hidden { display: none; }

.rpt-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.rpt-modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 440px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}

.rpt-modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 16px;
}

.rpt-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* ── Onboarding Wizard ──────────────────────────────── */
.onb-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.onb-card {
  width: 640px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 32px;
}

.onb-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 32px;
}

.onb-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}

.onb-step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-hover);
  color: var(--text-faint);
  border: 2px solid var(--border);
  transition: all 200ms;
}

.onb-step-active .onb-step-dot {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent);
}

.onb-step-done .onb-step-dot {
  background: var(--ok-subtle);
  color: var(--ok);
  border-color: var(--ok);
}

.onb-step-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.onb-step-active .onb-step-label { color: var(--accent); }
.onb-step-done .onb-step-label { color: var(--ok); }

.onb-step-line {
  width: 40px;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
  margin-bottom: 22px;
}

.onb-body {
  margin-bottom: 24px;
}

.onb-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}

.onb-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 20px;
}

.onb-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.onb-btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition: all var(--transition);
}

.onb-btn:hover { background: var(--accent-hover); }
.onb-btn:disabled { opacity: 0.5; cursor: default; }

.onb-btn-secondary {
  padding: 10px 20px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--sans);
  transition: all var(--transition);
}

.onb-btn-secondary:hover { border-color: var(--text-faint); color: var(--text); }

.onb-goals-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.onb-goal-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-family: var(--sans);
}

.onb-goal-card:hover { border-color: var(--border-light); }

.onb-goal-selected {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.onb-goal-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.onb-goal-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.onb-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.onb-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.onb-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.onb-input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: var(--sans);
  transition: border-color var(--transition);
  outline: none;
  width: 100%;
}

.onb-input:focus { border-color: var(--accent); }
.onb-input::placeholder { color: var(--text-faint); }

.onb-row {
  display: flex;
  gap: 12px;
}

.onb-upload-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.onb-upload-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 14px;
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.onb-upload-card:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.onb-upload-icon { color: var(--text-faint); }
.onb-upload-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.onb-upload-ext { font-size: 10px; color: var(--text-faint); }

.onb-hint {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  margin-top: 12px;
}

.onb-modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.onb-mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  font-family: var(--sans);
}

.onb-mode-card:hover { border-color: var(--border-light); }

.onb-mode-selected {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.onb-mode-icon { color: var(--text-faint); }
.onb-mode-selected .onb-mode-icon { color: var(--accent); }
.onb-mode-label { font-size: 13px; font-weight: 600; color: var(--text); }
.onb-mode-desc { font-size: 11px; color: var(--text-muted); }

.onb-ready {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.onb-ready-icon { margin-bottom: 8px; }

.onb-summary {
  width: 100%;
  max-width: 360px;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.onb-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.onb-summary-row:last-child { border-bottom: none; }

.onb-summary-label { color: var(--text-faint); font-weight: 500; }
.onb-summary-value { color: var(--text); font-weight: 600; text-align: right; max-width: 200px; }

@media (max-width: 640px) {
  .onb-card { padding: 20px; }
  .onb-goals-grid, .onb-upload-grid { grid-template-columns: 1fr; }
  .onb-modes-grid { grid-template-columns: 1fr 1fr; }
  .onb-row { flex-direction: column; gap: 14px; }
  .onb-step-label { display: none; }
  .rpt-grid { grid-template-columns: 1fr; }
  .rpt-toolbar { flex-direction: column; }
  .rpt-categories { overflow-x: auto; flex-wrap: nowrap; }
  .aut-stats { flex-wrap: wrap; }
  .automation-runs { display: none; }
  .search-modal-content { width: 95vw; max-width: none; margin: 16px; }
  .notif-dropdown { right: 8px; width: calc(100vw - 16px); max-width: 380px; }
  .team-invite-row { flex-direction: column; }
  .settings-form-grid { grid-template-columns: 1fr; }
  .team-member-row { flex-wrap: wrap; }
}

.search-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.search-modal.hidden { display: none; }
.search-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}
.search-modal-content {
  position: relative;
  width: 560px;
  max-height: 480px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.search-modal-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.search-modal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: var(--sans);
}
.search-modal-input::placeholder { color: var(--text-faint); }
.search-kbd {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-faint);
  border: 1px solid var(--border);
  font-family: var(--mono);
}
.search-results {
  overflow-y: auto;
  max-height: 380px;
  padding: 8px;
}
.search-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}
.search-group-label {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background var(--transition);
}
.search-result-item:hover { background: var(--bg-hover); }
.search-result-icon { color: var(--text-muted); flex-shrink: 0; }
.search-result-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.search-result-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-sub { font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}
.notif-badge.visible { display: flex; }

.topbar-icon-btn { position: relative; }

.notif-dropdown {
  position: fixed;
  top: 56px;
  right: 60px;
  width: 380px;
  max-height: 480px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.notif-dropdown.hidden { display: none; }
.notif-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.notif-dropdown-title { font-size: 14px; font-weight: 600; color: var(--text); }
.notif-mark-all {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--sans);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.notif-mark-all:hover { background: var(--accent-subtle); }
.notif-list {
  overflow-y: auto;
  max-height: 400px;
}
.notif-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { background: var(--accent-subtle); }
.notif-item-icon { color: var(--text-muted); flex-shrink: 0; margin-top: 2px; }
.notif-item-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.notif-item-title { font-size: 13px; font-weight: 500; color: var(--text); }
.notif-item-text { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-time { font-size: 11px; color: var(--text-faint); }
.notif-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 4px;
}

.settings-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 24px;
}
.settings-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--sans);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active {
  background: var(--bg-secondary);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.settings-body { }

.settings-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.settings-field { display: flex; flex-direction: column; gap: 6px; }
.settings-field-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }
.settings-field-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  font-family: var(--sans);
  outline: none;
  transition: border-color var(--transition);
}
.settings-field-input:focus { border-color: var(--accent); }
.settings-field-input:disabled { opacity: 0.5; cursor: not-allowed; }
.settings-field-hint { font-size: 11px; color: var(--text-faint); }
.settings-status {
  font-size: 12px;
  margin-left: 12px;
}
.settings-status.success { color: var(--ok); }
.settings-status.error { color: var(--danger); }
.settings-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--bg-active);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
  padding: 0 6px;
}

.team-invite-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.team-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.team-member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.team-member-row:last-child { border-bottom: none; }
.team-member-row:hover { background: var(--bg-hover); }
.team-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}
.team-member-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}
.team-member-name { font-size: 13px; font-weight: 500; color: var(--text); }
.team-member-email { font-size: 12px; color: var(--text-faint); }
.team-member-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.team-role-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text);
  font-family: var(--sans);
  outline: none;
  cursor: pointer;
}
.team-role-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 500;
}
.team-remove-btn {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: all var(--transition);
}
.team-remove-btn:hover { color: var(--danger); background: var(--danger-subtle); }
.team-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

.aut-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: all var(--transition);
  opacity: 0;
}
.automation-card:hover .aut-delete-btn { opacity: 1; }
.aut-delete-btn:hover { color: var(--danger); background: var(--danger-subtle); }

.nav-item-locked {
  opacity: 0.45;
  cursor: default;
  position: relative;
}
.nav-item-locked:hover {
  background: var(--bg-tertiary);
  opacity: 0.65;
}
.nav-lock-icon {
  margin-left: auto;
  opacity: 0.5;
  flex-shrink: 0;
}

.upgrade-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.upgrade-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  max-width: 580px;
  width: 90vw;
  text-align: center;
  position: relative;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.upgrade-modal-close {
  position: absolute;
  top: 14px; right: 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upgrade-modal-close:hover { background: var(--bg-tertiary); color: var(--text); }
.upgrade-modal-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--accent-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.upgrade-modal-icon svg { width: 22px; height: 22px; color: var(--accent); }
.upgrade-modal-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}
.upgrade-modal-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 28px;
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}
.upgrade-modal-tiers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}
.upgrade-tier {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: left;
  position: relative;
}
.upgrade-tier-featured {
  border-color: var(--accent);
  background: rgba(78,205,196,0.04);
}
.upgrade-tier-badge {
  position: absolute;
  top: -10px; right: 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 20px;
}
.upgrade-tier-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.upgrade-tier-price {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.upgrade-tier-price span {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}
.upgrade-tier-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.upgrade-tier-cta {
  margin-top: 14px;
  width: 100%;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.upgrade-tier-cta:hover { filter: brightness(1.1); }
.upgrade-modal-plans-link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  display: inline-block;
  margin-top: 4px;
}
.upgrade-modal-plans-link:hover { color: var(--accent); }

.plans-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}
@media (max-width: 1100px) {
  .plans-grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .plans-grid-4 { grid-template-columns: 1fr; }
  .upgrade-modal-tiers { grid-template-columns: 1fr; }
  .upgrade-modal { padding: 28px 20px; }
}
.plan-current {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.usage-bar-container {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 140px;
}
.usage-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}
.usage-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.usage-bar-fill.usage-bar-warn { background: var(--warn); }
.usage-bar-fill.usage-bar-danger { background: var(--danger); }
.usage-bar-label {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 30px;
  text-align: right;
}

.settings-upgrade-cta {
  margin-top: 16px;
  padding: 16px;
  background: rgba(78,205,196,0.04);
  border: 1px solid var(--accent-subtle);
  border-radius: var(--radius);
}
.settings-upgrade-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.action-btn-accent {
  background: var(--accent) !important;
  color: var(--bg) !important;
  border: none !important;
  font-weight: 600;
  white-space: nowrap;
}
.action-btn-accent:hover { filter: brightness(1.1); }

@media (max-width: 640px) {
  .settings-upgrade-inner { flex-direction: column; align-items: stretch; }
}
