/* ============================================================
   FINANCIAL ARCHITECT — Design System v2
   Palette: Deep Emerald #006c49 / Vibrant #10b981 / Ice #f7f9fb
   Fonts: Manrope (headings) + Inter (body)
   Philosophy: Structural Serenity · No-Line Rule · Tonal Depth
   ============================================================ */

/* === 0. GOOGLE FONTS IMPORT ========================================== */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Inter:wght@300;400;500;600;700&display=swap');

/* === 1. DESIGN TOKENS (CSS Custom Properties) ======================== */
:root {
  /* --- Brand Palette --- */
  --primary:            #006c49;
  --primary-container:  #10b981;
  --primary-gradient:   linear-gradient(135deg, #006c49 0%, #10b981 100%);
  --primary-hover:      #005a3c;
  --primary-active:     #004d33;

  /* --- Surface Hierarchy (Ice Grey system) --- */
  --surface:            #f7f9fb;   /* Level 0 — canvas */
  --surface-low:        #f2f4f6;   /* Level 1 — sections */
  --surface-mid:        #eceef0;   /* Level 2 — hover states */
  --surface-high:       #e6e8ea;   /* Level 3 — borders/dividers */
  --surface-highest:    #e0e3e5;   /* Level 4 — strong contrast */
  --surface-white:      #ffffff;   /* Card face */

  /* --- Text --- */
  --on-surface:         #191c1e;   /* Critical text — never pure black */
  --on-surface-variant: #565e74;   /* Supporting / helper text */
  --on-surface-muted:   #8b95a3;   /* Placeholders */
  --on-primary:         #ffffff;

  /* --- Semantic --- */
  --outline-variant:    rgba(187, 202, 191, 0.15); /* Ghost border */
  --shadow-ambient:     0 12px 32px -4px rgba(25, 28, 30, 0.06);
  --shadow-card:        0 2px 8px -2px rgba(25, 28, 30, 0.04);
  --glass-bg:           rgba(247, 249, 251, 0.80);
  --glass-blur:         24px;

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

  /* --- Spacing --- */
  --card-pad: 1.5rem;

  /* --- Typography --- */
  --font-display: 'Manrope', sans-serif;
  --font-body:    'Inter', sans-serif;

  /* Legacy persona tokens — kept for compatibility */
  --brand-primary:    #006c49;
  --brand-secondary:  #10b981;
  --brand-hover:      #005a3c;
  --brand-active:     #004d33;
  --soft-bg:          #ecfdf5;
  --hover-bg:         #d1fae5;

  /* Icon filter tokens */
  --icon-active-filter-research: invert(56%) sepia(87%) saturate(452%) hue-rotate(346deg) brightness(91%) contrast(88%);
  --icon-active-filter-finance:  invert(30%) sepia(61%) saturate(641%) hue-rotate(120deg) brightness(88%) contrast(92%);
  --icon-active-filter-legal:    invert(35%) sepia(88%) saturate(1637%) hue-rotate(208deg) brightness(96%) contrast(94%);

  --header-h: 64px;

  --indicator-messages: "Processing...|Still processing...|Working on it...|Yep... talking to the AI thingy...|Waiting... waiting... waiting...|Nearly there... just gimme a moment|Good things take time...|Bear with me...|Oh man! Come on!|Tick toc...|Do you feel like a coffee? Chai Latte?";
  --indicator-jokes: "How come it was called the Dark Ages? There were a lot of knights.|What do you call fake fettuccine? Impasta.|What do you call a toothless grizzly? Gummy bear.|What did the janitor say when he jumped out of the closet? Supplies!!|What do you call a fish with no eyes? Fsh.|Why did the skeleton skip the dance? He had no body to go with.|Where do snowmen get loans? Snowbanks.|Why was Cinderella kicked off her soccer team? She kept running away from the ball.|What do you call a can opener that doesn't work? A cant opener.|There wasn't a dry eye at the wedding. Even the cake was in tiers.";
}

/* === 2. PERSONA THEME OVERRIDES ====================================== */

/* FINANCE — uses the full Architect palette (default) */
.theme-finance {
  --brand-primary:   #006c49;
  --brand-secondary: #10b981;
  --brand-hover:     #005a3c;
  --brand-active:    #004d33;
  --soft-bg:         #ecfdf5;
  --hover-bg:        #d1fae5;
}

/* RESEARCH — warm amber, kept intact */
.theme-research {
  --brand-primary:   #F28C28;
  --brand-secondary: #e78a20;
  --brand-hover:     #FF5F1F;
  --brand-active:    #FFA500;
  --soft-bg:         #fdf2e9;
  --hover-bg:        #f1f5f9;
  --sidebar-active-bg: rgba(242, 140, 40, 0.15);
  --sidebar-active-text: #F28C28;
  --primary:         #F28C28;
  --primary-container: #e78a20;
  --primary-gradient: linear-gradient(135deg, #F28C28 0%, #FFAD60 100%);
}

/* LEGAL — navy blue, kept intact */
.theme-legal {
  --brand-primary:   #1e3a8a;
  --brand-secondary: #3b82f6;
  --brand-hover:     #1e40af;
  --brand-active:    #172554;
  --soft-bg:         #eff6ff;
  --hover-bg:        #dbeafe;
  --sidebar-active-bg: rgba(30, 58, 138, 0.15);
  --sidebar-active-text: #3b82f6
  --primary:         #1e3a8a;
  --primary-container: #3b82f6;
  --primary-gradient: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
}

/* === 3. GLOBAL BASE =================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--on-surface);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--surface);
  color: var(--on-surface);
  font-family: var(--font-body);
}

/* Headings use Manrope */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--on-surface);
  letter-spacing: -0.01em;
}

p, li, span, td, th, label, input, select, textarea, button {
  font-family: var(--font-body);
}

/* === 4. SIDEBAR / NAVIGATION ========================================= */

.aside-dark {
  position: fixed;
  top: var(--header-h, 64px);
  left: 0;
  width: 16rem;
  height: calc(100vh - var(--header-h, 64px));
  background: var(--surface-white);   /* White panel on ice-grey canvas */
  border-right: none;                 /* No-line rule — shadow separates */
  z-index: 40;
  overflow-y: auto;
  box-shadow: 2px 0 12px rgba(25, 28, 30, 0.05);
}

/* No accent strip on light sidebar */
.aside-dark::before { display: none; }

/* Override persona borders on sidebar */
.theme-finance .aside-dark,
.theme-legal .aside-dark,
.theme-research .aside-dark {
  border-right: none !important;
  background: var(--surface-white) !important;
}

/* Nav links — dark text on light background */
.aside-dark .nav-link,
#main-sidebar .nav-link,
#main-sidebar a.nav-link {
  color: var(--on-surface-variant) !important;
  background: transparent !important;
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: var(--radius-md);
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.875rem;
  margin: 1px 0.5rem;
}

.aside-dark .nav-link:hover,
#main-sidebar .nav-link:hover,
#main-sidebar a.nav-link:hover {
  background: var(--surface-low) !important;
  color: var(--on-surface) !important;
}

/* Active nav link — green text, subtle tinted bg, green left bar */
.aside-dark .nav-link-active,
#main-sidebar .nav-link-active,
#main-sidebar a.nav-link-active,
[class*="theme-"] .nav-link-active {
  background: #ecfdf5 !important;   /* Very faint green tint */
  color: var(--primary) !important;
  font-weight: 600 !important;
  box-shadow: inset 3px 0 0 var(--primary); /* Green left accent bar */
}

/* Icons — dark on light sidebar, green when active */
.icon-white {
  filter: brightness(0) saturate(0%) invert(40%); /* Dark grey by default */
  transition: filter 0.2s;
}

.nav-link-active .icon-white,
.aside-dark .nav-link-active .icon-white,
#main-sidebar .nav-link-active .icon-white {
  filter: var(--icon-active-filter-finance) !important;
}

/* Per-persona active icon colours */
.theme-research .nav-link-active .icon-white { filter: var(--icon-active-filter-research) !important; }
.theme-finance  .nav-link-active .icon-white { filter: var(--icon-active-filter-finance) !important; }
.theme-legal    .nav-link-active .icon-white { filter: var(--icon-active-filter-legal) !important; }

/* Header */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    background: white;
}

/* Finance persona — very pale green/lime header */
.theme-finance header,
.theme-finance header.bg-white {
  background-color: #f0fdf4 !important;
  border-bottom: 1px solid #d1fae5 !important;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.08) !important;
}

/* === 6. TYPOGRAPHY SCALE ============================================= */

/* Display */
.text-display { font-family: var(--font-display); font-size: 3.5rem; font-weight: 700; letter-spacing: -0.02em; color: var(--on-surface); }

/* Headline */
.text-headline { font-family: var(--font-display); font-size: 1.75rem; font-weight: 600; letter-spacing: -0.01em; }

/* Title — used for card headers, section intros */
.text-title { font-family: var(--font-body); font-size: 1.125rem; font-weight: 500; }

/* Body */
.text-body { font-family: var(--font-body); font-size: 0.875rem; font-weight: 400; letter-spacing: 0.01em; color: var(--on-surface-variant); }

/* Label — ALL CAPS, tight tracking */
.text-label { font-family: var(--font-body); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--on-surface-variant); }

/* Manrope for page H1/H2 */
h1 { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.375rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1.0625rem; font-weight: 600; }

/* === 7. BUTTONS ======================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.125rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.8125rem;
  border: none;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
  min-height: 40px;
  white-space: nowrap;
}

/* Primary — gradient signature */
.btn-primary {
  background: var(--brand-primary) !important;
  color: var(--on-primary) !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(0, 108, 73, 0.25);
}
.btn-primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 4px 16px rgba(0, 108, 73, 0.32);
}
.btn-primary:active { transform: translateY(1px); filter: brightness(0.96); }

/* Secondary — surface tonal, no border */
.btn-secondary {
  background: var(--surface-low) !important;
  color: var(--on-surface) !important;
  border: none !important;
}
.btn-secondary:hover {
  background: var(--surface-mid) !important;
  color: var(--brand-primary) !important;
}

/* Large variant */
.btn-lg { padding: 0.625rem 1.5rem; font-size: 0.9375rem; min-height: 48px; border-radius: var(--radius-md); }

/* Icon Buttons */
.btn-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 34px !important; height: 34px !important;
  border-radius: var(--radius-md) !important;
  transition: background 0.15s;
  padding: 0 !important;
  margin: 0 2px !important;
  background: transparent !important;
  border: none !important;
}
.btn-view:hover { background: var(--surface-low) !important; }
.btn-edit:hover { background: #fffbeb !important; }
.btn-del:hover  { background: #fff1f2 !important; }

/* Mobile minimum touch target */
.btn, .landing-cta, .landing-ghost { min-height: 48px; }

/* === 8. CARDS ========================================================= */

/* Base card — white face on low surface */
.card {
  background: var(--surface-white);
  border-radius: var(--radius-xl);
  padding: var(--card-pad);
  box-shadow: var(--shadow-card);
  /* No border — tonal separation handles it */
}

/* Section container */
.section-container {
  background: var(--surface-low);
  border-radius: var(--radius-xl);
  padding: var(--card-pad);
}

/* Ghost border fallback for high-density tables only */
.ghost-border { border: 1px solid var(--outline-variant); }

/* === 9. INPUTS ======================================================== */

.input, input[type="text"], input[type="search"], input[type="email"],
input[type="password"], input[type="number"], select, textarea {
  background: var(--surface-white);
  border: 1px solid var(--surface-high);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--on-surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.input::placeholder,
input::placeholder,
textarea::placeholder { color: var(--on-surface-muted); }

.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 108, 73, 0.12);
}

input[type="radio"],
input[type="checkbox"] {
  accent-color: var(--brand-primary) !important;
  font-size: 16px !important; /* prevent iOS zoom */
}

/* Hardcoded green for finance — prevents research orange bleed */
.theme-finance input[type="radio"],
.theme-finance input[type="checkbox"] {
  accent-color: #006c49 !important;
}

/* Mobile: prevent zoom on focus */
input, select, textarea { font-size: 16px !important; }

/* === 10. FEATURE UI: KB, TABS, TRANSCRIPTS =========================== */

/* --- Knowledge Base dual panel --- */
.kb-dual { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: start; }

.kb-panel {
  display: flex;
  flex-direction: column;
  background: var(--surface-white);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  min-width: 0;
  /* No border — card shadow defines boundary */
}

.kb-list-header {
  font-family: var(--font-body);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  padding: 0.75rem 1rem;
  background: var(--surface-low);
  /* No border-bottom — background shift is the divider */
}

.kb-list { height: 420px; overflow-y: auto; }

.kb-row {
  display: flex;
  align-items: center;
  padding: 0.625rem 1rem;
  height: 44px;
  overflow: hidden;
  background: var(--surface-white);
  /* Gap between rows via box-shadow instead of border */
  border-bottom: 1px solid var(--surface-low);
  transition: background 0.12s;
  cursor: pointer;
}

.kb-row:hover { background: var(--surface-low); }

.kb-row-title {
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.8125rem;
  color: var(--on-surface);
}

.kb-row-date {
  color: var(--on-surface-muted);
  font-size: 0.6875rem;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  margin-left: 0.75rem;
  flex-shrink: 0;
}

.kb-shuttle { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1rem; padding-top: 2rem; }

.kb-shuttle-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-gradient);
  border: none; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,108,73,0.25);
  transition: filter 0.15s;
}
.kb-shuttle-btn:hover { filter: brightness(1.1); }

/* --- Interrogate Tabs --- */
#tabbar { display: flex; align-items: flex-end; gap: 0.375rem; padding-left: 4px; }

#tabbar .tab-pill {
  padding: 0.5rem 1.125rem;
  border: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-high);
  color: var(--on-surface-variant);
  transition: background 0.15s, color 0.15s;
}

#tabbar .tab-pill:hover {
  background: var(--surface-mid);
  color: var(--on-surface);
}

#tabbar .tab-pill.active {
  background: var(--surface-white);
  color: var(--brand-primary);
  margin-bottom: -1px;
  position: relative;
  z-index: 2;
  box-shadow: 0 -2px 0 var(--brand-primary) inset;
}

/* --- Transcript Viewport --- */
.transcript-viewport {
  background: var(--surface-white);
  border-radius: var(--radius-lg);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.8125rem;
  max-height: 600px;
  overflow-y: auto;
  margin-top: 0.75rem;
}

.line-container { display: flex; align-items: flex-start; border-bottom: 1px solid var(--surface-low); }

.ln-gutter {
  width: 48px;
  background: var(--surface-low);
  color: var(--on-surface-muted);
  text-align: right;
  padding: 3px 8px;
  user-select: none;
  font-size: 0.6875rem;
  flex-shrink: 0;
}

.ln-text { padding: 3px 12px; white-space: pre-wrap; color: var(--on-surface); font-size: 0.8125rem; }

/* --- Reference / Citation links --- */
.citation-link {
  color: var(--brand-primary);
  background: var(--soft-bg);
  padding: 0 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  border: 1px solid rgba(0,108,73,0.2);
}

.ref-link {
  color: var(--brand-primary);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0 1px;
  border-bottom: 1px dotted var(--brand-primary);
}
.ref-link:hover { border-bottom-style: solid; filter: brightness(1.2); }

/* === 11. AI SUMMARY COMPONENTS ======================================= */

/* Unified section heading in AI output */
.ai-header-unified {
  font-family: var(--font-display) !important;
  font-size: 0.6875rem !important;
  font-weight: 700 !important;
  color: var(--on-surface-variant) !important;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding-bottom: 6px;
  margin-bottom: 10px;
  margin-top: 24px;
  display: block;
  /* Subtle tonal rule instead of hard border */
  border-bottom: 1px solid var(--surface-high);
}

/* AI chat bubble — tonal, not harsh */
.ai-chat-bubble {
  background: var(--surface-low) !important;
  border: none !important;
  border-radius: var(--radius-xl) !important;
  color: var(--on-surface) !important;
  box-shadow: var(--shadow-card);
}

.theme-finance .ai-chat-bubble {
  background: #f0fdf8 !important;
  color: var(--on-surface) !important;
}

.theme-legal .ai-chat-bubble {
  background: #f0f6ff !important;
  color: var(--on-surface) !important;
}

.theme-research .ai-chat-bubble {
  background: #fff9f0 !important;
  color: var(--on-surface) !important;
}

/* === 12. SORT BUTTONS ================================================= */

.sort-btn {
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-body);
  letter-spacing: 0.02em;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  background: var(--surface-low);
  color: var(--on-surface-variant);
}
.sort-btn:hover, .active-sort-btn {
  background: var(--soft-bg) !important;
  color: var(--brand-primary) !important;
}

/* === 13. PERSONA HIJACK (Tailwind override engine) =================== */

/* FINANCE — force all blue/green Tailwind classes to brand */
.theme-finance [class*="bg-blue-6"], .theme-finance [class*="bg-blue-7"],
.theme-finance [class*="bg-green-6"], .theme-finance [class*="bg-green-7"],
.theme-finance [class*="bg-emerald-6"], .theme-finance [class*="bg-emerald-7"],
.theme-finance [class*="bg-amber-"], .theme-finance [class*="bg-orange-"],
.theme-finance .bg-amber-600 {
  background-color: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
  color: white !important;
}
.theme-finance [class*="bg-emerald-5"],
.theme-finance [class*="bg-green-5"],
.theme-finance .btn-accent {
  background-color: var(--brand-secondary) !important;
  border-color: var(--brand-secondary) !important;
}
.theme-finance [class*="bg-emerald-5"]:hover,
.theme-finance [class*="bg-green-5"]:hover { filter: brightness(0.9) !important; }

.theme-finance [class*="hover:bg-"]:hover,
.theme-finance [class*="bg-amber-"]:hover,
.theme-finance [class*="bg-orange-"]:hover {
  background-color: var(--brand-hover) !important;
  border-color: var(--brand-hover) !important;
}

.theme-finance [class*="text-blue-"],
.theme-finance [class*="text-green-"],
.theme-finance [class*="text-emerald-"] { color: var(--brand-primary) !important; }

.theme-finance [class*="border-blue-"],
.theme-finance [class*="border-green-"],
.theme-finance [class*="border-emerald-"] { border-color: var(--brand-primary) !important; }

/* RESEARCH */
.theme-research [class*="bg-blue-6"], .theme-research [class*="bg-blue-7"],
.theme-research [class*="bg-green-6"], .theme-research [class*="bg-green-7"],
.theme-research [class*="bg-emerald-6"], .theme-research [class*="bg-emerald-7"],
.theme-research [class*="hover:bg-"]:hover {
  background-color: var(--brand-hover) !important;
  border-color: var(--brand-hover) !important;
}
.theme-research [class*="text-blue-"],
.theme-research [class*="text-green-"],
.theme-research [class*="text-emerald-"] { color: var(--brand-primary) !important; }
.theme-research [class*="border-blue-"],
.theme-research [class*="border-green-"],
.theme-research [class*="border-emerald-"] { border-color: var(--brand-primary) !important; }

/* Nav active — persona-aware */
.theme-research .nav-link-active {
  background-color: #fff7ed !important;
  color: var(--brand-primary) !important;
}

/* LEGAL */
.theme-legal [class*="bg-blue-"], .theme-legal [class*="bg-green-"],
.theme-legal [class*="bg-emerald-"], 
.theme-legal [class*="hover:bg-"]:hover {
  background-color: var(--brand-hover) !important;
}
.theme-legal [class*="text-blue-"],
.theme-legal [class*="text-green-"],
.theme-legal [class*="text-emerald-"] { color: var(--brand-primary) !important; }
.theme-legal .nav-link-active {
  background-color: #eff6ff !important;
  color: var(--brand-primary) !important;
}

/* === 14. ADMIN TABLE LAYOUT =========================================== */

td .flex, td div {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-end !important;
}
td form { display: inline-block !important; margin: 0 !important; padding: 0 !important; }

/* === 15. ICONS & LOGO ================================================= */

.app-logo { height: 40px; width: auto; transition: filter 0.3s; }
.theme-research .app-logo { filter: var(--icon-active-filter-research); }
.theme-finance  .app-logo { filter: var(--icon-active-filter-finance); }
.theme-legal    .app-logo { filter: var(--icon-active-filter-legal); }

.sbi { width: 18px; height: 18px; display: inline-block; vertical-align: middle; }

/* Robust icon colour filters */
.icon-orange { filter: brightness(0) saturate(100%) invert(61%) sepia(85%) saturate(2225%) hue-rotate(3deg) brightness(102%) contrast(105%) !important; }
.icon-amber  { filter: brightness(0) saturate(100%) invert(82%) sepia(61%) saturate(2256%) hue-rotate(357deg) brightness(103%) contrast(105%) !important; }
.icon-blue   { filter: brightness(0) saturate(100%) invert(68%) sepia(51%) saturate(511%) hue-rotate(184deg) brightness(100%) contrast(95%) !important; }
.icon-red    { filter: brightness(0) saturate(100%) invert(18%) sepia(87%) saturate(6144%) hue-rotate(357deg) brightness(95%) contrast(110%) !important; }
.icon-gray   { filter: brightness(0) saturate(0%) invert(60%) !important; }

/* Search icon button */
/* Search button icon is always white — never inherits icon-white grey */
.search-icon-btn img { filter: brightness(0) invert(1) !important; }
.search-icon-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-gradient) !important;
  border: none !important;
  cursor: pointer; z-index: 10;
  box-shadow: 0 2px 8px rgba(0,108,73,0.2);
}

/* Pager button */
.pager-icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-gradient) !important;
  border: none !important;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,108,73,0.2);
}
.pager-icon-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.pager-icon-btn img { filter: brightness(0) invert(1) !important; }

/* === 16. DROPDOWN MENUS ============================================== */

.menu-item {
  transition: background 0.15s;
  display: block;
  padding: 10px 16px;
  font-size: 0.875rem;
  color: var(--on-surface);
  text-decoration: none;
  font-family: var(--font-body);
}

.persona-finance .menu-item:hover { background: #e6faf3 !important; color: var(--on-surface) !important; }
.persona-legal   .menu-item:hover { background: #e8f0fd !important; color: var(--on-surface) !important; }
.persona-research .menu-item:hover { background: #fff0dd !important; color: var(--on-surface) !important; }

/* === 17. MARKET TICKERS ============================================== */

.market-ticker-badge:hover {
  background-color: var(--brand-hover) !important;
  color: #ffffff !important;
  filter: brightness(1.1);
}

/* === 18. IMAGE VIEWER ================================================ */

#image-viewer-container .grid > div {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === 19. ANALYTICS / KPI DASHBOARD =================================== */

.kpi-grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }

.kpi-tile {
  background: var(--surface-white);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: 80px;
}

.kpi-tile-label { font-size: 0.6875rem; color: var(--on-surface-variant); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1.3; margin-bottom: 6px; }
.kpi-tile-value { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; color: var(--on-surface); }
.kpi-tile-value.positive { color: #059669; }
.kpi-tile-value.negative { color: #dc2626; }
.kpi-tile-value.neutral  { color: var(--on-surface); }

.kpi-chart-tile { background: var(--surface-white); border-radius: var(--radius-lg); padding: 4px; box-shadow: var(--shadow-card); }

.kpi-tile--green { background: #f0fdf4 !important; }
.kpi-tile--green .kpi-tile-value { color: #166534 !important; }
.kpi-tile--red   { background: #fff1f2 !important; }
.kpi-tile--red   .kpi-tile-value { color: #991b1b !important; }
.kpi-tile--blue  { background: #eff6ff !important; }
.kpi-tile--blue  .kpi-tile-value { color: #1e40af !important; }
.kpi-tile--gray  { background: var(--surface-low) !important; }
.kpi-tile--gray  .kpi-tile-value { color: var(--on-surface-variant) !important; }

/* === 20. MODELING TABLE ============================================== */

.modeling-table tr:hover td { background: var(--surface-low); }

/* === 21. UTILITY CLASSES ============================================= */

.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.col-actions { width: 130px !important; text-align: right !important; white-space: nowrap !important; }

/* === 22. AUTH / PASSWORD TOGGLE ====================================== */

.pw-wrapper { position: relative; width: 100%; }
.pw-input { width: 100%; padding-right: 2.5rem; box-sizing: border-box; }
.pw-toggle { position: absolute; right: 0.75rem; top: 50%; transform: translateY(-50%); background: transparent; border: none; cursor: pointer; font-size: 1rem; color: var(--on-surface-muted); }

/* === 23. MOBILE OPTIMIZATIONS ======================================== */

:root { --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px); }

.landing-hero { padding-top: calc(2rem + var(--safe-top)); padding-bottom: 2rem; }
.history-table-container { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.cvs-modal__card {
  max-height: calc(90vh - var(--safe-top) - var(--safe-bottom));
  width: 95% !important; margin: 10px auto !important;
  display: flex; flex-direction: column;
}
.cvs-modal__body { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }

@media (max-width: 640px) {
  .video-item { flex-direction: column; }
  .video-item img { width: 100%; height: 180px; margin-bottom: 1rem; }
  .video-item input[type="checkbox"] { position: absolute; top: 10px; left: 10px; z-index: 10; transform: scale(1.5); }
}

/* === 24. GLASSMORPHISM (Modals, Tooltips, Overlays) ================== */

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-ambient);
}

/* === 25. SCROLLBAR (webkit — editorial thin style) =================== */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-highest); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--on-surface-muted); }

/* === 26. CHECKBOX & RADIO — force green accent app-wide ============= */
input[type=checkbox],
input[type=radio],
[type=checkbox],
[type=radio] {
  accent-color: var(--brand-primary) !important;
}

/* Finance persona — explicit green override to prevent theme bleed */
.theme-finance input[type=checkbox],
.theme-finance input[type=radio],
.theme-finance [type=checkbox],
.theme-finance [type=radio],
body.theme-finance input[type=checkbox],
body.theme-finance input[type=radio] {
  accent-color: #006c49 !important;
}

/* === 27. TABLE ROW HOVER — light lime, not dark ===================== */
.modeling-table tr:hover td,
table tbody tr:hover td {
  background-color: #f0fdf8 !important; /* very faint mint */
}

/* Background Patterns */
.hex-pattern { 
    background-size: 30px 26px; 
    background-attachment: fixed; 
}

.hex-pattern-admin { 
    background-size: 30px 26px; 
    background-attachment: fixed; 
}

/* HTMX Loading Indicators */
.htmx-indicator { opacity: 0; }
.htmx-request .htmx-indicator { opacity: 1; transition: opacity 200ms ease-in; }
.htmx-request.htmx-indicator { opacity: 1; transition: opacity 200ms ease-in; }

/* Help Chip */
.help-chip {
    width: 32px; 
    height: 32px; 
    border-radius: 50%;
    display: flex; 
    align-items: center; 
    justify-content: center;
    background: #10b981; 
    color: white; 
    border: none;
    cursor: pointer; 
    font-weight: bold; 
    font-size: 18px;
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .help-chip { 
        width: 28px; 
        height: 28px; 
        font-size: 16px; 
    }
}

/* Sidebar positioning */
#main-sidebar {
    top: 64px;
}

@media (max-width: 767px) {
    #main-sidebar {
        position: fixed !important;
        top: 64px !important;
        left: 0 !important;
        height: calc(100vh - 64px) !important;
        width: 280px !important;
        z-index: 9999 !important;
        box-shadow: 4px 0 10px rgba(0,0,0,0.1);
    }
    
    #sidebar-backdrop {
        z-index: 9998 !important;
        position: fixed !important;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
    }
}

@media (min-width: 768px) {
    #main-sidebar {
        position: static !important;
        top: auto !important;
        transform: translateX(0) !important;
        z-index: auto !important;
        height: auto !important;
    }
}

/* Main Content Layout - global 10px padding */
#main-content {
    margin-left: 0;
    padding-left: 10px;
    padding-right: 10px;
}

@media (min-width: 768px) {
    #main-content {
        margin-left: 16rem;
        padding-left: 10px;
        padding-right: 10px;
    }
}