/* ═══════════════════════════════════════════════════════════
   Credentik Credentialing Ops v2 — Design System
   Version 2.0 — Investor-Ready SaaS UI
   ═══════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─── */
:root {
  /* Brand */
  --brand-50: #ecfeff;
  --brand-100: #cffafe;
  --brand-200: #a5f3fc;
  --brand-300: #67e8f9;
  --brand-400: #22d3ee;
  --brand-500: #06b6d4;
  --brand-600: #0891b2;
  --brand-700: #0e7490;
  --brand-800: #155e75;
  --brand-900: #164e63;
  --brand-950: #083344;

  /* Neutral */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --gray-950: #020617;

  /* Semantic Status */
  --success-50: #f0fdf4;
  --success-100: #dcfce7;
  --success-500: #22c55e;
  --success-600: #16a34a;
  --success-700: #15803d;
  --warning-50: #fffbeb;
  --warning-100: #fef3c7;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #b45309;
  --danger-50: #fef2f2;
  --danger-100: #fee2e2;
  --danger-500: #ef4444;
  --danger-600: #dc2626;
  --danger-700: #b91c1c;
  --info-50: #eff6ff;
  --info-100: #dbeafe;
  --info-500: #3b82f6;
  --info-600: #2563eb;
  --info-700: #1d4ed8;
  --purple-50: #faf5ff;
  --purple-100: #f3e8ff;
  --purple-500: #a855f7;
  --purple-600: #9333ea;
  --purple-700: #7c3aed;

  /* Legacy compat aliases */
  --teal: var(--brand-700);
  --teal-dark: var(--gray-900);
  --teal-light: var(--brand-600);
  --gold: #e0a830;
  --gold-hover: #ca9520;
  --sage: var(--brand-600);
  --sage-hover: var(--brand-700);
  --slate: var(--gray-500);
  --light: var(--gray-50);
  --white: #ffffff;
  --border: var(--gray-200);
  --border-dark: var(--gray-300);
  --red: var(--danger-500);
  --red-bg: var(--danger-100);
  --green: var(--success-500);
  --green-bg: var(--success-100);
  --amber: var(--warning-500);
  --amber-bg: var(--warning-100);
  --blue: var(--info-500);
  --blue-bg: var(--info-100);
  --purple: var(--purple-500);
  --purple-bg: var(--purple-100);
  --text: var(--gray-800);
  --text-muted: var(--gray-500);
  --text-light: var(--gray-400);

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-bg: var(--gray-900);
  --sidebar-border: rgba(255,255,255,0.06);
  --header-height: 64px;

  /* Spacing Scale (4px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-full: 9999px;

  /* Shadows — multi-layer for depth */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.06);
  --shadow-2xl: 0 25px 50px -12px rgba(0,0,0,0.2);
  --shadow-inner: inset 0 2px 4px rgba(0,0,0,0.04);
  --shadow-ring: 0 0 0 3px rgba(8,145,178,0.15);
  --shadow-ring-danger: 0 0 0 3px rgba(239,68,68,0.15);

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 120ms;
  --duration: 200ms;
  --duration-slow: 300ms;

  /* ─── Semantic Surface Tokens (Light Mode) ─── */
  --surface-bg: var(--gray-100);
  --surface-card: #ffffff;
  --surface-card-hover: var(--gray-50);
  --surface-raised: #ffffff;
  --surface-overlay: rgba(15,23,42,0.6);
  --surface-input: #ffffff;
  --border-color: var(--gray-200);
  --border-color-strong: var(--gray-300);
  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-700);
  --text-tertiary: var(--gray-500);
  --text-quaternary: var(--gray-400);
  --table-header-bg: var(--gray-50);
  --table-row-hover: var(--gray-50);
  --card-bg: var(--surface-card);
  --header-bg: #ffffff;
}

/* ─── Dark Mode ─── */
[data-theme="dark"] {
  --surface-bg: #0c1222;
  --surface-card: #151d2e;
  --surface-card-hover: #1a2538;
  --surface-raised: #1a2538;
  --surface-overlay: rgba(0,0,0,0.7);
  --surface-input: #1a2538;
  --border-color: #1e2d42;
  --border-color-strong: #2a3f5a;
  --text-primary: #e2e8f0;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  --text-quaternary: #64748b;
  --table-header-bg: #111827;
  --table-row-hover: #1a2538;
  --card-bg: var(--surface-card);
  --header-bg: #111827;

  /* Override legacy aliases */
  --text: var(--text-secondary);
  --text-muted: var(--text-tertiary);
  --text-light: var(--text-quaternary);
  --border: var(--border-color);
  --border-dark: var(--border-color-strong);
  --light: var(--surface-card);
  --white: var(--surface-card);

  /* Semantic status — darker tones for dark bg */
  --success-50: #052e16;
  --success-100: #064e3b;
  --warning-50: #451a03;
  --warning-100: #78350f;
  --danger-50: #450a0a;
  --danger-100: #7f1d1d;
  --info-50: #172554;
  --info-100: #1e3a5f;
  --purple-50: #2e1065;
  --purple-100: #3b0764;

  /* Shadows — stronger in dark mode */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.2);
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.35), 0 4px 6px -4px rgba(0,0,0,0.2);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.4), 0 8px 10px -6px rgba(0,0,0,0.25);
  --shadow-2xl: 0 25px 50px -12px rgba(0,0,0,0.5);

  color-scheme: dark;
}

/* Auto dark mode (system preference) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-bg: #0c1222;
    --surface-card: #151d2e;
    --surface-card-hover: #1a2538;
    --surface-raised: #1a2538;
    --surface-overlay: rgba(0,0,0,0.7);
    --surface-input: #1a2538;
    --border-color: #1e2d42;
    --border-color-strong: #2a3f5a;
    --text-primary: #e2e8f0;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-quaternary: #64748b;
    --table-header-bg: #111827;
    --table-row-hover: #1a2538;
    --card-bg: var(--surface-card);
    --header-bg: #111827;
    --text: var(--text-secondary);
    --text-muted: var(--text-tertiary);
    --text-light: var(--text-quaternary);
    --border: var(--border-color);
    --border-dark: var(--border-color-strong);
    --light: var(--surface-card);
    --white: var(--surface-card);
    --success-50: #052e16; --success-100: #064e3b;
    --warning-50: #451a03; --warning-100: #78350f;
    --danger-50: #450a0a; --danger-100: #7f1d1d;
    --info-50: #172554; --info-100: #1e3a5f;
    --purple-50: #2e1065; --purple-100: #3b0764;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.2);
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.35), 0 4px 6px -4px rgba(0,0,0,0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.4), 0 8px 10px -6px rgba(0,0,0,0.25);
    --shadow-2xl: 0 25px 50px -12px rgba(0,0,0,0.5);
    color-scheme: dark;
  }
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--text);
  background: var(--surface-bg);
  line-height: 1.6;
  font-size: 14px;
  overflow-x: hidden;
  transition: background-color var(--duration-slow) var(--ease), color var(--duration-slow) var(--ease);
}

/* Modern sans-serif headings for SaaS */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

::selection {
  background: var(--brand-200);
  color: var(--brand-900);
}

/* Better scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ═══════════════════════════════════════════
   AUTH GATE
   ═══════════════════════════════════════════ */

/* ─── Auth Gate — V2-aligned (indigo palette, dark-mode aware) ───
   Reads `credentik_theme` from localStorage (set by V2's ThemeContext)
   and toggles .dark on <html> on load so the gate matches the chrome
   the user just left. Inline <script> at the bottom of <head> in
   index.html does that bootstrap. */
.auth-gate {
  display: flex;
  align-items: stretch;
  justify-content: center;
  min-height: 100vh;
  background: #f8fafc;
  position: relative;
  overflow: hidden;
}
html.dark .auth-gate { background: #020617; }
.auth-gate::before { display: none; }

/* Split layout: brand left, form right */
.auth-split {
  display: flex;
  width: 100%;
  min-height: 100vh;
}
.auth-brand {
  flex: 0 0 480px;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 55%, #4338ca 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.auth-brand::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse at 25% 30%, rgba(99,102,241,0.30) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 75%, rgba(139,92,246,0.18) 0%, transparent 45%);
  animation: auroraFloat 24s ease-in-out infinite;
}
@keyframes auroraFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(20px, -30px) rotate(1deg); }
  66% { transform: translate(-15px, 20px) rotate(-1deg); }
}
.auth-brand-inner { position: relative; z-index: 1; }

.auth-feature-list { display: flex; flex-direction: column; gap: 14px; }
.auth-feature-row { display: flex; align-items: flex-start; gap: 12px; }
.auth-feature-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.10);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #c7d2fe;
}
.auth-feature-icon svg { width: 18px; height: 18px; stroke-width: 2; }
.auth-feature-title {
  font-weight: 600; color: #fff; font-size: 14px;
  letter-spacing: -0.005em;
}
.auth-feature-desc {
  font-size: 12.5px;
  color: rgba(255,255,255,0.62);
  margin-top: 2px;
  line-height: 1.5;
}

.auth-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: #fff;
}
html.dark .auth-form-panel { background: #0f172a; }

.auth-box {
  max-width: 420px;
  width: 100%;
  position: relative;
  z-index: 1;
  animation: authFadeIn 0.4s ease-out;
}
@keyframes authFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-box .logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.auth-box .logo img {
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 4px 20px rgba(15,23,42,0.08);
}
.auth-box h2 {
  font-size: 26px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
  letter-spacing: -0.03em;
}
html.dark .auth-box h2 { color: #f1f5f9; }
.auth-box p {
  color: #64748b;
  font-size: 14px;
  margin-bottom: 28px;
  line-height: 1.6;
}
html.dark .auth-box p { color: #94a3b8; }
.auth-box input, .auth-box select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  text-align: left;
  letter-spacing: 0;
  font-family: inherit;
  font-weight: 400;
  background: #fff;
  color: #0f172a;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
html.dark .auth-box input, html.dark .auth-box select {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}
.auth-box input::placeholder {
  color: #94a3b8;
  letter-spacing: 0;
}
html.dark .auth-box input::placeholder { color: #64748b; }
.auth-box input:focus, .auth-box select:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79,70,229,0.18);
}
html.dark .auth-box input:focus, html.dark .auth-box select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.25);
}
.auth-box .btn-enter {
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  background: #4f46e5;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.01em;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.auth-box .btn-enter:hover {
  background: #4338ca;
  box-shadow: 0 6px 16px -4px rgba(79,70,229,0.45);
}
.auth-box .btn-enter:active {
  transform: translateY(1px);
}
.auth-field { margin-bottom: 14px; }
.auth-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
html.dark .auth-field label { color: #cbd5e1; }
.auth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.auth-switch {
  font-size: 13px;
  color: #64748b;
  margin-top: 12px;
}
html.dark .auth-switch { color: #94a3b8; }
.auth-switch a { color: #4f46e5; text-decoration: none; font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }
html.dark .auth-switch a { color: #818cf8; }

.auth-box .error {
  color: #dc2626;
  font-size: 13px;
  margin-top: 12px;
  display: none;
  padding: 8px 12px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.18);
  border-radius: var(--radius-sm);
}
html.dark .auth-box .error {
  color: #fca5a5;
  background: rgba(239,68,68,0.14);
  border-color: rgba(239,68,68,0.30);
}

/* ─── Demo Login Buttons — light-theme aware ───
   These live inside the WHITE form panel, so they need light colors.
   Each role keeps a tinted accent stripe via the colored .demo-role. */
.demo-accounts {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
}
html.dark .demo-accounts { border-top-color: #334155; }
.demo-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #94a3b8;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
}
.demo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.demo-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
  text-align: left;
  width: 100%;
}
.demo-btn:hover {
  border-color: #4f46e5;
  background: #eef2ff;
}
.demo-btn:active { transform: translateY(1px); }
.demo-btn:disabled { cursor: wait; opacity: 0.6; }
html.dark .demo-btn {
  background: #1e293b;
  border-color: #334155;
}
html.dark .demo-btn:hover {
  border-color: #6366f1;
  background: rgba(99,102,241,0.10);
}
.demo-icon {
  font-size: 20px;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid #e2e8f0;
}
html.dark .demo-icon { background: #0f172a; border-color: #334155; }
.demo-role {
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
  display: block;
  letter-spacing: -0.005em;
}
html.dark .demo-role { color: #f1f5f9; }
.demo-desc {
  font-size: 10.5px;
  color: #64748b;
  display: block;
  margin-top: 1px;
}
html.dark .demo-desc { color: #94a3b8; }
.demo-owner .demo-role { color: #d97706; }
.demo-agency .demo-role { color: #059669; }
.demo-org .demo-role { color: #2563eb; }
.demo-provider .demo-role { color: #7c3aed; }
.demo-staff .demo-role { color: #0891b2; }
.demo-super .demo-role { color: #dc2626; }
html.dark .demo-owner .demo-role { color: #fbbf24; }
html.dark .demo-agency .demo-role { color: #34d399; }
html.dark .demo-org .demo-role { color: #60a5fa; }
html.dark .demo-provider .demo-role { color: #a78bfa; }
html.dark .demo-staff .demo-role { color: #22d3ee; }
html.dark .demo-super .demo-role { color: #f87171; }

/* Inline links beneath the sign-in form. _muted is the neutral
   gray ("Forgot password?", "No account?"), _strong is the brand
   indigo CTA ("Sign up", "View Pricing →"). */
.auth-link-muted {
  font-size: 13px;
  color: #64748b;
  text-decoration: none;
}
.auth-link-muted:hover { color: #475569; }
html.dark .auth-link-muted { color: #94a3b8; }
html.dark .auth-link-muted:hover { color: #cbd5e1; }
.auth-link-strong {
  font-size: 13px;
  color: #4f46e5;
  text-decoration: none;
  font-weight: 600;
}
.auth-link-strong:hover { color: #4338ca; text-decoration: underline; }
html.dark .auth-link-strong { color: #818cf8; }
html.dark .auth-link-strong:hover { color: #a5b4fc; }

/* Stacks on narrow screens so the brand panel doesn't crowd the form. */
@media (max-width: 900px) {
  .auth-split { flex-direction: column; }
  .auth-brand { flex: 0 0 auto; padding: 32px 32px 40px; }
  .auth-feature-list { display: none; }
  .auth-form-panel { padding: 32px; }
}

/* ─── Funding Hub Portal Theme ─── */
.nav-item-portal {
  background: linear-gradient(135deg, rgba(16,185,129,0.08), rgba(5,150,105,0.04)) !important;
  border-top: 1px solid rgba(16,185,129,0.15);
  border-bottom: 1px solid rgba(16,185,129,0.15);
  margin: 4px 0 !important;
}
.nav-item-portal:hover {
  background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(5,150,105,0.08)) !important;
  color: #10b981 !important;
}
.nav-item-portal .icon { color: #10b981; opacity: 1 !important; }

/* Funding Hub Mode — applied to body when in portal */
body.funding-hub-active .sidebar {
  border-right-color: rgba(16,185,129,0.15);
}
body.funding-hub-active .sidebar-header {
  border-bottom-color: rgba(16,185,129,0.2);
}
body.funding-hub-active .sidebar-header .version {
  color: #10b981;
}
body.funding-hub-active .nav-item.active {
  background: rgba(16,185,129,0.12);
  color: #34d399;
}
body.funding-hub-active .nav-item.active::before {
  background: #10b981;
}
body.funding-hub-active .nav-item:hover {
  color: #34d399;
}
body.funding-hub-active .page-header {
  border-bottom-color: rgba(16,185,129,0.15);
}

.funding-nav-container {
  padding: 8px 0;
}
.funding-nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  border: none;
  background: transparent;
  color: var(--gray-400);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.funding-nav-item:hover {
  background: rgba(16,185,129,0.08);
  color: #6ee7b7;
}
.funding-nav-item.active {
  background: rgba(16,185,129,0.12);
  color: #34d399;
  font-weight: 600;
}
.funding-nav-item .icon {
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}
.funding-nav-item.active .icon { opacity: 1; }

.funding-back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  color: var(--gray-400);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: rgba(255,255,255,0.03);
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: all 0.2s;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.funding-back-btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--gray-200);
}
.funding-back-btn svg { opacity: 0.5; }

.funding-stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s;
}
.funding-stat-card:hover {
  border-color: rgba(16,185,129,0.3);
  box-shadow: 0 0 20px rgba(16,185,129,0.08);
}
.funding-stat-value {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, #10b981, #059669);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.funding-stat-label {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.funding-opp-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.funding-opp-card:hover {
  border-color: rgba(16,185,129,0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.funding-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.funding-source-federal { background: rgba(59,130,246,0.12); color: #60a5fa; }
.funding-source-state { background: rgba(168,85,247,0.12); color: #c084fc; }
.funding-source-foundation { background: rgba(245,158,11,0.12); color: #fbbf24; }
.funding-source-pharma { background: rgba(236,72,153,0.12); color: #f472b6; }
.funding-source-va { background: rgba(239,68,68,0.12); color: #f87171; }

/* ─── Login / Register Form ─── */
.auth-form-group {
  margin-bottom: 16px;
  text-align: left;
}
.auth-form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-400);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.auth-form-group input {
  text-align: left;
  letter-spacing: normal;
  padding: 12px 16px;
  font-size: 14px;
}
.auth-form-group input[type="password"] {
  letter-spacing: 2px;
}

.auth-toggle {
  margin-top: 24px;
  font-size: 13px;
  color: var(--gray-500);
}
.auth-toggle a,
.auth-toggle button {
  color: var(--brand-400);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease);
}
.auth-toggle a:hover,
.auth-toggle button:hover {
  color: var(--brand-300);
  text-decoration: underline;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--gray-500);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.1);
}

.auth-forgot {
  display: block;
  margin-top: 12px;
  font-size: 12px;
  color: var(--gray-500);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease);
}
.auth-forgot:hover {
  color: var(--brand-400);
}

@media (max-width: 768px) {
  .auth-split { flex-direction: column; }
  .auth-brand { flex: 0 0 auto; padding: 28px 24px; min-height: auto; }
  .auth-brand-inner h1 { font-size: 22px !important; }
  .auth-brand-inner > div:last-child { display: none; } /* Hide feature list on mobile */
  .auth-form-panel { padding: 24px; }
  .auth-row { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 480px) {
  .auth-gate { padding: 0; }
  .auth-brand { padding: 20px 16px; }
  .auth-brand-inner h1 { font-size: 20px !important; margin-bottom: 4px !important; }
  .auth-brand-inner p { font-size: 13px !important; }
  .auth-form-panel { padding: 16px; }
  .auth-box h2 { font-size: 20px; }
  .auth-box p { font-size: 13px; margin-bottom: 16px; }
  /* iOS prevents zoom on 16px+ font inputs */
  .auth-box input, .auth-box select { padding: 14px 14px; font-size: 16px; min-height: 48px; border-radius: 12px; }
  .auth-box .btn-enter { padding: 14px; font-size: 16px; min-height: 48px; border-radius: 12px; }
  .auth-field { margin-bottom: 12px; }
  .auth-field label { font-size: 12px; margin-bottom: 4px; }
  .demo-grid { grid-template-columns: 1fr; gap: 6px; }
  .demo-btn { padding: 12px; min-height: 48px; }
  .demo-icon { font-size: 18px; }
  .demo-role { font-size: 13px; }
  .auth-switch { font-size: 13px; margin-top: 16px; text-align: center; }
  .auth-row { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 360px) {
  .auth-brand { padding: 16px 12px; }
  .auth-brand-inner h1 { font-size: 18px !important; }
  .auth-form-panel { padding: 12px; }
  .auth-box h2 { font-size: 18px; }
  .auth-box .logo img { width: 48px !important; height: 48px !important; }
}

/* ═══════════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════════ */

.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--surface-bg);
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--duration-slow) var(--ease);
  border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar-header {
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-header h1 {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}
.sidebar-header .version {
  font-size: 11px;
  color: var(--brand-400);
  margin-top: 1px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.nav-section {
  padding: 16px 20px 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--gray-500);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: color 0.15s;
}
.nav-section:hover { color: var(--gray-300); }
.nav-section::after {
  content: '';
  width: 6px; height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s;
  flex-shrink: 0;
  opacity: 0.5;
}
.nav-section.collapsed::after { transform: rotate(-45deg); }
.nav-section.collapsed ~ .nav-item:not(.nav-section ~ .nav-section ~ .nav-item) { /* handled by JS */ }
.nav-section:first-child {
  padding-top: 4px;
}

/* Quick Actions Bar */
.sidebar-quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 12px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sq-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border: none;
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  color: var(--gray-400);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.sq-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  transform: translateY(-1px);
}
.sq-btn svg { opacity: 0.7; }
.sq-btn:hover svg { opacity: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px 9px 20px;
  color: var(--gray-400);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: all var(--duration-fast) var(--ease);
  border-radius: 0;
  margin: 1px 0;
  position: relative;
}
.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--gray-200);
}
.nav-item.active {
  background: rgba(6,182,212,0.1);
  color: var(--brand-300);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--brand-400);
  border-radius: 0 3px 3px 0;
}
.nav-item .icon {
  width: 20px;
  text-align: center;
  font-size: 15px;
  opacity: 0.7;
  flex-shrink: 0;
}
.nav-item.active .icon {
  opacity: 1;
}
.nav-item .badge {
  margin-left: auto;
  background: var(--danger-500);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
  line-height: 16px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--sidebar-border);
}
.sidebar-footer a {
  color: var(--gray-500);
  text-decoration: none;
  font-size: 12px;
  transition: color var(--duration-fast);
}
.sidebar-footer a:hover { color: var(--gray-300); }

.btn-logout {
  display: block;
  width: 100%;
  margin-top: 0;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--gray-400);
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--duration-fast) var(--ease);
}
.btn-logout:hover {
  color: var(--gray-200);
  border-color: rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
}

.sync-indicator {
  display: block;
  font-size: 11px;
  margin-bottom: 8px;
  font-weight: 500;
}
.sync-indicator.syncing { color: var(--brand-400); }
.sync-indicator.error { color: var(--danger-400); cursor: help; }

/* ─── MAIN CONTENT AREA ─── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── PAGE HEADER ─── */
.page-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 0 var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--header-height);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-wrap: wrap;
  gap: 8px;
}
.page-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.page-header .subtitle {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 1px;
  font-weight: 400;
}

.header-actions-group {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}
.page-header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.page-header-actions .btn {
  padding: 6px 12px;
  font-size: 12px;
}

/* ─── HEADER ICON BAR ─── */
.header-icon-bar {
  display: flex;
  gap: 4px;
  align-items: center;
}
.header-icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--surface-card);
  cursor: pointer;
  font-size: 15px;
  color: var(--text-tertiary);
  transition: all var(--duration-fast) var(--ease);
}
.header-icon-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-800);
  box-shadow: var(--shadow-xs);
}
.header-icon-btn:active {
  transform: scale(0.95);
}
.header-icon-btn .notification-count {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--danger-500);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 0 0 2px #fff;
}

/* ─── TOOLS DROPDOWN ─── */
.header-icon-dropdown {
  position: relative;
}
.tools-dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  background: var(--surface-raised);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl), 0 0 0 1px var(--border-color);
  z-index: 200;
  overflow: hidden;
  animation: dropdownIn 0.15s var(--ease-out);
}
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.tools-dropdown-panel.active {
  display: block;
}
.tools-dropdown-header {
  padding: 14px 18px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--gray-100);
}
.tools-dropdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 6px;
}
.tools-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--gray-700);
  transition: all var(--duration-fast) var(--ease);
  text-align: left;
}
.tools-dropdown-item:hover {
  background: var(--gray-50);
  color: var(--gray-900);
}
.tools-dropdown-item .tdi-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--gray-100);
  font-size: 15px;
  flex-shrink: 0;
  transition: all var(--duration-fast) var(--ease);
}
.tools-dropdown-item:hover .tdi-icon {
  background: var(--brand-100);
  color: var(--brand-700);
}
.tools-dropdown-item .tdi-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tools-dropdown-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 199;
}
.tools-dropdown-overlay.active {
  display: block;
}

/* ─── PAGE BODY ─── */
.page-body {
  padding: var(--sp-6) var(--sp-8);
  flex: 1;
  animation: pageContentIn 0.25s var(--ease-out);
}
@keyframes pageContentIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════
   STAT CARDS
   ═══════════════════════════════════════════ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  transition: all var(--duration) var(--ease);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gray-200);
  transition: background var(--duration) var(--ease);
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--gray-300);
}
.stat-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--gray-500);
  margin-bottom: 6px;
  font-weight: 600;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.stat-card .value.green { color: var(--success-600); }
.stat-card .value.amber { color: var(--warning-600); }
.stat-card .value.blue { color: var(--info-600); }
.stat-card .value.red { color: var(--danger-600); }
.stat-card .value.purple { color: var(--purple-600); }

/* Colored top bars for stat cards with colored values */
.stat-card:has(.value.green)::before { background: var(--success-500); }
.stat-card:has(.value.amber)::before { background: var(--warning-500); }
.stat-card:has(.value.blue)::before { background: var(--info-500); }
.stat-card:has(.value.red)::before { background: var(--danger-500); }
.stat-card:has(.value.purple)::before { background: var(--purple-500); }

.stat-card .sub {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
  font-weight: 400;
}

/* ═══════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════ */

.card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
  transition: box-shadow var(--duration) var(--ease);
}
.card:hover {
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.card-body {
  padding: 20px 22px;
}
.card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ═══════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════ */

.table-wrap {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  background: var(--table-header-bg);
  color: var(--text-tertiary);
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border-color);
  transition: background var(--duration-fast);
}
thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius-lg) 0 0; }
thead th:hover { background: var(--gray-100); color: var(--gray-800); }
thead th .sort-arrow {
  margin-left: 4px;
  opacity: 0.3;
  font-size: 10px;
}
thead th.sorted .sort-arrow { opacity: 1; color: var(--brand-600); }
tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  color: var(--text-secondary);
}
tbody tr {
  transition: background var(--duration-fast);
}
tbody tr:hover { background: var(--table-row-hover); }
tbody tr:last-child td { border-bottom: none; }
tbody tr.overdue { background: var(--danger-50); }
tbody tr.overdue:hover { background: var(--danger-100); }

/* ═══════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

/* Status badges — with dot indicator */
.badge-not_started { background: var(--gray-100); color: var(--gray-600); }
.badge-submitted { background: var(--info-100); color: var(--info-700); }
.badge-in_review { background: var(--warning-100); color: var(--warning-700); }
.badge-pending_info { background: var(--purple-100); color: var(--purple-700); }
.badge-approved { background: var(--success-100); color: var(--success-700); }
.badge-denied { background: var(--danger-100); color: var(--danger-700); }
.badge-withdrawn { background: var(--gray-100); color: var(--gray-500); }

.badge-active { background: var(--success-100); color: var(--success-700); }
.badge-pending { background: var(--warning-100); color: var(--warning-700); }
.badge-expired { background: var(--danger-100); color: var(--danger-700); }
.badge-inactive { background: var(--gray-100); color: var(--gray-500); }

/* Payer strategic tags */
.payer-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
  margin: 1px 2px;
  line-height: 1.6;
}
.payer-tag-filter {
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s, box-shadow 0.15s;
}
.payer-tag-filter:hover { opacity: 0.75; }
.payer-tag-filter.active {
  opacity: 1;
  box-shadow: 0 0 0 2px currentColor;
}

.wave-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.wave-1 { background: var(--brand-100); color: var(--brand-800); }
.wave-2 { background: var(--info-100); color: var(--info-700); }
.wave-3 { background: var(--gray-100); color: var(--gray-600); }

/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--surface-card);
  color: var(--text-secondary);
  font-family: inherit;
  transition: all var(--duration-fast) var(--ease);
  white-space: nowrap;
  line-height: 1.4;
  letter-spacing: 0.005em;
}
.btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-900);
  box-shadow: var(--shadow-xs);
}
.btn:active {
  transform: translateY(1px);
  box-shadow: none;
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-ring);
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  color: white;
  border-color: var(--brand-600);
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  border-color: var(--brand-700);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-gold {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  color: white;
  border-color: var(--brand-600);
  font-weight: 700;
  box-shadow: var(--shadow-xs);
}
.btn-gold:hover {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  border-color: var(--brand-700);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-danger {
  background: var(--danger-500);
  color: white;
  border-color: var(--danger-500);
}
.btn-danger:hover {
  background: var(--danger-600);
  border-color: var(--danger-600);
  color: white;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.btn-icon {
  padding: 6px 8px;
  min-width: 32px;
  justify-content: center;
}
.btn-group {
  display: flex;
  gap: 0;
}
.btn-group .btn {
  border-radius: 0;
  margin-left: -1px;
}
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

/* ═══════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════ */

.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-secondary);
  background: var(--surface-input);
  transition: all var(--duration-fast) var(--ease);
  line-height: 1.5;
}
.form-control::placeholder {
  color: var(--gray-400);
}
.form-control:hover {
  border-color: var(--gray-400);
}
.form-control:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--shadow-ring);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
textarea.form-control {
  min-height: 88px;
  resize: vertical;
}
select.form-control {
  appearance: auto;
  cursor: pointer;
}

/* ─── Filters Bar ─── */
.filters-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.filters-bar .form-control {
  width: auto;
  min-width: 150px;
  font-size: 13px;
  padding: 8px 12px;
}
.filters-bar .search-input {
  flex: 1;
  min-width: 200px;
}

/* ═══════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--surface-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}
.modal-overlay.active {
  display: flex;
  animation: overlayIn 0.2s var(--ease-out);
}
@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-2xl);
  animation: modalIn 0.25s var(--ease-spring);
  border: 1px solid var(--border-color);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast);
  line-height: 1;
}
.modal-close:hover {
  color: var(--gray-700);
  background: var(--gray-100);
}
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ═══════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════ */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 24px;
  gap: 0;
}
.tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--duration-fast) var(--ease);
  white-space: nowrap;
}
.tab:hover {
  color: var(--gray-800);
}
.tab.active {
  color: var(--brand-700);
  border-bottom-color: var(--brand-500);
}

/* ═══════════════════════════════════════════
   NOTIFICATIONS
   ═══════════════════════════════════════════ */

.btn-notification {
  position: relative;
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  display: none;
}
.notification-overlay {
  position: fixed;
  inset: 0;
  z-index: 199;
}
.notification-panel {
  position: fixed;
  top: var(--header-height);
  right: 16px;
  width: 400px;
  max-height: 520px;
  background: var(--surface-raised);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl), 0 0 0 1px var(--border-color);
  z-index: 200;
  overflow: hidden;
  animation: dropdownIn 0.15s var(--ease-out);
}
.notification-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-100);
}
.notification-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-900);
}
.notification-body {
  max-height: 460px;
  overflow-y: auto;
  padding: 4px 0;
}
.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--gray-50);
  cursor: pointer;
  transition: background var(--duration-fast);
}
.notif-item:hover { background: var(--gray-50); }
.notif-item:last-child { border-bottom: none; }
.notif-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.notif-icon.red { background: var(--danger-100); color: var(--danger-600); }
.notif-icon.amber { background: var(--warning-100); color: var(--warning-600); }
.notif-icon.blue { background: var(--info-100); color: var(--info-600); }
.notif-icon.green { background: var(--success-100); color: var(--success-600); }
.notif-text { flex: 1; min-width: 0; }
.notif-text .title { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.notif-text .desc { font-size: 12px; color: var(--gray-500); margin-top: 2px; line-height: 1.4; }

/* ─── Bulk Actions Bar ─── */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--info-50);
  border: 1px solid var(--info-100);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.bulk-bar .count { font-size: 13px; font-weight: 600; color: var(--info-700); }

/* ═══════════════════════════════════════════
   CALENDAR GRID
   ═══════════════════════════════════════════ */

.cal-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
}
.cal-month {
  padding: 10px 8px;
  border-radius: var(--radius);
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  text-align: center;
  font-size: 11px;
  min-height: 80px;
  transition: box-shadow var(--duration-fast);
}
.cal-month:hover {
  box-shadow: var(--shadow-sm);
}
.cal-month .month-label {
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--gray-600);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cal-event {
  display: block;
  padding: 2px 4px;
  margin: 2px 0;
  border-radius: 3px;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event.expiring { background: var(--warning-100); color: var(--warning-700); }
.cal-event.expired { background: var(--danger-100); color: var(--danger-700); }
.cal-event.renewal { background: var(--success-100); color: var(--success-700); }
.cal-event.cred-renewal { background: var(--purple-100); color: var(--purple-700); }
.cal-event.cred-estimated { background: var(--warning-50); color: var(--warning-700); border: 1px dashed var(--warning-500); }

/* ═══════════════════════════════════════════
   REIMBURSEMENT TABLE
   ═══════════════════════════════════════════ */

.reimb-cell {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
}
.reimb-high { background: var(--success-100); color: var(--success-700); }
.reimb-mid { background: var(--warning-100); color: var(--warning-700); }
.reimb-low { background: var(--danger-100); color: var(--danger-700); }
.reimb-none { background: var(--gray-100); color: var(--gray-400); }

/* ═══════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════ */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-900);
  color: #ffffff;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  font-weight: 500;
  z-index: 300;
  display: none;
  box-shadow: var(--shadow-xl);
  max-width: 440px;
  min-width: 280px;
  line-height: 1.5;
  border: 1px solid rgba(255,255,255,0.06);
}
.toast.show {
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastSlideUp 0.3s var(--ease-spring);
}
[data-theme="dark"] .toast {
  background: var(--surface-raised);
  border-color: var(--border-color);
}
/* Onboarding org search dropdown */
.onboard-org-item:hover { background: rgba(8, 145, 178, 0.15) !important; }

@keyframes toastSlideUp {
  from { transform: translateY(16px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ═══════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════ */

.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--gray-500);
}
.empty-state h3 {
  font-size: 17px;
  color: var(--gray-700);
  margin-bottom: 8px;
  font-weight: 700;
}
.empty-state p {
  font-size: 14px;
  max-width: 400px;
  margin: 0 auto 24px;
  color: var(--gray-500);
  line-height: 1.6;
}

/* ═══════════════════════════════════════════
   LOADING / SPINNER
   ═══════════════════════════════════════════ */

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--gray-200);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════
   EMAIL PREVIEW
   ═══════════════════════════════════════════ */

.email-preview {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
  font-size: 12.5px;
  white-space: pre-wrap;
  line-height: 1.7;
  max-height: 400px;
  overflow-y: auto;
  color: var(--gray-700);
}
.email-preview .subject-line {
  font-family: inherit;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-200);
}

/* ═══════════════════════════════════════════
   ALERTS / NOTICES
   ═══════════════════════════════════════════ */

.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  line-height: 1.5;
}
.alert-info {
  background: var(--info-50);
  color: var(--info-700);
  border-color: var(--info-100);
}
.alert-warning {
  background: var(--warning-50);
  color: var(--warning-700);
  border-color: var(--warning-100);
}
.alert-success {
  background: var(--success-50);
  color: var(--success-700);
  border-color: var(--success-100);
}
.alert-danger {
  background: var(--danger-50);
  color: var(--danger-700);
  border-color: var(--danger-100);
}

/* ═══════════════════════════════════════════
   ACTIVITY TIMELINE
   ═══════════════════════════════════════════ */

.activity-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.activity-entry {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--duration-fast);
}
.activity-entry:last-child { border-bottom: none; }
.activity-entry:hover { background: var(--gray-50); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: var(--radius); }
.activity-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: var(--gray-100);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.activity-content { flex: 1; min-width: 0; }
.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.activity-body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--gray-700);
  margin-bottom: 4px;
}

/* ═══════════════════════════════════════════
   ACTION BUTTONS
   ═══════════════════════════════════════════ */

.action-btns {
  flex-wrap: nowrap;
  white-space: nowrap;
}

/* ─── MOBILE MENU BUTTON ─── */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--gray-700);
  cursor: pointer;
  padding: 6px 8px;
  margin-right: 8px;
  border-radius: var(--radius);
  transition: all var(--duration-fast);
}
.mobile-menu-btn:hover { background: var(--gray-100); }

/* ─── OFFLINE BAR ─── */
.offline-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--warning-500);
  color: var(--gray-900);
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  z-index: 301;
}

/* ─── SIDEBAR OVERLAY ─── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(2px);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ─── POLICY ROW ─── */
.policy-row { cursor: pointer; transition: background var(--duration-fast); }
.policy-row:hover { background: var(--brand-50) !important; }

/* ═══════════════════════════════════════════
   RESPONSIVE — TABLET (1024px)
   ═══════════════════════════════════════════ */

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-menu-btn { display: block; }
  .page-header { padding: 14px 20px; }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — MOBILE (768px)
   ═══════════════════════════════════════════ */

@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    padding: 14px 16px;
    min-height: auto;
  }
  .header-icon-bar { gap: 3px; }
  .header-icon-btn { width: 40px; height: 40px; font-size: 16px; }
  .tools-dropdown-panel {
    width: calc(100vw - 32px);
    right: 16px;
    left: 16px;
  }
  .tools-dropdown-grid { grid-template-columns: 1fr; }
  .page-body { padding: 16px; }
  .page-header h2 { font-size: 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 16px; }
  .stat-card .value { font-size: 22px; }
  .stat-card .label { font-size: 10px; }
  .filters-bar { flex-direction: column; }
  .filters-bar .form-control { width: 100%; }
  .modal { max-width: 100%; margin: 0 8px; border-radius: var(--radius-lg); min-width: auto; }
  .modal-overlay { padding: 16px 8px; }
  .modal-body { padding: 18px; }
  .modal-header { padding: 16px 18px; }
  .modal-footer { padding: 14px 18px; flex-wrap: wrap; }
  table { font-size: 12px; }
  thead th, tbody td { padding: 8px 10px; }
  .toast { left: 16px; right: 16px; text-align: center; }
  .card-header { flex-direction: column; gap: 8px; align-items: flex-start; }
  .card-body { padding: 16px; }
  .action-btns { flex-wrap: wrap; gap: 4px !important; }
  .action-btns .btn { padding: 6px 10px; font-size: 11px; min-height: 36px; }
  .btn { min-height: 40px; }
  .nav-item { padding: 12px 20px; font-size: 15px; min-height: 44px; }
  .activity-header { flex-direction: column; align-items: flex-start; gap: 2px; }
  .truncate { max-width: 100px; }
  .cal-grid { grid-template-columns: repeat(4, 1fr); }
  .notification-panel { width: calc(100vw - 32px); right: 16px; left: 16px; }
  /* Ensure form inputs meet touch target size */
  .form-control { min-height: 44px; font-size: 16px; }
  select.form-control { min-height: 44px; }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — SMALL PHONE (480px)
   ═══════════════════════════════════════════ */

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-body { padding: 10px; }
  .btn { padding: 10px 14px; font-size: 13px; min-height: 44px; }
  .stat-card .value { font-size: 20px; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { width: 100%; justify-content: center; }
  .cal-grid { grid-template-columns: repeat(3, 1fr); }
  .modal { margin: 0 4px; }
  .modal-overlay { padding: 8px 4px; }
  .modal-footer .btn { flex: 1; min-width: 0; font-size: 12px; padding: 10px 8px; }
  .card { border-radius: 12px; }
  .card-header h3 { font-size: 14px; }
  .page-header h2 { font-size: 15px; }
  .page-header .subtitle { font-size: 11px; }
  /* Table scroll container */
  .card-body { overflow-x: auto; }
}

/* ═══════════════════════════════════════════
   TOUCH DEVICE OPTIMIZATIONS
   ═══════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
  .btn, .nav-item, .header-icon-btn { min-height: 44px; }
  .header-icon-btn { min-width: 44px; }
  /* Larger tap targets for table action buttons */
  .action-btns .btn { min-height: 36px; min-width: 44px; }
  /* Prevent iOS zoom on input focus */
  input, select, textarea { font-size: 16px !important; }
}

/* ─── Chart Grid Responsive ─── */
@media (max-width: 900px) {
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* ═══════════════════════════════════════════
   MOBILE EXCELLENCE — TOUCH, TABLES, LAYOUT
   ═══════════════════════════════════════════ */

/* Safe area insets for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
  .sidebar { padding-top: env(safe-area-inset-top); }
  .page-header { padding-top: max(14px, env(safe-area-inset-top)); }
  .page-body { padding-bottom: env(safe-area-inset-bottom); }
}

@media (max-width: 768px) {
  /* Touch-friendly nav items (44px min tap target) */
  .nav-item { min-height: 44px; display: flex; align-items: center; }
  .sidebar-footer { padding-bottom: max(16px, env(safe-area-inset-bottom, 16px)); }

  /* Horizontal scrollable tables on mobile */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }

  /* Touch-friendly form inputs */
  .form-control, input, select, textarea {
    min-height: 44px;
    font-size: 16px !important; /* Prevents iOS zoom on focus */
  }

  /* Better modals on mobile — full screen */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    margin: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Prevent body scroll when modal is open */
  body.modal-open { overflow: hidden; position: fixed; width: 100%; }

  /* Touch-friendly buttons */
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn-sm { min-height: 36px; }

  /* Better card headers on mobile */
  .card-header h3 { font-size: 15px; }

  /* Sidebar slide animation — spring feel */
  .sidebar {
    transition: transform 0.35s var(--ease-spring);
    will-change: transform;
  }
  .sidebar-overlay {
    transition: opacity 0.25s ease;
    opacity: 0;
    pointer-events: none;
  }
  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Mobile modal — slide up from bottom with spring */
  .modal-overlay.active .modal {
    animation: modalSlideUp 0.35s var(--ease-spring);
  }

  /* Compact stat cards */
  .stat-card { padding: 12px; }
  .stat-card .sub { font-size: 9px; }

  /* Better badge readability */
  .badge { font-size: 10px; padding: 3px 8px; }
}

@media (max-width: 480px) {
  /* Full-width action buttons on small phones */
  .page-header-actions {
    display: flex;
    flex-direction: column;
    width: 100%;
  }
  .page-header-actions .btn { width: 100%; justify-content: center; }

  /* Stack filter chips */
  .filters-bar { gap: 8px; }
  .filters-bar .form-control { min-width: 0; }

  /* Compact table cells */
  thead th, tbody td { padding: 6px 8px; font-size: 11px; }

  /* Mobile-optimized header */
  .page-header h2 { font-size: 15px; }
  .page-header .page-subtitle { font-size: 11px; }

  /* Better toast on small screens */
  .toast {
    left: 8px;
    right: 8px;
    bottom: max(20px, env(safe-area-inset-bottom, 20px));
    font-size: 13px;
  }
}

/* ═══════════════════════════════════════════
   BOTTOM NAV BAR (Mobile Native Feel)
   ═══════════════════════════════════════════ */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  background: var(--surface-card);
  border-top: 1px solid var(--border-color);
  padding: 4px 0 max(4px, env(safe-area-inset-bottom, 4px));
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}

.bottom-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: none;
  border: none;
  font-size: 10px;
  font-weight: 500;
  color: var(--gray-400);
  cursor: pointer;
  transition: color 0.15s;
  min-width: 56px;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--brand-600); }
.bottom-nav-item:active { transform: scale(0.92); }

.bottom-nav-item .nav-badge {
  position: absolute;
  top: 2px;
  right: 12px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

@media (max-width: 768px) {
  .bottom-nav { display: block; }
  .page-body { padding-bottom: 80px; }
  .toast { bottom: max(76px, calc(72px + env(safe-area-inset-bottom, 0px))); }

  /* Stat cards: 2-col balanced grid */
  .pt-stats, .rcm-stat, .stpg-stats, .pypg-stats, .facv2-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Revenue Cycle tab groups: horizontal scroll */
  .rc-tab-row { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .rc-tab { flex-shrink: 0; padding: 6px 8px; font-size: 11px; }

  /* Page header actions: horizontal scroll instead of stack */
  .page-header-actions { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; white-space: nowrap; }
  .page-header-actions .btn { flex-shrink: 0; }

  /* Credentialing/workspace tabs: scroll */
  .cred-tabs, .ws-tabs, .mc-tabs, .adm-tabs, .cc-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .cred-tab, .ws-tab, .mc-tab, .adm-tab, .cc-tab { flex-shrink: 0; }

  /* Quick Actions bar hidden on mobile (use bottom nav instead) */
  .sidebar-quick-actions { display: none; }
}

/* ─── Mobile More Menu ─── */
.mobile-more-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.mobile-more-overlay.active { display: flex; align-items: flex-end; }

.mobile-more-sheet {
  width: 100%;
  background: var(--surface-card, #fff);
  border-radius: 20px 20px 0 0;
  padding: 8px 0 max(16px, env(safe-area-inset-bottom, 16px));
  max-height: 80vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: moreSlideUp 0.3s var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1));
}
@keyframes moreSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.mobile-more-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px 8px;
  font-size: 16px;
  color: var(--text-primary);
}

.mobile-more-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 12px;
}

.mobile-more-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 4px;
  border: none;
  background: none;
  border-radius: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.mobile-more-item:active { background: var(--gray-100); transform: scale(0.95); }
.mobile-more-item svg { color: var(--brand-600); }
.mobile-more-item span { text-align: center; line-height: 1.2; }

@media (max-width: 360px) {
  .mobile-more-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ═══════════════════════════════════════════
   PWA INSTALL PROMPT
   ═══════════════════════════════════════════ */

.pwa-install-banner {
  display: none;
  position: fixed;
  bottom: 72px;
  left: 12px;
  right: 12px;
  z-index: 95;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-900));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-install-banner.visible { display: flex; align-items: center; gap: 12px; }
.pwa-install-banner .pwa-icon { font-size: 28px; flex-shrink: 0; }
.pwa-install-banner .pwa-text { flex: 1; }
.pwa-install-banner .pwa-title { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.pwa-install-banner .pwa-desc { font-size: 12px; opacity: 0.85; }
.pwa-install-banner .pwa-btn {
  background: #fff;
  color: var(--brand-700);
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.pwa-install-banner .pwa-dismiss {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Pull-to-refresh visual cue ─── */
@media (max-width: 1024px) {
  .page-body { overscroll-behavior-y: contain; }
}

/* ─── Smooth scrolling on mobile ─── */
.page-body, .modal-body, .sidebar-nav {
  -webkit-overflow-scrolling: touch;
}

/* ─── Active state feedback for mobile taps ─── */
@media (hover: none) and (pointer: coarse) {
  .nav-item:active { background: var(--brand-100); transform: scale(0.98); }
  .btn:active { transform: scale(0.97); }
  .stat-card:active { transform: scale(0.98); }
  tbody tr:active { background: var(--brand-50) !important; }
}

/* ═══════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════ */

@media print {
  @page { margin: 0.6in 0.5in; size: letter; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; }
  body { background: white !important; font-size: 11px; color: #000; line-height: 1.4; }
  .sidebar, .sidebar-overlay, .mobile-menu-btn,
  .toast, .modal-overlay, .no-print, .header-icon-bar,
  .offline-bar, .bottom-nav, .sidebar-quick-actions { display: none !important; }
  .main-content { margin-left: 0; padding: 0; }
  .page-header {
    position: static;
    border-bottom: 2px solid #1a1a2e;
    padding: 8px 0 12px;
    backdrop-filter: none;
    margin-bottom: 16px;
  }
  .page-header-actions { display: none !important; }
  #page-title { font-size: 18px; color: #1a1a2e; }
  #page-subtitle { font-size: 10px; color: #666; }
  .page-body { padding: 0; animation: none; }

  /* Cards print clean */
  .card, .cd-card, .cd-section, .pt-stat, .rcm-stat { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; border-radius: 4px; }
  .stat-card, .pt-stat, .rcm-stat { box-shadow: none; border: 1px solid #ddd; }
  .stat-card::before, .pt-stat::before, .rcm-stat::before { print-color-adjust: exact; }

  /* Tables print professionally */
  .table-wrap { box-shadow: none; border: 1px solid #ccc; overflow: visible; }
  table { font-size: 10px; border-collapse: collapse; }
  thead th {
    background: #2C4A5A !important;
    color: white !important;
    font-size: 9px;
    padding: 6px 8px;
    letter-spacing: 0.3px;
  }
  tbody td { padding: 5px 8px; border-bottom: 1px solid #eee; }
  tbody tr:nth-child(even) { background: #f8f9fa !important; }

  /* Badges print with color */
  .badge, .wave-badge { print-color-adjust: exact; font-size: 9px; }

  /* Hide interactive elements */
  .btn, button:not(.print-visible) { display: none !important; }
  .filters-bar, .action-btns { display: none !important; }
  select, input[type="text"], input[type="search"], textarea { display: none !important; }
  .nav-section, .nav-item { display: none !important; }

  /* Stats grid stays horizontal */
  .stats-grid, .pt-stats { grid-template-columns: repeat(5, 1fr); }
  .cd-grid { grid-template-columns: repeat(3, 1fr); }

  /* Links don't show underlines */
  a { text-decoration: none; color: inherit; }

  /* Print header/footer */
  .print-header { display: block !important; text-align: center; margin-bottom: 8px; font-size: 9px; color: #999; border-bottom: 1px solid #eee; padding-bottom: 6px; }
  .print-footer { display: block !important; }

  /* Claim detail prints well */
  .cd-back { display: none !important; }
  .cd-timeline { break-inside: avoid; }
  .cd-tl-dot { print-color-adjust: exact; }

  /* Charts don't print well — hide them */
  canvas { max-height: 200px; }
}
.print-header { display: none; }
.print-footer { display: none; font-size: 9px; color: #999; text-align: center; margin-top: 24px; padding-top: 8px; border-top: 1px solid #eee; }

/* ═══════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════ */

.hidden { display: none !important; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 12px; }
.text-mono { font-family: 'SF Mono', 'JetBrains Mono', Consolas, monospace; font-size: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

/* Skeleton loading animation */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite linear;
  border-radius: var(--radius);
}
@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Theme toggle button */
#theme-toggle svg {
  transition: transform var(--duration) var(--ease);
}
#theme-toggle:hover svg {
  transform: rotate(15deg);
}

/* Smooth theme transitions */
.card, .stat-card, .table-wrap, .modal, .page-header, .bottom-nav,
.btn, .form-control, .notification-panel, .tools-dropdown-panel {
  transition: background-color var(--duration-slow) var(--ease),
              border-color var(--duration-slow) var(--ease),
              color var(--duration-slow) var(--ease),
              box-shadow var(--duration-slow) var(--ease);
}

/* Focus-visible for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}

/* ── Contract Terms Rich Text ── */
.contract-terms-content h2 { font-size: 16px; font-weight: 700; margin: 0 0 16px; color: #1e293b; }
.contract-terms-content h3 { font-size: 14px; font-weight: 700; margin: 20px 0 8px; color: #334155; }
.contract-terms-content p { margin: 0 0 10px; }
.contract-terms-content ul, .contract-terms-content ol { margin: 0 0 12px; padding-left: 24px; }
.contract-terms-content li { margin-bottom: 4px; }
.contract-terms-content strong { font-weight: 700; }
.contract-terms-content em { font-style: italic; }

/* Quill editor overrides inside modals */
.modal .ql-container { font-family: inherit; font-size: 13px; }
.modal .ql-editor { min-height: 200px; line-height: 1.6; }
.modal .ql-toolbar { border-radius: 8px 8px 0 0; border-color: var(--gray-200); }
.modal .ql-container { border-radius: 0 0 8px 8px; border-color: var(--gray-200); }

/* ═══════════════════════════════════════════════════════════════
   MOBILE-FIRST RESPONSIVE OVERHAUL — Native App Feel
   Added: 2026-03-24
   ═══════════════════════════════════════════════════════════════ */

/* ─── 10. PWA Feel — Global ─── */
html {
  -webkit-text-size-adjust: 100%;
}
body {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
.page-body,
.modal-body,
.sidebar-nav,
.table-wrap,
.notification-body {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ─── 9. Touch Improvements — Global ─── */
a, button, [role="button"], .nav-item, .btn, .tab,
.bottom-nav-item, .stat-card, .notif-item, .demo-btn,
.tools-dropdown-item, .policy-row, .funding-nav-item {
  -webkit-tap-highlight-color: transparent;
}

/* ═══════════════════════════════════════════
   TABLET — 1024px
   ═══════════════════════════════════════════ */

@media (max-width: 1024px) {
  /* 6. Sidebar — semi-transparent overlay already exists, ensure blur */
  .sidebar-overlay {
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  /* 3. Stat cards — verify 2-col on tablet (already set at 768, add for 1024) */
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  /* 2. Tables — ensure horizontal scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }

  /* 8. Filters — slightly tighter */
  .filters-bar {
    gap: 8px;
  }
}

/* ═══════════════════════════════════════════
   MOBILE — 768px
   ═══════════════════════════════════════════ */

@media (max-width: 768px) {

  /* ─── 1. Bottom Navigation Bar — Enhanced ─── */
  .bottom-nav {
    background: var(--surface-card);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    padding: 2px 0 0;
    padding-bottom: max(4px, env(safe-area-inset-bottom, 4px));
    transition: transform 0.3s var(--ease);
  }

  /* Slide-up entrance */
  .bottom-nav {
    animation: bottomNavSlideUp 0.4s var(--ease-spring);
  }
  @keyframes bottomNavSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .bottom-nav-item {
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    min-width: 60px;
    min-height: 48px;
    justify-content: center;
    position: relative;
    border-radius: var(--radius-lg);
    transition: color 0.2s var(--ease), transform 0.1s var(--ease);
  }

  .bottom-nav-item svg,
  .bottom-nav-item .icon {
    width: 24px;
    height: 24px;
    font-size: 20px;
    transition: transform 0.15s var(--ease);
  }

  .bottom-nav-item span:last-child,
  .bottom-nav-item .nav-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1;
  }

  /* Active state with brand color pill */
  .bottom-nav-item.active {
    color: var(--brand-600);
  }
  .bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 28px;
    background: var(--brand-100);
    border-radius: var(--radius-full);
    z-index: -1;
    animation: pillFadeIn 0.25s var(--ease-out);
  }
  @keyframes pillFadeIn {
    from { opacity: 0; transform: translateX(-50%) scale(0.7); }
    to { opacity: 1; transform: translateX(-50%) scale(1); }
  }

  /* Haptic-feel tap effect */
  .bottom-nav-item:active {
    transform: scale(0.88);
    transition-duration: 0.06s;
  }

  /* Badge positioning fix */
  .bottom-nav-item .nav-badge {
    position: absolute;
    top: 0;
    right: 8px;
  }

  /* ─── 2. Tables on Mobile — Card Layout ─── */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .table-wrap::-webkit-scrollbar {
    display: none;
  }

  /* Scroll hint gradient */
  .table-wrap {
    position: relative;
  }
  .table-wrap::after {
    content: '';
    position: sticky;
    right: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(to left, var(--surface-card), transparent);
    pointer-events: none;
    z-index: 2;
  }

  /* Sticky first column */
  table thead th:first-child,
  table tbody td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--surface-card);
  }
  table thead th:first-child {
    background: var(--table-header-bg);
    z-index: 4;
  }
  table tbody td:first-child::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 0;
    bottom: 0;
    width: 8px;
    background: linear-gradient(to right, rgba(0,0,0,0.04), transparent);
    pointer-events: none;
  }

  /* ─── 4. Modals — Full-screen bottom sheet ─── */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal {
    max-width: 100%;
    width: 100%;
    margin: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 95vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Drag handle at top of modal */
  .modal::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    margin: 8px auto 0;
    flex-shrink: 0;
  }

  .modal-header {
    padding: 12px 20px 16px;
  }
  .modal-header h2 {
    font-size: 17px;
  }

  /* Larger touch targets for modal buttons */
  .modal-footer {
    padding: 16px 20px;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
  }
  .modal-footer .btn {
    min-height: 48px;
    padding: 12px 20px;
    font-size: 15px;
    border-radius: var(--radius-lg);
    flex: 1;
  }
  .modal-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border-radius: var(--radius);
  }

  /* ─── 5. Page Header — Compact ─── */
  .page-header {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 16px;
    min-height: 52px;
    gap: 6px;
  }
  .page-header h2 {
    font-size: 16px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .page-header .subtitle {
    display: none;
  }

  /* Collapse header actions into compact row */
  .header-actions-group {
    gap: 4px;
    margin-left: 0;
  }
  .page-header-actions .btn {
    padding: 6px 10px;
    font-size: 12px;
    min-height: 36px;
  }

  /* ─── 6. Sidebar — Swipe gesture area (visual cue) ─── */
  .sidebar.open ~ .sidebar-overlay::before {
    content: '';
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    z-index: 101;
  }

  /* ─── 7. Cards — Flush edges on mobile ─── */
  .card {
    border-radius: 0;
    border-left: none;
    border-right: none;
    margin-left: -16px;
    margin-right: -16px;
  }
  .card-header {
    padding: 14px 16px;
  }
  .card-body {
    padding: 14px 16px;
  }
  .card-footer {
    padding: 12px 16px;
  }

  /* ─── 7. Forms — Single column, iOS-safe inputs ─── */
  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .form-group {
    margin-bottom: 14px;
  }
  .form-control,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="number"],
  input[type="date"],
  input[type="url"],
  select,
  textarea {
    min-height: 44px;
    font-size: 16px !important; /* Prevent iOS zoom */
    padding: 10px 14px;
    border-radius: var(--radius);
  }

  /* ─── 8. Filters — Collapse into scrollable row ─── */
  .filters-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px;
    padding-bottom: 4px;
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .filters-bar::-webkit-scrollbar {
    display: none;
  }
  .filters-bar .form-control {
    min-width: 140px;
    flex-shrink: 0;
  }
  .filters-bar .search-input {
    min-width: 180px;
    flex-shrink: 0;
  }

  /* ─── 9. Touch Improvements ─── */
  .btn,
  .nav-item,
  .tab,
  .bottom-nav-item,
  .notif-item,
  .tools-dropdown-item {
    min-height: 44px;
  }

  /* Tabs — horizontal scroll on mobile */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0;
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .tabs::-webkit-scrollbar {
    display: none;
  }
  .tab {
    min-height: 44px;
    padding: 10px 16px;
    flex-shrink: 0;
  }

  /* Notification panel — full width */
  .notification-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: modalSlideUp 0.3s var(--ease-spring);
  }
  .notification-panel::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    margin: 8px auto 0;
  }

  /* Tools dropdown — bottom sheet on mobile */
  .tools-dropdown-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 60vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: modalSlideUp 0.3s var(--ease-spring);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tools-dropdown-panel::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    margin: 8px auto 4px;
  }
  .tools-dropdown-grid {
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 8px;
  }
  .tools-dropdown-item {
    padding: 14px 12px;
    border-radius: var(--radius-lg);
  }
  .tools-dropdown-overlay.active {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  /* Calendar grid — compact on mobile */
  .cal-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Empty state — less padding */
  .empty-state {
    padding: 40px 20px;
  }

  /* Bulk bar — stack */
  .bulk-bar {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  /* Toast — above bottom nav */
  .toast {
    left: 12px;
    right: 12px;
    bottom: max(80px, calc(76px + env(safe-area-inset-bottom, 0px)));
    border-radius: var(--radius-lg);
  }

  /* Activity timeline — tighter */
  .activity-entry {
    gap: 10px;
    padding: 10px 0;
  }
  .activity-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 14px;
  }

  /* Page body — account for bottom nav */
  .page-body {
    padding-bottom: max(80px, calc(72px + env(safe-area-inset-bottom, 0px)));
  }
}

/* ═══════════════════════════════════════════
   SMALL PHONE — 480px
   ═══════════════════════════════════════════ */

@media (max-width: 480px) {
  /* 3. Stat cards — single column */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .stat-card {
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .stat-card .value {
    font-size: 22px;
    order: 2;
    margin-left: auto;
  }
  .stat-card .label {
    font-size: 11px;
    order: 1;
    margin-bottom: 0;
  }
  .stat-card .sub {
    display: none;
  }
  .stat-card::before {
    width: 3px;
    height: auto;
    top: 8px;
    bottom: 8px;
    left: 0;
    right: auto;
  }

  /* Page body — minimal padding */
  .page-body {
    padding: 10px 12px;
    padding-bottom: max(80px, calc(72px + env(safe-area-inset-bottom, 0px)));
  }

  /* Cards — full bleed */
  .card {
    margin-left: -12px;
    margin-right: -12px;
  }

  /* Bottom nav — 5 items tighter */
  .bottom-nav-item {
    min-width: 48px;
    padding: 4px 6px;
    gap: 1px;
  }
  .bottom-nav-item svg,
  .bottom-nav-item .icon {
    width: 22px;
    height: 22px;
  }
  .bottom-nav-item span:last-child,
  .bottom-nav-item .nav-label {
    font-size: 9px;
  }

  /* Modal — full screen on small phones */
  .modal {
    max-height: 100vh;
    min-height: 60vh;
    border-radius: 0;
  }
  .modal-body {
    padding: 16px;
  }

  /* Buttons — full width in footers */
  .modal-footer {
    flex-direction: column;
  }
  .modal-footer .btn {
    width: 100%;
  }

  /* Header — super compact */
  .page-header h2 {
    font-size: 15px;
  }

  /* Auth box — tighter on tiny screens */
  .auth-box {
    padding: 24px 16px;
  }

  /* Table minimum width smaller */
  table {
    min-width: 500px;
  }

  /* Calendar — 2-col on tiny */
  .cal-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Badge — compact */
  .badge {
    font-size: 10px;
    padding: 2px 6px;
  }
}

/* ═══════════════════════════════════════════
   VERY SMALL PHONE — 360px
   ═══════════════════════════════════════════ */

@media (max-width: 360px) {
  .page-body {
    padding: 8px;
    padding-bottom: max(80px, calc(72px + env(safe-area-inset-bottom, 0px)));
  }
  .card {
    margin-left: -8px;
    margin-right: -8px;
  }
  .page-header {
    padding: 8px 12px;
  }
  .page-header h2 {
    font-size: 14px;
  }
  .stat-card .value {
    font-size: 20px;
  }
  .bottom-nav-item {
    min-width: 44px;
    padding: 4px 4px;
  }
}

/* ═══════════════════════════════════════════
   TOUCH DEVICE ENHANCEMENTS
   ═══════════════════════════════════════════ */

@media (hover: none) and (pointer: coarse) {
  /* Remove hover-only interactions — show actions inline */
  .nav-item:hover {
    background: transparent;
    color: var(--gray-400);
  }
  .nav-item.active:hover {
    background: rgba(6, 182, 212, 0.1);
    color: var(--brand-300);
  }

  /* Tap feedback */
  .nav-item:active {
    background: var(--brand-100);
    transform: scale(0.98);
    transition-duration: 0.06s;
  }
  .btn:active {
    transform: scale(0.97);
    transition-duration: 0.06s;
  }
  .stat-card:active {
    transform: scale(0.98);
    transition-duration: 0.06s;
  }
  tbody tr:active {
    background: var(--brand-50) !important;
  }
  .card:active {
    transform: scale(0.995);
    transition-duration: 0.06s;
  }
  .tab:active {
    background: var(--gray-100);
    transform: scale(0.97);
  }
  .notif-item:active {
    background: var(--gray-100);
  }

  /* All clickable: 44px minimum */
  a, button, [role="button"], select {
    min-height: 44px;
  }

  /* Better scrollbar hiding on touch */
  ::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
  }
  * {
    scrollbar-width: none;
  }
}

/* ═══════════════════════════════════════════
   SAFE AREA INSETS — Notched Phones (iPhone X+)
   ═══════════════════════════════════════════ */

@supports (padding-top: env(safe-area-inset-top)) {
  .bottom-nav {
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
  .modal {
    padding-bottom: env(safe-area-inset-bottom);
  }

  @media (max-width: 768px) {
    .page-body {
      padding-left: max(16px, env(safe-area-inset-left));
      padding-right: max(16px, env(safe-area-inset-right));
    }
    .page-header {
      padding-left: max(16px, env(safe-area-inset-left));
      padding-right: max(16px, env(safe-area-inset-right));
    }
  }

  @media (max-width: 480px) {
    .page-body {
      padding-left: max(12px, env(safe-area-inset-left));
      padding-right: max(12px, env(safe-area-inset-right));
    }
  }
}

/* ═══════════════════════════════════════════
   LANDSCAPE PHONE
   ═══════════════════════════════════════════ */

@media (max-height: 480px) and (orientation: landscape) {
  .bottom-nav {
    padding-top: 2px;
    padding-bottom: max(2px, env(safe-area-inset-bottom, 2px));
  }
  .bottom-nav-item {
    min-height: 40px;
    padding: 2px 8px;
  }
  .bottom-nav-item svg,
  .bottom-nav-item .icon {
    width: 20px;
    height: 20px;
  }
  .bottom-nav-item span:last-child,
  .bottom-nav-item .nav-label {
    font-size: 9px;
  }
  .modal {
    max-height: 100vh;
  }
  .page-body {
    padding-bottom: max(56px, calc(48px + env(safe-area-inset-bottom, 0px)));
  }
}

/* ═══════════════════════════════════════════
   DARK MODE — Mobile-specific adjustments
   ═══════════════════════════════════════════ */

@media (max-width: 768px) {
  [data-theme="dark"] .bottom-nav,
  :root:not([data-theme="light"]) .bottom-nav {
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
  }
  [data-theme="dark"] .bottom-nav-item.active::before,
  :root:not([data-theme="light"]) .bottom-nav-item.active::before {
    background: rgba(6, 182, 212, 0.15);
  }
  [data-theme="dark"] .modal::before,
  :root:not([data-theme="light"]) .modal::before {
    background: var(--gray-600);
  }
  [data-theme="dark"] table thead th:first-child,
  :root:not([data-theme="light"]) table thead th:first-child {
    background: var(--table-header-bg);
  }
  [data-theme="dark"] table tbody td:first-child,
  :root:not([data-theme="light"]) table tbody td:first-child {
    background: var(--surface-card);
  }
  [data-theme="dark"] table tbody td:first-child::after {
    background: linear-gradient(to right, rgba(0, 0, 0, 0.15), transparent);
  }
}

/* ═══════════════════════════════════════════
   REDUCED MOTION — Accessibility
   ═══════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .bottom-nav,
  .bottom-nav-item,
  .modal,
  .modal-overlay,
  .sidebar,
  .notification-panel,
  .tools-dropdown-panel {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
  .bottom-nav-item:active {
    transform: none;
  }
  .bottom-nav-item.active::before {
    animation: none;
  }
}

/* ═══════════════════════════════════════════════════════════════
   DARK MODE — Comprehensive Component Overrides
   Covers all hardcoded colors, hover states, and raw --gray-* usage
   ═══════════════════════════════════════════════════════════════ */

/* --- Gray palette inversion for dark mode --- */
[data-theme="dark"] {
  --gray-50: #1e293b;
  --gray-100: #1e293b;
  --gray-200: #334155;
  --gray-300: #475569;
  --gray-400: #94a3b8;
  --gray-500: #94a3b8;
  --gray-600: #cbd5e1;
  --gray-700: #e2e8f0;
  --gray-800: #f1f5f9;
  --gray-900: #f8fafc;
  --gray-950: #ffffff;

  /* Keep sidebar dark regardless */
  --sidebar-bg: #0f172a;
  --sidebar-border: rgba(255,255,255,0.06);
}

/* Duplicate gray overrides for system-preference dark mode */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --gray-50: #1e293b;
    --gray-100: #1e293b;
    --gray-200: #334155;
    --gray-300: #475569;
    --gray-400: #94a3b8;
    --gray-500: #94a3b8;
    --gray-600: #cbd5e1;
    --gray-700: #e2e8f0;
    --gray-800: #f1f5f9;
    --gray-900: #f8fafc;
    --gray-950: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-border: rgba(255,255,255,0.06);
  }
}

/* --- Scrollbar --- */
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--border-color-strong); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* --- Selection --- */
[data-theme="dark"] ::selection {
  background: var(--brand-800);
  color: var(--brand-200);
}

/* --- Header icon button hover / notification ring --- */
[data-theme="dark"] .header-icon-btn .notification-count {
  box-shadow: 0 0 0 2px var(--surface-card);
}

/* --- Tools dropdown --- */
[data-theme="dark"] .tools-dropdown-header {
  border-bottom-color: var(--border-color);
}

/* --- Card footer / Modal footer --- */
[data-theme="dark"] .card-footer {
  border-top-color: var(--border-color);
}
[data-theme="dark"] .modal-footer {
  border-top-color: var(--border-color);
}

/* --- Notification panel --- */
[data-theme="dark"] .notification-header {
  border-bottom-color: var(--border-color);
}
[data-theme="dark"] .notification-header h3 {
  color: var(--text-primary);
}
[data-theme="dark"] .notif-item {
  border-bottom-color: var(--border-color);
}
[data-theme="dark"] .notif-text .title {
  color: var(--text-primary);
}

/* --- Tabs --- */
[data-theme="dark"] .tabs {
  border-bottom-color: var(--border-color);
}
[data-theme="dark"] .tab.active {
  color: var(--brand-400);
}

/* --- Activity timeline --- */
[data-theme="dark"] .activity-entry {
  border-bottom-color: var(--border-color);
}

/* --- Email preview --- */
[data-theme="dark"] .email-preview {
  background: var(--surface-card);
  border-color: var(--border-color);
  color: var(--text-secondary);
}
[data-theme="dark"] .email-preview .subject-line {
  color: var(--text-primary);
  border-bottom-color: var(--border-color);
}

/* --- Spinner --- */
[data-theme="dark"] .spinner {
  border-color: var(--border-color);
  border-top-color: var(--brand-400);
}

/* --- Empty state --- */
[data-theme="dark"] .empty-state h3 {
  color: var(--text-secondary);
}

/* --- Skeleton loading --- */
[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 200% 100%;
}

/* --- Contract terms content --- */
[data-theme="dark"] .contract-terms-content h2 {
  color: var(--text-primary);
}
[data-theme="dark"] .contract-terms-content h3 {
  color: var(--text-secondary);
}

/* --- Quill editor --- */
[data-theme="dark"] .modal .ql-toolbar {
  border-color: var(--border-color);
  background: var(--surface-card);
}
[data-theme="dark"] .modal .ql-container {
  border-color: var(--border-color);
  background: var(--surface-input);
  color: var(--text-primary);
}
[data-theme="dark"] .ql-toolbar button,
[data-theme="dark"] .ql-toolbar .ql-picker {
  color: var(--text-secondary);
}
[data-theme="dark"] .ql-toolbar button:hover,
[data-theme="dark"] .ql-toolbar .ql-picker:hover {
  color: var(--text-primary);
}
[data-theme="dark"] .ql-editor.ql-blank::before {
  color: var(--text-quaternary);
}

/* --- PWA install banner button --- */
[data-theme="dark"] .pwa-install-banner .pwa-btn {
  background: var(--surface-card);
  color: var(--brand-400);
}

/* --- Policy row hover --- */
[data-theme="dark"] .policy-row:hover {
  background: rgba(6, 182, 212, 0.08) !important;
}

/* --- Inline styles in app.js-rendered content ---
     These handle common patterns where JS uses hardcoded white/light backgrounds */

/* v2-apps-card and similar dynamically-styled elements */
[data-theme="dark"] [style*="background:white"],
[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #fff"] {
  background: var(--surface-card) !important;
}

[data-theme="dark"] [style*="color:#1e293b"],
[data-theme="dark"] [style*="color: #1e293b"] {
  color: var(--text-primary) !important;
}
[data-theme="dark"] [style*="color:#334155"],
[data-theme="dark"] [style*="color: #334155"] {
  color: var(--text-secondary) !important;
}
[data-theme="dark"] [style*="color:#475569"],
[data-theme="dark"] [style*="color: #475569"] {
  color: var(--text-tertiary) !important;
}
[data-theme="dark"] [style*="color:#64748b"],
[data-theme="dark"] [style*="color: #64748b"] {
  color: var(--text-tertiary) !important;
}

/* Border overrides for inline styles */
[data-theme="dark"] [style*="border-color:#e2e8f0"],
[data-theme="dark"] [style*="border-color: #e2e8f0"],
[data-theme="dark"] [style*="border:1px solid #e2e8f0"],
[data-theme="dark"] [style*="border: 1px solid #e2e8f0"] {
  border-color: var(--border-color) !important;
}

/* Background gray overrides for inline styles */
[data-theme="dark"] [style*="background:#f8fafc"],
[data-theme="dark"] [style*="background: #f8fafc"],
[data-theme="dark"] [style*="background:#f1f5f9"],
[data-theme="dark"] [style*="background: #f1f5f9"] {
  background: var(--surface-card) !important;
}

/* --- Sidebar stays dark (re-assert original values) --- */
[data-theme="dark"] .sidebar {
  background: #0f172a;
  color: white;
}
[data-theme="dark"] .sidebar-header h1 {
  color: #fff;
}
[data-theme="dark"] .sidebar-header .version {
  color: var(--brand-400);
}
[data-theme="dark"] .nav-section {
  color: #64748b;
}
[data-theme="dark"] .nav-item {
  color: #94a3b8;
}
[data-theme="dark"] .nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: #e2e8f0;
}
[data-theme="dark"] .nav-item.active {
  background: rgba(6,182,212,0.1);
  color: #67e8f9;
}
[data-theme="dark"] .nav-item .badge {
  color: white;
}
[data-theme="dark"] .sidebar-footer a {
  color: #64748b;
}
[data-theme="dark"] .sidebar-footer a:hover {
  color: #cbd5e1;
}
[data-theme="dark"] .btn-logout {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
  color: #94a3b8;
}
[data-theme="dark"] .btn-logout:hover {
  color: #e2e8f0;
  border-color: rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
}

/* --- Badges: ensure text contrast in dark mode --- */
[data-theme="dark"] .badge-not_started { background: #334155; color: #cbd5e1; }
[data-theme="dark"] .badge-withdrawn { background: #334155; color: #94a3b8; }
[data-theme="dark"] .badge-inactive { background: #334155; color: #94a3b8; }
[data-theme="dark"] .badge-submitted { color: #93c5fd; }
[data-theme="dark"] .badge-in_review { color: #fcd34d; }
[data-theme="dark"] .badge-pending_info { color: #c4b5fd; }
[data-theme="dark"] .badge-approved { color: #86efac; }
[data-theme="dark"] .badge-denied { color: #fca5a5; }
[data-theme="dark"] .badge-active { color: #86efac; }
[data-theme="dark"] .badge-pending { color: #fcd34d; }
[data-theme="dark"] .badge-expired { color: #fca5a5; }

/* Wave badges */
[data-theme="dark"] .wave-1 { background: rgba(6,182,212,0.15); color: var(--brand-300); }
[data-theme="dark"] .wave-2 { background: rgba(59,130,246,0.15); color: #93c5fd; }
[data-theme="dark"] .wave-3 { background: #334155; color: #cbd5e1; }

/* --- Stat card top bar in dark mode --- */
[data-theme="dark"] .stat-card::before {
  background: var(--border-color);
}

/* --- Mobile touch active states in dark mode --- */
@media (hover: none) and (pointer: coarse) {
  [data-theme="dark"] .nav-item:active {
    background: rgba(6, 182, 212, 0.15);
  }
  [data-theme="dark"] tbody tr:active {
    background: rgba(6, 182, 212, 0.08) !important;
  }
  [data-theme="dark"] .tab:active {
    background: var(--surface-card);
  }
}

/* --- Scope selector button --- */
[data-theme="dark"] #scope-btn {
  border-color: var(--border-color) !important;
  color: var(--text-secondary) !important;
  background: var(--surface-card) !important;
}

/* --- Global search & command palette overrides --- */
[data-theme="dark"] .search-overlay,
[data-theme="dark"] .cmd-palette-overlay {
  background: rgba(0, 0, 0, 0.7);
}
[data-theme="dark"] .search-modal,
[data-theme="dark"] .cmd-palette {
  background: var(--surface-card);
  border-color: var(--border-color);
}
[data-theme="dark"] .search-result-item:hover,
[data-theme="dark"] .cmd-item:hover {
  background: var(--surface-card-hover);
}

/* --- Table header hover in dark mode --- */
[data-theme="dark"] thead th:hover {
  background: var(--surface-card-hover);
  color: var(--text-primary);
}

/* --- Confirm modal / prompt dialog --- */
[data-theme="dark"] .confirm-modal,
[data-theme="dark"] .prompt-dialog {
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

/* --- V2 page components (inline <style> in app.js uses background:white) --- */
[data-theme="dark"] .v2-apps-stat,
[data-theme="dark"] .v2-apps-pipeline,
[data-theme="dark"] .v2-apps-card,
[data-theme="dark"] .v2-fu-stat,
[data-theme="dark"] .v2-fu-cal,
[data-theme="dark"] .sp2-stat,
[data-theme="dark"] .rv2-stat,
[data-theme="dark"] .cm2-stat,
[data-theme="dark"] .v2-prov-stat,
[data-theme="dark"] .v2-prov-card,
[data-theme="dark"] .v2-lic-stat,
[data-theme="dark"] .v2-lic-map,
[data-theme="dark"] .v2-lic-timeline,
[data-theme="dark"] .v2-payers-stat,
[data-theme="dark"] .v2-payers-filter,
[data-theme="dark"] .v2-tasks-stat,
[data-theme="dark"] .v2-tasks-progress {
  background: var(--surface-card) !important;
  border-color: var(--border-color) !important;
}

/* V2 view toggle buttons */
[data-theme="dark"] .v2-apps-view-toggle button {
  background: var(--surface-card) !important;
  color: var(--text-secondary) !important;
}
[data-theme="dark"] .v2-apps-view-toggle button.active {
  background: var(--brand-600) !important;
  color: white !important;
}

/* V2 card hover */
[data-theme="dark"] .v2-apps-card:hover,
[data-theme="dark"] .v2-prov-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.3) !important;
}

/* --- Bottom nav shadow in dark mode --- */
[data-theme="dark"] .bottom-nav {
  box-shadow: 0 -2px 12px rgba(0,0,0,0.3);
}

/* --- All inline-style background:white catchall --- */
[data-theme="dark"] [style*="background:white"],
[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background:#ffffff"],
[data-theme="dark"] [style*="background: #ffffff"] {
  background: var(--surface-card) !important;
}

/* --- Inline color:#000 or color:black text --- */
[data-theme="dark"] [style*="color:#000"],
[data-theme="dark"] [style*="color: #000"],
[data-theme="dark"] [style*="color:black"],
[data-theme="dark"] [style*="color: black"] {
  color: var(--text-primary) !important;
}

/* ─── Patient Module ─── */
.pt-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.pt-stat { background: var(--surface-card, #fff); border-radius: 16px; padding: 18px 16px; position: relative; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.06); transition: transform 0.18s, box-shadow 0.18s; }
.pt-stat:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.1); }
.pt-stat::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.pt-stat:nth-child(1)::before { background: linear-gradient(90deg, var(--brand-500), var(--brand-700)); }
.pt-stat:nth-child(2)::before { background: linear-gradient(90deg, #22c55e, #16a34a); }
.pt-stat:nth-child(3)::before { background: linear-gradient(90deg, #f59e0b, #d97706); }
.pt-stat:nth-child(4)::before { background: linear-gradient(90deg, #8b5cf6, #6d28d9); }
.pt-stat:nth-child(5)::before { background: linear-gradient(90deg, #ef4444, #dc2626); }
.pt-stat .pt-val { font-size: 28px; font-weight: 800; line-height: 1.1; }
.pt-stat .pt-lbl { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-500); margin-top: 4px; }
.pt-row:hover { background: var(--gray-50); cursor: pointer; }

/* ─── Message Center ─── */
.mc-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--gray-200); margin-bottom: 12px; overflow-x: auto; }
.mc-tab { padding: 10px 16px; font-size: 12px; font-weight: 600; color: var(--gray-500); cursor: pointer; border: none; background: none; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; transition: all 0.15s; }
.mc-tab:hover { color: var(--brand-600); background: var(--gray-50); }
.mc-tab.active { color: var(--brand-600); border-bottom-color: var(--brand-600); }

.mc-layout { display: grid; grid-template-columns: 320px 1fr 280px; height: calc(100vh - 200px); min-height: 500px; gap: 0; border: 1px solid var(--border-color, var(--gray-200)); border-radius: 12px; overflow: hidden; background: var(--surface-card, #fff); }
.mc-layout.no-context { grid-template-columns: 320px 1fr; }

.mc-left { border-right: 1px solid var(--border-color, var(--gray-200)); display: flex; flex-direction: column; overflow: hidden; }
.mc-left-search { padding: 10px 12px; border-bottom: 1px solid var(--border-color, var(--gray-100)); }
.mc-thread-list { flex: 1; overflow-y: auto; }
.mc-thread-item { padding: 12px 16px; border-bottom: 1px solid var(--border-color, var(--gray-100)); cursor: pointer; transition: background 0.15s; }
.mc-thread-item:hover { background: var(--gray-50); }
.mc-thread-item.active { background: var(--brand-50, #eff6ff); border-left: 3px solid var(--brand-600); padding-left: 13px; }
.mc-thread-item.unread { background: rgba(37, 99, 235, 0.03); }

.mc-center { display: flex; flex-direction: column; overflow: hidden; }
.mc-center-header { padding: 14px 20px; border-bottom: 1px solid var(--border-color, var(--gray-200)); flex-shrink: 0; }
.mc-messages { flex: 1; overflow-y: auto; padding: 16px 20px; }
.mc-reply-bar { padding: 12px 16px; border-top: 1px solid var(--border-color, var(--gray-200)); display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0; }

.mc-bubble { padding: 10px 14px; border-radius: 16px; font-size: 13px; line-height: 1.5; word-break: break-word; }
.mc-bubble.outgoing { background: var(--brand-600); color: #fff; border-bottom-right-radius: 4px; }
.mc-bubble.incoming { background: var(--gray-100); color: var(--text-primary); border-bottom-left-radius: 4px; }
[data-theme="dark"] .mc-bubble.incoming { background: var(--gray-800, #1e293b); }

.mc-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }

.mc-right { border-left: 1px solid var(--border-color, var(--gray-200)); overflow-y: auto; padding: 16px; }

@media (max-width: 1024px) {
  .mc-layout { grid-template-columns: 280px 1fr; }
  .mc-layout .mc-right { display: none; }
}
@media (max-width: 768px) {
  .mc-layout { grid-template-columns: 1fr; height: auto; min-height: auto; }
  .mc-layout .mc-right { display: none; }
  .mc-layout.show-thread .mc-left { display: none; }
  .mc-layout:not(.show-thread) .mc-center { display: none; }
  .mc-back-btn { display: inline-flex !important; }
}

/* ─── Guided Tour ─── */
#tour-overlay { position: fixed; inset: 0; z-index: 99999; }
.tour-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); transition: opacity 0.3s; }
.tour-spotlight { position: fixed; border-radius: 8px; box-shadow: 0 0 0 9999px rgba(0,0,0,0.55); z-index: 1; pointer-events: none; transition: all 0.3s ease; }
.tour-card { position: fixed; z-index: 2; width: 300px; background: var(--surface-card, #fff); border-radius: 16px; padding: 20px; box-shadow: 0 12px 40px rgba(0,0,0,0.25); animation: tour-in 0.3s ease; }
@keyframes tour-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.tour-step-indicator { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--brand-500); margin-bottom: 6px; }
.tour-title { font-size: 16px; font-weight: 800; margin: 0 0 6px; color: var(--text-primary); }
.tour-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; margin: 0 0 16px; }
.tour-actions { display: flex; justify-content: space-between; align-items: center; }
.tour-skip { background: none; border: none; color: var(--text-tertiary); font-size: 12px; font-weight: 600; cursor: pointer; padding: 6px 0; }
.tour-skip:hover { color: var(--text-primary); }
.tour-next { background: var(--brand-600); color: #fff; border: none; padding: 8px 20px; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer; transition: background 0.15s; }
.tour-next:hover { background: var(--brand-700); }
.tour-dots { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }
.tour-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gray-300); transition: all 0.2s; }
.tour-dot.active { background: var(--brand-500); width: 18px; border-radius: 3px; }
.tour-dot.done { background: var(--brand-300); }
@media (max-width: 768px) {
  .tour-card { width: calc(100vw - 32px); left: 16px !important; bottom: 16px; top: auto !important; }
}
