:root,
[data-theme="dark"] {
  --font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --bg-main: #0b0f19;
  --bg-card: rgba(23, 32, 54, 0.85);
  --bg-card-hover: rgba(30, 41, 69, 0.95);
  --bg-input: #1a233a;
  --border-color: rgba(255, 255, 255, 0.12);
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --primary-accent: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --emerald-accent: #10b981;
  --amber-accent: #f59e0b;
  --rose-accent: #f43f5e;
  --card-radius: 16px;
  --shadow-soft: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  --transition-speed: 0.25s;
  --accordion-icon-filter: invert(1) brightness(2);
  --btn-close-filter: invert(1) grayscale(100%) brightness(200%);
  --scrollbar-thumb: rgba(148, 163, 184, 0.35);
  --scrollbar-track: transparent;

  /* Override Bootstrap CSS Variables */
  --bs-body-color: #f8fafc;
  --bs-body-bg: #0b0f19;
  --bs-secondary-color: #cbd5e1;
  --bs-heading-color: #f8fafc;
}

[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: #ffffff;
  --bg-input: #ffffff;
  --border-color: rgba(0, 0, 0, 0.1);
  --text-main: #0f172a;
  --text-muted: #475569;
  --primary-accent: #4f46e5;
  --primary-glow: rgba(79, 70, 229, 0.15);
  --shadow-soft: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
  --accordion-icon-filter: none;
  --btn-close-filter: none;
  --scrollbar-thumb: rgba(100, 116, 139, 0.35);

  /* Override Bootstrap CSS Variables for Light mode */
  --bs-body-color: #0f172a;
  --bs-body-bg: #f1f5f9;
  --bs-secondary-color: #475569;
  --bs-heading-color: #0f172a;
}

/* Global text color enforcement & dark mode visibility guarantees */
.text-main {
  color: var(--text-main) !important;
}

/* High specificity dark mode text overrides to defeat Bootstrap !important */
:root:not([data-theme="light"]) .text-dark,
:root:not([data-theme="light"]) .text-black,
:root:not([data-theme="light"]) .text-body,
:root:not([data-theme="light"]) .text-dark-emphasis,
:root:not([data-theme="light"]) .text-body-emphasis,
[data-theme="dark"] .text-dark,
[data-theme="dark"] .text-black,
[data-theme="dark"] .text-body,
[data-theme="dark"] .text-dark-emphasis,
[data-theme="dark"] .text-body-emphasis {
  color: #f8fafc !important;
}

:root:not([data-theme="light"]) .text-muted,
:root:not([data-theme="light"]) .text-secondary,
:root:not([data-theme="light"]) small.text-muted,
:root:not([data-theme="light"]) p.text-muted,
:root:not([data-theme="light"]) label.form-label,
[data-theme="dark"] .text-muted,
[data-theme="dark"] .text-secondary,
[data-theme="dark"] small.text-muted,
[data-theme="dark"] p.text-muted,
[data-theme="dark"] label.form-label {
  color: #cbd5e1 !important;
}

:root:not([data-theme="light"]) input,
:root:not([data-theme="light"]) select,
:root:not([data-theme="light"]) textarea,
:root:not([data-theme="light"]) table,
:root:not([data-theme="light"]) th,
:root:not([data-theme="light"]) td,
:root:not([data-theme="light"]) .modal-content,
:root:not([data-theme="light"]) .modal-body,
:root:not([data-theme="light"]) .accordion-button,
:root:not([data-theme="light"]) .accordion-body,
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] table,
[data-theme="dark"] th,
[data-theme="dark"] td,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-body,
[data-theme="dark"] .accordion-button,
[data-theme="dark"] .accordion-body {
  color: #f8fafc !important;
}

/* Ensure form select options inherit theme colors and never show black text on dark bg */
select.form-control-custom option,
.form-control-custom option,
option {
  background-color: var(--bg-input);
  color: var(--text-main);
}

.deduction-input-block {
  background: rgba(255, 255, 255, 0.02) !important;
  border: 1px solid var(--border-color) !important;
  transition: all 0.2s ease;
}

.deduction-input-block:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: var(--primary-accent) !important;
}

.fs-7 { font-size: 0.825rem; }
.fs-8 { font-size: 0.75rem; }

[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: #ffffff;
  --bg-input: #ffffff;
  --border-color: rgba(0, 0, 0, 0.08);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --primary-accent: #4f46e5;
  --primary-glow: rgba(79, 70, 229, 0.15);
  --shadow-soft: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
  --accordion-icon-filter: none;
  --btn-close-filter: none;
  --scrollbar-thumb: rgba(100, 116, 139, 0.35);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

.fw-extrabold {
  font-weight: 800;
}

.text-emerald {
  color: var(--emerald-accent) !important;
}

.text-rose {
  color: var(--rose-accent) !important;
}

.text-amber {
  color: var(--amber-accent) !important;
}

.row > [class*="col-"] {
  min-width: 0;
}

/* Glassmorphism Cards */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.glass-card:hover {
  background: var(--bg-card-hover);
}

/* Navbar */
.navbar-custom {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.8rem 0;
}

[data-theme="light"] .navbar-custom {
  background: rgba(255, 255, 255, 0.85);
}

.navbar-brand {
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.5px;
  color: var(--text-main) !important;
}

.brand-badge {
  background: linear-gradient(135deg, #6366f1 0%, #10b981 100%);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  vertical-align: middle;
}

/* Custom Tabs */
.nav-pills-wrapper {
  width: 100%;
  max-width: 100%;
}

.nav-pills-custom {
  background: var(--bg-input);
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  display: inline-flex;
  flex-wrap: nowrap;
  white-space: nowrap;
  max-width: 100%;
}

.nav-pills-custom .nav-link {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 10px;
  padding: 0.65rem 1.25rem;
  transition: all var(--transition-speed) ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-pills-custom .nav-link.active {
  background: var(--primary-accent);
  color: #ffffff;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.nav-pills-custom .nav-link:hover:not(.active) {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .nav-pills-custom .nav-link:hover:not(.active) {
  background: rgba(0, 0, 0, 0.04);
}

.nav-pills-custom .nav-link:focus-visible {
  outline: 2px solid var(--primary-accent);
  outline-offset: 2px;
}

/* Input & Range Controls */
.form-label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-control-custom {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  font-weight: 600;
  transition: border-color var(--transition-speed) ease;
}

.form-control-custom:focus {
  background-color: var(--bg-input);
  color: var(--text-main);
  border-color: var(--primary-accent);
  box-shadow: 0 0 0 3px var(--primary-glow);
  outline: none;
}

.form-control-custom:focus-visible {
  border-color: var(--primary-accent);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.input-label-row .form-label {
  flex: 1 1 8rem;
  min-width: 0;
  line-height: 1.35;
}

.input-value-display {
  flex: 0 0 auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Styled Range Sliders */
.form-range,
.calc-slider {
  height: 6px;
  cursor: pointer;
}

.form-range:focus {
  outline: none;
}

.form-range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--primary-glow), 0 0 10px var(--primary-glow);
}

.form-range:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 3px var(--primary-glow), 0 0 10px var(--primary-glow);
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  background: var(--primary-accent);
  box-shadow: 0 0 10px var(--primary-glow);
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  border: 2px solid #fff;
  cursor: pointer;
}

.form-range::-webkit-slider-runnable-track {
  background-color: var(--border-color);
  height: 6px;
  border-radius: 3px;
}

.form-range::-moz-range-track {
  background-color: var(--border-color);
  height: 6px;
  border-radius: 3px;
}

.form-range::-moz-range-thumb {
  background: var(--primary-accent);
  box-shadow: 0 0 10px var(--primary-glow);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  cursor: pointer;
}

/* Summary Callout Banner */
.callout-banner {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(16, 185, 129, 0.15) 100%);
  border-left: 4px solid var(--emerald-accent);
  border-radius: 12px;
  padding: 1.25rem;
  color: var(--text-main);
}

.callout-banner.warning-banner {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.15) 0%, rgba(245, 158, 11, 0.15) 100%);
  border-left-color: var(--rose-accent);
}

.callout-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

/* Metric Display Cards */
.metric-card {
  padding: 1rem 1.1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

[data-theme="light"] .metric-card {
  background: rgba(0, 0, 0, 0.02);
}

.metric-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.3;
}

.metric-value {
  font-size: clamp(0.95rem, 2.2vw + 0.35rem, 1.45rem);
  font-weight: 800;
  margin-top: 0.35rem;
  letter-spacing: -0.5px;
  line-height: 1.2;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.metric-card small {
  display: block;
  margin-top: 0.25rem;
  overflow-wrap: anywhere;
}

.text-gradient-emerald {
  background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-gradient-indigo {
  background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-gradient-amber {
  background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-gradient-rose {
  background: linear-gradient(135deg, #f43f5e 0%, #fb7185 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Chart Canvas Wrapper */
.chart-wrapper {
  position: relative;
  width: 100%;
  height: clamp(260px, 42vw, 360px);
  min-height: 260px;
  padding: 0.25rem 0.25rem 0 0.5rem;
}

.chart-wrapper canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Data Tables */
.table-custom {
  color: var(--text-main);
  vertical-align: middle;
  font-size: 0.88rem;
}

.table-custom th {
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
  background: transparent;
  padding: 0.75rem;
}

.table-custom td {
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem;
}

.table-custom tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .table-custom tbody tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

.style-scroll {
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.style-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.style-scroll::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 6px;
}

.style-scroll .table-custom thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-card);
  backdrop-filter: blur(8px);
}

/* Theme Toggle Button */
.theme-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  flex-shrink: 0;
}

.theme-btn:hover {
  transform: rotate(15deg);
  border-color: var(--primary-accent);
}

.theme-btn:focus-visible {
  outline: 2px solid var(--primary-accent);
  outline-offset: 2px;
}

/* Navbar actions */
.navbar-actions {
  flex-shrink: 0;
}

.navbar-custom .btn-outline-secondary {
  color: var(--text-muted);
  border-color: var(--border-color);
  white-space: nowrap;
}

.navbar-custom .btn-outline-secondary:hover,
.navbar-custom .btn-outline-secondary:focus-visible {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--primary-accent);
}

[data-theme="light"] .navbar-custom .btn-outline-secondary:hover,
[data-theme="light"] .navbar-custom .btn-outline-secondary:focus-visible {
  background: rgba(0, 0, 0, 0.04);
}

/* Accordion (rental inputs) */
.accordion-button-custom {
  color: var(--text-main) !important;
  box-shadow: none !important;
}

.accordion-button-custom:not(.collapsed) {
  color: var(--text-main) !important;
  background: transparent !important;
}

.accordion-button-custom::after {
  filter: var(--accordion-icon-filter);
}

.accordion-button-custom:focus-visible {
  box-shadow: 0 0 0 2px var(--primary-glow) !important;
}

/* Chart toggle buttons */
.chart-toggle-group {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chart-toggle-group .btn {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  text-align: center;
}

.chart-toggle-group .btn-outline-primary {
  color: var(--primary-accent);
  border-color: var(--border-color);
}

.chart-toggle-group .btn-outline-primary:hover,
.chart-toggle-group .btn-outline-primary:focus-visible {
  color: #fff;
  background: var(--primary-accent);
  border-color: var(--primary-accent);
}

.chart-toggle-group .btn-outline-primary.active {
  color: #fff;
  background: var(--primary-accent);
  border-color: var(--primary-accent);
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* Bootstrap overrides */
.btn-outline-secondary {
  color: var(--text-muted);
  border-color: var(--border-color);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus-visible {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--primary-accent);
}

[data-theme="light"] .btn-outline-secondary:hover,
[data-theme="light"] .btn-outline-secondary:focus-visible {
  background: rgba(0, 0, 0, 0.04);
}

.btn-primary {
  background: var(--primary-accent);
  border-color: var(--primary-accent);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: #5558e3;
  border-color: #5558e3;
}

.modal-content.glass-card {
  color: var(--text-main);
}

.modal-content .btn-close {
  filter: var(--btn-close-filter);
}

.modal-content .btn-close:focus-visible {
  box-shadow: 0 0 0 2px var(--primary-accent);
}

footer a {
  color: var(--text-muted);
  transition: color var(--transition-speed) ease;
}

footer a:hover,
footer a:focus-visible {
  color: var(--primary-accent);
}

/* Footer */
footer {
  border-top: 1px solid var(--border-color);
  padding: 2rem 0;
  margin-top: 4rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Responsive adjustments */
@media (max-width: 767.98px) {
  .navbar-custom .container {
    gap: 0.5rem;
  }

  .navbar-brand {
    font-size: 1.15rem;
  }

  .brand-badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.45rem;
  }

  .navbar-custom .btn-disclaimer-label {
    display: none;
  }

  .navbar-custom .btn-outline-secondary {
    padding: 0.25rem 0.55rem;
  }

  .display-6 {
    font-size: calc(1.15rem + 1.2vw);
  }

  .lead {
    font-size: 0.9rem;
  }

  /* Mobile Tab 2x2 Grid Layout */
  .nav-pills-wrapper {
    justify-content: center !important;
    width: 100%;
  }

  .nav-pills-custom {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    width: 100%;
    max-width: 100%;
    padding: 6px;
    border-radius: 16px;
  }

  .nav-pills-custom .nav-link {
    width: 100%;
    font-size: 0.825rem;
    padding: 0.6rem 0.35rem;
    text-align: center;
    border-radius: 10px;
    justify-content: center;
    white-space: normal;
  }

  .nav-pills-custom .nav-link i {
    font-size: 0.85rem;
    margin-right: 0.3rem !important;
  }

  .glass-card {
    padding: 1.15rem 1rem !important;
    border-radius: 14px;
  }

  .metric-card {
    padding: 0.85rem 0.85rem !important;
  }

  .metric-label {
    font-size: 0.68rem;
  }

  .metric-value {
    font-size: clamp(0.88rem, 4.2vw, 1.15rem);
  }

  .callout-banner {
    padding: 0.9rem;
  }

  .callout-title {
    font-size: 1rem;
  }

  .chart-wrapper {
    height: clamp(220px, 50vw, 300px);
    min-height: 220px;
    padding: 0.1rem;
  }

  .chart-toggle-group .btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
  }

  .table-custom th,
  .table-custom td {
    padding: 0.5rem 0.4rem;
    font-size: 0.8rem;
  }

  .accordion-button-custom {
    font-size: 0.9rem;
  }
}

@media (max-width: 575.98px) {
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  .input-value-display {
    font-size: 1rem !important;
  }
}

@media (max-width: 400px) {
  .nav-pills-custom .nav-link {
    font-size: 0.75rem;
    padding: 0.55rem 0.2rem;
  }
}

/* ================================================================
   FINBOT CHATBOT
   ================================================================ */

/* ── Floating Action Button ──────────────────────────────────── */
.chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  font-size: 1.35rem;
  cursor: pointer;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.55);
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1),
              box-shadow 0.25s ease;
  outline: none;
}
.chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.75);
}
.chat-fab:active { transform: scale(0.96); }
.chat-fab-active {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

/* Pulse ring on idle */
.chat-fab::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(99, 102, 241, 0.5);
  animation: chatPulse 2.5s ease-out infinite;
}
.chat-fab-active::before { animation: none; opacity: 0; }

@keyframes chatPulse {
  0%   { transform: scale(1);   opacity: 0.8; }
  70%  { transform: scale(1.35);opacity: 0;   }
  100% { transform: scale(1.35);opacity: 0;   }
}

.chat-fab-icon { display: flex; align-items: center; justify-content: center; }

/* Badge */
.chat-fab-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #f43f5e;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  padding: 0 4px;
  display: none;
}
.chat-fab-badge:not(:empty) { display: block; }

/* ── Chat Panel ──────────────────────────────────────────────── */
.chat-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 130px);
  border-radius: 20px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  z-index: 1049;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(.34,1.3,.64,1),
              opacity 0.3s ease;
}
.chat-panel-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── Panel Header ────────────────────────────────────────────── */
.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(99,102,241,0.18) 0%, rgba(139,92,246,0.12) 100%);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.chat-header-info { display: flex; align-items: center; gap: 10px; }

.chat-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}
.chat-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid var(--bg-card);
  animation: onlinePulse 2s ease-in-out infinite;
}
@keyframes onlinePulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
.chat-header-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-model-badge {
  font-size: 0.6rem;
  font-weight: 600;
  background: linear-gradient(90deg, #6366f1, #10b981);
  color: #fff;
  padding: 2px 6px;
  border-radius: 99px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.chat-header-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.chat-header-actions { display: flex; gap: 6px; }

.chat-icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: background 0.2s, color 0.2s;
}
.chat-icon-btn:hover {
  background: var(--border-color);
  color: var(--text-main);
}

/* ── Messages ────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 2px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }

.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: msgIn 0.25s ease both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}
.chat-msg-user { flex-direction: row-reverse; }

.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
}
.chat-msg-avatar-user {
  background: linear-gradient(135deg, #10b981, #06b6d4);
}

.chat-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
  color: var(--text-main);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
}
.chat-bubble p    { margin: 0 0 6px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble ul   { margin: 6px 0; padding-left: 18px; }
.chat-bubble li   { margin-bottom: 3px; }
.chat-bubble code {
  background: rgba(99,102,241,0.15);
  color: #a5b4fc;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.82em;
}
.chat-msg-user .chat-bubble {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #fff;
  border-color: transparent;
  border-radius: 16px 16px 4px 16px;
}
.chat-msg-assistant .chat-bubble { border-radius: 16px 16px 16px 4px; }

.chat-bubble-error {
  background: rgba(244, 63, 94, 0.12) !important;
  border-color: rgba(244, 63, 94, 0.3) !important;
  color: #f43f5e !important;
}

/* ── Typing indicator ────────────────────────────────────────── */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  min-width: 58px;
}
.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingDot 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; }
  40%           { transform: scale(1.2); opacity: 1;   }
}

/* ── Suggestion Pills ────────────────────────────────────────── */
.chat-suggestions {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.chat-suggestions::-webkit-scrollbar { display: none; }

.chat-pill {
  white-space: nowrap;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-muted);
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.chat-pill:hover {
  background: rgba(99,102,241,0.15);
  border-color: rgba(99,102,241,0.4);
  color: var(--text-main);
}

/* ── Input Bar ───────────────────────────────────────────────── */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  background: var(--bg-card);
}
.chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.875rem;
  padding: 9px 12px;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.2s;
}
.chat-input:focus { border-color: var(--primary-accent); }
.chat-input::placeholder { color: var(--text-muted); }

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s;
}
.chat-send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.chat-send-btn:not(:disabled):hover { transform: scale(1.08); }
.chat-send-btn:not(:disabled):active { transform: scale(0.94); }

/* ── Light theme overrides ───────────────────────────────────── */
[data-theme="light"] .chat-msg-user .chat-bubble { color: #fff; }

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .chat-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    height: 75vh;
    max-height: 75vh;
  }
  .chat-fab { bottom: 20px; right: 20px; }
}

/* Header Navigation Links */
.nav-link-header {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  text-decoration: none;
  transition: all var(--transition-speed) ease;
}

.nav-link-header:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.nav-link-header.active {
  color: #ffffff !important;
  background: var(--primary-accent);
}

[data-theme="light"] .nav-link-header.active {
  color: #ffffff !important;
}

/* Mutual Fund AI Insights Search & Component Styles */
.bg-input-card {
  background-color: var(--bg-input);
}

.max-w-700 {
  max-width: 700px;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1050;
  background: var(--bg-input);
  backdrop-filter: blur(16px);
  margin-top: 6px;
  max-height: 350px;
  overflow-y: auto;
}

.search-item {
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.search-item:hover,
.search-item.active {
  background-color: rgba(16, 185, 129, 0.15);
  border-left: 3px solid #10b981;
}

[data-theme="light"] .search-item:hover,
[data-theme="light"] .search-item.active {
  background-color: rgba(16, 185, 129, 0.12);
  border-left: 3px solid #059669;
}

.pill-popular-mf {
  font-size: 0.8rem;
  padding: 0.3rem 0.8rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.pill-popular-mf:hover {
  background-color: var(--primary-accent);
  color: #fff;
  border-color: var(--primary-accent);
}

.ai-avatar-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.ai-markdown-output {
  color: var(--text-main);
  line-height: 1.65;
}

.ai-markdown-output h3 {
  color: var(--text-main);
  font-weight: 700;
  font-size: 1.15rem;
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.4rem;
}

.ai-markdown-output ul, .ai-markdown-output ol {
  padding-left: 1.2rem;
  margin-bottom: 1rem;
}

.ai-markdown-output li {
  margin-bottom: 0.4rem;
}

.ai-markdown-output strong {
  color: #f8fafc;
}

[data-theme="light"] .ai-markdown-output strong {
  color: #0f172a;
}
