:root {
  --bg-main: #f8fafc;
  --bg-subtle: #f0fdf4; /* Crisp light green / mint tint */
  --bg-card: #ffffff;
  --bg-card-hover: #ffffff;
  --border-subtle: #e2e8f0;
  --border-green: #a7f3d0;
  --border-glow: rgba(16, 185, 129, 0.35);
  
  --primary: #059669; /* Tata Power Green */
  --primary-hover: #047857;
  --primary-glow: rgba(16, 185, 129, 0.25);
  --primary-light: #ecfdf5;
  
  --accent-green-dark: #065f46;
  --accent-green: #10b981;
  --accent-mint: #34d399;
  --accent-cyan: #0284c7;
  --accent-emerald: #059669;
  --accent-indigo: #4f46e5;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  
  --text-main: #0f172a; /* Deep Slate - crisp readable */
  --text-muted: #475569; /* Slate 600 */
  --text-dim: #64748b;   /* Slate 500 */
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-card: 0 4px 18px -2px rgba(0, 0, 0, 0.05), 0 2px 6px -1px rgba(0, 0, 0, 0.02);
  --shadow-card-hover: 0 10px 25px -4px rgba(16, 185, 129, 0.12), 0 4px 10px -2px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body, body.light-theme, body.dark-theme {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  background-image: 
    radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.08) 0px, transparent 45%),
    radial-gradient(at 100% 100%, rgba(5, 150, 105, 0.06) 0px, transparent 45%),
    radial-gradient(at 50% 50%, rgba(240, 253, 244, 0.5) 0px, transparent 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

/* Glass Card */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  transition: all 0.25s ease;
}

.glass-card:hover {
  border-color: var(--border-green);
  box-shadow: var(--shadow-card-hover);
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(16, 185, 129, 0.2);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: #ecfdf5;
  border: 1px solid var(--border-green);
  border-radius: var(--radius-sm);
}

.brand-name {
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  color: #047857;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.divider {
  width: 1px;
  height: 24px;
  background: var(--border-subtle);
}

.header-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: #065f46;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.online {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

/* Dashboard Layout */
.dashboard-container {
  max-width: 1560px;
  margin: 0 auto;
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Tabs Navigation Bar */
.tabs-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.85rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 0.25rem;
}

.tabs-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1.35rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn:hover {
  color: #047857;
  background: #f0fdf4;
}

.tab-btn.active {
  color: #065f46;
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 1px solid #10b981;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.18);
}

.tab-btn .tab-icon {
  font-size: 1.15rem;
}

.tab-btn .tab-pill {
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: #d1fae5;
  color: #065f46;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 0.2rem;
}

.tab-status-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.95rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.tab-status-pill .tab-subtext {
  color: #047857;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.tab-status-pill .context-badge {
  color: #065f46;
  font-family: var(--font-mono);
  font-weight: 700;
}

/* Tab Content Visibility */
.tab-content {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  width: 100%;
  animation: fadeIn 0.22s ease-in-out;
}

.tab-content.hidden {
  display: none !important;
}

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

/* Control Panel */
.control-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.75rem;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.select-wrapper select {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  min-width: 220px;
  transition: all 0.2s ease;
}

.select-wrapper select:focus {
  border-color: #059669;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

.control-stats {
  display: flex;
  gap: 1rem;
}

.stat-pill {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-label {
  font-size: 0.8rem;
  color: #047857;
  font-weight: 500;
}

.stat-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: #065f46;
  font-family: var(--font-mono);
}

/* Causal Row */
.causal-row {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 1.5rem;
}

.causal-cards-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stat-card {
  padding: 0.95rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
}

.card-header-sm {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.tag-primary { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.tag-cyan { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.tag-amber { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.tag-purple { background: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; }

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.card-value {
  font-size: 1.85rem;
  font-weight: 800;
  color: #0f172a;
  font-family: var(--font-mono);
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.card-value .unit {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

.ci-range {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.ci-range span {
  color: #059669;
  font-weight: 700;
}

.card-footnote {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

/* HTE Chart Card */
.hte-chart-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

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

.card-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.badge-accent {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-blue {
  background: #f0fdf4;
  color: #059669;
  border: 1px solid #bbf7d0;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-green {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}

.chart-wrapper {
  position: relative;
  flex: 1;
  min-height: 240px;
}

.chart-wrapper-lg {
  position: relative;
  flex: 1;
  min-height: 340px;
}

/* DTW Section */
.dtw-section {
  padding: 1.5rem;
  background: #ffffff;
}

.dtw-content-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  margin-top: 1rem;
}

.dtw-matches-sidebar {
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dtw-matches-sidebar h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.disclaimer-text {
  font-size: 0.75rem;
  color: #b45309;
}

.matches-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.match-item {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.match-item:hover {
  border-color: #10b981;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.08);
  transform: translateX(4px);
}

.match-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.match-rank {
  color: #047857;
  font-family: var(--font-mono);
}

.match-dist {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.match-metrics {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Bottom Grid (SHAP + SQL Console) */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.shap-card, .sql-console-card {
  padding: 1.5rem;
  background: #ffffff;
}

.console-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.5rem;
}

.search-input-box {
  display: flex;
  gap: 0.75rem;
}

.search-input-box input {
  flex: 1;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s ease;
}

.search-input-box input:focus {
  border-color: #059669;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.sample-queries {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chip {
  background: #f0fdf4;
  border: 1px solid #a7f3d0;
  color: #047857;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  background: #d1fae5;
  border-color: #10b981;
  color: #064e3b;
}

.sql-result-panel {
  background: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.preview-label, .answer-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.25rem;
}

.sql-preview-box code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #047857;
  display: block;
  word-break: break-all;
  background: #ffffff;
  padding: 0.65rem;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

.query-answer-row {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.5rem;
}

.answer-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: #059669;
  font-family: var(--font-mono);
}

.sample-val {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Explanation & AI Reasoning Section */
.explanation-section {
  padding: 1.75rem;
}

.header-action-buttons {
  display: flex;
  gap: 0.75rem;
}

.prompt-input-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.5rem;
  margin-bottom: 1.25rem;
}

.prompt-input-row {
  display: flex;
  gap: 0.75rem;
}

.prompt-input-row input {
  flex: 1;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.prompt-input-row input:focus {
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.prompt-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.prompt-chip {
  background: #f0fdf4;
  border: 1px solid #a7f3d0;
  color: #047857;
}

.prompt-chip:hover {
  background: #d1fae5;
  border-color: #10b981;
  color: #064e3b;
}

/* Buttons */
.btn {
  padding: 0.55rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
}

.btn-primary {
  background: #059669;
  color: #fff;
}

.btn-primary:hover {
  background: #047857;
}

.btn-outline {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-muted);
}

.btn-outline:hover {
  background: #f0fdf4;
  border-color: #10b981;
  color: #047857;
}

.btn-outline.active {
  background: #ecfdf5;
  border-color: #10b981;
  color: #047857;
  font-weight: 700;
}

#newChatBtn {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #047857;
  font-weight: 600;
}

#newChatBtn:hover {
  background: #d1fae5;
  border-color: #10b981;
  color: #065f46;
}

#generateExplanationBtn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-weight: 500;
}

#generateExplanationBtn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

#clearChatBtn {
  background: #ffffff;
  border: 1px solid #fecdd3;
  color: #b91c1c;
  font-weight: 500;
}

#clearChatBtn:hover {
  background: #fff1f2;
  border-color: #f43f5e;
  color: #991b1b;
}

.btn-glow {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-glow:hover {
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
  transform: translateY(-1px);
}

/* Theme Toggle Button */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.85rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  color: #065f46;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.theme-toggle-btn:hover {
  background: #d1fae5;
  border-color: #10b981;
  color: #047857;
  transform: translateY(-1px);
}

.theme-toggle-icon {
  font-size: 0.95rem;
  display: inline-block;
  transition: transform 0.3s ease;
}

.theme-toggle-btn:hover .theme-toggle-icon {
  transform: rotate(20deg);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 2rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border-subtle);
  margin-top: 2rem;
}

/* ==========================================================================
   Chatbot Interface Styles (Interactive Causal AI Reasoning Console)
   Light Green & White Theme
   ========================================================================== */
.chatbot-card {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 190px);
  padding: 0;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid rgba(16, 185, 129, 0.3);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05), 0 0 15px rgba(16, 185, 129, 0.08);
}

.chat-card-header {
  padding: 1.25rem 1.75rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0;
}

.bot-status-pulse {
  display: inline-block;
  width: 9px;
  height: 9px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  animation: pulse 2s infinite;
}

/* Chat Messages Thread */
.chat-messages-thread {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 380px;
  max-height: calc(100vh - 380px);
  scroll-behavior: smooth;
  background: #fdfdfd;
}

.chat-messages-thread::-webkit-scrollbar {
  width: 6px;
}
.chat-messages-thread::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages-thread::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Welcome Card when no messages */
.chat-welcome-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 2rem;
  margin: auto;
  max-width: 680px;
  background: #f0fdf4;
  border: 1px dashed #34d399;
  border-radius: var(--radius-md);
}

.chat-welcome-card .welcome-icon {
  font-size: 2.2rem;
  margin-bottom: 0.75rem;
  background: #ecfdf5;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid #a7f3d0;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.2);
}

.chat-welcome-card h4 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #065f46;
  margin-bottom: 0.5rem;
}

.chat-welcome-card p {
  font-size: 0.9rem;
  color: #475569;
  line-height: 1.6;
}

/* Chat Message Bubbles */
.chat-message {
  display: flex;
  gap: 0.85rem;
  max-width: 85%;
  animation: messageIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-message.user-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message.assistant-message {
  align-self: flex-start;
  max-width: 92%;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.user-message .message-avatar {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
}

.assistant-message .message-avatar {
  background: #ecfdf5;
  border: 1px solid #10b981;
  color: #059669;
}

.message-bubble {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.95rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.6;
}

.user-message .message-bubble {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 1px solid #a7f3d0;
  color: #064e3b;
  border-top-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08);
}

.assistant-message .message-bubble {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: #1e293b;
  border-top-left-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  width: 100%;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
  margin-bottom: 0.2rem;
}

.user-message .message-meta {
  justify-content: flex-end;
}

.sender-name {
  font-weight: 700;
  color: #0f172a;
}

.message-time {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.model-tag {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-family: var(--font-mono);
}

.message-text {
  word-break: break-word;
}

.message-text p {
  margin-bottom: 0.5rem;
}
.message-text p:last-child {
  margin-bottom: 0;
}
.message-text strong {
  color: #047857;
}
.message-text code {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #047857;
}

/* Collapsible Evidence Accordion */
.evidence-accordion {
  margin-top: 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  overflow: hidden;
  transition: all 0.2s ease;
}

.evidence-accordion[open] {
  border-color: #10b981;
}

.evidence-summary {
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  background: #f1f5f9;
}

.evidence-summary:hover {
  color: #047857;
  background: #ecfdf5;
}

.evidence-body {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-subtle);
  background: #f8fafc;
}

.evidence-body pre {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: #334155;
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Typing / Reasoning Loading Bubble */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.15rem;
  background: #f0fdf4;
  border: 1px dashed #10b981;
  border-radius: var(--radius-md);
  color: #047857;
  font-size: 0.85rem;
}

.typing-dots {
  display: flex;
  gap: 0.3rem;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #059669;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Sticky Chat Bottom Bar */
.chat-bottom-bar {
  padding: 1rem 1.75rem 1.25rem;
  background: #f8fafc;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-bottom-bar .prompt-chips {
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chips-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chat-input-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.chat-input-row textarea {
  flex: 1;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.15rem;
  color: #0f172a;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.4;
  outline: none;
  resize: none;
  min-height: 48px;
  max-height: 120px;
  transition: all 0.2s ease;
}

.chat-input-row textarea:focus {
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.chat-input-row .btn {
  height: 48px;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.chat-footnote-bar {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
}

/* ==========================================================================
   Dark Theme Overrides
   ========================================================================== */
body.dark-theme {
  --bg-main: #090d16;
  --bg-subtle: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-green: rgba(16, 185, 129, 0.4);
  --border-glow: rgba(99, 102, 241, 0.4);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  background-color: #090d16;
  color: #f8fafc;
  background-image: 
    radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(99, 102, 241, 0.1) 0px, transparent 50%);
}

body.dark-theme .glass-card {
  background: rgba(17, 24, 39, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.36);
}

body.dark-theme .glass-card:hover {
  border-color: rgba(16, 185, 129, 0.4);
}

body.dark-theme .app-header {
  background: rgba(10, 15, 26, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

body.dark-theme .brand-badge {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

body.dark-theme .brand-name {
  color: #34d399;
}

body.dark-theme .model-badge {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
}

body.dark-theme .status-indicator {
  color: #94a3b8;
}

body.dark-theme .theme-toggle-btn {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
}

body.dark-theme .theme-toggle-btn:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #34d399;
}

body.dark-theme .tabs-nav-bar {
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-theme .tab-btn {
  color: #94a3b8;
}

body.dark-theme .tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

body.dark-theme .tab-btn.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(99, 102, 241, 0.25));
  border: 1px solid rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.22);
}

body.dark-theme .tab-status-pill {
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-theme .tab-status-pill .tab-subtext {
  color: #64748b;
}

body.dark-theme .tab-status-pill .context-badge {
  color: #34d399;
}

body.dark-theme .select-wrapper select {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

body.dark-theme .select-wrapper select:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.35);
}

body.dark-theme .stat-pill {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-theme .stat-label {
  color: #94a3b8;
}

body.dark-theme .stat-val {
  color: #38bdf8;
}

body.dark-theme .card-value {
  color: #ffffff;
}

body.dark-theme .ci-range {
  color: #64748b;
}

body.dark-theme .ci-range span {
  color: #10b981;
}

body.dark-theme .dtw-matches-sidebar {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-theme .match-item {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-theme .match-item:hover {
  border-color: #38bdf8;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

body.dark-theme .match-rank {
  color: #38bdf8;
}

body.dark-theme .match-dist {
  color: #94a3b8;
}

body.dark-theme .match-metrics {
  color: #64748b;
}

body.dark-theme .search-input-box input {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

body.dark-theme .chip {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #93c5fd;
}

body.dark-theme .chip:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #6ee7b7;
}

body.dark-theme .sql-result-panel {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-theme .sql-preview-box code {
  background: rgba(0, 0, 0, 0.35);
  color: #38bdf8;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

body.dark-theme .answer-val {
  color: #10b981;
}

body.dark-theme .sample-val {
  color: #94a3b8;
}

body.dark-theme .btn-outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
}

body.dark-theme .btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

body.dark-theme .btn-outline.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
  color: #34d399;
}

body.dark-theme #newChatBtn {
  background: rgba(16, 185, 129, 0.18) !important;
  border: 1px solid rgba(16, 185, 129, 0.45) !important;
  color: #34d399 !important;
  font-weight: 600;
}

body.dark-theme #newChatBtn:hover {
  background: rgba(16, 185, 129, 0.32) !important;
  border-color: #34d399 !important;
  color: #ffffff !important;
}

body.dark-theme #generateExplanationBtn {
  background: rgba(30, 41, 59, 0.7) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: #cbd5e1 !important;
}

body.dark-theme #generateExplanationBtn:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
  color: #ffffff !important;
}

body.dark-theme #clearChatBtn {
  background: rgba(239, 68, 68, 0.12) !important;
  border: 1px solid rgba(239, 68, 68, 0.3) !important;
  color: #fca5a5 !important;
}

body.dark-theme #clearChatBtn:hover {
  background: rgba(239, 68, 68, 0.22) !important;
  border-color: #ef4444 !important;
  color: #ffffff !important;
}

body.dark-theme .badge-accent,
body.dark-theme .badge-blue,
body.dark-theme .badge-green,
body.dark-theme .tag-primary {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
}

body.dark-theme select option {
  background: #0f172a;
  color: #f8fafc;
}

body.dark-theme .chatbot-card {
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

body.dark-theme .chat-card-header {
  background: rgba(15, 23, 42, 0.65);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-theme .chat-messages-thread {
  background: transparent;
}

body.dark-theme .chat-welcome-card {
  background: rgba(30, 41, 59, 0.35);
  border-color: rgba(16, 185, 129, 0.35);
}

body.dark-theme .chat-welcome-card .welcome-icon {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.4);
}

body.dark-theme .chat-welcome-card h4 {
  color: #34d399;
}

body.dark-theme .chat-welcome-card p {
  color: #94a3b8;
}

body.dark-theme .user-message .message-bubble {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.32), rgba(16, 185, 129, 0.38));
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #ffffff;
}

body.dark-theme .assistant-message .message-bubble {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

body.dark-theme .assistant-message .message-avatar {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
}

body.dark-theme .sender-name {
  color: #cbd5e1;
}

body.dark-theme .message-text strong {
  color: #34d399;
}

body.dark-theme .message-text code {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #38bdf8;
}

body.dark-theme .evidence-accordion {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-theme .evidence-summary {
  background: rgba(255, 255, 255, 0.03);
  color: #94a3b8;
}

body.dark-theme .evidence-summary:hover {
  color: #34d399;
  background: rgba(255, 255, 255, 0.06);
}

body.dark-theme .evidence-body {
  background: rgba(0, 0, 0, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

body.dark-theme .evidence-body pre {
  color: #94a3b8;
}

body.dark-theme .typing-bubble {
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

body.dark-theme .chat-bottom-bar {
  background: rgba(15, 23, 42, 0.75);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-theme .prompt-chip {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #a7f3d0;
}

body.dark-theme .prompt-chip:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #ffffff;
}

body.dark-theme .chat-input-row textarea {
  background: #1e293b;
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #ffffff;
}

body.dark-theme .model-tag {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
}

body.dark-theme .chips-title {
  color: #94a3b8;
}

body.dark-theme .chat-footnote-bar {
  color: #64748b;
}

body.dark-theme .chat-footnote-bar strong {
  color: #34d399;
}

body.dark-theme .chat-input-row textarea::placeholder {
  color: #64748b;
}

body.dark-theme .app-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.md-h2 {
  color: #047857;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-size: 1.15rem;
}
.md-h3 {
  color: #059669;
  margin-top: 0.85rem;
  margin-bottom: 0.45rem;
  font-size: 1.05rem;
}
.md-h4 {
  color: #0284c7;
  margin-top: 0.75rem;
  margin-bottom: 0.35rem;
  font-size: 0.98rem;
}

body.dark-theme .md-h2 {
  color: #93c5fd;
}
body.dark-theme .md-h3 {
  color: #38bdf8;
}
body.dark-theme .md-h4 {
  color: #67e8f9;
}

