/* ═══════════════════════════════════════════
   AusBooks — Design System & Full Styles
   ═══════════════════════════════════════════ */

:root {
  /* Colors */
  --bg-primary: #0f1117;
  --bg-secondary: #161822;
  --bg-tertiary: #1c1f2e;
  --bg-card: #1e2133;
  --bg-hover: #252841;
  --bg-active: #2a2e4a;

  --text-primary: #e8eaf0;
  --text-secondary: #9ca3b4;
  --text-muted: #636b80;

  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-hover: #7c6ff0;

  --success: #00cec9;
  --success-bg: rgba(0, 206, 201, 0.1);
  --warning: #fdcb6e;
  --warning-bg: rgba(253, 203, 110, 0.1);
  --danger: #ff7675;
  --danger-bg: rgba(255, 118, 117, 0.1);
  --info: #74b9ff;
  --info-bg: rgba(116, 185, 255, 0.1);

  --border: #2d3148;
  --border-light: #383d56;

  /* Layout */
  --sidebar-width: 260px;
  --chat-width: 480px;
  --chat-min-width: 320px;
  --chat-max-width: min(920px, 72vw);
  --header-height: 0px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);

  /* Transitions */
  --transition: 0.2s ease;
}

[data-theme="light"] {
  --bg-primary: #f8f9fc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f2f7;
  --bg-card: #ffffff;
  --bg-hover: #eef1f6;
  --bg-active: #e4e8f0;

  --text-primary: #1a1d2e;
  --text-secondary: #4a4f63;
  --text-muted: #8b92a8;

  --accent: #5b4cdb;
  --accent-light: #7a6df0;
  --accent-hover: #4a3ec7;

  --success: #0aae8f;
  --success-bg: rgba(10, 174, 143, 0.1);
  --warning: #c98a00;
  --warning-bg: rgba(201, 138, 0, 0.1);
  --danger: #d64c4c;
  --danger-bg: rgba(214, 76, 76, 0.1);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.1);

  --border: #dde1ea;
  --border-light: #e8ecf2;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.10);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Login Screen ─── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-tertiary) 50%, var(--bg-primary) 100%);
}

.login-card {
  text-align: center;
  padding: 3rem 2.5rem;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 100%;
}

.login-logo { margin-bottom: 2rem; }
.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: var(--radius-lg);
  font-size: 36px;
  color: white;
  margin-bottom: 1rem;
}
.login-logo h1 {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-light), var(--success));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-logo p { color: var(--text-secondary); margin-top: 0.25rem; }
.login-subtitle {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: var(--bg-hover);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 2rem;
  background: white;
  color: #333;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9375rem;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.google-btn:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* ─── Theme Toggle ─── */
.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  z-index: 50;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  transform: scale(1.05);
}

/* ─── AI Insights ─── */
.ai-insights-card {
  border-left: 3px solid var(--accent);
}
.ai-insight-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.ai-insight-item:last-child { margin-bottom: 0; }
.ai-insight-item:hover { background: var(--bg-hover); }
.ai-insight-item i {
  font-size: 1.125rem;
  margin-top: 0.125rem;
  flex-shrink: 0;
}
.ai-insight-info i { color: var(--info); }
.ai-insight-success i { color: var(--success); }
.ai-insight-warning i { color: var(--warning); }
.ai-insight-danger i { color: var(--danger); }
.ai-insight-text { flex: 1; line-height: 1.4; }

/* ─── Chat Suggestions ─── */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem 0;
  border-top: 1px solid var(--border);
}
.chat-suggestion-chip {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 0.25rem 0.625rem;
  font-size: 0.6875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.chat-suggestion-chip:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ─── Reconciliation Matches ─── */
.match-list { display: flex; flex-direction: column; gap: 0.5rem; }
.match-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  font-size: 0.8125rem;
  transition: var(--transition);
}
.match-item:hover { border-color: var(--accent); }
.match-high { border-left: 3px solid var(--success); }
.match-medium { border-left: 3px solid var(--warning); }
.match-confidence {
  font-weight: 700;
  font-size: 0.75rem;
  min-width: 36px;
  text-align: center;
  color: var(--text-secondary);
}
.match-details { flex: 1; min-width: 0; }
.match-reason { color: var(--text-primary); font-weight: 500; }
.match-action { color: var(--text-muted); font-size: 0.6875rem; margin-top: 0.125rem; }
.match-btn { flex-shrink: 0; }

/* ─── Main Layout ─── */
.main-app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 20;
}

.sidebar-header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
}

.sidebar-brand-text h2 {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.2;
}
.sidebar-brand-text span {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1rem 0.75rem 0.375rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent);
  color: white;
}
.nav-item i { font-size: 1.125rem; width: 20px; text-align: center; }

.nav-badge {
  margin-left: auto;
  padding: 0.125rem 0.5rem;
  background: var(--danger);
  color: white;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 0.8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-email { font-size: 0.6875rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-logout {
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.sidebar-logout:hover { color: var(--danger); background: var(--danger-bg); }

/* ─── Main Content ─── */
.main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-primary);
}

.page-content {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 2rem;
}
.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.page-header p { color: var(--text-secondary); font-size: 0.9375rem; }

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
}

/* ─── Stats Grid ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.stat-icon.purple { background: rgba(108,92,231,0.15); color: var(--accent-light); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.orange { background: var(--warning-bg); color: var(--warning); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }
.stat-icon.blue { background: var(--info-bg); color: var(--info); }

.loading { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.875rem; }
.error { padding: 1rem; background: var(--danger-bg, rgba(239,68,68,0.08)); border: 1px solid var(--danger, #ef4444); border-radius: var(--radius-sm); color: var(--danger, #ef4444); font-size: 0.8125rem; }
.stat { text-align: center; padding: 0.75rem; background: var(--bg-elevated, rgba(255,255,255,0.02)); border-radius: var(--radius-sm); }
.stat-info h3 { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 1.5rem; font-weight: 700; margin-top: 0.25rem; }
.stat-subtitle { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.25rem; }

/* ─── Tables ─── */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
tr:hover td { background: var(--bg-hover); }

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-purple { background: rgba(108,92,231,0.15); color: var(--accent-light); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-hover); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-active); }
.btn-success { background: var(--success); color: var(--bg-primary); }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 0.9375rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Forms ─── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  transition: var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,92,231,0.15);
}
.form-textarea { resize: vertical; min-height: 80px; }

/* ─── Chat Panel ─── */
.chat-panel {
  width: var(--chat-width);
  min-width: var(--chat-min-width);
  max-width: var(--chat-max-width);
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
  position: relative;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.chat-panel.is-resizing {
  transition: transform 0.3s ease, opacity 0.3s ease;
  user-select: none;
}
.chat-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  margin-left: -4px;
  cursor: col-resize;
  z-index: 12;
  touch-action: none;
}
.chat-resize-handle::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0;
  bottom: 0;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background 0.15s;
}
.chat-resize-handle:hover::after,
.chat-panel.is-resizing .chat-resize-handle::after {
  background: var(--accent);
}
.chat-panel.collapsed {
  transform: translateX(100%);
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  opacity: 0;
  pointer-events: none;
}

.chat-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.chat-header-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--success));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1rem;
}
.chat-header h3 { font-size: 0.9375rem; font-weight: 600; }
.chat-header span { font-size: 0.6875rem; color: var(--text-muted); }

.chat-export-bar {
  flex-shrink: 0;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chat-export-bar.hidden { display: none; }
.chat-export-bar-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.chat-export-bar-left i { color: var(--accent-light); }
.chat-export-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.chat-export-email-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.chat-export-email-row .form-input {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  padding: 0.35rem 0.5rem;
}
.chat-table-export-wrap {
  margin: 0.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-primary);
}
.chat-table-export-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-hover);
  cursor: pointer;
  user-select: none;
}
.chat-table-export-label input { accent-color: var(--accent); }
.chat-table-export-wrap:has(.chat-table-export-cb:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Chat threads drawer */
.chat-threads {
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  max-height: 38vh;
  overflow-y: auto;
  padding: 0.4rem;
}
.chat-threads-empty {
  padding: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
}
.chat-thread-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 8px;
  padding: 0.1rem;
}
.chat-thread-row:hover { background: var(--bg-card); }
.chat-thread-row.active { background: var(--bg-card); box-shadow: inset 0 0 0 1px var(--border); }
.chat-thread-open {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.45rem 0.5rem;
  text-align: left;
  color: var(--text-primary);
  font-size: 0.8125rem;
  min-width: 0;
}
.chat-thread-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-thread-rename,
.chat-thread-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.35rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.chat-thread-rename:hover { color: var(--text-primary); background: var(--bg-secondary); }
.chat-thread-del:hover { color: var(--danger); background: var(--danger-bg); }

/* Year-end planner */
.planner-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1rem; }
.planner-card h3 { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.6rem; }
.planner-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.7rem; }
.planner-form label { display: flex; flex-direction: column; font-size: 0.78rem; color: var(--text-muted); gap: 0.2rem; }
.planner-form label.chk { flex-direction: row; align-items: center; gap: 0.4rem; font-size: 0.82rem; grid-column: 1 / -1; color: var(--text-primary); }
.planner-form input, .planner-form select { padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: 8px; font-size: 0.88rem; }
.planner-form label:first-child { grid-column: 1 / -1; position: relative; }
.planner-form label:first-child button { position: absolute; right: 4px; bottom: 4px; }
.planner-sub { grid-column: 1 / -1; font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-top: 0.3rem; }
.planner-result { margin-top: 0.9rem; }
.planner-rec { background: linear-gradient(135deg, rgba(108,92,231,.08), rgba(0,206,201,.08)); border: 1px solid var(--border); border-radius: 12px; padding: 0.8rem; }
.rec-head { font-weight: 700; color: var(--accent); margin-bottom: 0.5rem; }
.rec-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.rec-grid > div { display: flex; flex-direction: column; }
.rec-grid span { font-size: 0.7rem; color: var(--text-muted); }
.rec-grid b { font-size: 1rem; }
.planner-table { width: 100%; border-collapse: collapse; margin-top: 0.7rem; font-size: 0.82rem; }
.planner-table th, .planner-table td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); text-align: left; }
.planner-table th.r, .planner-table td.r { text-align: right; }
.planner-table tr.best { background: rgba(46, 204, 113, .12); font-weight: 600; }
.planner-capacity { font-size: 2rem; font-weight: 800; color: var(--accent); display: flex; flex-direction: column; }
.planner-capacity span { font-size: 0.78rem; font-weight: 500; color: var(--text-muted); }
.planner-assume { margin-top: 0.7rem; font-size: 0.78rem; color: var(--text-muted); }
.planner-assume ul { margin: 0.4rem 0 0 1rem; }
.planner-actions { display: flex; gap: 0.5rem; margin-top: 0.9rem; flex-wrap: wrap; }

/* Ledger (mini-Xero) */
.ledger-tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.ledger-tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 0.55rem 0.9rem; cursor: pointer; color: var(--text-muted); font-size: 0.875rem;
}
.ledger-tab:hover { color: var(--text-primary); }
.ledger-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.ledger-acct-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.ledger-acct-form input, .ledger-acct-form select { padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: 8px; }
.ledger-jline { display: flex; gap: 0.4rem; margin-bottom: 0.35rem; align-items: center; }
.ledger-jline input { padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: 8px; }
.ledger-jline .jl-acct { width: 130px; }
.ledger-jline .jl-desc { flex: 1; min-width: 140px; }
.ledger-jline .jl-debit, .ledger-jline .jl-credit { width: 110px; text-align: right; }

/* Data portability — target picker */
.migration-targets { display: flex; flex-direction: column; gap: 0.5rem; }
.migration-target {
  display: flex; align-items: flex-start; gap: 0.6rem;
  padding: 0.7rem 0.85rem; border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.migration-target:hover { border-color: var(--accent); }
.migration-target input { margin-top: 0.2rem; }
.migration-target strong { display: block; font-size: 0.9rem; }
.migration-target span { font-size: 0.78rem; color: var(--text-muted); }
.migration-conn { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.migration-conn:last-child { border-bottom: none; }
.migration-conn-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }

/* Downloadable files saved in a chat */
.chat-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.chat-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.8125rem;
  max-width: 100%;
}
.chat-file-chip:hover { border-color: var(--accent); }
.chat-file-chip i { color: var(--accent); }
.chat-file-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.chat-file-chip-meta { color: var(--text-muted); font-size: 0.6875rem; }

.chat-msg {
  display: flex;
  gap: 0.75rem;
  max-width: 100%;
  width: 100%;
}
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.chat-msg-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
}
.chat-msg.assistant .chat-msg-avatar {
  background: linear-gradient(135deg, var(--accent), var(--success));
  color: white;
}
.chat-msg.user .chat-msg-avatar {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.chat-msg-bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  line-height: 1.6;
  min-width: 0;
  flex: 1;
  overflow-wrap: anywhere;
}
.chat-msg-bubble .md-table-wrap {
  overflow-x: auto;
  margin: 0.5rem 0;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.chat-msg-bubble table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}
.chat-msg-bubble th,
.chat-msg-bubble td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
  white-space: nowrap;
}
.chat-msg-bubble th {
  background: var(--bg-hover);
  font-weight: 600;
}
.chat-msg-bubble ul,
.chat-msg-bubble ol {
  margin: 0.35rem 0 0.35rem 1.1rem;
  padding: 0;
}
.chat-msg-bubble h1,
.chat-msg-bubble h2,
.chat-msg-bubble h3 {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.9rem;
}
.chat-msg.assistant .chat-msg-bubble {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}
.chat-msg.user .chat-msg-bubble {
  background: var(--accent);
  color: white;
}

.chat-msg-bubble p { margin-bottom: 0.5rem; }
.chat-msg-bubble p:last-child { margin-bottom: 0; }
.chat-msg-bubble code {
  background: rgba(0,0,0,0.2);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-size: 0.75rem;
}
.chat-msg-bubble pre {
  background: var(--bg-primary);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 0.5rem 0;
  font-size: 0.75rem;
}

.chat-msg-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.chat-confirm-btn {
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.chat-confirm-btn.yes { background: var(--success); color: var(--bg-primary); }
.chat-confirm-btn.no { background: var(--danger-bg); color: var(--danger); }

.chat-input-area {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  transition: var(--transition);
}
.chat-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,92,231,0.15);
}

.chat-file-btn, .chat-send-btn {
  width: 36px; height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.chat-file-btn { background: transparent; color: var(--text-muted); }
.chat-file-btn:hover { color: var(--accent-light); background: var(--bg-hover); }
.chat-send-btn { background: var(--accent); color: white; }
.chat-send-btn:hover { background: var(--accent-hover); }
.chat-send-btn:disabled { opacity: 0.4; }

.chat-textarea {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 36px;
  max-height: 120px;
  padding: 0.5rem;
  line-height: 1.5;
}

.chat-file-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0.5rem 0;
}

.chat-file-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  color: var(--text-secondary);
}
.chat-file-tag button {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 0.875rem; line-height: 1;
}

/* ── Chat Slide Tab (drawer pull, top-right) ── */
.chat-slide-tab {
  position: fixed;
  top: 5.5rem;
  right: var(--chat-width); /* sits at the LEFT edge of the chat panel when open */
  z-index: 230;
  width: 28px;
  height: 64px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.12);
  transition: right 0.3s ease, background 0.15s;
  font-size: 1rem;
  padding: 0;
}
.chat-slide-tab:hover { background: var(--accent-light, var(--accent)); }
/* When the chat is collapsed, the tab snaps to the screen edge */
.chat-panel.collapsed ~ .chat-slide-tab,
body:has(.chat-panel.collapsed) .chat-slide-tab {
  right: 0;
}
.chat-slide-tab-label {
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-transform: uppercase;
}
@media (max-width: 1024px) {
  /* On mobile/tablet, the chat is an overlay — pin the tab to the right
     edge of the viewport so it's always reachable. */
  .chat-slide-tab { right: 0 !important; top: 4.5rem; }
}

/* Chat Toggle (legacy bottom-right round button — keep for now as a
   secondary affordance, but defer to the slide tab visually) */
.chat-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--success));
  color: white;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  transition: var(--transition);
}
.chat-toggle:hover { transform: scale(1.1); }
/* Legacy bottom-right round button — hidden by default (the slide tab is
   always visible on desktop); shown only on small screens via the
   `.chat-toggle.visible { display: flex !important }` rule in the mobile
   media query below. */

/* ─── Calendar ─── */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.calendar-header-cell {
  background: var(--bg-tertiary);
  padding: 0.75rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.calendar-cell {
  background: var(--bg-card);
  min-height: 100px;
  padding: 0.5rem;
  cursor: pointer;
  transition: var(--transition);
}
.calendar-cell:hover { background: var(--bg-hover); }
.calendar-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.calendar-cell.other-month { opacity: 0.4; }

.calendar-date {
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

.calendar-event {
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-size: 0.625rem;
  font-weight: 500;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.calendar-event.super { background: var(--danger-bg); color: var(--danger); }
.calendar-event.bas { background: var(--warning-bg); color: var(--warning); }
.calendar-event.payg { background: var(--info-bg); color: var(--info); }
.calendar-event.fbt { background: rgba(108,92,231,0.15); color: var(--accent-light); }
.calendar-event.tpar { background: var(--success-bg); color: var(--success); }
.calendar-event.tax_return { background: var(--warning-bg); color: var(--warning); }
.calendar-event.payday_super { background: var(--danger-bg); color: var(--danger); }
.calendar-event.custom { background: var(--bg-hover); color: var(--text-secondary); }
.calendar-event.reminder { background: var(--info-bg); color: var(--info); }

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.calendar-nav h2 { font-size: 1.25rem; font-weight: 700; }

/* ─── Deadline List ─── */
.deadline-list { display: flex; flex-direction: column; gap: 0.75rem; }

.deadline-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--border);
  transition: var(--transition);
}
.deadline-item:hover { background: var(--bg-hover); }
.deadline-item.critical { border-left-color: var(--danger); }
.deadline-item.high { border-left-color: var(--warning); }
.deadline-item.medium { border-left-color: var(--info); }

.deadline-date {
  text-align: center;
  min-width: 50px;
}
.deadline-date .day { font-size: 1.25rem; font-weight: 700; }
.deadline-date .month { font-size: 0.6875rem; color: var(--text-muted); text-transform: uppercase; }
.deadline-info h4 { font-size: 0.875rem; font-weight: 600; margin-bottom: 0.25rem; }
.deadline-info p { font-size: 0.75rem; color: var(--text-secondary); line-height: 1.5; }

/* ─── Documents ─── */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.folder-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.folder-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.folder-card i { font-size: 2rem; color: var(--warning); margin-bottom: 0.5rem; }
.folder-card h4 { font-size: 0.875rem; font-weight: 600; }
.folder-card span { font-size: 0.6875rem; color: var(--text-muted); }

.doc-list { display: flex; flex-direction: column; gap: 0.5rem; }

.doc-item {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  gap: 0.5rem;
}
.doc-item:hover { background: var(--bg-hover); }
.doc-row { display: flex; align-items: center; gap: 1rem; }

/* Extracted-data block */
.doc-extracted {
  border-top: 1px solid var(--border);
  padding-top: 0.625rem;
  font-size: 0.8125rem;
}
.doc-extracted-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem 1rem;
}
.doc-extracted-grid > div { display: flex; flex-direction: column; gap: 0.125rem; }
.doc-extracted-grid .lbl {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.doc-extracted-grid code {
  font-size: 0.75rem;
  background: var(--bg-card);
  padding: 0.0625rem 0.25rem;
  border-radius: 3px;
}
.doc-extracted-notes {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-style: italic;
}
.doc-extracted-conf {
  margin: 0.25rem 0 0;
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.doc-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  flex-shrink: 0;
}
.doc-icon.pdf { background: var(--danger-bg); color: var(--danger); }
.doc-icon.image { background: var(--success-bg); color: var(--success); }
.doc-icon.csv { background: var(--info-bg); color: var(--info); }
.doc-icon.other { background: var(--bg-hover); color: var(--text-muted); }

.doc-info { flex: 1; min-width: 0; }
.doc-info h4 { font-size: 0.8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-info span { font-size: 0.6875rem; color: var(--text-muted); }

/* ─── Query Builder ─── */
.query-input-group {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.query-input-group .form-input { flex: 1; }

.query-result {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  max-height: 500px;
  overflow: auto;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

#qb-result-grid {
  min-height: 280px;
  width: 100%;
}
#qb-result-grid .gv-shell,
#qb-result-grid .dg-table-wrap {
  width: 100%;
}
#qb-result-json.query-result {
  max-height: min(70vh, 640px);
}

.query-templates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.75rem;
}

.query-template-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  cursor: pointer;
  transition: var(--transition);
}
.query-template-card:hover { border-color: var(--accent); }
.query-template-card h4 { font-size: 0.8125rem; font-weight: 600; margin-bottom: 0.25rem; }
.query-template-card p { font-size: 0.6875rem; color: var(--text-muted); }
.query-template-card .badge { margin-top: 0.5rem; }

/* Query Builder category-filter pills */
.qb-category-filter { padding-bottom: 0.75rem; }
.qb-cat-pill {
  background: var(--bg-alt, var(--bg-hover));
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 0.3125rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.qb-cat-pill:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.06);
}
.qb-cat-pill.active {
  background: var(--success, #10b981);
  color: white;
  border-color: var(--success, #10b981);
}

/* ─── Settings ─── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
}

.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.settings-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─── Toggle Switch ─── */
.toggle {
  position: relative;
  width: 44px; height: 24px;
  display: inline-block;
}
.toggle input { display: none; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-hover);
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: white;
  left: 3px; top: 3px;
  transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { left: 23px; }

/* ─── Loading / Empty ─── */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
}
.loading-spinner i { font-size: 2rem; animation: spin 1s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
.ri-spin { display: inline-block; animation: spin 1s linear infinite; }

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; display: block; }
.empty-state h3 { font-size: 1.125rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.875rem; }

/* ─── Mobile nav toggle + sidebar backdrop ─── */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 200;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: var(--shadow-md, 0 2px 8px rgba(0,0,0,0.08));
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 150;
  animation: fade-in 0.15s ease-out;
}
.sidebar-backdrop.visible { display: block; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ─── Responsive ─── */
@media (max-width: 1200px) {
  :root { --chat-width: 360px; }
}
/* Chat panel: from medium screens down, becomes an overlay that's
   toggled via the floating chat-toggle button. Same behaviour on phones. */
@media (max-width: 1024px) {
  .chat-panel { position: fixed; right: 0; top: 0; bottom: 0; z-index: 220; }
  .chat-panel:not(.collapsed) { box-shadow: -10px 0 30px rgba(0,0,0,0.5); }
}
/* Phone: panel takes most of the viewport (not all — leave a strip on
   the left so users can clearly see it's an overlay) with a clear close
   affordance pinned in the header. */
@media (max-width: 768px) {
  .chat-panel {
    width: min(360px, 92vw);
    min-width: 0;
    max-width: 92vw;
  }
  /* The header close button needs to be obvious — make it a real X */
  .chat-panel .chat-header { padding: 0.75rem 1rem; }
  /* Hide the version badge or org switcher accidentally bleeding through */
  .chat-panel { background: var(--bg-card); }
}
/* Floating chat toggle is shown whenever the chat is collapsed,
   on ALL widths — so the user can dismiss/restore at any size. */
.chat-toggle.visible { display: flex !important; }
/* Backdrop for the chat overlay on mobile — same pattern as the sidebar */
.chat-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 210;
}
.chat-backdrop.visible { display: block; }
@media (min-width: 1025px) {
  /* On desktop the chat is a side rail, not an overlay — no backdrop */
  .chat-backdrop { display: none !important; }
}

@media (max-width: 768px) {
  .mobile-nav-toggle { display: flex; }
  /* Push page content over so the hamburger doesn't overlap the page title */
  .page-content, .main-content > .page-content { padding-top: 3.5rem; }
  /* Sidebar slides in as an overlay; backdrop dims the rest */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 260px;
    min-width: 260px;
    z-index: 180;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.visible { transform: translateX(0); }
  /* Restore the labels on the slide-in sidebar — they were hidden by the
     earlier <768px rule that shrank to icon-only. */
  .nav-section-label, .sidebar-brand-text, .nav-item span, .sidebar-user-info { display: initial; }
  .nav-item { justify-content: flex-start; padding: 0.625rem 0.875rem; }
  .sidebar-user { justify-content: flex-start; }
  .page-content { padding: 3.5rem 1rem 1rem; }
  /* Health meters & financial stats stack */
  .health-meters-row, .stats-grid { grid-template-columns: 1fr !important; }
  /* Quick actions side-by-side grid collapses */
  main .card + div[style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
  /* GridView: filter chip row scrolls horizontally if it gets too wide */
  .gv-filter-bar { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.5rem; }
  .gv-toolbar-right { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  /* Modals fill the viewport on phones */
  .modal-content { max-height: 95vh !important; }
}

/* ─── Xero Results Table ─── */
.xero-result-table {
  font-size: 0.8125rem;
}
.xero-result-table th {
  font-size: 0.6875rem;
  background: var(--bg-tertiary);
}

/* ─── Animation ─── */
.fade-in {
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Tabs ─── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.tab-btn {
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent-light); border-bottom-color: var(--accent); }

/* Modal/Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ─── AusBooks 2.0: Reports ─── */
.report-launcher {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.report-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}
.report-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.report-icon {
  width: 48px; height: 48px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.report-title { font-size: 0.875rem; font-weight: 600; }
.report-desc { font-size: 0.6875rem; color: var(--text-muted); margin-top: 0.125rem; }
.report-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.report-charts { display: flex; gap: 1rem; margin-top: 1.5rem; flex-wrap: wrap; }
.chart-box { flex: 1; min-width: 250px; height: 200px; }

/* ─── DataGrid ─── */
.datagrid { width: 100%; }
.dg-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.dg-search { flex: 1; min-width: 200px; }
.dg-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.dg-filter { padding: 0.375rem 0.625rem; background: var(--bg-hover); border-radius: var(--radius-sm); font-size: 0.75rem; }
.dg-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.dg-table thead { background: var(--bg-tertiary); }
.dg-table th { padding: 0.625rem 0.75rem; text-align: left; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.dg-table td { padding: 0.625rem 0.75rem; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
.dg-table tr:hover td { background: var(--bg-hover); }
.dg-table tr.row-danger td { background: var(--danger-bg); }
.dg-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.dg-group-header {
  background: var(--bg-active);
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--accent);
}

/* DataGrid group-by pills (matches GridView styling) */
.dg-group-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.dg-tool-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-right: 0.25rem;
}
.dg-group-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.dg-group-pill {
  background: var(--bg-alt, var(--bg-hover));
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 0.3125rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.dg-group-pill:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.06);
}
.dg-group-pill.active {
  background: var(--success, #10b981);
  color: white;
  border-color: var(--success, #10b981);
}
@media (max-width: 768px) {
  .dg-group-row {
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .dg-group-pills { flex-wrap: nowrap; }
}

/* Print rules cover .dg-* too (extends the gv-printing rules) */
@media print {
  body.gv-printing .dg-toolbar,
  body.gv-printing .dg-group-row,
  body.gv-printing .dg-pagination,
  body.gv-printing .dg-footer {
    display: none !important;
  }
  body.gv-printing .gv-print-target .dg-table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 11pt !important;
    color: black !important;
  }
  body.gv-printing .gv-print-target .dg-table th,
  body.gv-printing .gv-print-target .dg-table td {
    border: 1px solid #ddd !important;
    padding: 4pt 6pt !important;
    background: white !important;
    color: black !important;
  }
  body.gv-printing .gv-print-target .dg-table thead th {
    background: #f3f3f3 !important;
    font-weight: 700 !important;
  }
  body.gv-printing .gv-print-target .dg-group {
    background: #f8f8f8 !important;
    font-weight: 700 !important;
  }
}

/* ─── DateRangeFilter ─── */
.date-range-filter {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.drf-presets select {
  padding: 0.375rem 0.625rem;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--text-primary);
}
.drf-custom {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.drf-custom label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.drf-custom input[type="date"] {
  padding: 0.375rem 0.625rem;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--text-primary);
}
.drf-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ─── InsightCard ─── */
.insight-strip { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.5rem; }
.insight-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
}
.insight-card.danger { border-left: 3px solid var(--danger); }
.insight-card.warning { border-left: 3px solid var(--warning); }
.insight-card.info { border-left: 3px solid var(--info); }
.insight-icon { font-size: 1.125rem; flex-shrink: 0; }
.insight-text { flex: 1; }
.insight-title { font-weight: 600; }
.insight-detail { color: var(--text-muted); margin-top: 0.125rem; }
.insight-action { font-size: 0.75rem; color: var(--accent-light); cursor: pointer; }

/* ─── Tabs ─── */
.tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.tab {
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.tab:hover { background: var(--bg-hover); }
.tab.active { background: var(--accent); color: white; border-color: var(--accent); }

/* ─── Grid Layouts ─── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 768px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ─── Form (stacked fields used by Tax Centre, Scenarios, Loans) ─── */
.form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.form label {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.form label input[type="checkbox"] {
  width: auto;
  margin: 0;
}
.form label:has(input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.form input, .form select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-family: inherit;
  transition: var(--transition);
}
.form input:focus, .form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,92,231,0.15);
}
.form .btn {
  grid-column: 1 / -1;
  justify-self: start;
}
@media (max-width: 600px) { .form { grid-template-columns: 1fr; } }

/* ─── Form Inline ─── */
.form-inline { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.form-inline input, .form-inline select {
  flex: 1;
  min-width: 140px;
  padding: 0.5rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-family: inherit;
  transition: var(--transition);
}
.form-inline input:focus, .form-inline select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,92,231,0.15);
}

/* ─── Result Box ─── */
.result-box {
  padding: 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 1rem;
}
.kv { display: flex; justify-content: space-between; padding: 0.375rem 0; border-bottom: 1px solid var(--border-light); }
.kv:last-child { border-bottom: none; }
.kv span { color: var(--text-secondary); }
.kv strong { font-weight: 600; }

/* ─── Owner Rows ─── */
.owner-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.owner-row input { flex: 1; min-width: 100px; padding: 0.375rem 0.5rem; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.8125rem; }

/* ─── Loan Styles ─── */
.loan-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.badge-ok { background: var(--success-bg); color: var(--success); padding: 0.25rem 0.5rem; border-radius: 999px; font-size: 0.6875rem; }
.badge-danger { background: var(--danger-bg); color: var(--danger); padding: 0.25rem 0.5rem; border-radius: 999px; font-size: 0.6875rem; }
.recommendation { color: var(--text-secondary); font-size: 0.8125rem; margin: 0.5rem 0; font-style: italic; }
.owner-result { padding: 0.5rem; background: var(--bg-tertiary); border-radius: var(--radius-sm); margin-bottom: 0.5rem; }

/* ─── Rate List ─── */
.rate-list { list-style: none; }
.rate-list li { display: flex; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid var(--border-light); }
.rate-list li:last-child { border-bottom: none; }
.rate-list strong { color: var(--accent-light); }

/* ─── Org Switcher ─── */
.org-switcher {
  margin-top: 0.5rem;
  position: relative;
}
.org-switcher-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated, rgba(255,255,255,0.05));
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
}
.org-switcher-btn:hover {
  border-color: var(--accent-light);
  background: rgba(99, 102, 241, 0.06);
}
.org-switcher-btn span {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.org-switcher-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 320px;
  max-width: calc(100vw - 2rem);
  background: var(--bg-card, var(--bg, #fff));
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18);
  z-index: 9999;
  padding: 0.375rem;
  max-height: 70vh;
  overflow-y: auto;
}
.org-option {
  font-size: 0.8125rem !important;
}
/* Make sure the dropdown is opaque even when CSS vars are missing */
.org-switcher-dropdown:not(.hidden) { backdrop-filter: none; }
.org-switcher-dropdown.hidden { display: none; }
.org-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
}
.org-option:hover { background: rgba(99, 102, 241, 0.08); }
.org-option.active { background: rgba(99, 102, 241, 0.12); color: var(--accent-light); }
.org-option.org-create { color: var(--accent-light); }
.org-divider { height: 1px; background: var(--border); margin: 0.25rem 0.5rem; }

/* ─── BAS Preparation ─── */
.bas-summary { display: flex; flex-direction: column; gap: 1rem; }
.bas-section { border-left: 3px solid var(--accent); }
.bas-section h3 { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.bas-detail-grid { display: grid; gap: 0; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.bas-total { border-left: 3px solid var(--success, #22c55e); }
.bas-grand-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-elevated, rgba(255,255,255,0.03));
  border-radius: 8px;
  font-size: 1.1rem;
}
.bas-grand-total strong { font-size: 1.4rem; color: var(--accent-light); }
.bas-warnings { border-left: 3px solid var(--warning, #f59e0b); }
.bas-warnings ul { list-style: none; padding: 0; }
.bas-warning-item { padding: 0.5rem 0; border-bottom: 1px dashed var(--border); font-size: 0.8125rem; color: var(--text-muted); }
.bas-warning-item:last-child { border-bottom: none; }
.bas-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.text-danger { color: var(--danger, #ef4444); }
.text-success { color: var(--success, #22c55e); }

/* ─── Chat Context Badge ─── */
.chat-context-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--accent-light);
  margin-bottom: 0.5rem;
  animation: fadeIn 0.2s ease;
}

/* ─── Client Profile ─── */
.profile-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .profile-layout { grid-template-columns: 1fr; } }
.profile-identity, .profile-style { grid-column: span 1; }
.profile-research, .profile-contacts, .profile-templates { grid-column: span 1; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 0.75rem; }
.form-group { display: flex; flex-direction: column; gap: 0.25rem; }
.form-group label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.form-input { padding: 0.5rem 0.75rem; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.8125rem; transition: var(--transition); }
.form-input:focus { border-color: var(--accent-light); outline: none; box-shadow: 0 0 0 2px rgba(99,102,241,0.1); }
textarea.form-input { resize: vertical; font-family: inherit; }
.research-results { margin-top: 0.75rem; }
.research-card { padding: 0.75rem; background: var(--bg-elevated, rgba(255,255,255,0.02)); border-radius: 8px; font-size: 0.8125rem; line-height: 1.6; }
.tag { display: inline-block; padding: 0.2rem 0.5rem; background: rgba(99,102,241,0.1); border-radius: 4px; font-size: 0.7rem; margin: 0.15rem; }
.contact-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border-light); }
.contact-row .btn-icon { margin-left: auto; }
.template-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border-light); }
.template-row .btn-icon { margin-left: auto; }
.btn-icon { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0.25rem; border-radius: 4px; transition: var(--transition); }
.btn-icon:hover { color: var(--danger); background: var(--danger-bg); }
.badge { padding: 0.15rem 0.4rem; background: var(--bg-hover); border-radius: 4px; font-size: 0.6875rem; color: var(--text-secondary); }

/* ─── Email Composer ─── */
.email-composer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .email-composer-grid { grid-template-columns: 1fr; } }
.email-form h3, .email-output h3 { margin-bottom: 1rem; }
.email-form .form-group { margin-bottom: 0.75rem; }
.email-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.email-placeholder { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.email-placeholder i { font-size: 2.5rem; margin-bottom: 0.5rem; display: block; }
.email-subject-line { margin-bottom: 0.75rem; }
.email-subject-line strong { font-size: 0.75rem; color: var(--text-muted); display: block; margin-bottom: 0.25rem; }
.email-body-output textarea { font-family: inherit; line-height: 1.6; }
.email-result-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.voice-input-area { margin-top: 0.75rem; padding: 0.75rem; background: var(--bg-elevated, rgba(255,255,255,0.02)); border-radius: 8px; }
.voice-btn { display: flex; align-items: center; gap: 0.4rem; }
.voice-btn.recording { color: var(--danger); animation: pulse 1.5s infinite; }
.voice-status { display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--danger); margin-top: 0.5rem; }
.voice-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.voice-transcript { margin-top: 0.5rem; }
.text-muted { color: var(--text-muted); font-size: 0.8125rem; }

/* ─── Toast ─── */
.toast { position: fixed; bottom: 2rem; right: 2rem; padding: 0.75rem 1.25rem; background: var(--accent); color: white; border-radius: 8px; font-size: 0.8125rem; z-index: 9999; animation: fadeIn 0.2s ease; }

/* ─── Admin Zone ─── */
.admin-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.admin-tab {
  padding: 0.625rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}
.admin-tab:hover { border-color: var(--accent); color: var(--text-primary); }
.admin-tab.active { background: var(--accent); border-color: var(--accent); color: white; }
.admin-hint { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.75rem; line-height: 1.6; }
.admin-toolbar { margin-bottom: 1rem; }
.admin-org-list { display: flex; flex-direction: column; gap: 1rem; }
.admin-org-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.admin-org-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.admin-org-meta { display: flex; gap: 1.5rem; flex-wrap: wrap; font-size: 0.8125rem; color: var(--text-secondary); margin: 0.75rem 0; }
.admin-members { margin-top: 1rem; }
.admin-member { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--border-light); font-size: 0.875rem; }
.admin-add-member { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.admin-add-member .form-input { flex: 1; min-width: 180px; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.admin-table th, .admin-table td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.admin-table th { color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }
.badge-success { background: var(--success-bg, rgba(34,197,94,0.15)); color: var(--success); }
.badge-warning { background: rgba(234,179,8,0.15); color: var(--warning); }
.badge-accent { background: rgba(99,102,241,0.15); color: var(--accent-light); }
.admin-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.admin-modal.hidden { display: none; }
.admin-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.admin-modal-content { position: relative; max-width: 520px; width: 90%; max-height: 90vh; overflow-y: auto; z-index: 1; }
.admin-modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.25rem; }
.loading-state { text-align: center; padding: 3rem; color: var(--text-muted); }
.btn-danger { background: var(--danger); color: white; border: none; }
.btn-danger:hover { opacity: 0.9; }

/* ─── Landing Page ─── */
.landing-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.landing-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3rem 0 2rem;
}

.landing-brand {
  margin-bottom: 2.5rem;
}

/* Cinematic hero — the AusBooks integrator story (LandingHero.js). */
.landing-cinematic {
  width: 100%;
  max-width: 760px;
  margin: -0.5rem auto 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #10131f;
  box-shadow: var(--shadow-md);
  line-height: 0; /* drop the inline-SVG descender gap */
}
.landing-cinematic svg { display: block; width: 100%; height: auto; }
@media (max-width: 640px) {
  .landing-cinematic { margin: 0 auto 1.5rem; border-radius: var(--radius-md); }
}

.landing-logo {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-size: 2rem;
  color: white;
  box-shadow: 0 8px 32px rgba(108, 92, 231, 0.3);
}

.landing-title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.landing-tagline {
  font-size: 1.125rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.landing-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  padding: 0.25rem 0.75rem;
  background: var(--bg-tertiary);
  border-radius: 999px;
}

/* Pre-send AI confirmation */
.chat-send-confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.chat-send-confirm-modal.hidden { display: none; }
.chat-send-confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.chat-send-confirm-card {
  position: relative;
  max-width: 480px;
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-lg);
}
.chat-send-confirm-card h3 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.chat-send-confirm-intro {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0 0 0.75rem;
}
.chat-send-confirm-list {
  margin: 0 0 1rem;
  padding-left: 1.15rem;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--text-primary);
  max-height: 40vh;
  overflow-y: auto;
}
.chat-send-confirm-list li { margin-bottom: 0.35rem; }
.chat-send-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.landing-chat-messages {
  max-height:  min(50vh, 420px);
  overflow-y: auto;
  margin-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: left;
}
.landing-chat-msg { width: 100%; }
.landing-chat-attach {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.landing-chat-attach:hover { color: var(--accent-light); background: var(--bg-hover); }
.landing-chat-container .chat-file-preview {
  margin-bottom: 0.35rem;
  justify-content: flex-start;
}
.landing-chat-container .chat-export-bar {
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  text-align: left;
}

.landing-chat-container {
  width: 100%;
  max-width: 640px;
  margin-bottom: 1.5rem;
}

.landing-chat-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.landing-chat-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.landing-chat-icon {
  color: var(--accent-light);
  font-size: 1.25rem;
  margin-right: 0.75rem;
  flex-shrink: 0;
}

.landing-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}

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

.landing-chat-send {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}

.landing-chat-send:hover { background: var(--accent-hover); transform: scale(1.05); }
.landing-chat-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.landing-chat-response {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
  text-align: left;
}

.landing-chat-response.hidden { display: none; }

.landing-chat-bubble {
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  line-height: 1.6;
  max-width: 100%;
  word-wrap: break-word;
}

.landing-chat-bubble.user {
  background: var(--accent);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.landing-chat-bubble.assistant {
  background: var(--bg-card);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.landing-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  max-width: 640px;
}

.landing-suggestions.hidden { display: none; }

.suggestion-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.suggestion-chip:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: var(--bg-hover);
  transform: translateY(-1px);
}

.suggestion-chip i { font-size: 0.875rem; }

/* ── Landing page: org setup CTA ── */
.landing-org-setup {
  width: 100%;
  max-width: 760px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(99, 102, 241, 0.02));
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin: 0.5rem auto 1.5rem;
}
.landing-org-setup-inflight {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(16, 185, 129, 0.02));
  border-color: rgba(16, 185, 129, 0.3);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.landing-org-setup-head {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  margin-bottom: 0.875rem;
}
.landing-org-setup-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}
.landing-org-setup-inflight .landing-org-setup-icon {
  background: var(--success);
}
.landing-org-setup h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}
.landing-org-setup p {
  margin: 0.25rem 0 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.5;
}
.landing-org-setup-steps {
  margin: 0 0 1rem 0.5rem;
  padding-left: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--text-secondary);
}
.landing-org-setup-steps li {
  margin-bottom: 0.375rem;
}
.landing-org-setup-steps li strong {
  color: var(--text-primary);
}
.landing-org-setup-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
@media (max-width: 640px) {
  .landing-org-setup { padding: 1rem; }
  .landing-org-setup-head { flex-direction: row; }
  .landing-org-setup h2 { font-size: 1rem; }
}

.landing-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  width: 100%;
  max-width: 640px;
  margin: 1.5rem auto;
}

.landing-stat-card {
  text-align: center;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.landing-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.landing-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.landing-nav-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  width: 100%;
  max-width: 640px;
  margin: 0.5rem auto 2rem;
}

.landing-nav-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.landing-nav-card:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.landing-nav-card i {
  font-size: 1.5rem;
}

/* ─── Page Transitions ─── */
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-content {
  animation: pageEnter 0.25s ease-out;
}

/* ─── Skeleton Loading ─── */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text { height: 1rem; margin-bottom: 0.5rem; }
.skeleton-title { height: 1.5rem; width: 60%; margin-bottom: 1rem; }
.skeleton-card { height: 120px; margin-bottom: 1rem; }

/* ─── Button Micro-interactions ─── */
.btn { transition: all var(--transition); }
.btn:active:not(:disabled) { transform: scale(0.97); }

.stat-card { transition: transform var(--transition), box-shadow var(--transition); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.card { transition: box-shadow var(--transition); }
.card:hover { box-shadow: var(--shadow-md); }

/* ─── Onboarding ─── */
.onboarding-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 2rem;
}

.onboarding-progress-dots {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 3rem;
}

.onboarding-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.3s ease;
}

.onboarding-dot.active {
  background: var(--accent);
  width: 24px;
  border-radius: 4px;
}

.onboarding-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 480px;
  animation: pageEnter 0.3s ease-out;
}

.onboarding-step h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.onboarding-step p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.onboarding-icon {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.25rem;
  color: white;
  margin-bottom: 1.5rem;
  box-shadow: 0 8px 32px rgba(108, 92, 231, 0.25);
}

.onboarding-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.onboarding-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* ─── Mobile Responsive ─── */
@media (max-width: 768px) {
  .landing-stats { grid-template-columns: repeat(2, 1fr); }
  .landing-nav-grid { grid-template-columns: repeat(2, 1fr); }
  .landing-title { font-size: 1.75rem; }
  .landing-tagline { font-size: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ═══════════════════════════════════════════
   Simulation Studio
   ═══════════════════════════════════════════ */

.sim-studio {
  max-width: 1200px;
  margin: 0 auto;
  animation: pageEnter 0.4s ease;
}

/* Header */
.sim-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.sim-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
}
.sim-header h1 i { color: var(--accent-light); }
.sim-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* Profit bar */
.sim-profit-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.sim-profit-input label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
  display: block;
}
.sim-profit-field {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0 0.75rem;
}
.sim-dollar {
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 0.25rem;
}
.sim-profit-field input {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 600;
  width: 140px;
  padding: 0.5rem 0;
  outline: none;
}
.sim-profit-toggle { display: flex; align-items: center; }
.sim-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.sim-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}
.sim-toggle-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.sim-profit-presets {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}
.sim-chip {
  padding: 0.375rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.sim-chip:hover { border-color: var(--accent); color: var(--accent-light); }
.sim-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Tabs */
.sim-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  margin-bottom: 1.25rem;
}
.sim-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.sim-tab:hover { color: var(--text-secondary); background: var(--bg-tertiary); }
.sim-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Loading & empty */
.sim-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem;
  color: var(--text-muted);
}
.sim-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; display: inline-block; }
.sim-empty {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}
.sim-empty p { margin-top: 0.5rem; }
.sim-error {
  text-align: center;
  padding: 2rem;
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: var(--radius-md);
}

/* ── Preset cards grid ── */
.sim-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}
.sim-preset-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: all 0.25s;
  position: relative;
}
.sim-preset-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.sim-preset-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-md);
}
.sim-preset-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.sim-preset-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.sim-preset-title {
  flex: 1;
  min-width: 0;
}
.sim-preset-title h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.3;
}
.sim-preset-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.4;
}

/* Badges */
.sim-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.25rem;
}
.sim-badge-tax { background: var(--success-bg); color: var(--success); }
.sim-badge-cash { background: var(--info-bg); color: var(--info); }
.sim-badge-super { background: rgba(108, 92, 231, 0.15); color: var(--accent-light); }

/* Compare checkbox */
.sim-compare-check {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.2s;
}
.sim-compare-check:hover { color: var(--accent-light); }
.sim-compare-check.active { color: var(--accent); }

/* Metrics */
.sim-preset-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.sim-metric {
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}
.sim-metric-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.sim-metric-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}
.sim-metric-cash { color: var(--success); }
.sim-metric-tax { color: var(--danger); }
.sim-metric-super { color: var(--accent-light); }

/* Breakdown bars */
.sim-preset-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}
.sim-bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 55px;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.sim-bar {
  height: 6px;
  background: var(--bg-hover);
  border-radius: 3px;
  overflow: hidden;
}
.sim-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.sim-bar-salary { background: var(--info); }
.sim-bar-dividend { background: var(--success); }
.sim-bar-super { background: var(--accent-light); }
.sim-bar-loan { background: var(--warning); }

/* Loan warning */
.sim-loan-warning {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--warning-bg);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--warning);
  margin-bottom: 0.75rem;
}

/* Detail button */
.sim-detail-btn {
  width: 100%;
  justify-content: center;
  font-size: 0.8rem;
}

/* ── Detail panel ── */
.sim-detail-panel {
  margin-top: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: pageEnter 0.3s ease;
}
.sim-detail-panel.hidden { display: none; }
.sim-detail-inner { padding: 1.5rem; }
.sim-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.sim-detail-head h2 {
  font-size: 1.1rem;
  font-weight: 600;
}
.sim-detail-close {
  font-size: 1.2rem;
}
.sim-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.sim-detail-section h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.sim-detail-section h4 i { color: var(--accent-light); }
.sim-table {
  width: 100%;
  font-size: 0.8rem;
}
.sim-table td {
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--border);
}
.sim-table td:first-child { color: var(--text-secondary); }
.sim-table td:last-child {
  text-align: right;
  font-weight: 500;
  color: var(--text-primary);
}
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }

.sim-compliance-list {
  margin-top: 0.75rem;
}
.sim-compliance-list h5 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--warning);
  margin-bottom: 0.25rem;
}
.sim-compliance-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sim-compliance-list li {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 0.25rem 0;
  padding-left: 1rem;
  position: relative;
}
.sim-compliance-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--warning);
  transform: translateY(-50%);
}

/* Detail summary bar */
.sim-detail-summary {
  display: flex;
  gap: 2rem;
  padding: 1rem 1.25rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}
.sim-summary-item {
  display: flex;
  flex-direction: column;
}
.sim-summary-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.sim-summary-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Custom builder ── */
.sim-custom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.sim-custom-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.sim-custom-form h3 {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.sim-custom-form h3 i { color: var(--accent-light); }
.sim-custom-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.sim-sliders {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.sim-slider-group {}
.sim-slider-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.sim-slider-label i {
  color: var(--accent-light);
  font-size: 0.9rem;
}
.sim-slider-value-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.125rem;
}
.sim-dollar-sm {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.sim-slider-num {
  width: 80px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  color: var(--text-primary);
  font-size: 0.8rem;
  text-align: right;
}
.sim-slider-input {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--bg-hover);
  border-radius: 3px;
  outline: none;
}
.sim-slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 0 2px var(--accent);
  transition: transform 0.15s;
}
.sim-slider-input::-webkit-slider-thumb:hover { transform: scale(1.15); }
.sim-slider-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-card);
}
.sim-run-btn {
  width: 100%;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  padding: 0.75rem;
}

/* Custom result panel */
.sim-custom-result {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.sim-empty-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  color: var(--text-muted);
  text-align: center;
}
.sim-empty-result i {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.3;
}
.sim-custom-outcome h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.sim-outcome-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.sim-outcome-stat {
  display: flex;
  flex-direction: column;
  padding: 0.625rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}
.sim-outcome-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.sim-outcome-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}
.sim-outcome-detail {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
.sim-outcome-col h4 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}
.sim-kv {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
}
.sim-kv span:last-child { color: var(--text-primary); font-weight: 500; }
.sim-loan-detail {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-bottom: 1rem;
}
.sim-loan-detail h4 {
  font-size: 0.85rem;
  color: var(--warning);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

/* ── Compare tab ── */
.sim-compare { }
.sim-compare-table-wrap {
  overflow-x: auto;
  margin-bottom: 1.5rem;
}
.sim-compare-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: 0.85rem;
}
.sim-compare-table th {
  background: var(--bg-tertiary);
  padding: 0.75rem 1rem;
  text-align: center;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.sim-compare-table th:first-child { text-align: left; }
.sim-compare-table td {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
  color: var(--text-secondary);
}
.sim-compare-table td:first-child {
  text-align: left;
  color: var(--text-primary);
  font-weight: 500;
}
.sim-compare-divider td {
  padding: 0;
  height: 2px;
  background: var(--border-light);
}
.sim-compare-highlight td {
  background: var(--bg-tertiary);
}

/* Compare bar charts */
.sim-compare-bars {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.sim-compare-bars h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.sim-compare-chart {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.sim-chart-group {}
.sim-chart-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.5rem;
}
.sim-chart-row {
  display: grid;
  grid-template-columns: 120px 1fr 60px;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.375rem;
}
.sim-chart-name {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sim-chart-bar {
  height: 20px;
  background: var(--bg-hover);
  border-radius: 4px;
  overflow: hidden;
}
.sim-chart-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
  min-width: 2px;
}
.sim-chart-val {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

/* ── Law guide tab ── */
.sim-laws {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.sim-law-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: border-color 0.2s;
}
.sim-law-card:hover { border-color: var(--border-light); }
.sim-law-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.sim-law-header i {
  font-size: 1.25rem;
  color: var(--accent-light);
}
.sim-law-header h3 {
  font-size: 1rem;
  font-weight: 600;
}
.sim-law-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 1rem;
}
.sim-law-tag {
  padding: 0.2rem 0.6rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.sim-law-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1rem;
}
.sim-law-col h5 {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.sim-law-pros h5 { color: var(--success); }
.sim-law-cons h5 { color: var(--danger); }
.sim-law-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sim-law-col li {
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 0.25rem 0 0.25rem 1rem;
  position: relative;
  line-height: 1.4;
}
.sim-law-pros li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.6rem;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--success);
}
.sim-law-cons li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.6rem;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--danger);
}
.sim-law-compliance {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
}
.sim-law-compliance h5 {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--warning);
  margin-bottom: 0.5rem;
}
.sim-law-compliance ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sim-law-compliance li {
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding: 0.25rem 0 0.25rem 1rem;
  position: relative;
  line-height: 1.4;
}
.sim-law-compliance li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.6rem;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--warning);
}

/* ── Sim Studio responsive ── */
@media (max-width: 768px) {
  .sim-presets-grid { grid-template-columns: 1fr; }
  .sim-custom { grid-template-columns: 1fr; }
  .sim-outcome-grid { grid-template-columns: repeat(2, 1fr); }
  .sim-outcome-detail { grid-template-columns: 1fr; }
  .sim-law-columns { grid-template-columns: 1fr; }
  .sim-detail-grid { grid-template-columns: 1fr; }
  .sim-detail-summary { flex-wrap: wrap; gap: 1rem; }
  .sim-profit-bar { flex-direction: column; align-items: stretch; }
  .sim-profit-presets { margin-left: 0; justify-content: center; }
  .sim-compare-table { font-size: 0.75rem; }
  .sim-chart-row { grid-template-columns: 80px 1fr 50px; }
}

/* ═══════════════════════════════════════════
   Newsletter Studio
   ═══════════════════════════════════════════ */

.nl-studio {
  max-width: 1200px;
  margin: 0 auto;
  animation: pageEnter 0.4s ease;
}
.nl-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.nl-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nl-header h1 i { color: var(--accent-light); }
.nl-header p { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.25rem; }
.nl-header-actions { display: flex; gap: 0.5rem; }
.nl-tab-btn.active {
  background: var(--accent) !important;
  color: white !important;
  border-color: var(--accent) !important;
}

/* Templates grid */
.nl-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}
.nl-template-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: all 0.25s;
  display: flex;
  flex-direction: column;
}
.nl-template-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.nl-template-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}
.nl-template-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.nl-template-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 1rem;
  flex: 1;
}
.nl-template-sections {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.nl-section-tag {
  padding: 0.15rem 0.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: capitalize;
}
.nl-use-template {
  width: 100%;
  justify-content: center;
}

/* Generate form */
.nl-generate-form {
  max-width: 600px;
  margin: 0 auto;
}
.nl-generate-form h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}
.nl-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.nl-form-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 1.25rem;
}

/* Status badges */
.nl-status {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.nl-status-draft { background: var(--bg-tertiary); color: var(--text-muted); }
.nl-status-final { background: var(--info-bg); color: var(--info); }
.nl-status-sent { background: var(--success-bg); color: var(--success); }

/* Editor */
.nl-editor {}
.nl-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}
.nl-toolbar-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}
.nl-editor-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
}
.nl-editor-meta {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.nl-editor-meta .form-group { margin-bottom: 0.75rem; }
.nl-refine-panel {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}
.nl-refine-panel.hidden { display: none; }
.nl-refine-panel h4 {
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  color: var(--accent-light);
}

/* Preview pane */
.nl-preview-pane {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.nl-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.nl-preview-device {
  display: flex;
  gap: 0.25rem;
}
.nl-device-btn {
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}
.nl-device-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.nl-preview-frame {
  padding: 1rem;
  display: flex;
  justify-content: center;
  background: #f0f0f0;
  min-height: 400px;
}

/* History table */
.nl-history-table-wrap { overflow-x: auto; }
.nl-history-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: 0.85rem;
}
.nl-history-table th {
  background: var(--bg-tertiary);
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}
.nl-history-table td {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.nl-hist-subject {
  color: var(--text-primary) !important;
  font-weight: 500;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nl-empty {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}
.nl-empty p { margin-top: 0.75rem; }

/* Recent newsletters (landing page strip) */
.nl-recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}
.nl-recent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  transition: border-color 0.12s, transform 0.1s, box-shadow 0.15s;
}
.nl-recent-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.nl-recent-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.nl-recent-head strong {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.nl-recent-status {
  color: white;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.125rem 0.375rem;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.nl-recent-meta {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.nl-recent-card .btn { align-self: flex-start; margin-top: 0.25rem; }

/* Newsletter responsive */
@media (max-width: 768px) {
  .nl-templates-grid { grid-template-columns: 1fr; }
  .nl-editor-grid { grid-template-columns: 1fr; }
  .nl-form-grid { grid-template-columns: 1fr; }
  .nl-header { flex-direction: column; }
  .nl-toolbar-actions { flex-wrap: wrap; }
}

/* ═══════════════════════════════════════════
   Version Badge (sidebar footer)
   ═══════════════════════════════════════════ */
.sidebar-version {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
  cursor: pointer;
  border-top: 1px solid var(--border);
  transition: background var(--transition), color var(--transition);
}
.sidebar-version:hover {
  background: var(--bg-hover);
  color: var(--accent-light);
}
.sidebar-version i { font-size: 0.875rem; }
.sidebar-version-date {
  margin-left: auto;
  opacity: 0.7;
}

/* ═══════════════════════════════════════════
   Help Icon Button (injected per page header)
   ═══════════════════════════════════════════ */
.help-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-muted);
  cursor: pointer;
  margin-left: 0.75rem;
  transition: all var(--transition);
  vertical-align: middle;
  font-size: 0.875rem;
}
.help-icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: var(--bg-hover);
  transform: scale(1.1);
}

/* ═══════════════════════════════════════════
   Help Slide Panel (right side overlay)
   ═══════════════════════════════════════════ */
.help-slide-panel {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
}
.help-slide-panel.open { pointer-events: auto; }

.help-slide-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.help-slide-panel.open .help-slide-backdrop { opacity: 1; }

.help-slide-content {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 90vw;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
}
.help-slide-panel.open .help-slide-content { transform: translateX(0); }

.help-slide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.help-slide-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.help-slide-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg-hover);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  transition: all var(--transition);
}
.help-slide-close:hover {
  background: var(--danger);
  color: white;
}

.help-slide-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}
.help-summary {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.help-section {
  margin-bottom: 1.25rem;
}
.help-section h4 {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 0.375rem;
}
.help-section p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0;
}

/* ═══════════════════════════════════════════
   Help Centre Page
   ═══════════════════════════════════════════ */
.help-page-search {
  position: relative;
  margin-bottom: 1.25rem;
}
.help-page-search i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}
.help-page-search .form-input {
  padding-left: 2.75rem;
}

.help-page-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}
.help-tab {
  padding: 0.625rem 1.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.help-tab:hover { color: var(--text-primary); }
.help-tab.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

/* Topics */
.help-section-group { margin-bottom: 2rem; }
.help-section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
}
.help-topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}
.help-topic-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: all var(--transition);
}
.help-topic-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}
.help-topic-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
}
.help-topic-header h4 {
  flex: 1;
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
}
.help-topic-summary {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}
.help-topic-sections {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}
.help-topic-detail {
  margin-bottom: 0.625rem;
}
.help-topic-detail strong {
  font-size: 0.75rem;
  color: var(--accent-light);
}
.help-topic-detail p {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0.125rem 0 0;
}

/* Release Notes */
.help-releases { max-width: 720px; }
.help-release-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  transition: border-color var(--transition);
}
.help-release-card.latest {
  border-color: var(--accent);
  border-width: 2px;
}
.help-release-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.help-release-version {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-right: 0.5rem;
}
.help-release-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.help-release-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.help-release-list {
  padding-left: 1.25rem;
  margin: 0;
}
.help-release-list li {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* Quick Reference */
.help-shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.help-shortcut-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.help-shortcut-card h4 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.help-shortcut-card ul {
  padding-left: 1.25rem;
  margin: 0;
}
.help-shortcut-card li {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* Ghost button */
.btn-ghost {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.btn-ghost:hover {
  color: var(--accent-light);
  background: var(--bg-hover);
}

/* Help responsive */
@media (max-width: 768px) {
  .help-topics-grid { grid-template-columns: 1fr; }
  .help-shortcuts-grid { grid-template-columns: 1fr; }
  .help-slide-content { width: 100vw; }
  .sidebar-version span:last-child { display: none; }
}

/* ── Org Request Wizard ───────────────────────────── */
.wizard-progress { display:flex; align-items:center; gap:0.5rem; margin:1.5rem 0; }
.wizard-step { display:flex; align-items:center; gap:0.5rem; opacity:0.5; font-size:0.875rem; }
.wizard-step.active, .wizard-step.done { opacity:1; }
.wizard-step.active .wizard-dot { background:var(--accent); color:white; }
.wizard-step.done .wizard-dot { background:var(--success); color:white; }
.wizard-dot {
  width:28px; height:28px; border-radius:50%;
  background:var(--bg-alt); border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center;
  font-weight:600; font-size:0.8125rem;
}
.wizard-line { flex:1; height:1px; background:var(--border); }
.wizard-body { padding:1.5rem; margin-bottom:1rem; }
.wizard-nav { display:flex; justify-content:space-between; margin-top:1rem; }

.model-card { transition: border-color 0.15s, background 0.15s; }
.model-card:hover:not(.disabled) { background:var(--bg-alt); }
.model-card.selected { background:rgba(99,102,241,0.06); }

.tag-list { display:flex; flex-wrap:wrap; gap:0.375rem; min-height:1.5rem; }
.tag-removable { display:inline-flex; align-items:center; gap:0.25rem; }
.tag-remove, .tag-remove-comp, .tag-remove-fact {
  background:none; border:0; cursor:pointer; color:var(--text-muted);
  font-size:1rem; line-height:1; padding:0 0.125rem;
}
.tag-remove:hover, .tag-remove-comp:hover, .tag-remove-fact:hover { color:var(--danger); }

/* Org Switcher Request Button hover */
.org-option.org-request:hover { background:rgba(99,102,241,0.15) !important; }

/* ── Help slide panel: Related chips ──────────────────────────────── */
.help-related-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}
.help-related-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--bg-alt, var(--bg-hover));
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3125rem 0.75rem;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-primary);
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
}
.help-related-chip:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.06);
  transform: translateY(-1px);
}
.help-related-chip i {
  color: var(--accent-light);
  font-size: 0.875rem;
}
.help-related-kind {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 0.0625rem 0.375rem;
  border-radius: 4px;
  margin-left: 0.25rem;
}

/* ── Help · Ask AI ────────────────────────────────────────────────── */
.help-ask-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.help-ask-intro {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.help-ask-intro i {
  font-size: 1.75rem;
  color: var(--accent-light);
  background: rgba(99, 102, 241, 0.1);
  padding: 0.625rem;
  border-radius: 12px;
}
.help-ask-sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}
.help-ask-input-row {
  display: flex;
  gap: 0.5rem;
}
.help-ask-input-row .form-input {
  flex: 1;
}
.help-ask-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}
.help-ask-example {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.help-ask-example:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.06);
}
.help-ask-thread {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  max-height: 60vh;
  overflow-y: auto;
  padding-top: 0.25rem;
}
.help-ask-bubble {
  display: flex;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.55;
}
.help-ask-bubble i {
  flex-shrink: 0;
  font-size: 1.125rem;
  margin-top: 0.125rem;
}
.help-ask-bubble.user {
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(99,102,241,0.05));
  color: var(--text-primary);
  margin-left: 2rem;
}
.help-ask-bubble.user i { color: var(--accent); }
.help-ask-bubble.assistant {
  background: var(--bg-alt, rgba(0,0,0,0.02));
  margin-right: 2rem;
  border: 1px solid var(--border);
}
.help-ask-bubble.assistant i { color: var(--accent-light); }
.help-ask-bubble p { margin: 0 0 0.5rem; }
.help-ask-bubble p:last-child { margin-bottom: 0; }
.help-ask-list {
  margin: 0.375rem 0 0.5rem;
  padding-left: 1.25rem;
}
.help-ask-list li {
  margin-bottom: 0.25rem;
  line-height: 1.55;
}
.help-ask-typing {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.8125rem;
}
.help-ask-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--accent);
  color: white !important;
  padding: 0.1875rem 0.5rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.8125rem;
  transition: background 0.15s, transform 0.1s;
}
.help-ask-link:hover {
  background: var(--accent-light, var(--accent));
  transform: translateY(-1px);
}
.help-ask-link i { font-size: 0.875rem; color: white; }

@media (max-width: 640px) {
  .help-ask-bubble.user { margin-left: 0.5rem; }
  .help-ask-bubble.assistant { margin-right: 0.5rem; }
  .help-ask-input-row { flex-direction: column; }
  .help-ask-input-row .btn { width: 100%; }
}

/* ── Health & Data Quality meters ────────────────────────────────── */
.health-meters-row .health-meter-card {
  transition: transform 0.1s, box-shadow 0.15s;
}
.health-meters-row .health-meter-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}
.health-score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 32px;
  padding: 0 0.625rem;
  border-radius: 999px;
  background: var(--text-muted);
  color: white;
  font-weight: 700;
  font-size: 0.9375rem;
}
.health-meter-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-alt);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.5rem 0 0.75rem;
}
.health-meter-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.health-summary {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.health-check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
}
.health-check-row:last-child { border-bottom: 0; }
.health-check-icon { flex-shrink: 0; padding-top: 0.125rem; }
.health-check-body { flex: 1; min-width: 0; }
.health-check-label {
  font-weight: 600;
  color: var(--text-primary);
}
.health-check-value {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-top: 0.125rem;
}
.health-check-hint {
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-style: italic;
  margin-top: 0.125rem;
}
.health-check-score {
  flex-shrink: 0;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

@media (max-width: 768px) {
  .health-meters-row { grid-template-columns: 1fr !important; }
}

/* Toast */
.toast {
  position:fixed; bottom:1.5rem; left:50%; transform:translateX(-50%);
  background:var(--text-primary); color:var(--bg-card);
  padding:0.625rem 1.25rem; border-radius:var(--radius);
  font-size:0.875rem; z-index:9999;
  box-shadow:0 4px 12px rgba(0,0,0,0.15);
}

/* ── Inline help tooltips (HelpSystem.HelpTip) ────────────────────── */
.help-tip {
  border-bottom: 1px dotted var(--text-muted, #6b7280);
  cursor: help;
  white-space: nowrap;
}
.help-tip-icon {
  font-size: 0.72em;
  color: var(--text-muted, #6b7280);
  margin-left: 2px;
  vertical-align: super;
}

/* "Ask AI about this report" bar (injected above every report by ReportAI.js). */
.report-ai-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0 0 1rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--bg-card);
}
.report-ai-bar-text {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.86rem;
  color: var(--text-muted);
  min-width: 220px;
  flex: 1 1 auto;
}
.report-ai-bar-text i { color: var(--accent); font-size: 1.05rem; flex: 0 0 auto; }
.report-ai-btn { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 640px) { .report-ai-btn { width: 100%; } }
