/* ═══════════════════════════════════════════════════════════════════
   SmartTagAI — Design System v2
   Stripe/Linear aesthetic · 8px grid · Geist + Inter typography
   ═══════════════════════════════════════════════════════════════════ */

/* ── Google Fonts ── */
/* Inter loaded from layout/landing <link> (#130) — was @import (render-blocking). */
/* ═══════════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════════ */
:root {
  /* #756: shared public text-link colour (>=4.5:1 on light bgs) */
  --link-color:        #1a6cb5;
  --link-hover:        #155a99;
  /* --- Palette --- */
  --bg-primary:        #f7f8fa;
  --bg-secondary:      #ffffff;
  --bg-tertiary:       #f0f2f5;

  --text-main:         #0f1117;
  --text-secondary:    #4b5563;
  --text-muted:        #0f1117;
  --text-inverse:      #ffffff;

  --accent-primary:    #1a6cb5;
  --accent-primary-hover: #155a99;
  --accent-primary-subtle: #eef4fb;
  --accent-primary-border: #bcd7f0;

  /* #982 top / mobile nav icon colours (Lucide rose/sky/amber/emerald/blue) */
  --nav-icon-target: #f43f5e;
  --nav-icon-search: #0ea5e9;
  --nav-icon-clipboard: #f59e0b;
  --nav-icon-chart: #10b981;
  --nav-icon-settings: #2563eb;
  --nav-icon-ban: #ef4444;
  --nav-icon-tag: #2563eb;
  --nav-icon-calendar: #f59e0b;
  --nav-icon-save: #2563eb;
  --nav-icon-infinity: #2563eb;
  --nav-icon-zap: #f59e0b;
  --nav-icon-lightbulb: #eab308;
  --nav-icon-bot: #8b5cf6;
  --nav-icon-check: #0ea5e9;
  --nav-icon-pencil: #2563eb;

  --accent-green:      #5a9e16;
  --accent-green-text: #34700d;
  --accent-link-text:  #1a6cb5;
  --accent-green-hover:#4a8410;
  --accent-green-subtle:#f0f8e6;

  --accent-purple:     #6d28d9;
  --accent-chatgpt:    #10a37f;
  --accent-gemini:     #1a73e8;

  --status-success:    #16a34a;
  --status-warning:    #d97706;
  --status-danger:     #dc2626;
  --status-info:       var(--accent-primary);

  /* --- Status subtle pairs (#731): badges, chips, soft buttons --- */
  --success-subtle-bg:     #f0fdf4;
  --success-subtle-text:   #15803d;
  --success-subtle-border: #bbf7d0;
  --warning-subtle-bg:     #fffbeb;
  --warning-subtle-text:   #92400e;
  --warning-subtle-border: #fde68a;
  --danger-subtle-bg:      #fef2f2;
  --danger-subtle-text:    #dc2626;
  --qi-failed-text:        #b91c1c; /* #751: 4.5:1+ on the #f0f2f5 tile */
  --qi-ok-text:            #166534;
  --danger-subtle-border:  #fecaca;
  --danger-subtle-hover-bg:     #fee2e2;
  --danger-subtle-hover-border: #fca5a5;
  --info-subtle-bg:        #eff6ff;
  --info-subtle-text:      #1d4ed8;
  --info-subtle-border:    #bfdbfe;
  --green-badge-border:    #c3e6a0;

  /* --- Borders --- */
  --border-subtle:     #e5e7eb;
  --border-medium:     #d1d5db;
  --border-strong:     #9ca3af;

  /* --- Surfaces --- */
  --surface:           #ffffff;
  --surface-raised:    #ffffff;
  --surface-overlay:   rgba(255, 255, 255, 0.9);

  /* --- Shadows --- */
  --shadow-xs:  0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm:  0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.06);
  --shadow-md:  0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg:  0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
  --shadow-xl:  0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.05);
  --shadow-focus: 0 0 0 3px rgba(26, 108, 181, 0.18);

  /* --- Radius --- */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   18px;
  --radius-2xl:  24px;
  --radius-pill: 9999px;

  /* --- Typography --- */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;

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

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

  /* --- Z-index scale --- */
  --z-nav:      100;
  --card-radius: 14px;
  --card-pad: 1.15rem 1.25rem;
  --stat-num-size: 1.4rem;
  --stat-num-weight: 800;
  --stat-label-size: .72rem;
  --page-max-w: 1400px;
  --page-gutter: 1rem;
  --rail-w: 268px;
  --z-page-sticky: 90;   /* page toolbars: must stay below #stickyHeader */
  --app-header-h: 104px; /* fallback (logo + nav, no search row since #585); layout.html keeps this equal to #stickyHeader's real height */
  --z-dropdown: 200;
  --z-modal:    300;
  --z-toast:    400;
}

/* ── Dark Mode ── */
[data-theme="dark"] {
  --link-color:        #8cc4f5;
  --link-hover:        #b9dcfa;
  --bg-primary:        #0d0f14;
  --bg-secondary:      #141720;
  --bg-tertiary:       #1a1d27;
  --text-main:         #f1f3f7;
  --text-secondary:    #9ca3af;
  --text-muted:        #6b7280;
  --border-subtle:     #252b38;
  --border-medium:     #2e3444;
  --surface:           #1a1d27;
  --surface-raised:    #1f2333;
  --accent-primary-subtle: #111d2f;
  --accent-primary-border: #1e3a5f;

  /* #982: one step lighter so the icons stay readable on dark surfaces.
     blue-600 in particular is only ~3:1 on the header. */
  --nav-icon-target: #fb7185;
  --nav-icon-search: #38bdf8;
  --nav-icon-clipboard: #fbbf24;
  --nav-icon-chart: #34d399;
  --nav-icon-settings: #60a5fa;
  --nav-icon-ban: #f87171;
  --nav-icon-tag: #60a5fa;
  --nav-icon-calendar: #fbbf24;
  --nav-icon-save: #60a5fa;
  --nav-icon-infinity: #60a5fa;
  --nav-icon-zap: #fbbf24;
  --nav-icon-lightbulb: #facc15;
  --nav-icon-bot: #a78bfa;
  --nav-icon-check: #38bdf8;
  --nav-icon-pencil: #60a5fa;
  --accent-green-subtle: #0d1f05;
  --accent-green-text: #a3e635;
  --accent-link-text:  #93c5fd;
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.25);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3);

  /* Status subtle pairs (#731) */
  --success-subtle-bg:     #0f2820;
  --success-subtle-text:   #86efac;
  --success-subtle-border: #166534;
  --warning-subtle-bg:     #2d2210;
  --warning-subtle-text:   #fcd34d;
  --warning-subtle-border: #78530f;
  --danger-subtle-bg:      #2d1515;
  --danger-subtle-text:    #fca5a5;
  --qi-failed-text:        #fca5a5;
  --qi-ok-text:            #86efac;
  --danger-subtle-border:  #7f1d1d;
  --danger-subtle-hover-bg:     #3b1a1a;
  --danger-subtle-hover-border: #991b1b;
  --info-subtle-bg:        #111d2f;
  --info-subtle-text:      #93c5fd;
  --info-subtle-border:    #1e3a5f;
  --green-badge-border:    #2f4d12;

  /* Page-local token families used by shared partials (#731): without these the
     partials fall back to light hex values outside the page that defines them. */
  --pg-surface:   var(--surface);
  --pg-bg:        var(--bg-primary);
  --pg-border:    var(--border-subtle);
  --wcov-surface: var(--surface);
  --wcov-bg:      var(--bg-primary);
  --wcov-border:  var(--border-subtle);
  /* #731 PR 4: text tokens too, or tag names / titles fall back to #111827 (dark on dark). */
  --pg-text:      var(--text-main);
  --pg-muted:     var(--text-secondary);   /* #731 PR 7: --text-muted is 3.5:1 on the dark surface */
  --wcov-text:    var(--text-main);
  --wcov-muted:   var(--text-secondary);
}

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

html {
  -webkit-text-size-adjust: 100%;
  font-feature-settings: 'cv11', 'ss01';
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-main);
  background: var(--bg-primary);
  transition: background var(--ease-out), color var(--ease-out);
}

/* Override Bootstrap blue everywhere */
.btn-primary,
.bg-primary,
.badge.bg-primary { background-color: var(--accent-primary) !important; border-color: var(--accent-primary) !important; }
.text-primary { color: var(--accent-primary) !important; }
.border-primary { border-color: var(--accent-primary) !important; }
.btn-outline-primary { color: var(--accent-primary) !important; border-color: var(--accent-primary) !important; }
.btn-outline-primary:hover { background-color: var(--accent-primary) !important; color: #fff !important; }

/* ═══════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text-main);
}

.tutorial-hero h1, .tutorial-hero p {
  color: white;
}

h1 { font-size: clamp(2rem, 4vw, 3rem);   font-weight: 800; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; }
h3 { font-size: clamp(1.2rem, 2.5vw, 1.5rem); }
h4 { font-size: 1.1rem; }

p { color: var(--text-secondary);  }

.text-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.text-gradient {
  background: linear-gradient(135deg, var(--accent-primary) 0%, #5b8dee 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ═══════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════ */
.st-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

@media (max-width: 768px) {
  .st-container { padding: 0 var(--space-4); }
}

/* ═══════════════════════════════════════════
   STICKY NAVIGATION — App Layout
   ═══════════════════════════════════════════ */
#stickyHeader {
  position: sticky;
  box-sizing: border-box;
  top: 0;
  z-index: var(--z-nav);
  background: var(--surface-overlay, rgba(255,255,255,0.85));
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-xs);
  margin-bottom: 1rem;
}

[data-theme="dark"] #stickyHeader {
  background: rgba(13, 15, 20, 0.88);
}

#topBar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  min-height: 52px;
}

#brandLink {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

#brandName {
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

/* ── Brand Logo Colors ── */
.brand-logo .logo-primary { fill: #1a6cb5; }
.brand-logo .logo-secondary { fill: var(--text-secondary); }
.brand-logo .logo-accent { fill: #6ab023; }

[data-theme="dark"] .brand-logo .logo-primary { fill: #5ba3e0; }
[data-theme="dark"] .brand-logo .logo-secondary { fill: #9ca3af; }
[data-theme="dark"] .brand-logo .logo-accent { fill: #6ab023; }

/* ── Main Nav ── */
.main-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0 var(--space-4) var(--space-1);
  border-top: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }

[data-theme="dark"] .main-nav .nav-item { color: #9ca3af; }
[data-theme="dark"] .main-nav .nav-item:hover { background: #1f2333; color: #f1f3f7; }
[data-theme="dark"] .main-nav .nav-item.active {
  background: var(--accent-primary-subtle);
  color: #7cb4f0;
  border-color: var(--accent-primary-border);
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: background var(--ease-out-fast), color var(--ease-out-fast);
  white-space: nowrap;
}

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

.nav-item.active {
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
  font-weight: 600;
}

/* #982: accent-tinted pill, 12px corners, and a little more icon/label gap.
   Scoped to the top nav so other .nav-item uses (Bootstrap tabs) stay as they were. */
.main-nav .nav-item {
  gap: var(--space-2);
  padding: var(--space-2) 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  transition: background var(--ease-out-fast), color var(--ease-out-fast), border-color var(--ease-out-fast);
}
.main-nav .nav-item.active {
  border-color: var(--accent-primary-border);
}

/* #982 line icons — colour stays on the icon, not on the label */
.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: block;
}
.nav-icon-target { color: var(--nav-icon-target); }
.nav-icon-search { color: var(--nav-icon-search); }
.nav-icon-clipboard { color: var(--nav-icon-clipboard); }
.nav-icon-chart { color: var(--nav-icon-chart); }
.nav-icon-settings { color: var(--nav-icon-settings); }
.nav-icon-ban { color: var(--nav-icon-ban); }
.nav-icon-tag { color: var(--nav-icon-tag); }
.nav-icon-calendar { color: var(--nav-icon-calendar); }
.nav-icon-save { color: var(--nav-icon-save); }
.nav-icon-infinity { color: var(--nav-icon-infinity); }
.nav-icon-zap { color: var(--nav-icon-zap); }
.nav-icon-lightbulb { color: var(--nav-icon-lightbulb); }
.nav-icon-bot { color: var(--nav-icon-bot); }
.nav-icon-check { color: var(--nav-icon-check); }
.nav-icon-pencil { color: var(--nav-icon-pencil); }

/* Tinted squares for landing feature cards (#982) */
.fi-rose { background: #ffe4e6; }
.fi-red { background: #fee2e2; }
.fi-sky { background: #e0f2fe; }
.fi-amber { background: #fef3c7; }
.fi-emerald { background: #d1fae5; }
.fi-blue { background: #e8f2fb; }
.fi-violet { background: #ede9fe; }
.fi-yellow { background: #fef9c3; }
.fi-green { background: #f0f8e8; }
.fi-grey { background: #f0f2f5; }
[data-theme="dark"] .fi-rose { background: #3f1219; }
[data-theme="dark"] .fi-red { background: #3f1515; }
[data-theme="dark"] .fi-sky { background: #0c2a3d; }
[data-theme="dark"] .fi-amber { background: #3b2d0a; }
[data-theme="dark"] .fi-emerald { background: #0d2a22; }
[data-theme="dark"] .fi-blue { background: #132b45; }
[data-theme="dark"] .fi-violet { background: #2e1a4a; }
[data-theme="dark"] .fi-yellow { background: #3b3208; }
[data-theme="dark"] .fi-green { background: #1a300a; }
[data-theme="dark"] .fi-grey { background: #252830; }

.feature-icon-wrap .nav-icon { width: 24px; height: 24px; }
.feature-list.has-icons .nav-icon,
.pro-feature-list .nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: block;
  margin-top: 2px;
}
.pro-feature-list li,
.feature-list.has-icons li {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}

/* ── User Area ── */
#userArea {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.user-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1) var(--space-3);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background var(--ease-out-fast), color var(--ease-out-fast);
  text-decoration: none;
}

.user-action:hover {
  background: var(--bg-tertiary);
  color: var(--text-main);
}

.logout-btn {
  color: var(--status-danger); /* #dc2626 */
}
.logout-btn:hover {
  color: var(--status-danger);
  background: #fef2f2;
}
[data-theme="dark"] .logout-btn:hover { background: #2d1515 !important; }

/* Usage bar — small linear progress */
#usageBar {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px var(--space-2);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background var(--ease-out-fast);
}
#usageBar:hover { background: var(--bg-tertiary); }

.usage-track {
  width: 48px;
  height: 4px;
  background: var(--border-subtle);
  border-radius: 2px;
  overflow: hidden;
}
.usage-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.usage-fill.warn { background: var(--status-warning); }
.usage-fill.full { background: var(--status-danger); }

/* PRO badge */
.badge-pro-sm {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #1a6cb5, #2080d0);
  color: #fff;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

/* ── Hamburger (mobile) ── */
#menuToggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  padding: 4px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--ease-out-fast);
}
#menuToggle:hover { background: var(--bg-tertiary); }
#menuToggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}
#menuToggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
#menuToggle.open span:nth-child(2) { opacity: 0; }
#menuToggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 768px) {
  #menuToggle { display: flex; }
  .main-nav {
    display: none;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-4) var(--space-3);
    border-top: 1px solid var(--border-subtle);
  }
  .main-nav.open { display: flex; }
  .nav-item { width: 100%; }
}

/* ── Global Search ── */
#globalSearchBar {
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border-subtle);
}
/* #585: the search now sits at the top of Manage → Topics, not in the header */
#globalSearchBar.topics-search { padding: 0; border-top: 0; margin-bottom: .75rem; }
@media (max-width: 768px) { #globalSearchBar.topics-search #globalAvoidSearch { font-size: 16px; } }  /* iOS: no zoom on focus */
#globalSearchBar.topics-search #globalAvoidSearch::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
#globalSearchBar.topics-search #globalSearchResults { max-height: 50vh; overflow-y: auto; border: 1px solid var(--border-subtle); background: var(--surface, #fff); }

#globalSearchBar .input-group-text {
  background: var(--bg-primary);
  border-color: var(--border-subtle);
  border-right: none;
}

#globalSearchBar .form-control {
  border-color: var(--border-subtle);
  border-left: none;
  border-right: none;
  background: var(--bg-primary);
  font-size: 0.82rem;
  color: var(--text-main);
}

#globalSearchBar .btn-outline-secondary {
  border-color: var(--border-subtle);
  color: var(--text-muted);
  border-left: none;
}

/* ═══════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════ */
.st-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--ease-out), transform var(--ease-out);
}

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

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

.st-card-body {
  padding: var(--space-5);
}

/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */
.st-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--ease-out-fast), transform var(--ease-out-fast),
              box-shadow var(--ease-out-fast), border-color var(--ease-out-fast);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.st-btn:active { transform: scale(0.97); }
.st-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

/* Variants */
.st-btn-primary {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
  box-shadow: 0 1px 2px rgba(26, 108, 181, 0.2);
}
.st-btn-primary:hover {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
  box-shadow: 0 3px 8px rgba(26, 108, 181, 0.3);
  color: #fff;
}

.st-btn-secondary {
  background: var(--surface);
  color: var(--text-main);
  border-color: var(--border-medium);
}
.st-btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.st-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.st-btn-ghost:hover { background: var(--bg-tertiary); color: var(--text-main); }

.st-btn-danger {
  background: var(--danger-subtle-bg);
  color: var(--status-danger);
  border-color: var(--danger-subtle-border);
}
[data-theme="dark"] .st-btn-danger { color: var(--danger-subtle-text); }
.st-btn-danger:hover { background: var(--danger-subtle-hover-bg); border-color: var(--danger-subtle-hover-border); }

/* Sizes */
.st-btn-sm { padding: 4px var(--space-3); font-size: 0.8rem; border-radius: var(--radius-sm); }
.st-btn-lg { padding: var(--space-3) var(--space-6); font-size: 1rem; border-radius: var(--radius-lg); }


/* ════════════════════════════════════════════
   AUTH PAGES
   ════════════════════════════════════════════ */

.auth-card {
  max-width: 420px; margin: 60px auto;
  background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 2.5rem 2rem; border: 1px solid var(--border);
}
.auth-title { font-size: 1.4rem; font-weight: 700; margin-bottom: .25rem; }
.auth-subtitle { color: var(--text-muted); margin-bottom: 1.5rem; font-size: .9rem; text-align:center; }
.btn-google {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  font-size: .9rem; padding: .55rem 1rem; transition: background .15s; border-radius: var(--radius-sm);
}
.btn-google:hover { background: var(--surface-2); }
.divider { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0; color: var(--text-faint); font-size: .8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.strength-bar { height: 4px; border-radius: 2px; transition: all .3s; background: var(--border); }


/* ════════════════════════════════════════════
   DARK MODE
   ════════════════════════════════════════════ */

[data-theme="dark"] {
  --surface: #1e2128;
  --surface-2: #252830;
  --surface-3: #2d3139;
  --border: #353840;
  --border-strong: #454850;
  --text: #e8eaed;
  --text-muted: #9aa0aa;
  --text-faint: #636870;
  --accent-soft: #1e2d4a;
  --success-soft: #0f2820;
  --warning-soft: #2d2210;
  --danger-soft: #2d1515;
  color-scheme: dark;
}

[data-theme="dark"] .nav-tabs .nav-link { color: #9aa0aa; }
[data-theme="dark"] .nav-tabs .nav-link:hover { background: #2d3139; color: #e8eaed; }
[data-theme="dark"] .nav-tabs .nav-link.active { background: #1e2d4a; color: #60a5fa; }
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] textarea { background: #252830; border-color: #454850; color: #e8eaed; }
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus { background: #252830; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
[data-theme="dark"] .form-control::placeholder { color: #636870; }
[data-theme="dark"] .input-group-text { background: #2d3139; border-color: #454850; color: #9aa0aa; }
[data-theme="dark"] .card { background: #1e2128; border-color: #353840; color: #e8eaed; }
[data-theme="dark"] .card-header { background: #252830 !important; border-color: #353840; }
[data-theme="dark"] .table { --bs-table-bg: #1e2128; --bs-table-striped-bg: #252830; --bs-table-hover-bg: #2d3139; --bs-table-border-color: #353840; color: #e8eaed; }
[data-theme="dark"] .table th { background: #252830 !important; color: #9aa0aa; }
[data-theme="dark"] .modal-content { background: #1e2128; border-color: #353840; color: #e8eaed; }
[data-theme="dark"] .modal-header, [data-theme="dark"] .modal-footer { border-color: #353840; }
/* ── #731 shared dark base: Bootstrap parts that stayed light ── */
/* Modal header/footer: some pages paint them #fff; keep them on the modal surface. */
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { background-color: #1e2128 !important; color: #e8eaed; }
/* Close button: Bootstrap's dark X icon is invisible on dark; invert it (skip the -white variant). */
[data-theme="dark"] .btn-close:not(.btn-close-white) { filter: invert(1) grayscale(100%) brightness(200%); }
/* Checkboxes, radios and switches */
[data-theme="dark"] .form-check-input { background-color: #252830; border-color: #454850; }
[data-theme="dark"] .form-check-input:checked { background-color: #1a6cb5; border-color: #1a6cb5; }
[data-theme="dark"] .form-check-input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.25); }
[data-theme="dark"] .form-check-input:disabled { opacity: .45; }
[data-theme="dark"] .form-switch .form-check-input:not(:checked) {
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%28255,255,255,0.55%29'/%3e%3c/svg%3e");
}
[data-theme="dark"] .form-check-label { color: #e8eaed; }
/* Shared light Bootstrap badges/chips */
[data-theme="dark"] .badge.bg-light,
[data-theme="dark"] .badge.text-bg-light { background-color: #2d3139 !important; color: #e8eaed !important; }
[data-theme="dark"] .badge.bg-white { background-color: #252830 !important; color: #e8eaed !important; }
[data-theme="dark"] .btn-light { background: #252830; border-color: #454850; color: #e8eaed; }
[data-theme="dark"] .btn-light:hover { background: #2d3139; border-color: #454850; color: #fff; }
[data-theme="dark"] .list-group-item { background: #1e2128; border-color: #353840; color: #e8eaed; }
[data-theme="dark"] .list-group-flush .list-group-item { background: transparent; }
[data-theme="dark"] .alert-secondary { background: #252830; border-color: #353840; color: #9aa0aa; }
[data-theme="dark"] .alert-light { background: #252830; border-color: #353840; color: #9aa0aa; }
[data-theme="dark"] .alert-info { background: #1a3a4a; border-color: #1e4d70; color: #7dd3fc; }
[data-theme="dark"] .bg-light { background: #252830 !important; }
[data-theme="dark"] .text-muted { color: #9aa0aa !important; }
[data-theme="dark"] .border { border-color: #353840 !important; }
[data-theme="dark"] #globalSearchResults { background: #1e2128; border-color: #353840; }
[data-theme="dark"] .review-paste-bar { background: #1e2128 !important; border-bottom-color: #3b82f6; }
[data-theme="dark"] .tag-card { background: #1e2128; border-color: #353840; }
[data-theme="dark"] .heatmap-cell { background: #2d3139; }
[data-theme="dark"] .heatmap-cell[data-level="1"] { background: #0e4429; }
[data-theme="dark"] .heatmap-cell[data-level="2"] { background: #006d32; }
[data-theme="dark"] .heatmap-cell[data-level="3"] { background: #26a641; }
[data-theme="dark"] .heatmap-cell[data-level="4"] { background: #39d353; }
[data-theme="dark"] .word-chip { background: #2d3139 !important; border-color: #454850 !important; }
[data-theme="dark"] .inactive-tag { background: #2d2210; color: #fbbf24; border-color: #78350f; }
[data-theme="dark"] .skeleton { background: linear-gradient(90deg, #252830 25%, #2d3139 50%, #252830 75%); background-size: 200% 100%; }
[data-theme="dark"] .topic-year-badge { background: #2d3139; color: #9aa0aa; }
[data-theme="dark"] pre, [data-theme="dark"] code { background: #252830; color: #e8a87c; }
[data-theme="dark"] .auth-card { background: #1e2128; border-color: #353840; }
[data-theme="dark"] .btn-google { background: #252830; border-color: #454850; color: #e8eaed; }
[data-theme="dark"] .clickable { background: #252830; }
[data-theme="dark"] .clickable:hover { background: #2d3139; }
[data-theme="dark"] .dark-toggle:hover { background: #2d3139; }
[data-theme="dark"] .compare-table td { color: #9aa0aa; }
[data-theme="dark"] h5 { color: #6ab023; }
[data-theme="dark"] h6, .interactive-demo, .demo-section ul li { color: #9ca3af; }
tag-chip



/* ═══════════════════════════════════════════
   FORM ELEMENTS
   ═══════════════════════════════════════════ */
.st-input,
input[type="text"].form-control,
input[type="email"].form-control,
input[type="password"].form-control,
input[type="date"].form-control,
textarea.form-control {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-main);
  background: var(--surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  transition: border-color var(--ease-out-fast), box-shadow var(--ease-out-fast);
  outline: none;
}

.st-input:focus,
input[type="text"].form-control:focus,
input[type="email"].form-control:focus,
input[type="password"].form-control:focus,
textarea.form-control:focus {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-focus);
}

[data-theme="dark"] .st-input,
[data-theme="dark"] .form-control {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
  color: var(--text-main);
}

/* ═══════════════════════════════════════════
   BADGE / PILL / STATUS INDICATORS
   ═══════════════════════════════════════════ */
.st-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: var(--radius-pill);
  letter-spacing: 0.03em;
}

.st-badge-blue   { background: var(--accent-primary-subtle); color: var(--accent-primary); border: 1px solid var(--accent-primary-border); }
.st-badge-green  { background: var(--accent-green-subtle);   color: var(--accent-green); border: 1px solid var(--green-badge-border); }
.st-badge-neutral { background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border-subtle); }
.st-badge-warning { background: var(--warning-subtle-bg); color: var(--warning-subtle-text); border: 1px solid var(--warning-subtle-border); }
.st-badge-danger  { background: var(--danger-subtle-bg); color: var(--status-danger); border: 1px solid var(--danger-subtle-border); }
[data-theme="dark"] .st-badge-danger { color: var(--danger-subtle-text); }

/* Status dot */
.st-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.st-dot-green { background: var(--accent-green); }
.st-dot-blue  { background: var(--accent-primary); }
.st-dot-amber { background: var(--status-warning); }
.st-dot-red   { background: var(--status-danger); }
.st-dot-grey  { background: var(--border-medium); }

/* ═══════════════════════════════════════════
   CHIPS (Tag selector)
   ═══════════════════════════════════════════ */
.st-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--ease-out-fast), border-color var(--ease-out-fast),
              color var(--ease-out-fast), transform 100ms;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.st-chip:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-primary-subtle);
}

.st-chip:active { transform: scale(0.94); }

.st-chip--active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
  font-weight: 600;
}

.st-chip--done {
  opacity: 0.45;
}

/* ═══════════════════════════════════════════
   SKELETON / LOADING
   ═══════════════════════════════════════════ */
.st-skeleton {
  background: linear-gradient(
    90deg,
    var(--border-subtle) 25%,
    var(--bg-tertiary)   50%,
    var(--border-subtle) 75%
  );
  background-size: 200% 100%;
  animation: st-skeleton-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

@keyframes st-skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ═══════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════ */
.st-toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: 0.83rem;
  font-weight: 600;
  color: #fff;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  max-width: 360px;
  animation: st-toast-in 0.2s ease;
}

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

/* ═══════════════════════════════════════════
   STAT CARDS (Dashboard)
   ═══════════════════════════════════════════ */
.st-stat-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.st-stat-card .st-stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.st-stat-card .st-stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  line-height: 1;
}

.st-stat-card .st-stat-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.st-stat-card .st-stat-indicator {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  margin-top: var(--space-2);
}
.st-stat-indicator--up   { background: var(--success-subtle-bg); color: var(--success-subtle-text); }
.st-stat-indicator--down { background: var(--danger-subtle-bg); color: var(--danger-subtle-text); }

/* ═══════════════════════════════════════════
   CHART CONTAINER
   ═══════════════════════════════════════════ */
.chart-container {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.chart-container .chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.chart-container .chart-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.chart-container .chart-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.chart-container canvas,
.chart-container .chart-body {
  max-height: 260px;
}

/* ═══════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════ */
#footer {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  margin-top: var(--space-12);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-muted);
}

[data-theme="dark"] #footer { border-top-color: #252b38 !important; }

/* ═══════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════ */
.fade-in {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Text Scale control (keep functional) ── */
#textScaleWrap { position: relative; display: inline-block; }

/* ── Quick Submit bar cleanup ── */
#quickSubmitBar {
  padding: var(--space-2) var(--space-4) var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

#quickSubmitBar textarea.form-control {
  font-size: 0.82rem;
  min-height: 34px;
}

/* ═══════════════════════════════════════════
   DARK-MODE OVERRIDES for Bootstrap components
   ═══════════════════════════════════════════ */
[data-theme="dark"] .form-control,
[data-theme="dark"] .input-group-text {
  background-color: var(--bg-tertiary);
  border-color: var(--border-medium);
  color: var(--text-main);
}

[data-theme="dark"] .btn-outline-secondary {
  color: var(--text-secondary);
  border-color: var(--border-medium);
}
[data-theme="dark"] .btn-outline-secondary:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-main);
}

[data-theme="dark"] .list-group-item {
  background: var(--surface);
  border-color: var(--border-subtle);
  color: var(--text-main);
}

/* Text green must remain readable on green-tinted surfaces in both themes. */
.section-label,
.st-hero-badge,
.st-badge-green,
#prompt-status {
  color: var(--accent-green-text) !important;
}


/* Dark-mode landing-page text overrides outrank its inline light-theme colors. */
html[data-theme=dark] .section-label {
  color: var(--accent-green-text) !important;
}
html[data-theme=dark] a[href*=login],
html[data-theme=dark] a[href*=tutorial] {
  color: var(--accent-link-text) !important;
}

html[data-theme=dark] .landing-footer a,
html[data-theme=dark] .landing-nav a.lnav-link,
html[data-theme=dark] .landing-nav a.lnav-btn-outline {
  color: var(--accent-link-text) !important;
}

html[data-theme=dark] .st-badge-blue {
  color: #5ba3e0 !important;
}
html[data-theme=dark] .tier-box.featured .tier-name {
  color: #5ba3e0 !important;
}

html[data-theme=dark] .pricing-section a[href*=pricing] {
  color: var(--accent-link-text) !important;
}
html[data-theme=dark] .pricing-section a.btn[href*=pricing] {
  color: #fff !important;
}


/* ═══════════════════════════════════════════════════════════════════
   PHASE 3 — shared page title, tabs, actions menu, card tokens
   ═══════════════════════════════════════════════════════════════════ */

/* ── Page title ([icon] [Page Name]) ── */
.page-title {
  font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2;
  margin: 0; color: var(--text-primary, inherit);
}
.page-title--sub { font-size: 1.1rem; font-weight: 600; }
.page-title-icon { margin-right: .15rem; }
.page-title-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; margin-bottom: 1rem; flex-wrap: nowrap;
}
.page-title-actions { display: flex; align-items: center; gap: .5rem; flex: 0 0 auto; }
.page-title-row--sticky {
  position: sticky; top: var(--app-header-h, 108px); z-index: var(--z-page-sticky, 90);
  background: var(--bg-primary, #f7f8fa); padding: .4rem 0; margin-bottom: 0;
}
/* Sticky only from a breakpoint up (Queue ≥769px, Review ≥1024px); static below, where those
   pages have their own sticky bars. NOTE: the row must be a direct child of the tall content
   container (no wrapper) or sticky has no runway. */
@media (min-width: 769px)  { .page-title-row--sticky-md { position: sticky; top: var(--app-header-h, 108px); z-index: var(--z-page-sticky, 90); background: var(--bg-primary, #f7f8fa); padding: .4rem 0; margin-bottom: 0; } }
@media (min-width: 1024px) { .page-title-row--sticky-lg { position: sticky; top: var(--app-header-h, 108px); z-index: var(--z-page-sticky, 90); background: var(--bg-primary, #f7f8fa); padding: .4rem 0; margin-bottom: 0; } }
.page-title-row--sticky-md, .page-title-row--sticky-lg { margin-bottom: .5rem; }
[data-theme="dark"] .page-title-row--sticky, [data-theme="dark"] .page-title-row--sticky-md, [data-theme="dark"] .page-title-row--sticky-lg { background: var(--bg-primary, #0d0f14); }
@media (max-width: 768px) {
  .page-title { font-size: 1.15rem; }
  .page-title--sub { font-size: 1rem; }
}

/* ── Unified tabs: underlined, count badges, horizontal scroll on mobile.
   Legacy hook classes (.manage-tab-btn, .qft-btn, .mq-ft, .qs-nav-btn, .rv-chip)
   stay on the buttons for JS; the doubled selectors below beat their old
   look (incl. !important rules) until those can be deleted. ── */
.st-tabs.st-tabs {
  display: flex; flex-direction: row; flex-wrap: nowrap; gap: 0; overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  border-bottom: 1px solid var(--border-subtle, #e5e7eb) !important;
}
.st-tabs.st-tabs::-webkit-scrollbar { display: none; }
.st-tabs.st-tabs > .st-tab.st-tab {
  flex: 0 0 auto; width: auto !important; white-space: nowrap; cursor: pointer;
  display: inline-flex; align-items: center; gap: .35rem;
  font-family: inherit !important; font-size: .85rem !important; font-weight: 600 !important;
  padding: .55rem .9rem !important; margin: 0 0 -1px 0 !important;
  background: none !important; border: none !important; border-radius: 0 !important;
  border-bottom: 2px solid transparent !important; box-shadow: none !important;
  color: var(--text-muted, #6b7280) !important;
  transition: color .12s, border-color .12s;
}
.st-tabs.st-tabs > .st-tab.st-tab:hover { color: var(--text-primary, #111827) !important; background: none !important; }
[data-theme="dark"] .st-tabs.st-tabs > .st-tab.st-tab:hover { color: var(--text-main) !important; background: var(--bg-tertiary, rgba(255,255,255,.06)) !important; }
.st-tabs.st-tabs > .st-tab.st-tab.active {
  color: var(--accent-primary, #1a6cb5) !important;
  border-bottom-color: var(--accent-primary, #1a6cb5) !important; background: none !important;
}
.st-tabs.st-tabs > .st-tab:focus-visible { outline: 2px solid var(--accent-primary, #1a6cb5); outline-offset: -2px; }
.st-tab .st-tab-badge {
  min-width: 1.35rem; padding: 0 .4rem; border-radius: 999px; text-align: center;
  font-size: .68rem; font-weight: 700; line-height: 1.35rem;
  background: var(--bg-tertiary, #f0f2f5) !important; color: var(--text-muted, #6b7280) !important;
}
.st-tab.active .st-tab-badge {
  background: color-mix(in srgb, var(--accent-primary, #1a6cb5) 14%, transparent) !important;
  color: var(--accent-primary, #1a6cb5) !important;
}
.st-tab .st-tab-badge:empty { display: none; }
/* compact variant for view switchers / filter chips inside narrow panels */
.st-tabs--compact.st-tabs > .st-tab.st-tab { font-size: .68rem !important; padding: .1rem .45rem !important; }

/* ── Shared Actions ▾ dropdown ── */
.actions-dd { position: relative; }
.actions-dd-toggle { display: inline-flex; align-items: center; gap: 6px; }
.actions-dd-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; z-index: 1050;
  background: var(--surface, #fff); border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 12px; box-shadow: 0 8px 28px rgba(15,17,23,.12); padding: 6px; display: none;
}
.actions-dd-menu.open { display: block; }
.actions-dd-group-label {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .04em;
  color: #9ca3af; padding: 8px 10px 4px; font-weight: 600;
}
.actions-dd-item {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  background: none; border: none; text-align: left; padding: 9px 10px; border-radius: 8px;
  cursor: pointer; font-size: .85rem; color: var(--text-primary, #0f1117); line-height: 1.25;
}
.actions-dd-item:hover { background: var(--bg-tertiary, #f3f4f6); }
.actions-dd-item .ai-ic { font-size: 1.05rem; line-height: 1.2; width: 20px; text-align: center; flex: 0 0 auto; }
.actions-dd-item .ai-sub { font-size: .7rem; color: #9ca3af; display: block; margin-top: 1px; }
.actions-dd-divider { height: 1px; background: var(--border-subtle, #e5e7eb); margin: 5px 8px; }
@media (max-width: 700px) {
  .actions-dd-menu {
    z-index: 9100; position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    min-width: 0; width: 100%; border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 28px rgba(15,17,23,.18); padding: 6px 6px 14px;
  }
  .actions-dd-item { padding: 12px 14px; font-size: .92rem; }
}

/* ── Shared card tokens ── */
.stat-card, .rv-queue-card, .tag-card, .billing-card .card, .dcl-card-wrap, .scl-card-wrap {
  border-radius: var(--card-radius);
}
.stat-card, .tag-card, .billing-card .card-body, .billing-card .card-header { padding: var(--card-pad); }
.stat-card .number, .stat-card .stat-num {
  font-size: var(--stat-num-size); font-weight: var(--stat-num-weight); letter-spacing: -.03em; line-height: 1;
}
.stat-card .label { font-size: var(--stat-label-size); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* ── Page container rule: main column + optional RIGHT rail ──
   .page-shell { max-width: var(--page-max-w); padding-inline: var(--page-gutter) }
   .page-with-rail → grid [main | rail]; rail stacks BELOW main under 1024px. ── */
.page-shell { max-width: var(--page-max-w); margin-inline: auto; padding-inline: var(--page-gutter); }
.page-with-rail { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail-w); gap: 1.25rem; align-items: start; }
@media (max-width: 1023px) { .page-with-rail { grid-template-columns: minmax(0, 1fr); } }

.user-action.active { background: var(--accent-primary-subtle, rgba(26,108,181,.12)); color: var(--accent-primary, #1a6cb5); box-shadow: inset 0 -2px 0 var(--accent-primary, #1a6cb5); }

/* ── #698: compact time zone label + banner (templates/layout.html, static/js/timezone.js) ── */
/* margin-top tucks the 🕒 button into #stickyHeader's 16px bottom margin. */
.tz-indicator { position: relative; text-align: right; font-size: .72rem; line-height: 1.25; padding: 0; margin: -.6rem 0 0; }
.tz-indicator:empty { display: none; }
.tz-ind-btn { background: none; border: 0; padding: 0 .3rem; font-size: .85rem; line-height: 1.2; border-radius: .25rem; cursor: pointer; }
.tz-ind-btn:focus-visible { outline: 2px solid #0d6efd; outline-offset: 1px; }
.tz-popover { position: absolute; right: 0; top: 100%; z-index: 1030; margin-top: .25rem; text-align: left;
  width: max-content; max-width: min(300px, calc(100vw - 2rem)); padding: .5rem .6rem; font-size: .8rem;
  background: #fff; color: #212529; border: 1px solid rgba(0,0,0,.15); border-radius: .4rem; box-shadow: 0 .25rem .75rem rgba(0,0,0,.12); }
.tz-pop-text { margin-bottom: .3rem; }
.tz-pop-change { font-weight: 600; }
/* Closed: kept in the DOM but visually hidden (not display:none). */
.tz-popover.tz-pop-closed { width: 1px; height: 1px; padding: 0; margin: -1px; border: 0; box-shadow: none;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.tz-banner { gap: .4rem; padding: .25rem .5rem; margin: .2rem 0 .35rem; font-size: .78rem; line-height: 1.25; }
.tz-banner-text { flex: 1 1 0; min-width: 0; display: -webkit-box; -webkit-box-orient: vertical;
  -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.tz-banner-btn { flex: none; white-space: nowrap; padding: .15rem .5rem; font-size: .75rem; line-height: 1.3; }
.tz-change-box { flex-basis: 100%; }
@media (min-width: 768px) { .tz-banner-text { -webkit-line-clamp: 2; line-clamp: 2; } }

/* #751: Stats > Quick Insights health line (text >= 4.5:1 on the tile in both themes). */
.qi-delta { color: var(--text-secondary); }
.qi-health { font-weight: 600; }
.qi-health--ok { color: var(--qi-ok-text); }
.qi-health--failed { color: var(--qi-failed-text); }
.qi-health-link { color: var(--link-color); text-decoration: underline; }
.qi-health-link:hover, .qi-health-link:focus { color: var(--link-hover); }

/* ── #341: Image Cleanup storage bar, In use badge, Smart Cleanup — light defaults (new elements only) ── */
.admin-dash .storage-usage-text { color: #1a1d23; }
.admin-dash .storage-usage-note { font-size: .74rem; color: #4b5563; margin-top: 4px; }
.admin-dash .storage-bar { height: 8px; border-radius: 6px; background: #e5e7eb; overflow: hidden; margin-top: 6px; }
.admin-dash .storage-bar-fill { height: 100%; background: #1a6cb5; }
.admin-dash .storage-warn .storage-bar-fill { background: #f59e0b; }
.admin-dash .storage-danger .storage-bar-fill { background: #dc2626; }
.admin-dash .storage-warn .storage-level-label { color: #92400e; }
.admin-dash .storage-danger .storage-level-label { color: #b91c1c; }
.admin-dash .in-use-badge { font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: 20px; background: #fef3c7; color: #92400e; margin-right: 4px; }
.admin-dash .img-reason { color: #374151; }
.admin-dash .cleanup-safe { color: #166534; }
.admin-dash .cleanup-inuse { color: #92400e; }

/* ── #731 PR 7: navbar + onboarding dark mode (dark-only; light mode untouched) ── */
[data-theme="dark"] #brandName > span:first-child { color: #6ea8fe !important; }
[data-theme="dark"] #brandLink:hover { color: #e8eaed; }
[data-theme="dark"] .logout-btn,
[data-theme="dark"] .logout-btn:hover { color: #f87171 !important; }
[data-theme="dark"] .mbn-item.active { color: #6ea8fe; }
/* Onboarding domain picker / first draft (styles are injected by JS, so these carry an id for specificity) */
[data-theme="dark"] #ob-domain-overlay .dp-step-pill,
[data-theme="dark"] #ob-domain-overlay .dp-source-badge,
[data-theme="dark"] #ob-domain-overlay .dp-hint a,
[data-theme="dark"] #ob-domain-overlay .dp-add-custom button,
[data-theme="dark"] #ob-domain-overlay .dp-desc-toggle:hover,
[data-theme="dark"] #ob-domain-overlay .dp-desc-toggle.on { color: #6ea8fe !important; }
[data-theme="dark"] #ob-domain-overlay .dp-hint a:hover,
[data-theme="dark"] #ob-domain-overlay .dp-add-custom button:hover { color: #ffffff !important; }
[data-theme="dark"] #ob-domain-overlay .dp-platform-btn.selected .dp-platform-label,
[data-theme="dark"] #ob-domain-overlay .dp-domain-btn.selected .dp-domain-label { color: #f1f3f7; }
[data-theme="dark"] #ob-domain-overlay .dp-tag-counter.at-limit,
[data-theme="dark"] #ob-domain-overlay .dp-chip-remove:hover { color: #f87171; }
[data-theme="dark"] #ob-domain-overlay input::placeholder { color: #9ca3af; }
[data-theme="dark"] .ob-fd-pill { color: #c4b5fd; background: rgba(167,139,250,.16); }
[data-theme="dark"] .ob-check-item.done .ob-box { background: #4d7c0f; border-color: #4d7c0f; color: #ffffff; }
[data-theme="dark"] #ob-drawer { background: #1a1d27; }
[data-theme="dark"] #ob-drawer h6 { color: #f1f3f7; }
[data-theme="dark"] #ob-drawer p { color: #fca5a5; }
[data-theme="dark"] #ob-drawer .btn-outline-secondary { color: #d1d5db; border-color: #4b5563; }
[data-theme="dark"] #ob-drawer .btn-outline-secondary:hover { color: #ffffff; background: #374151; }

/* ── #731 PR 7: Admin pages dark mode — every templates/admin/ page carries .admin-dash (dark-only; light mode untouched) ── */
[data-theme="dark"] .admin-dash {
  --card-bg: #1a1d27; --text: #f1f3f7; --text-muted: #9ca3af;
  --border: #2d3340; --surface-2: #232733;
}
[data-theme="dark"] .admin-dash .table { --bs-table-color: #e8eaed; --bs-table-bg: #1a1d27; --bs-table-border-color: #2d3340; }
[data-theme="dark"] .admin-dash .admin-users-table tbody tr:hover { background: #232733 !important; color: #f1f3f7; }
[data-theme="dark"] .admin-dash a:not(.btn) { color: #6ea8fe; }
[data-theme="dark"] .admin-dash a:not(.btn):hover { color: #9ec5fe; }
[data-theme="dark"] .admin-dash .btn-link { color: #6ea8fe; }
[data-theme="dark"] .admin-dash .btn-link:hover { color: #9ec5fe; }
[data-theme="dark"] .admin-dash .btn-outline-primary { color: #6ea8fe !important; border-color: #6ea8fe !important; background: transparent; }
[data-theme="dark"] .admin-dash .btn-outline-primary:hover,
[data-theme="dark"] .admin-dash .btn-outline-primary:focus-visible { color: #ffffff !important; background: #1a6cb5 !important; border-color: #1a6cb5 !important; }
[data-theme="dark"] .admin-dash .btn-outline-secondary { color: #d1d5db; border-color: #4b5563; background: transparent; }
[data-theme="dark"] .admin-dash .btn-outline-secondary:hover { color: #ffffff; background: #374151; border-color: #6b7280; }
[data-theme="dark"] .admin-dash .btn-outline-danger { color: #f87171; border-color: #f87171; background: transparent; }
[data-theme="dark"] .admin-dash .btn-outline-danger:hover { color: #ffffff; background: #b91c1c; border-color: #b91c1c; }
[data-theme="dark"] .admin-dash .btn-danger { background: #b91c1c; border-color: #b91c1c; color: #ffffff; }
[data-theme="dark"] .admin-dash .btn-danger:hover { background: #991b1b; border-color: #991b1b; color: #ffffff; }
[data-theme="dark"] .admin-dash .btn-success { background: #15803d; border-color: #15803d; color: #ffffff; }
[data-theme="dark"] .admin-dash .btn-success:hover { background: #166534; border-color: #166534; color: #ffffff; }
[data-theme="dark"] .admin-dash .form-text { color: #9ca3af; }
[data-theme="dark"] .admin-dash .form-label { color: #e8eaed; }
[data-theme="dark"] .admin-dash .form-control::placeholder { color: #9ca3af; }
[data-theme="dark"] .admin-dash .text-warning-emphasis { color: #fcd34d !important; }
[data-theme="dark"] .admin-dash .alert-danger { background: rgba(239,68,68,.14); border-color: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .admin-dash .alert-warning { background: rgba(234,179,8,.14); border-color: #713f12; color: #fcd34d; }
[data-theme="dark"] .admin-dash .rp-badge { background: #2d3139; color: #d1d5db; }
[data-theme="dark"] .admin-dash #bulkBar { background: rgba(249,115,22,.12) !important; border-color: #7c2d12 !important; }
[data-theme="dark"] .admin-dash [style*="color:#9a3412"] { color: #fdba74 !important; }
[data-theme="dark"] .admin-dash [style*="color:#6ab023"] { color: #a3e635 !important; }
[data-theme="dark"] .admin-dash [style*="color:#3d4752"] { color: #f1f3f7 !important; }
[data-theme="dark"] .admin-dash [style*="background:#dcfce7"], [data-theme="dark"] .admin-dash #importStatus[style*="rgb(220, 252, 231)"] { background: rgba(34,197,94,.16) !important; }
[data-theme="dark"] .admin-dash [style*="background:#fef9c3"], [data-theme="dark"] .admin-dash #importStatus[style*="rgb(254, 249, 195)"] { background: rgba(234,179,8,.16) !important; }
[data-theme="dark"] .admin-dash [style*="background:#fee2e2"], [data-theme="dark"] .admin-dash #importStatus[style*="rgb(254, 226, 226)"] { background: rgba(239,68,68,.16) !important; }
[data-theme="dark"] .admin-dash [style*="background:#f3f4f6"] { background: rgba(156,163,175,.14) !important; }
[data-theme="dark"] .admin-dash [style*="background:#e8f0fe"], [data-theme="dark"] .admin-dash #importStatus[style*="rgb(232, 240, 254)"] { background: rgba(110,168,254,.14) !important; }
[data-theme="dark"] .admin-dash [style*="color:#16a34a"], [data-theme="dark"] .admin-dash #importStatus[style*="rgb(22, 163, 74)"] { color: #86efac !important; }
[data-theme="dark"] .admin-dash [style*="color:#b45309"], [data-theme="dark"] .admin-dash #importStatus[style*="rgb(180, 83, 9)"] { color: #fcd34d !important; }
[data-theme="dark"] .admin-dash [style*="color:#dc2626"], [data-theme="dark"] .admin-dash #importStatus[style*="rgb(220, 38, 38)"] { color: #fca5a5 !important; }
[data-theme="dark"] .admin-dash [style*="color:#6b7280"] { color: #d1d5db !important; }
[data-theme="dark"] .admin-dash [style*="color:#1a6cb5"], [data-theme="dark"] .admin-dash #importStatus[style*="rgb(26, 108, 181)"] { color: #9ec5fe !important; }
[data-theme="dark"] .admin-dash a[style*="color:#1a6cb5"]:hover { color: #cfe2ff !important; }
[data-theme="dark"] .admin-dash #fetchError { background: rgba(220,38,38,.18) !important; color: #fca5a5 !important; }

/* #341 dark rules (light counterparts sit above the #731 dark blocks) */
[data-theme="dark"] .admin-dash .storage-usage-text { color: #f1f3f7; }
[data-theme="dark"] .admin-dash .storage-usage-note { color: #b8bfcc; }
[data-theme="dark"] .admin-dash .storage-bar { background: #2d3340; }
[data-theme="dark"] .admin-dash .storage-bar-fill { background: #6ea8fe; }
[data-theme="dark"] .admin-dash .storage-warn .storage-bar-fill { background: #fbbf24; }
[data-theme="dark"] .admin-dash .storage-danger .storage-bar-fill { background: #f87171; }
[data-theme="dark"] .admin-dash .storage-warn .storage-level-label { color: #fcd34d; }
[data-theme="dark"] .admin-dash .storage-danger .storage-level-label { color: #fca5a5; }
[data-theme="dark"] .admin-dash .in-use-badge { background: #3b2f12; color: #fcd34d; }
[data-theme="dark"] .admin-dash .img-reason { color: #d1d5db; }
[data-theme="dark"] .admin-dash .cleanup-safe { color: #86efac; }
[data-theme="dark"] .admin-dash .cleanup-inuse { color: #fcd34d; }
