/* ============================================================
   LBOS Design System — v1.0
   Brand: Navy #0B1F3A · Gold #C9A84C
   Style: Enterprise SaaS — clean, white, minimal shadows
   ============================================================ */

/* ============================================================
   1. CUSTOM PROPERTIES (DESIGN TOKENS)
   ============================================================ */
:root {
  /* Brand */
  --navy:           #0B1F3A;
  --navy-light:     #162f57;
  --navy-dark:      #071527;
  --gold:           #C9A84C;
  --gold-light:     #d9bb72;
  --gold-dark:      #a8872e;
  --gold-muted:     rgba(201, 168, 76, 0.12);

  /* Grays */
  --gray-50:        #f9fafb;
  --gray-100:       #f3f4f6;
  --gray-200:       #e5e7eb;
  --gray-300:       #d1d5db;
  --gray-400:       #9ca3af;
  --gray-500:       #6b7280;
  --gray-600:       #4b5563;
  --gray-700:       #374151;
  --gray-800:       #1f2937;
  --gray-900:       #111827;

  /* Semantic */
  --color-success:       #047857;
  --color-success-bg:    #d1fae5;
  --color-success-border:#a7f3d0;
  --color-danger:        #dc2626;
  --color-danger-bg:     #fee2e2;
  --color-danger-border: #fca5a5;
  --color-warning:       #d97706;
  --color-warning-bg:    #fef3c7;
  --color-warning-border:#fde68a;
  --color-info:          #2563eb;
  --color-info-bg:       #dbeafe;
  --color-info-border:   #bfdbfe;
  --color-orange:        #ea580c;
  --color-orange-bg:     #fff7ed;
  --color-orange-border: #fed7aa;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 10px 20px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);
  --shadow-xl:  0 25px 50px rgba(0,0,0,0.12);

  /* Border radius */
  --radius-sm:  4px;
  --radius-md:  6px;
  --radius-lg:  8px;
  --radius-xl:  12px;
  --radius-2xl: 16px;
  --radius-full: 9999px;

  /* Spacing scale */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

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

  --text-xs:   0.6875rem;
  --text-sm:   0.8125rem;
  --text-base: 0.875rem;
  --text-md:   0.9375rem;
  --text-lg:   1.0625rem;
  --text-xl:   1.125rem;
  --text-2xl:  1.375rem;
  --text-3xl:  1.75rem;

  --leading-tight:  1.25;
  --leading-normal: 1.5;
  --leading-relaxed:1.75;

  /* Layout */
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --content-max-w: none;

  /* Transitions */
  --transition-fast:   0.1s ease;
  --transition-normal: 0.15s ease;
  --transition-slow:   0.25s ease;
}


/* ============================================================
   2. RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--gray-900);
  background: var(--gray-50);
}

a {
  color: var(--gold);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--gold-dark); text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: var(--leading-tight);
  color: var(--navy);
}
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-md); }
h6 { font-size: var(--text-base); }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

ul, ol { padding-left: var(--space-6); }

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--gray-100);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  color: var(--navy);
}


/* ============================================================
   3. IMPERSONATION BANNER
   ============================================================ */
.impersonation-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: var(--color-orange);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: 0.5rem var(--space-6);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.35);
}

.impersonation-banner__icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.impersonation-banner__text {
  flex: 1;
  text-align: center;
}

.impersonation-banner__exit {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-md);
  padding: 0.25rem 0.875rem;
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition-fast);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-family: var(--font-ui);
}
.impersonation-banner__exit:hover { background: rgba(255,255,255,0.3); }

/* Shift layout when impersonation banner is active.
   The is-impersonating class is on .layout (not body),
   so selectors must match that. Sidebar and topbar are fixed/sticky
   so they need explicit top offsets. */
.layout.is-impersonating .sidebar {
  top: 36px;
}
.layout.is-impersonating .topbar {
  top: 36px;
}
.layout.is-impersonating .main {
  padding-top: 36px;
}


/* ============================================================
   4. LAYOUT SHELL
   ============================================================ */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-slow);
}

.sidebar-logo {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.sidebar-logo .wordmark {
  font-size: 1.375rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.03em;
  line-height: 1;
}
.sidebar-logo .wordmark span { color: var(--gold); }

.sidebar-logo .tagline {
  font-size: var(--text-xs);
  color: rgba(255, 255, 255, 0.6);
  margin-top: 0.3rem;
  letter-spacing: 0.01em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: var(--radius-full); }

.nav-section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.875rem 1.25rem 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5625rem 1.25rem;
  font-size: var(--text-base);
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  position: relative;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--gold);
  text-decoration: none;
}

.nav-item.active {
  color: var(--gold);
  border-left-color: var(--gold);
  background: var(--gold-muted);
}
.nav-item.active:hover { background: rgba(201, 168, 76, 0.16); }

.nav-icon {
  width: 18px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
  opacity: 1;
  color: #fff;
  transition: color var(--transition-fast);
}
.nav-item:hover .nav-icon { color: var(--gold); }
.nav-item.active .nav-icon { color: var(--gold); opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--gold);
  color: var(--navy);
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  line-height: 1.4;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: var(--space-4) 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-info {
  margin-bottom: var(--space-3);
}

.user-name {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  font-size: var(--text-xs);
  color: var(--gold);
  letter-spacing: 0.01em;
}

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

/* ---- TOPBAR ---- */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.topbar-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.01em;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--gray-400);
}
.topbar-breadcrumb a { color: var(--gray-500); }
.topbar-breadcrumb a:hover { color: var(--navy); }
.topbar-breadcrumb .sep { color: var(--gray-300); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Hamburger for mobile */
.sidebar-toggle {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
  color: var(--gray-600);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}
.sidebar-toggle:hover { background: var(--gray-100); }

/* ---- CONTENT ---- */
.content {
  padding: 1.75rem;
  flex: 1;
  max-width: var(--content-max-w);
  width: 100%;
}

.content-full {
  padding: 1.75rem;
  flex: 1;
}


/* ============================================================
   5. PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}

.page-header-left { flex: 1; min-width: 0; }

.page-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-subtitle {
  font-size: var(--text-base);
  color: var(--gray-500);
  margin-top: 0.25rem;
  font-weight: 400;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}


/* ============================================================
   6. BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.5rem 1.125rem;
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast), box-shadow var(--transition-fast),
              opacity var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
}
.btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Sizes */
.btn-xs { padding: 0.25rem 0.625rem; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-sm { padding: 0.375rem 0.875rem; font-size: var(--text-sm); }
.btn-lg { padding: 0.6875rem 1.5rem; font-size: var(--text-md); }
.btn-xl { padding: 0.875rem 2rem;    font-size: var(--text-lg); border-radius: var(--radius-lg); }

/* Variants */
.btn-primary {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold);
}
.btn-primary:hover {
  background: var(--gold-dark);
  border-color: var(--gold-dark);
  color: var(--navy);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.btn-secondary:hover {
  background: var(--navy-light);
  border-color: var(--navy-light);
  color: #fff;
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border-color: var(--gray-300);
}
.btn-ghost:hover {
  background: var(--gray-50);
  color: var(--gray-900);
  border-color: var(--gray-400);
  text-decoration: none;
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
  text-decoration: none;
}

.btn-danger-ghost {
  background: transparent;
  color: var(--color-danger);
  border-color: var(--color-danger-border);
}
.btn-danger-ghost:hover {
  background: var(--color-danger-bg);
  border-color: var(--color-danger);
  text-decoration: none;
}

.btn-success {
  background: var(--color-success);
  color: #fff;
  border-color: var(--color-success);
}
.btn-success:hover { background: #035f44; color: #fff; text-decoration: none; }

.btn-outline-navy {
  background: transparent;
  color: var(--navy);
  border-color: var(--navy);
}
.btn-outline-navy:hover { background: var(--navy); color: #fff; text-decoration: none; }

/* Icon-only button */
.btn-icon {
  padding: 0.5rem;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-md);
}
.btn-icon.btn-sm { width: 1.75rem; height: 1.75rem; padding: 0.3125rem; }

/* Full-width */
.btn-block { width: 100%; }

/* Loading state */
.btn-loading { position: relative; color: transparent; pointer-events: none; }
.btn-loading::after {
  content: '';
  position: absolute;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}


/* ============================================================
   7. CARDS
   ============================================================ */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: var(--space-6);
  box-shadow: var(--shadow-xs);
}

.card-sm { padding: var(--space-4); }
.card-lg { padding: var(--space-8); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--gray-100);
}

.card-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.01em;
}
.card-subtitle {
  font-size: var(--text-sm);
  color: var(--gray-500);
  margin-top: 0.125rem;
}

.card-body { flex: 1; }

.card-footer {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Hover card */
.card-hover {
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
  cursor: pointer;
}
.card-hover:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}


/* ============================================================
   8. STAT CARDS
   ============================================================ */
.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 1.25rem 1.5rem 1.375rem;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gray-200);
}

.stat-gold::before   { background: var(--gold); }
.stat-navy::before   { background: var(--navy); }
.stat-green::before  { background: var(--color-success); }
.stat-red::before    { background: var(--color-danger); }
.stat-blue::before   { background: var(--color-info); }
.stat-orange::before { background: var(--color-orange); }

.stat-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--navy);
  margin-top: 0.3rem;
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-meta {
  font-size: var(--text-xs);
  color: var(--gray-400);
  margin-top: var(--space-2);
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: var(--text-xs);
  font-weight: 600;
  margin-top: var(--space-1);
}
.stat-change.up   { color: var(--color-success); }
.stat-change.down { color: var(--color-danger); }

/* Stat grid helper */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stats-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stats-grid-2 { grid-template-columns: repeat(2, 1fr); }


/* ============================================================
   9. BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-gold    { background: var(--color-warning-bg);  color: #92400e; }
.badge-green   { background: var(--color-success-bg);  color: var(--color-success); }
.badge-red     { background: var(--color-danger-bg);   color: var(--color-danger); }
.badge-gray    { background: var(--gray-100);          color: var(--gray-600); }
.badge-navy    { background: var(--navy);              color: #fff; }
.badge-blue    { background: var(--color-info-bg);     color: var(--color-info); }
.badge-orange  { background: var(--color-orange-bg);   color: var(--color-orange); }
.badge-purple  { background: #f3e8ff;                  color: #7c3aed; }
.badge-teal    { background: #ccfbf1;                  color: #0f766e; }

/* Role-specific badges */
.badge-role-client    { background: var(--color-info-bg);    color: var(--color-info); }
.badge-role-advisor   { background: var(--color-success-bg); color: var(--color-success); }
.badge-role-lwcg      { background: var(--navy);             color: var(--gold); }

/* Outline badges */
.badge-outline {
  background: transparent;
  border: 1px solid currentColor;
}

/* Dot indicator */
.badge-dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  flex-shrink: 0;
}


/* ============================================================
   10. TABLES
   ============================================================ */
.table-wrap {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

.table th {
  text-align: left;
  padding: 0.6875rem 1rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
  font-size: var(--text-xs);
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}

/* Sortable column header */
.th-sortable {
  cursor: pointer;
  transition: color var(--transition-fast);
}
.th-sortable:hover { color: var(--navy); }
.th-sortable::after {
  content: ' ↕';
  opacity: 0.4;
  font-size: 0.7em;
}
.th-sort-asc::after  { content: ' ↑'; opacity: 1; color: var(--gold); }
.th-sort-desc::after { content: ' ↓'; opacity: 1; color: var(--gold); }

.table td {
  padding: 0.8125rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table tbody tr {
  transition: background var(--transition-fast);
}
.table tbody tr:hover td {
  background: var(--gray-50);
}

/* Table footer for pagination / summary */
.table-footer {
  padding: 0.75rem 1rem;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-sm);
  color: var(--gray-500);
}

/* Cell helpers */
.td-mono  { font-family: var(--font-mono); font-size: 0.8125rem; }
.td-right { text-align: right; }
.td-center { text-align: center; }
.td-truncate { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Empty state inside table */
.table-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-400);
}
.table-empty-icon { font-size: 2.5rem; margin-bottom: var(--space-3); opacity: 0.5; }
.table-empty-msg  { font-size: var(--text-md); font-weight: 600; color: var(--gray-500); }
.table-empty-sub  { font-size: var(--text-sm); margin-top: var(--space-2); }


/* ============================================================
   11. FORMS
   ============================================================ */
.form-group {
  margin-bottom: 1.125rem;
}

.form-group:last-child { margin-bottom: 0; }

label, .label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.375rem;
  line-height: 1.4;
}

.label-optional {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--gray-400);
  margin-left: 0.25rem;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--gray-500);
  margin-top: 0.3rem;
}
.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  margin-top: 0.3rem;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
textarea,
select {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--gray-900);
  background: #fff;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.15);
}

input::placeholder,
textarea::placeholder {
  color: var(--gray-400);
}

input:disabled,
textarea:disabled,
select:disabled {
  background: var(--gray-50);
  color: var(--gray-400);
  cursor: not-allowed;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

textarea { resize: vertical; min-height: 100px; }

/* Input with prefix/suffix icon */
.input-group {
  position: relative;
}
.input-prefix,
.input-suffix {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: var(--text-base);
  pointer-events: none;
}
.input-prefix { left: 0.75rem; }
.input-suffix { right: 0.75rem; }
.input-group input[type="text"],
.input-group input[type="email"],
.input-group input[type="search"] {
  padding-left: 2.25rem;
}
.input-group.has-suffix input { padding-right: 2.25rem; }

/* Error state */
.input-error {
  border-color: var(--color-danger) !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1) !important;
}

/* Checkbox and radio */
input[type="checkbox"],
input[type="radio"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--gold);
  cursor: pointer;
}

.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}
.form-check input { flex-shrink: 0; }
.form-check label { margin-bottom: 0; cursor: pointer; }

/* Inline form */
.form-inline {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.form-inline .form-group { margin-bottom: 0; flex: 1; }

/* Search bar */
.search-bar {
  position: relative;
  max-width: 320px;
}
.search-bar input {
  padding-left: 2.25rem;
  padding-right: var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  height: 36px;
}
.search-bar__icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 0.875rem;
  pointer-events: none;
}


/* ============================================================
   12. ALERTS / NOTIFICATIONS
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  border: 1px solid transparent;
  margin-bottom: var(--space-4);
}

.alert-icon { flex-shrink: 0; font-size: 1rem; margin-top: 0.1rem; }
.alert-body { flex: 1; }
.alert-title { font-weight: 700; margin-bottom: 0.2rem; font-size: var(--text-base); }
.alert-close {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  font-size: 1rem;
  padding: 0;
  flex-shrink: 0;
}
.alert-close:hover { opacity: 1; }

.alert-error   { background: var(--color-danger-bg);  color: var(--color-danger);  border-color: var(--color-danger-border); }
.alert-success { background: var(--color-success-bg); color: var(--color-success); border-color: var(--color-success-border); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: var(--color-warning-border); }
.alert-info    { background: var(--color-info-bg);    color: var(--color-info);    border-color: var(--color-info-border); }


/* ============================================================
   13. MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 31, 58, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--space-4);
}

.modal-box {
  background: #fff;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  padding: 2rem;
  box-shadow: var(--shadow-xl);
  position: relative;
  animation: modal-in 0.18s ease;
}

.modal-box-lg { max-width: 720px; }
.modal-box-sm { max-width: 360px; }

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.02em;
}
.modal-subtitle { font-size: var(--text-sm); color: var(--gray-500); margin-top: 0.2rem; }

.modal-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 1.25rem;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
  margin-left: var(--space-3);
}
.modal-close:hover { color: var(--gray-700); background: var(--gray-100); }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--gray-100);
}


/* ============================================================
   14. TABS
   ============================================================ */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: var(--space-6);
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.625rem 1.125rem;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  text-decoration: none;
}
.tab-item:hover { color: var(--navy); text-decoration: none; }
.tab-item.active {
  color: var(--navy);
  border-bottom-color: var(--gold);
  font-weight: 700;
}

.tab-count {
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
}
.tab-item.active .tab-count {
  background: var(--gold-muted);
  color: var(--gold-dark);
}


/* ============================================================
   15. AVATAR
   ============================================================ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  text-transform: uppercase;
}

.avatar-xs { width: 1.5rem;  height: 1.5rem;  font-size: 0.5rem; }
.avatar-sm { width: 2rem;    height: 2rem;    font-size: 0.6875rem; }
.avatar-md { width: 2.5rem;  height: 2.5rem;  font-size: 0.875rem; }
.avatar-lg { width: 3rem;    height: 3rem;    font-size: 1.125rem; }
.avatar-xl { width: 4rem;    height: 4rem;    font-size: 1.5rem; }

/* Color variants for initials */
.avatar-navy   { background: var(--navy);  color: var(--gold); }
.avatar-gold   { background: var(--gold);  color: var(--navy); }
.avatar-blue   { background: #dbeafe;      color: #1e40af; }
.avatar-green  { background: #d1fae5;      color: #065f46; }
.avatar-purple { background: #ede9fe;      color: #6d28d9; }
.avatar-red    { background: #fee2e2;      color: #991b1b; }
.avatar-teal   { background: #ccfbf1;      color: #115e59; }
.avatar-orange { background: #ffedd5;      color: #9a3412; }


/* ============================================================
   16. DROPDOWN / ACTION MENU
   ============================================================ */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 160px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  overflow: hidden;
  animation: dropdown-in 0.12s ease;
}

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

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.5625rem 1rem;
  font-size: var(--text-base);
  color: var(--gray-700);
  cursor: pointer;
  transition: background var(--transition-fast);
  text-decoration: none;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-ui);
}

.dropdown-item:hover { background: var(--gray-50); color: var(--navy); text-decoration: none; }
.dropdown-item.danger { color: var(--color-danger); }
.dropdown-item.danger:hover { background: var(--color-danger-bg); }

.dropdown-divider {
  height: 1px;
  background: var(--gray-100);
  margin: var(--space-1) 0;
}

.dropdown-header {
  padding: 0.375rem 1rem;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}


/* ============================================================
   17. EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--gray-400);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.empty-state-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--gray-600);
  margin-bottom: var(--space-2);
}

.empty-state-description {
  font-size: var(--text-base);
  max-width: 380px;
  margin-bottom: var(--space-6);
  line-height: var(--leading-relaxed);
}


/* ============================================================
   18. PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  background: #fff;
}
.page-link:hover { background: var(--gray-50); border-color: var(--gray-300); text-decoration: none; }
.page-link.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.page-link:disabled { opacity: 0.4; cursor: not-allowed; }


/* ============================================================
   19. UTILITY CLASSES
   ============================================================ */

/* Flex helpers */
.flex      { display: flex; }
.flex-col  { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.flex-1    { flex: 1; }
.gap-1     { gap: var(--space-1); }
.gap-2     { gap: var(--space-2); }
.gap-3     { gap: var(--space-3); }
.gap-4     { gap: var(--space-4); }
.gap-6     { gap: var(--space-6); }
.flex-wrap { flex-wrap: wrap; }

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

/* Spacing */
.mt-1  { margin-top: var(--space-1); }
.mt-2  { margin-top: var(--space-2); }
.mt-3  { margin-top: var(--space-3); }
.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mt-8  { margin-top: var(--space-8); }
.mb-1  { margin-bottom: var(--space-1); }
.mb-2  { margin-bottom: var(--space-2); }
.mb-3  { margin-bottom: var(--space-3); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.mb-8  { margin-bottom: var(--space-8); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

/* Text */
.text-xs  { font-size: var(--text-xs); }
.text-sm  { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg  { font-size: var(--text-lg); }
.text-xl  { font-size: var(--text-xl); }
.text-navy   { color: var(--navy); }
.text-gold   { color: var(--gold); }
.text-muted  { color: var(--gray-400); }
.text-light  { color: var(--gray-500); }
.text-dark   { color: var(--gray-700); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.font-mono   { font-family: var(--font-mono); }
.font-bold   { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Misc */
.divider {
  height: 1px;
  background: var(--gray-200);
  margin: var(--space-4) 0;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}

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

/* Dot separator */
.dot-sep::before {
  content: '·';
  margin: 0 var(--space-2);
  color: var(--gray-300);
}


/* ============================================================
   20. HTMX HELPERS
   ============================================================ */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.htmx-indicator { display: inline-block; }

@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  display: inline-block;
  width: 1rem; height: 1rem;
  border: 2px solid var(--gray-200);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.spinner-sm { width: 0.75rem; height: 0.75rem; }
.spinner-lg { width: 1.5rem; height: 1.5rem; }


/* ============================================================
   21. DRAG AND DROP KANBAN
   ============================================================ */
.kanban-board {
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  align-items: flex-start;
  padding-bottom: var(--space-4);
}

.kanban-column {
  flex-shrink: 0;
  width: 280px;
  background: var(--gray-100);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  padding: var(--space-1) var(--space-1);
}

.kanban-column-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kanban-count {
  background: var(--gray-300);
  color: var(--gray-600);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
}

.kanban-card {
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-2);
  cursor: grab;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition-fast);
}
.kanban-card:hover { box-shadow: var(--shadow-sm); }
.kanban-card.dragging { opacity: 0.5; cursor: grabbing; }


/* ============================================================
   22. RESPONSIVE — SIDEBAR MOBILE COLLAPSE
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 31, 58, 0.5);
  z-index: 99;
  backdrop-filter: blur(1px);
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-overlay.is-open {
    display: block;
  }

  .main {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: flex;
  }

  .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Sidebar is hidden off-canvas — hamburger (sidebar-toggle) reveals it */
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.is-open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0 !important;
    padding: 0 !important;
  }

  .sidebar-toggle {
    display: flex;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
  }
  .stats-grid-4 {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Kanban/engagement board columns stack vertically */
  .board {
    flex-direction: column !important;
  }
  .board-col {
    flex: none !important;
    width: 100% !important;
  }

  table {
    font-size: 0.8125rem;
  }

  .topbar {
    padding: 0.75rem 1rem !important;
  }
}

@media (max-width: 640px) {
  .content, .content-full { padding: var(--space-4); }
  .topbar { padding: 0 var(--space-4); }

  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header-actions { width: 100%; }

  .stats-grid-4 { grid-template-columns: 1fr; }
  .stats-grid-3 { grid-template-columns: 1fr; }
  .stats-grid-2 { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  .modal-box { padding: 1.25rem; }
  .kanban-board { flex-direction: column; }
  .kanban-column { width: 100%; }

  .table th, .table td { padding: 0.625rem 0.625rem; }
}

/* ============================================================
   DARK MODE
   Toggle via html[data-theme="dark"]. Stored in localStorage.
   ============================================================ */
html[data-theme="dark"] {
  /* Neutrals - invert the gray scale */
  --gray-50:  #0d1117;
  --gray-100: #161b22;
  --gray-200: #21262d;
  --gray-300: #30363d;
  --gray-400: #a0aab4;
  --gray-500: #b8c4ce;
  --gray-600: #d0d8e0;
  --gray-700: #dde2e8;
  --gray-800: #eaecef;
  --gray-900: #f0f6fc;

  /* Success/danger/warning - muted for dark */
  --color-success:        #3fb950;
  --color-success-bg:     #0d2817;
  --color-success-border: #1a4a2b;
  --color-danger:         #f85149;
  --color-danger-bg:      #2d0f0e;
  --color-danger-border:  #6e1a18;
  --color-warning:        #e3b341;
  --color-warning-bg:     #2d1f02;
  --color-warning-border: #5e4202;
  --color-info:           #58a6ff;
  --color-info-bg:        #051d4d;
  --color-info-border:    #0d419d;
  --color-orange:         #f0883e;
  --color-orange-bg:      #2d1500;
}

html[data-theme="dark"] body {
  background: var(--gray-50);
  color: var(--gray-900);
}

/* Cards */
html[data-theme="dark"] .card,
html[data-theme="dark"] .stat-card {
  background: var(--gray-100);
  border-color: var(--gray-200);
}

/* Topbar */
html[data-theme="dark"] .rf-topbar {
  background: var(--gray-100);
  border-bottom-color: var(--gray-200);
}

/* Main content area */
html[data-theme="dark"] .rf-main {
  background: var(--gray-50);
}

html[data-theme="dark"] .rf-shell {
  background: var(--gray-50);
}

/* Form inputs */
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background: var(--gray-200);
  border-color: var(--gray-300);
  color: var(--gray-900);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: var(--gray-400);
}

/* Tables */
html[data-theme="dark"] table {
  color: var(--gray-900);
}

html[data-theme="dark"] th {
  background: var(--gray-200);
  border-bottom-color: var(--gray-300);
  color: var(--gray-600);
}

html[data-theme="dark"] td {
  border-bottom-color: var(--gray-200);
}

html[data-theme="dark"] tr:hover td {
  background: var(--gray-200);
}

/* Headings */
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6 {
  color: var(--gray-900);
}

/* Page header */
html[data-theme="dark"] .page-title {
  color: var(--gray-900);
}

html[data-theme="dark"] .page-subtitle {
  color: var(--gray-500);
}

/* Badges */
html[data-theme="dark"] .badge {
  filter: brightness(0.85);
}

/* Topbar search */
html[data-theme="dark"] .rf-search {
  background: var(--gray-200);
  border-color: var(--gray-300);
  color: var(--gray-500);
}

/* Dropdowns / menus */
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #fff"] {
  background: var(--gray-100) !important;
  border-color: var(--gray-200) !important;
}

/* Help bubble panel */
html[data-theme="dark"] #help-panel {
  background: var(--gray-100) !important;
}

html[data-theme="dark"] .help-msg--ai .help-msg__body {
  background: var(--gray-200) !important;
  color: var(--gray-900) !important;
}

html[data-theme="dark"] #help-input {
  background: var(--gray-200) !important;
  border-color: var(--gray-300) !important;
  color: var(--gray-900) !important;
}

/* Stat cards */
html[data-theme="dark"] .stat-label {
  color: var(--gray-500);
}

html[data-theme="dark"] .stat-value {
  color: var(--gray-900);
}

/* Dividers / borders */
html[data-theme="dark"] hr,
html[data-theme="dark"] .divider {
  border-color: var(--gray-200);
}

/* Buttons in dark mode — reset browser default white background */
html[data-theme="dark"] .btn {
  background: transparent;
  color: var(--gray-700);
}

html[data-theme="dark"] .btn-primary {
  background: var(--gold);
  color: #0B1F3A;
  border-color: var(--gold);
}

html[data-theme="dark"] .btn-secondary {
  background: #1e3a5c;
  color: var(--gray-900);
  border-color: #2a4f7a;
}

html[data-theme="dark"] .btn-ghost,
html[data-theme="dark"] .btn-outline {
  background: transparent;
  border-color: var(--gray-300);
  color: var(--gray-700);
}

html[data-theme="dark"] .btn-ghost:hover,
html[data-theme="dark"] .btn-outline:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}

/* Chat messages */
html[data-theme="dark"] #messages {
  background: var(--gray-100) !important;
}

html[data-theme="dark"] .chat-msg .msg-bubble {
  background: var(--gray-200);
  color: var(--gray-900);
}

/* ---- Step 1: redefine --navy and --gold in dark mode ---- */
html[data-theme="dark"] {
  --navy:      #ffffff;
  --navy-dark: #b8d4ea;
  --gold:      #f0b429;
  --gold-dark: #d4981f;
}

/* ---- Step 2: inline style="color:var(--navy)" ---- */
html[data-theme="dark"] [style*="color:var(--navy)"],
html[data-theme="dark"] [style*="color: var(--navy)"] {
  color: var(--navy) !important;
}

/* ---- Step 4: inline background:var(--navy) inside content cards ---- */
html[data-theme="dark"] [style*="background:var(--navy)"],
html[data-theme="dark"] [style*="background: var(--navy)"] {
  background: #1a3a5c !important;
  color: #e8f0f8 !important;
}

/* ---- Step 6: hardcoded near-black text colors ---- */
html[data-theme="dark"] [style*="color:#374151"],
html[data-theme="dark"] [style*="color: #374151"],
html[data-theme="dark"] [style*="color:#1f2937"],
html[data-theme="dark"] [style*="color: #1f2937"],
html[data-theme="dark"] [style*="color:#111827"],
html[data-theme="dark"] [style*="color: #111827"],
html[data-theme="dark"] [style*="color:#0f172a"],
html[data-theme="dark"] [style*="color: #0f172a"] {
  color: var(--gray-800) !important;
}

/* ---- Step 7: hardcoded mid-gray text colors ---- */
html[data-theme="dark"] [style*="color:#6b7280"],
html[data-theme="dark"] [style*="color: #6b7280"],
html[data-theme="dark"] [style*="color:#9ca3af"],
html[data-theme="dark"] [style*="color: #9ca3af"] {
  color: var(--gray-500) !important;
}

/* ---- Step 8: hardcoded white / light-gray backgrounds ---- */
html[data-theme="dark"] [style*="background:#ffffff"],
html[data-theme="dark"] [style*="background: #ffffff"],
html[data-theme="dark"] [style*="background:white"],
html[data-theme="dark"] [style*="background: white"],
html[data-theme="dark"] [style*="background:#f9fafb"],
html[data-theme="dark"] [style*="background: #f9fafb"],
html[data-theme="dark"] [style*="background:#f3f4f6"],
html[data-theme="dark"] [style*="background: #f3f4f6"] {
  background: var(--gray-100) !important;
}

/* ---- Step 9: hardcoded light border colors ---- */
html[data-theme="dark"] [style*="border:1px solid #e5e7eb"],
html[data-theme="dark"] [style*="border: 1px solid #e5e7eb"],
html[data-theme="dark"] [style*="border-color:#e5e7eb"],
html[data-theme="dark"] [style*="border-bottom:1px solid var(--gray-100)"],
html[data-theme="dark"] [style*="border-bottom: 1px solid var(--gray-100)"] {
  border-color: var(--gray-300) !important;
}

/* ---- Step 12: date and time inputs ---- */
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="time"] {
  background: var(--gray-200);
  border-color: var(--gray-300);
  color: var(--gray-900);
}

/* ---- Step 13: label text color ---- */
html[data-theme="dark"] label,
html[data-theme="dark"] .form-group label {
  color: var(--gray-700);
}

/* ---- Step 14: card base text ---- */
html[data-theme="dark"] .card {
  color: var(--gray-800);
}

/* ---- Inline signal badge backgrounds — flip to dark equivalents ---- */
html[data-theme="dark"] [style*="background:#fee2e2"][style*="color:#dc2626"] {
  background: #3d1414 !important;
  color: #f87171 !important;
}
html[data-theme="dark"] [style*="background:#fef3c7"][style*="color:#d97706"] {
  background: #3d2c00 !important;
  color: #fbbf24 !important;
}
html[data-theme="dark"] [style*="background:#eff6ff"][style*="color:#1d4ed8"] {
  background: #0c1f4a !important;
  color: #60a5fa !important;
}
html[data-theme="dark"] [style*="background:#d1fae5"][style*="color:#065f46"] {
  background: #0d2e1f !important;
  color: #34d399 !important;
}
/* Alert boxes */
html[data-theme="dark"] [style*="background:#fee2e2"] {
  background: #3d1414 !important;
  color: #f87171 !important;
  border-color: #6e2424 !important;
}
html[data-theme="dark"] [style*="background:#fef3c7"] {
  background: #3d2c00 !important;
  color: #fbbf24 !important;
  border-color: #5e4202 !important;
}
html[data-theme="dark"] [style*="background:#d1fae5"] {
  background: #0d2e1f !important;
  color: #34d399 !important;
  border-color: #1a4a2b !important;
}
html[data-theme="dark"] [style*="background:#dbeafe"] {
  background: #0c1f4a !important;
  color: #60a5fa !important;
  border-color: #1e3a7a !important;
}

/* Sidebar stays dark (already dark navy) but tweak for dark mode */
html[data-theme="dark"] .rf-sidebar {
  background: linear-gradient(180deg, #07152a 0%, #0B1F3A 100%);
}

/* Modals */
html[data-theme="dark"] [style*="background:#fff"] {
  background: var(--gray-100) !important;
}

/* Empty states */
html[data-theme="dark"] .empty-state-title {
  color: var(--gray-900);
}

html[data-theme="dark"] .empty-state-description,
html[data-theme="dark"] .empty-state-body {
  color: var(--gray-500);
}

/* Dashboard home stat cards  */
html[data-theme="dark"] [style*="background:var(--gray-50)"],
html[data-theme="dark"] [style*="background: var(--gray-50)"] {
  background: var(--gray-200) !important;
}

/* Scrollbars */
html[data-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--gray-100);
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--gray-300);
}

/* ============================================================
   HARDCODED DARK MODE TEXT OVERRIDES
   Bypass CSS variable resolution entirely — these use #hex
   values so they work regardless of variable cascade issues.
   ============================================================ */

/* CSS classes that set color: var(--navy) */
html[data-theme="dark"] .card-title,
html[data-theme="dark"] .page-title,
html[data-theme="dark"] .stat-value,
html[data-theme="dark"] .rf-topbar-title {
  color: #ffffff !important;
}

/* Inline style="...color:var(--navy)..." on any element */
html[data-theme="dark"] [style*="color:var(--navy)"],
html[data-theme="dark"] [style*="color: var(--navy)"] {
  color: #ffffff !important;
}

/* Navy backgrounds used for badge circles, pills, filled buttons */
html[data-theme="dark"] [style*="background:var(--navy)"],
html[data-theme="dark"] [style*="background: var(--navy)"],
html[data-theme="dark"] .badge-navy,
html[data-theme="dark"] .btn-secondary {
  background: #1e3a5c !important;
  color: #ffffff !important;
}

/* .card-header border uses var(--gray-100) which is fine, but reinforce title */
html[data-theme="dark"] .card-header {
  border-bottom-color: #21262d;
}

/* th and td text that use var(--navy) via inline */
html[data-theme="dark"] th[style*="color:var(--navy)"],
html[data-theme="dark"] td[style*="color:var(--navy)"],
html[data-theme="dark"] th[style*="color: var(--navy)"],
html[data-theme="dark"] td[style*="color: var(--navy)"] {
  color: #ffffff !important;
}

/* Link text using var(--navy) */
html[data-theme="dark"] a[style*="color:var(--navy)"],
html[data-theme="dark"] a[style*="color: var(--navy)"] {
  color: #5ba8f5 !important;
}

/* .help-msg uses var(--navy) for AI body and user label */
html[data-theme="dark"] .help-msg--ai .help-msg__body {
  background: #21262d !important;
  color: #ffffff !important;
}
html[data-theme="dark"] .help-msg--user .help-msg__label {
  color: #5ba8f5 !important;
}
html[data-theme="dark"] .help-msg--user .help-msg__body {
  background: #1e3a5c !important;
  color: #ffffff !important;
}

/* btn-outline-navy */
html[data-theme="dark"] .btn-outline-navy {
  color: #ffffff !important;
  border-color: #4a7aac !important;
  background: transparent !important;
}

/* ============================================================
   TOPBAR v2  (.tb-*)
   Three-zone header: left (burger + breadcrumb),
   center (search), right (actions + dropdowns).
   Namespaced to avoid collision with legacy .rf-topbar rules.
   Uses existing brand CSS custom properties from :root above.
   ============================================================ */

/* Shell */
.tb {
  display: flex;
  align-items: center;
  height: var(--topbar-height, 56px);
  padding: 0 1rem;
  gap: 0.75rem;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
}

/* Zones */
.tb-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  min-width: 0;
}

.tb-center {
  flex: 1 1 0;
  min-width: 0;
  max-width: 560px;
  margin: 0 auto;
}

.tb-right {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
  margin-left: auto;
}

/* Burger button */
.tb-burger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: color var(--transition-fast);
  flex-shrink: 0;
}
.tb-burger:hover { color: var(--navy); }

/* Breadcrumb */
.tb-crumb {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
}
.tb-crumb a {
  color: var(--gray-500);
  text-decoration: none;
  font-weight: 500;
}
.tb-crumb a:hover { color: var(--navy); }
.tb-crumb .sep {
  color: var(--gray-300);
  font-size: 0.75rem;
}
.tb-crumb b {
  color: var(--navy);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Role switcher - dual-role (client + advisor) topbar control, .tb-left zone */
.role-switcher {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--gray-200);
  gap: 0.125rem;
}
.role-switcher-opt {
  font-size: 0.6875rem;
  font-weight: 600;
  font-family: var(--font-ui);
  line-height: 1;
  white-space: nowrap;
  padding: 0.3125rem 0.5rem;
  border-radius: 999px;
  color: var(--gray-500);
  text-decoration: none;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}
.role-switcher-opt:hover:not(.is-active) { color: var(--navy); background: var(--gray-100); }
.role-switcher-opt.is-active {
  background: var(--navy);
  color: #fff;
  cursor: default;
}

/* Search */
.tb-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 0.3rem 0.3rem 0.3rem 0.75rem;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tb-search:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}
.tb-search svg { flex-shrink: 0; color: var(--gray-400); }
.tb-search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.875rem;
  font-family: var(--font-ui);
  color: var(--navy);
  min-width: 0;
}
.tb-search input::placeholder { color: var(--gray-400); }

/* Kbd chips */
.tb-kbd {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}
.tb-kbd kbd {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--gray-400);
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  padding: 0.1rem 0.3rem;
  font-family: var(--font-ui);
  line-height: 1.4;
}

/* Generic action button */
.tb-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 8px;
  border: 1.5px solid var(--gray-200);
  background: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
  font-family: var(--font-ui);
}
.tb-btn:hover { border-color: var(--gold); }
.tb-btn.open { border-color: var(--gold); background: #fffbf0; }

/* Ask AI variant */
.tb-btn-ai {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--gold);
}
.tb-btn-ai:hover { background: var(--navy-light); border-color: var(--navy-light); }
.tb-btn-ai.open { background: var(--navy-light); border-color: var(--navy-light); }

/* Icon-only button */
.tb-iconbtn {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--gray-500);
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.tb-iconbtn:hover { border-color: var(--gold); color: var(--gold); }

/* Vertical divider */
.tb-divider {
  width: 1px;
  height: 20px;
  background: var(--gray-200);
  flex-shrink: 0;
}

/* Start Session button */
.tb-start {
  background: transparent;
  border: 1.5px solid var(--navy);
  color: var(--navy);
  font-weight: 700;
  font-size: 0.8125rem;
}
.tb-start:hover { background: var(--navy); color: #fff; }

/* Invite Client button */
.tb-invite {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--navy);
  font-weight: 700;
}
.tb-invite:hover { background: var(--gold-dark); border-color: var(--gold-dark); }

/* Dropdown popover */
.tb-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 9200;
  min-width: 300px;
  max-width: 380px;
  background: #fff;
  border: 1.5px solid var(--gray-200);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(11,31,58,0.14);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.tb-pop-head {
  padding: 0.875rem 1rem 0.625rem;
  border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}
.tb-pop-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--navy);
}
.tb-pop-sub {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 0.125rem;
}
.tb-pop-body {
  overflow-y: auto;
  max-height: 480px;
  padding: 0.5rem 0;
}

/* Ask AI textarea */
.tb-ai-input {
  width: 100%;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: var(--font-ui);
  color: var(--navy);
  resize: none;
  outline: none;
  line-height: 1.5;
  background: var(--gray-50);
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.tb-ai-input:focus { border-color: var(--gold); background: #fff; }

/* Ask AI send button */
.tb-ai-send {
  margin-top: 0.5rem;
  width: 100%;
  padding: 0.5rem;
  background: var(--navy);
  color: var(--gold);
  border: none;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: background 0.15s;
}
.tb-ai-send:hover { background: var(--navy-light); }
.tb-ai-send:disabled { opacity: 0.55; cursor: not-allowed; }

/* Suggested prompts label */
.tb-suglabel {
  font-size: 0.6375rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--gray-400);
  padding: 0.5rem 1rem 0.25rem;
}

/* Dropdown list item */
.tb-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-ui);
  text-decoration: none;
  transition: background 0.1s;
}
.tb-item:hover { background: var(--gray-50); color: var(--navy); }
.tb-item.active { background: #f0f4ff; color: var(--navy); font-weight: 700; }

.tb-item-ico {
  flex-shrink: 0;
  color: var(--gray-400);
  display: flex;
  align-items: center;
}
.tb-item-t {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tb-item-s {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--gold);
  min-width: 1.125rem;
  text-align: right;
}
.tb-item-go {
  flex-shrink: 0;
  color: var(--gray-300);
}

/* Playbook menu item (aliased) */
.tb-menu-item { /* same as .tb-item */ }

/* Alpine x-cloak */
[x-cloak] { display: none !important; }

/* Answer area inside the AI pop */
#tb-ai-answer {
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--navy);
  white-space: pre-line;
  font-family: Georgia, 'Times New Roman', serif;
  padding: 0.75rem 0 0;
  min-height: 2.5rem;
}

/* Responsive */
@media (max-width: 1024px) {
  .tb-center { max-width: 100%; }
  .tb-crumb b { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 768px) {
  .tb-center { display: none; }
  .tb-right .tb-btn span:not(.tb-btn-icon) { display: none; }
  .tb-kbd { display: none !important; }
}

@media (max-width: 480px) {
  .tb { padding: 0 0.625rem; gap: 0.5rem; }
  .tb-right { gap: 0.25rem; }
}

/* Dark mode overrides for .tb */
html[data-theme="dark"] .tb {
  background: var(--navy-dark);
  border-bottom-color: rgba(255,255,255,0.08);
}
html[data-theme="dark"] .tb-crumb a,
html[data-theme="dark"] .tb-crumb { color: rgba(255,255,255,0.5); }
html[data-theme="dark"] .tb-crumb b { color: #fff; }
html[data-theme="dark"] .role-switcher { border-left-color: rgba(255,255,255,0.12); }
html[data-theme="dark"] .role-switcher-opt { color: rgba(255,255,255,0.5); }
html[data-theme="dark"] .role-switcher-opt:hover:not(.is-active) { color: #fff; background: rgba(255,255,255,0.08); }
html[data-theme="dark"] .role-switcher-opt.is-active { background: #fff; color: #0B1F3A; }
html[data-theme="dark"] .tb-search {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
}
html[data-theme="dark"] .tb-search input { color: #fff; }
html[data-theme="dark"] .tb-btn {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
  color: #fff;
}
html[data-theme="dark"] .tb-iconbtn {
  border-color: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.6);
}
html[data-theme="dark"] .tb-pop {
  background: #162f57;
  border-color: rgba(255,255,255,0.1);
}
html[data-theme="dark"] .tb-pop-title { color: #fff; }
html[data-theme="dark"] .tb-item { color: rgba(255,255,255,0.75); }
html[data-theme="dark"] .tb-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
html[data-theme="dark"] .tb-divider { background: rgba(255,255,255,0.1); }

/* ============================================================
   SIDEBAR TOGGLE CHEVRON
   Points left (<) when sidebar is open; rotates to point right
   (>) when .sidebar-collapsed is on .rf-shell (desktop collapse).
   On mobile the sidebar uses is-open class, so the chevron
   direction is inverted via the sibling combinator.
   ============================================================ */
.tb-sidebar-chevron {
  transition: transform 0.2s ease;
}
.sidebar-collapsed .tb-sidebar-chevron {
  transform: rotate(180deg);
}

/* ============================================================
   DARK MODE CONTRAST FIXES
   Items #11-#16 from QA pass.
   ============================================================ */

/* #11 - Generic .btn (transparent base) needs legible text in dark mode.
   The base rule sets color:var(--gray-700) which maps to #dde2e8 in dark -
   that is fine, but any un-typed .btn on a dark card surface can appear
   washed out. Reinforce to a fully readable light value. */
html[data-theme="dark"] .btn {
  color: var(--gray-800);
}

/* #12 - Chat option/suggestion buttons: tb-item inside tb-pop already has
   color:rgba(255,255,255,0.75) above, which is readable.  The standalone
   channel-list links use inline style="color:var(--navy)" which the Step-2
   rule above already lifts to #fff.  The empty-state and send-form area use
   hardcoded near-white - covered by Step 6/8 rules.  Additionally ensure
   the chat send-form input textarea is readable. */
html[data-theme="dark"] #chat-input {
  background: var(--gray-200) !important;
  border-color: var(--gray-300) !important;
  color: var(--gray-900) !important;
}

/* #13 - Agent panel description card: background is hardcoded #f8f6f0
   (a warm off-white) which reads as near-black in dark mode. Lift it. */
html[data-theme="dark"] [style*="background:#f8f6f0"] {
  background: var(--gray-200) !important;
}

/* Agent heading "Financial Agent" uses style color:var(--navy) - already
   covered by Step-2 rule above (lifted to #fff).  Reinforce via class
   match in case the inline var resolution is off. */
html[data-theme="dark"] .agent-panel [style*="color:var(--navy)"] {
  color: #ffffff !important;
}

/* #14 - Agent pill (inactive) label: uses color:var(--gray-600) which in
   dark maps to #d0d8e0 - already readable.  Active pill is navy bg + white
   text - fine.  Inactive pill has background:#fff which goes dark via
   Step-8 rule, leaving the gray-600 text (#d0d8e0) on gray-100 bg - ok.
   Ensure inactive pills have enough contrast by pinning to gray-800. */
html[data-theme="dark"] .agent-pill {
  background: var(--gray-200);
  border-color: var(--gray-300);
  color: var(--gray-800);
}
html[data-theme="dark"] .agent-pill:hover {
  border-color: var(--gold);
  color: var(--gray-900);
}
html[data-theme="dark"] .agent-pill--active {
  background: #1e3a5c;
  border-color: #3a6090;
  color: #ffffff;
}

/* #15 - Focus Commitments filter tabs: .tab-item uses color:var(--gray-500)
   which in dark mode maps to #b8c4ce - visible but the active state uses
   color:var(--navy) which Step-2 lifts to #fff. The inactive "All" tab
   therefore needs its own dark-mode colour to meet contrast. */
html[data-theme="dark"] .tab-item {
  color: var(--gray-600);
}
html[data-theme="dark"] .tab-item:hover {
  color: var(--gray-900);
}
html[data-theme="dark"] .tab-item.active {
  color: var(--gray-900);
  border-bottom-color: var(--gold);
}

/* #16 - Legacy Blueprint field helper/placeholder text:
   style="color:var(--gray-300)" is used for the italic placeholder text
   ("What principles guide every decision?", etc.). In dark mode --gray-300
   resolves to #30363d which is near-black on a dark card - invisible.
   Lift those dim placeholders to a mid-light value. */
html[data-theme="dark"] [style*="color:var(--gray-300)"],
html[data-theme="dark"] [style*="color: var(--gray-300)"] {
  color: var(--gray-500) !important;
}

/* ============================================================
   ADVISOR QA - DARK MODE FIXES (#4, #5, #6, #7, #8)
   ============================================================ */

/* #4 - Sidebar user-menu: Settings / Account / Sign out links
   The sidebar stays dark-navy in both themes; the 50% white opacity
   is too dim. Lift to 85% so text is clearly readable. */
html[data-theme="dark"] .rf-sidebar a[href*="settings"],
html[data-theme="dark"] .rf-sidebar a[href*="account"],
html[data-theme="dark"] .rf-sidebar button[type="submit"] {
  color: rgba(255, 255, 255, 0.85) !important;
  border-color: rgba(255, 255, 255, 0.28) !important;
}
html[data-theme="dark"] .rf-sidebar a[href*="settings"]:hover,
html[data-theme="dark"] .rf-sidebar a[href*="account"]:hover,
html[data-theme="dark"] .rf-sidebar button[type="submit"]:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.1) !important;
}

/* #5 - Members table: .table-wrap has background:#fff from CSS (not inline),
   so it is not caught by the [style*="background:#fff"] blanket rule.
   Give the wrap, rows, footer, and selected/hover states dark-mode colors. */
html[data-theme="dark"] .table-wrap {
  background: var(--gray-100);
  border-color: var(--gray-200);
}
html[data-theme="dark"] .table tbody tr td {
  background: var(--gray-100);
  color: var(--gray-800);
  border-bottom-color: var(--gray-200);
}
html[data-theme="dark"] .table tbody tr:hover td {
  background: var(--gray-200) !important;
  color: var(--gray-900);
}
html[data-theme="dark"] .table-footer {
  background: var(--gray-200);
  border-top-color: var(--gray-300);
  color: var(--gray-600);
}
html[data-theme="dark"] .table-empty {
  background: var(--gray-100);
  color: var(--gray-500);
}

/* #6 - Members filter tabs active text contrast.
   In dark mode --navy is redefined to #fff, so .tab-item.active uses
   color:var(--navy) = white - correct. But the inherited gray-900 text
   from the previous fix (#15) can conflict. Ensure active tab is gold-
   underlined AND white text, inactive tabs are mid-gray readable. */
html[data-theme="dark"] .tab-item {
  color: var(--gray-500);  /* #b8c4ce - readable mid-tone */
}
html[data-theme="dark"] .tab-item:hover {
  color: var(--gray-800);
  text-decoration: none;
}
html[data-theme="dark"] .tab-item.active {
  color: var(--gray-900);       /* #f0f6fc - near-white, high contrast */
  border-bottom-color: var(--gold);
  font-weight: 700;
}
html[data-theme="dark"] .tab-item.active .tab-count {
  background: rgba(240, 180, 41, 0.18);
  color: var(--gold);
}

/* #7 - Programs filter tabs: same classes, covered by the rules above. */

/* #8 - Engagement Board: .btn-ghost "View" text and "No engagements here"
   empty text inside board columns. The board columns use background:var(--gray-100)
   which maps to #161b22 in dark mode - already dark. The btn-ghost rule
   (defined earlier) gives color:var(--gray-700) = #dde2e8 - readable.
   Reinforce here in case specificity is overridden by the board inline style. */
html[data-theme="dark"] .board-col .btn-ghost {
  color: var(--gray-700);
  border-color: var(--gray-300);
}
html[data-theme="dark"] .board-col .btn-ghost:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}
/* "No engagements here" uses color:var(--gray-300) inline - already lifted
   by rule #16 above. Reinforce for the board italic empty text specifically. */
html[data-theme="dark"] .board-col [style*="color:var(--gray-300)"] {
  color: var(--gray-500) !important;
}
