/* =====================================================
   ROOT VARIABLES
===================================================== */
:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --sidebar-bg: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-contrast: #ffffff;
  --assistant-bubble: #f1f5f9;
  --user-bubble: #e8f0ff;
  --shadow: 0 6px 30px rgba(2, 6, 23, 0.08);

  /* sizing */
  --sidebar-w: 280px;
  --sidebar-w-collapsed: 80px;
  --header-h: 60px;
  --composer-h: 72px;
  --radius: 12px;
  --glass: rgba(255, 255, 255, 0.6);
  --transition: 220ms cubic-bezier(.2, .9, .25, 1);
}

html[data-theme="dark"] {
  --bg: #0b1220;
  --panel: #0f172a;
  --sidebar-bg: #0d1424;
  --text: #e5e7eb;
  --muted: #9aa4b2;
  --border: #1f2937;
  --primary: #60a5fa;
  --primary-contrast: #0b1220;
  --assistant-bubble: #111827;
  --user-bubble: #1e293b;
  --shadow: 0 6px 30px rgba(0, 0, 0, 0.35);
}

/* =====================================================
   RESET & BASE
===================================================== */
* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

/* =====================================================
   AUTHENTICATION STYLES
===================================================== */
.auth-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg), var(--panel));
  font-family: Inter, system-ui, sans-serif;
}

.auth-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
}

.auth-header h1 {
  margin: 0 0 8px 0;
  color: var(--text);
  font-size: 24px;
  font-weight: 600;
}

.auth-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 500;
  color: var(--text);
  font-size: 14px;
}

.form-group input {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-full {
  width: 100%;
  padding: 12px;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.auth-footer a {
  color: var(--primary);
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-messages {
  margin-bottom: 20px;
}

.message {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
}

.message.success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.message.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.message.info {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.form-errors {
  background: #fee2e2;
  color: #991b1b;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.field-errors {
  color: #dc2626;
  font-size: 12px;
  margin-top: 4px;
}

/* =====================================================
   PROFILE STYLES
===================================================== */
.profile-main {
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
}

.profile-header {
  margin-bottom: 32px;
}

.profile-header h1 {
  margin: 0;
  color: var(--text);
  font-size: 28px;
  font-weight: 600;
}

.profile-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.profile-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.profile-card h2 {
  margin: 0 0 20px 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.info-item:last-child {
  border-bottom: none;
}

.info-item label {
  font-weight: 500;
  color: var(--text);
}

.info-item span {
  color: var(--muted);
}

.token-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.stat-card h3 {
  margin: 0 0 8px 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.stat-number {
  margin: 0;
  color: var(--primary);
  font-size: 24px;
  font-weight: 600;
}

.chat-stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.stat-label {
  color: var(--text);
  font-weight: 500;
}

.stat-value {
  color: var(--primary);
  font-weight: 600;
}

.profile-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.profile-nav {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  transition: background-color 0.2s ease;
}

.nav-link:hover {
  background: var(--assistant-bubble);
}

/* =====================================================
   APP LAYOUT
===================================================== */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: linear-gradient(180deg, transparent 0%, transparent 100%);
  position: relative;
  overflow: hidden;
}

/* Sidebar (mobile offcanvas default) */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-w);
  max-width: 92vw;
  transform: translateX(-100%);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 0;
  z-index: 40;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 10px 40px rgba(2, 6, 23, 0.12);
  -webkit-overflow-scrolling: touch;
  will-change: transform;
}

.sidebar.open {
  transform: translateX(0);
  box-shadow: 0 10px 60px rgba(2, 6, 23, 0.25);
}

/* Desktop persistent sidebar */
@media (min-width:1024px) {
  .app {
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: 100dvh;
  }

  .sidebar {
    position: relative;
    transform: none;
    height: 100dvh;
    box-shadow: none;
    width: var(--sidebar-w);
    z-index: 1;
  }
}

/* Tablet: Use hamburger menu like mobile */
@media (min-width:768px) and (max-width:1023px) {
  .sidebar {
    width: var(--sidebar-w);
    max-width: 320px;
  }

  .chat-header {
    padding: 10px 16px;
  }

  .truncate {
    max-width: 55vw;
  }

  .messages {
    padding: 16px;
  }
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

#hamburgerBtn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  transition: transform var(--transition), background var(--transition);
  flex-shrink: 0;
}

#hamburgerBtn:hover {
  background: var(--assistant-bubble);
  border-color: var(--primary);
}

#hamburgerBtn:active {
  transform: scale(.95)
}

.logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 600;
  color: var(--text);
  font-size: 14px
}

/* Sidebar controls */
.sidebar-controls {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border)
}

.search {
  display: flex;
  gap: 8px
}

.search input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  outline: none
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer
}

.icon-btn:hover {
  filter: brightness(1.05)
}

/* Conversation nav */
.convo-nav {
  overflow: auto;
  padding: 8px;
  flex: 1 1 auto;
  min-height: 0
}

.convo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px
}

.convo-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer
}

.convo-item:hover {
  border-color: var(--primary)
}

.convo-title {
  font-weight: 600;
  font-size: 14px
}

.convo-snippet {
  color: var(--muted);
  font-size: 12px
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px
}

/* Overlay (for mobile sidebar) */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 40;
  backdrop-filter: blur(2px);
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto
}

/* =====================================================
   CHAT AREA
===================================================== */
.chat {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: var(--header-h) 1fr var(--composer-h);
  gap: 0;
  min-width: 0;
  background: transparent;
}

.chat-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 5;
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60vw;
  font-size: 16px
}

/* Mobile hamburger in chat header */
.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.mobile-menu-btn:hover {
  background: var(--assistant-bubble);
  border-color: var(--primary);
}

.mobile-menu-btn:active {
  transform: scale(.95)
}

@media (max-width:1023px) {
  .mobile-menu-btn {
    display: flex
  }
}

/* Messages */
.messages {
  overflow: auto;
  padding: 12px 16px 24px;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.message {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  align-items: start;
  margin-bottom: 8px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  background: var(--assistant-bubble);
}

.message[data-role="user"] .avatar {
  background: var(--user-bubble)
}

.bubble {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: var(--assistant-bubble);
  box-shadow: var(--shadow)
}

.message[data-role="user"] .bubble {
  background: var(--user-bubble)
}

.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px
}

.content {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  font-size: 14px
}

/* =====================================================
   COMPOSER + VOICE INPUT
===================================================== */
.composer {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg), transparent);
  padding: 12px;
  z-index: 6;
}

.composer-form {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  background: var(--panel);
  border-radius: 14px;
  padding: 10px;
  border: 1px solid var(--border);
}

.composer-form textarea {
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  padding: 6px 8px;
  font-size: 15px;
  max-height: 220px;
  color: var(--text);
}

.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-contrast)
}

/* 🎤 Voice Feedback Modal */
.voice-feedback {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 100;
  animation: fadeIn .25s ease;
}

.voice-feedback.hidden {
  display: none !important
}

.voice-pulse {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1.2s infinite ease-in-out;
}

.voice-transcript {
  font-size: 14px;
  color: var(--text);
  text-align: center;
  max-width: 280px;
  word-break: break-word;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1
  }

  50% {
    transform: scale(1.4);
    opacity: 0.6
  }

  100% {
    transform: scale(1);
    opacity: 1
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, 20px)
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0)
  }
}

/* =====================================================
   TABLE STYLING IMPROVEMENTS
===================================================== */
/* Excel-like table styling */
.excel-table-container {
  overflow-x: auto;
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.excel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 500px;
}

.excel-table th {
  background: var(--assistant-bubble);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  color: var(--text);
  position: sticky;
  top: 0;
  z-index: 1;
}

.excel-table th:last-child {
  border-right: none;
}

.excel-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: top;
  color: var(--text);
}

.excel-table td:last-child {
  border-right: none;
}

.excel-table tr:last-child td {
  border-bottom: none;
}

.excel-table tr:hover {
  background: var(--user-bubble);
  transition: background 0.2s ease;
}

.excel-table tr:nth-child(even) {
  background: var(--assistant-bubble);
}

.excel-table tr:nth-child(even):hover {
  background: var(--user-bubble);
}

/* Table header styling */
.excel-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Table caption */
.table-caption {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text);
  padding: 8px 0;
}

.excel-table-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  padding: 6px 0;
  font-style: italic;
}

/* Responsive table improvements */
@media (max-width: 768px) {
  .excel-table {
    font-size: 12px;
    min-width: 400px;
  }

  .excel-table th,
  .excel-table td {
    padding: 6px 8px;
  }

  .excel-table-container {
    margin: 8px -8px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}

@media (max-width: 480px) {
  .excel-table {
    font-size: 11px;
    min-width: 350px;
  }

  .excel-table th,
  .excel-table td {
    padding: 4px 6px;
  }
}

/* Auto-generated table styling (for non-excel tables) */
.content table { 
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0; font-size: 13px;
  background: var(--panel);
  } 
  .content table th { 
  background: var(--assistant-bubble); 
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border);
  color: var(--text); }
  .content table td {
  padding: 8px 12px;
  border: 1px solid var(--border); 
  vertical-align: top;
  color: var(--text);
   } 
  .content table tr:hover { 
  background: var(--user-bubble);
}
/* =====================================================
   VISUALIZATION STYLES
===================================================== */
.visualization-container {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.chart-iframe {
  width: 100%;
  height: 500px;
  border: none;
  background: white;
}

.chart-image {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.visualization-explanation {
  background: var(--assistant-bubble);
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 14px;
}

.viz-summary {
  display: grid;
  gap: 4px;
}

.btn-view-chart {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 8px;
  font-size: 12px;
}

.btn-view-chart:hover {
  opacity: 0.9;
}

.visualization-placeholder {
  background: var(--assistant-bubble);
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 15px;
  text-align: center;
  color: var(--muted);
  margin: 10px 0;
}

.auto-embedded-chart {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.forecast-result {
  background: var(--assistant-bubble);
  padding: 12px;
  border-radius: 8px;
  margin: 8px 0;
}

.forecast-result h4 {
  margin: 0 0 8px 0;
  color: var(--primary);
}

.forecast-result ul {
  margin: 0;
  padding-left: 20px;
}

.forecast-result li {
  margin: 4px 0;
}

/* ==================== MULTI-CHART STYLES ==================== */

/* Multi-chart container */
.multi-charts-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin: 20px 0;
  padding: 10px;
}

/* Chart card styling */
.chart-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

.chart-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Chart header */
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.chart-header h4 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}

.chart-badge {
  background: var(--primary);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  text-transform: capitalize;
}

/* Chart content */
.chart-content {
  flex: 1;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

.chart-iframe {
  width: 100%;
  height: 100%;
  min-height: 300px;
  border: none;
  background: white;
}

.chart-placeholder {
  color: var(--muted);
  font-style: italic;
  padding: 40px;
  text-align: center;
}

/* Chart actions */
.chart-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.btn-view-chart,
.btn-download-chart {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.btn-view-chart:hover,
.btn-download-chart:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-download-all {
  width: 100%;
  padding: 12px;
  margin-top: 15px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

.btn-download-all:hover {
  opacity: 0.9;
}

/* Multi-visualization summary */
.multi-viz-summary {
  background: linear-gradient(135deg, var(--assistant-bubble), var(--user-bubble));
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 20px;
  border-left: 4px solid var(--primary);
}

.multi-viz-summary h4 {
  margin: 0 0 8px 0;
  color: var(--primary);
  font-size: 16px;
}

.multi-viz-summary p {
  margin: 0 0 12px 0;
  color: var(--text);
}

.viz-stats {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.viz-stats .stat {
  background: var(--panel);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
}

/* Single visualization summary */
.single-viz-summary {
  background: var(--assistant-bubble);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 15px;
}

.single-viz-summary h4 {
  margin: 0 0 4px 0;
  color: var(--primary);
}

.single-viz-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* Charts navigation */
.charts-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--assistant-bubble);
  border-radius: 8px;
  margin-bottom: 15px;
  grid-column: 1 / -1;
}

.nav-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.nav-info span {
  font-weight: 500;
  color: var(--text);
}

.nav-hint {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.nav-controls {
  display: flex;
  gap: 8px;
}

.nav-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Data summary */
.data-summary {
  background: var(--assistant-bubble);
  padding: 12px 16px;
  border-radius: 8px;
  margin-top: 15px;
  border: 1px solid var(--border);
}

.summary-header {
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
  font-size: 14px;
}

.summary-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-stats .stat {
  font-size: 13px;
  color: var(--text);
}

.summary-stats .stat strong {
  color: var(--primary);
}

/* Visualization container enhancements */
.visualization-container {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

/* Auto-embedded chart improvements */
.auto-embedded-chart {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

/* ==================== RESPONSIVE DESIGN ==================== */

/* Tablet */
@media (max-width: 1024px) {
  .multi-charts-container {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 15px;
  }

  .chart-card {
    min-height: 350px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .multi-charts-container {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 5px;
  }

  .chart-card {
    min-height: 300px;
    padding: 12px;
  }

  .chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .chart-header h4 {
    font-size: 13px;
  }

  .charts-navigation {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }

  .nav-info {
    justify-content: space-between;
  }

  .nav-controls {
    justify-content: center;
  }

  .viz-stats {
    justify-content: center;
  }

  .chart-actions {
    flex-direction: column;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .multi-charts-container {
    margin: 10px -8px;
  }

  .chart-card {
    min-height: 280px;
    padding: 10px;
  }

  .chart-content {
    min-height: 250px;
  }

  .multi-viz-summary,
  .single-viz-summary {
    padding: 12px;
    margin: 0 -8px 15px -8px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}

/* Dark mode enhancements */
html[data-theme="dark"] .chart-content {
  background: #1a1a1a;
}

html[data-theme="dark"] .chart-card {
  background: var(--panel);
  border-color: var(--border);
}

html[data-theme="dark"] .auto-embedded-chart {
  background: #1a1a1a;
}

/* Animation for chart cards */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chart-card {
  animation: fadeInUp 0.3s ease-out;
}

/* Stagger animation for multiple charts */
.multi-charts-container .chart-card:nth-child(1) {
  animation-delay: 0.1s;
}

.multi-charts-container .chart-card:nth-child(2) {
  animation-delay: 0.2s;
}

.multi-charts-container .chart-card:nth-child(3) {
  animation-delay: 0.3s;
}

.multi-charts-container .chart-card:nth-child(4) {
  animation-delay: 0.4s;
}

/* =====================================================
   REPORT STYLES
===================================================== */
.report-body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.report-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.report-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.report-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.report-brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.report-nav {
  display: flex;
  gap: 8px;
}

.report-main {
  flex: 1;
  padding: 24px;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.report-grid .card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.report-grid .card.span-2 {
  grid-column: span 2;
}

.report-grid .card h2 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.report-footer {
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.bullets {
  margin: 0;
  padding-left: 20px;
}

.bullets li {
  margin-bottom: 8px;
  line-height: 1.5;
}

/* Responsive design for reports */
@media (max-width: 768px) {
  .report-grid {
    grid-template-columns: 1fr;
  }

  .report-grid .card.span-2 {
    grid-column: span 1;
  }

  .report-header {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }

  .report-nav {
    width: 100%;
    justify-content: center;
  }
}

/* =====================================================
   MISC UTILITIES
===================================================== */
.hidden {
  display: none !important
}

.truncate-ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  transition: opacity .25s;
  opacity: 0;
  pointer-events: none;
  z-index: 60
}

:focus {
  outline: none
}

:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.18);
  outline-offset: 3px;
  border-radius: 8px
}

/* Responsive fine-tuning */
@media (min-width:1024px) {
  .chat {
    grid-template-rows: var(--header-h) 1fr var(--composer-h);
    height: 100dvh;
  }

  .messages {
    padding: 20px 28px 36px
  }

  .truncate {
    max-width: 36vw
  }

  #hamburgerBtn {
    display: none
  }

  .overlay {
    display: none
  }
}

/* Mobile: Show hamburger, hide sidebar by default */
@media (max-width:1023px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 100dvh;
  }

  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    width: var(--sidebar-w);
    max-width: 85vw;
    height: 100vh;
    z-index: 50;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  #hamburgerBtn {
    display: inline-grid;
  }

  .overlay {
    display: block;
  }

  .chat {
    grid-column: 1;
    width: 100%;
  }
}

@media (max-width:767px) {
  .chat-header {
    padding: 8px 12px
  }

  .truncate {
    max-width: 50vw
  }

  .brand-name {
    font-size: 13px
  }

  .composer-form {
    grid-template-columns: auto 1fr auto;
    gap: 6px;
    padding: 8px
  }

  .messages {
    padding: 10px
  }

  .message {
    grid-template-columns: 36px 1fr;
    gap: 8px
  }

  .avatar {
    width: 36px;
    height: 36px;
    font-size: 16px
  }

  .bubble {
    padding: 8px 10px
  }

  .content {
    font-size: 13px
  }

  .sidebar {
    max-width: 80vw;
  }

  .convo-item {
    padding: 8px;
  }

  .convo-title {
    font-size: 13px;
  }

  .convo-snippet {
    font-size: 11px;
  }
}

@media (max-width:480px) {
  .chat-header {
    padding: 6px 10px
  }

  .truncate {
    max-width: 45vw;
    font-size: 14px
  }

  .composer-form {
    padding: 6px;
    gap: 4px
  }

  .composer-form textarea {
    font-size: 14px;
    padding: 4px 6px
  }

  .messages {
    padding: 8px
  }

  .message {
    grid-template-columns: 32px 1fr;
    gap: 6px;
    padding: 6px
  }

  .avatar {
    width: 32px;
    height: 32px;
    font-size: 14px
  }

  .bubble {
    padding: 6px 8px
  }

  .content {
    font-size: 12px
  }

  .sidebar {
    max-width: 75vw;
  }

  .brand {
    padding: 10px
  }

  .logo {
    width: 24px;
    height: 24px
  }

  .brand-name {
    font-size: 12px
  }

  .sidebar-controls {
    padding: 8px 10px
  }

  .search input {
    padding: 8px 10px;
    font-size: 13px
  }

  .convo-nav {
    padding: 6px
  }

  .convo-item {
    padding: 6px 8px
  }

  .convo-title {
    font-size: 12px
  }

  .convo-snippet {
    font-size: 10px
  }

  .sidebar-footer {
    padding: 10px;
    font-size: 12px
  }
}

/* Chart card visuals */
.card canvas {
  width: 100% !important;
  height: auto !important
}
/
* ========================================
   Suggestions Container Styles
   ======================================== */
.suggestions-container {
  padding: 16px;
  background: var(--assistant-bubble);
  border-top: 1px solid var(--border);
  margin-top: 12px;
  border-radius: 12px;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.suggestions-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.suggestions-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.suggestion-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.suggestion-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.suggestion-btn:active {
  transform: translateY(0);
}

.suggestion-icon {
  font-size: 16px;
  line-height: 1;
}

/* Dark mode adjustments */
[data-theme="dark"] .suggestions-container {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .suggestion-btn {
  background: var(--primary);
}

[data-theme="dark"] .suggestion-btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

/* Mobile responsive */
@media (max-width: 768px) {
  .suggestions-container {
    padding: 12px;
  }
  
  .suggestions-buttons {
    gap: 6px;
  }
  
  .suggestion-btn {
    padding: 6px 12px;
    font-size: 12px;
  }
}
