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

:root {
  /* Light mode colors */
  --bg-primary: #f5f5f5;
  --bg-secondary: #ffffff;
  --text-primary: #111111;
  --text-secondary: #3a3a3a;
  --border-color: #e0e0e0;
  --header-gradient: linear-gradient(135deg, #1565c0 0%, #1e88e5 100%);
  --accent-color: #2196f3;
  --accent-dark: #1565c0;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-dark: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Data Quality Info styling - color coded by completeness */
#dataQualityInfo {
  background: #e3f2fd;
  color: #1565c0;
}

#dataQualityInfo.quality-critical {
  background: #ffebee;
  color: #c62828;
}

#dataQualityInfo.quality-warning {
  background: #fff3e0;
  color: #e65100;
}

#dataQualityInfo.quality-good {
  background: #e8f5e9;
  color: #2e7d32;
}

html.dark-mode {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --border-color: #404040;
  --header-gradient: linear-gradient(135deg, #0d47a1 0%, #1565c0 100%);
  --accent-color: #64b5f6;
  --accent-dark: #1565c0;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-dark: 0 2px 8px rgba(0, 0, 0, 0.5);
}

html {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Site header */
header {
  background: var(--header-gradient);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-dark);
  width: 100%;
}

.header-content {
  width: 100%;
  padding: 0.75rem 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-img {
  height: 40px;
}

.logo {
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: 0.03em;
  margin-left: 0.5rem;
}

header h1 {
  display: flex;
  align-items: center;
  margin: 0;
}

.logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

header nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

nav a, nav button {
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 4px;
  transition: all 0.3s ease;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

nav a:hover, nav button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

nav a.active {
  background: rgba(255, 255, 255, 0.2);
  border-color: white;
  font-weight: bold;
}

/* Hamburger menu button */
.hamburger-menu {
  display: none;
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: transform 0.3s ease;
}

.hamburger-menu:hover {
  transform: scale(1.1);
}

/* Dark mode toggle button */
.dark-mode-toggle {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: transform 0.3s ease;
}

.dark-mode-toggle:hover {
  transform: scale(1.1);
}

/* Main Container (no sidebar layout) */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

/* Dashboard layout without sidebar */
.dashboard-layout {
  width: 100%;
  height: auto;
  margin-bottom: 2rem;
}

.sidebar-menu {
  list-style: none;
}

.sidebar-menu li {
  margin-bottom: 0.5rem;
}

.sidebar-menu a {
  display: block;
  padding: 0.75rem 1rem;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  border-left: 3px solid transparent;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.sidebar-menu a:hover {
  background-color: rgba(255, 255, 255, 0.15);
  border-left-color: rgba(255, 255, 255, 0.8);
  padding-left: 1.25rem;
  color: white;
}

.sidebar-menu a.active {
  background-color: rgba(255, 255, 255, 0.25);
  border-left-color: white;
  color: white;
  font-weight: bold;
  padding-left: 1.25rem;
}

/* Sidebar info text */
.sidebar div {
  color: rgba(255, 255, 255, 0.85);
}

.sidebar p, .sidebar strong {
  color: white;
}

.sidebar select, .sidebar input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  margin-bottom: 0.5rem;
}

.sidebar select:focus, .sidebar input:focus {
  outline: none;
  border-color: white;
  background: rgba(255, 255, 255, 0.2);
}

.sidebar select option {
  background: #2d2d2d;
  color: white;
}

html.dark-mode .sidebar select option {
  background: #1a1a1a;
}

.sidebar label {
  color: rgba(255, 255, 255, 0.9);
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

/* Main Content */
.main-content {
  flex: 1;
}

/* Hero Section */
.hero {
  background: linear-gradient(rgba(21, 101, 192, 0.9), rgba(30, 136, 229, 0.9)), url('/images/screenshot.png');
  background-size: cover;
  background-position: center;
  color: white;
  padding: 4rem 2rem;
  border-radius: 12px;
  margin-bottom: 2rem;
  text-align: center;
  position: relative;
}

.hero h2 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.hero p {
  font-size: 1.1rem;
  margin-bottom: 2rem;
  opacity: 0.95;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Dark mode hero */
html.dark-mode .hero {
  background: linear-gradient(rgba(13, 71, 161, 0.95), rgba(21, 101, 192, 0.95)), url('/images/screenshot.png');
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  cursor: pointer;
  color: var(--text-primary);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-dark);
}

.card h3 {
  color: var(--accent-dark);
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.card-stat {
  font-size: 2rem;
  font-weight: bold;
  color: #1565c0;
  margin-bottom: 0.5rem;
}

.card-link {
  color: #1565c0;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
}

.card-link:hover {
  text-decoration: underline;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background-color: white;
  color: #1565c0;
  text-decoration: none;
  border: 2px solid white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.3s ease;
}

.btn:hover {
  background-color: transparent;
  color: white;
  border-color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border-color: white;
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.3);
  border-color: white;
}

.btn-block {
  width: 100%;
  margin-top: 1rem;
}

/* Dashboard grid container */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
  width: 100%;
  align-items: stretch;
}

/* Chart grid items */
.chart-grid-item {
  width: 100%;
}

/* Make all chart tiles equal height */
.chart-ct,
.chart-district {
  min-height: 350px;
  width: 100%;
}

.chart-ct .chart-container,
.chart-district .chart-container {
  height: 100%;
  width: 100%;
}

/* Side-by-side bar charts */
.chart-ct {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
}

.chart-district {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
}

.chart-container {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  overflow: visible;
  display: flex;
  flex-direction: column;
  color: var(--text-primary);
  width: 100%;
  max-width: 100%;
}

.chart-container h3 {
  color: var(--accent-dark);
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.chart-container svg {
  width: 100% !important;
  height: auto !important;
  display: block;
  max-width: 100%;
  flex-grow: 1;
}

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

/* People directory panel */
.directory-panel {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
  margin-top: 2rem;
}

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

.directory-header h3 {
  color: var(--accent-dark);
  margin: 0 0 0.35rem 0;
  font-size: 1.25rem;
}

.directory-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.directory-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.directory-search input {
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  border: 1px solid #d0d7de;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-width: 240px;
}

html.dark-mode .directory-search input {
  border-color: #40464f;
}

.directory-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border: 1px solid #e3e7eb;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
}

html.dark-mode .directory-count {
  border-color: #40464f;
}

.directory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.directory-card {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid #eef1f4;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.85rem;
  align-items: center;
}

html.dark-mode .directory-card {
  border-color: #3b414b;
}

.directory-image {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(21, 101, 192, 0.15);
}

.directory-image.image-error {
  display: none;
}

.directory-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(21, 101, 192, 0.15);
  color: #1565c0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

html.dark-mode .directory-avatar {
  background: rgba(21, 101, 192, 0.25);
}

.directory-name {
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
  font-size: 1rem;
}

.directory-meta {
  margin: 0.25rem 0 0 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.3;
}

.directory-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.directory-tag {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(21, 101, 192, 0.15);
  color: #0d47a1;
  font-weight: 500;
}

.directory-tag.custody-transfer {
  background: rgba(255, 152, 0, 0.2);
  color: #e65100;
  font-weight: 500;
}

.directory-empty {
  margin-top: 1rem;
  color: var(--text-secondary);
  text-align: center;
}

.directory-pagination {
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
}

.directory-pagination-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.pagination-btn {
  padding: 0.5rem 0.85rem;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
  border-color: #1565c0;
  color: #1565c0;
}

.pagination-btn.active {
  background: #1565c0;
  color: white;
  border-color: #1565c0;
}

html.dark-mode .pagination-btn {
  border-color: #40464f;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.stat {
  background: var(--bg-secondary);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  text-align: center;
  box-shadow: var(--shadow);
  color: var(--text-primary);
  min-height: unset;
}
.stat-value {
  font-size: 1.3rem;
  font-weight: bold;
  color: #1565c0;
  margin-bottom: 0.25rem;
}
.stat-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Controls */
.controls {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
  color: var(--text-primary);
}

.controls label {
  display: inline-block;
  margin-right: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.controls select,
.controls input {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  margin-right: 1rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.controls select:focus,
.controls input:focus {
  outline: none;
  border-color: var(--accent-color);
}

html.dark-mode .controls select,
html.dark-mode .controls input {
  background: #3a3a3a;
}

/* Footer */
footer {
  background: var(--accent-dark);
  color: white;
  text-align: center;
  padding: 2rem;
  margin-top: 4rem;
}

.footer-tagline {
  background: rgba(21, 101, 192, 0.15);
  color: var(--text-primary);
  text-align: center;
  padding: 0.75rem;
  font-size: 0.9rem;
  border-top: 1px solid rgba(21, 101, 192, 0.2);
}

.footer-tagline p {
  margin: 0;
  font-weight: 500;
}

html.dark-mode .footer-tagline {
  background: rgba(21, 101, 192, 0.1);
  border-top-color: rgba(21, 101, 192, 0.3);
}

/* Insights Section */
.insights-section {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
  margin-top: 2rem;
}

.insights-title {
  color: var(--accent-dark);
  margin: 0 0 1.25rem 0;
  font-size: 1.25rem;
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.insight-tile {
  background: var(--bg-primary);
  border-radius: 10px;
  padding: 1.1rem;
  border: 1px solid #e3e7eb;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

html.dark-mode .insight-tile {
  border-color: #3b414b;
}

.insight-icon {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.insight-label {
  margin: 0 0 0.25rem 0;
  color: #1a1a1a;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.insight-value {
  margin: 0 0 0.35rem 0;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.insight-description {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.2;
}

@media (max-width: 1024px) {
  .insights-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .insights-section {
    padding: 1.1rem;
  }

  .insights-grid {
    grid-template-columns: 1fr;
  }

  .insight-tile {
    padding: 0.9rem;
  }

  .insight-value {
    font-size: 0.95rem;
  }
}

footer {
  background: var(--accent-dark);
  color: white;
  text-align: center;
  padding: 2rem;
  margin-top: 4rem;
}

@media (max-width: 1024px) {
  .stats-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .directory-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .directory-search input {
    min-width: 200px;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
  }

  /* Tablet: 2x2 grid */
  .chart-age,
  .chart-detention,
  .chart-ct,
  .chart-district {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 768px) {
  /* Show hamburger menu on tablet/mobile */
  .hamburger-menu {
    display: block;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .directory-panel {
    padding: 1.1rem;
  }

  .directory-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .directory-search input {
    min-width: 100%;
    width: 100%;
  }

  .directory-grid {
    grid-template-columns: 1fr;
  }

  .directory-card {
    padding: 0.85rem;
  }

  .directory-pagination-buttons {
    gap: 0.35rem;
  }

  .pagination-btn {
    padding: 0.4rem 0.65rem;
    font-size: 0.8rem;
  }

  /* Hide sidebar by default, show when class is not minimized */
  .sidebar {
    position: fixed;
    width: 280px;
    transform: translateX(-280px);
    top: 70px;
    height: calc(100vh - 70px);
    z-index: 99;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .container {
    margin: 0;
    width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }

  /* Mobile: stack all charts full-width */
  .chart-main,
  .chart-age,
  .chart-detention,
  .chart-ct,
  .chart-district {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  /* Mobile header/nav */
  header .primary-nav {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--header-gradient);
    padding: 0.75rem 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    display: none;
  }

  header.nav-open .primary-nav {
    display: flex;
  }

  .primary-nav a,
  .primary-nav button.btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.95rem;
  }

  .hero {
    padding: 2rem 1rem;
  }

  .hero h2 {
    font-size: 1.8rem;
  }

  .chart-container {
    min-height: 280px;
  }
}

/* Loading spinner */
.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--accent-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 2rem auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Utility classes */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }

/* AI Assistant Styles */
.sample-question {
  padding: 0.5rem 0.75rem;
  background: white;
  border: 2px solid #1565c0;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #1565c0;
  font-weight: 500;
}

.sample-question:hover {
  background: #1565c0;
  color: white;
  border-color: #1565c0;
  transform: translateY(-2px);
}

.ai-tab-content {
  animation: fadeIn 0.3s ease;
}

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

/* Dark Mode Readability Improvements */
html.dark-mode section[style*="background: white"],
html.dark-mode section[style*="background: #f8f9fa"] {
  background: var(--bg-secondary) !important;
  border-color: #454d55 !important;
}

html.dark-mode section p,
html.dark-mode section li {
  color: var(--text-primary) !important;
}

html.dark-mode section p[style*="color: #999"] {
  color: var(--text-secondary) !important;
}

html.dark-mode section strong {
  color: #f0f2f5 !important;
}

html.dark-mode section ul {
  color: var(--text-primary) !important;
}

/* Dark mode for AI panel */
html.dark-mode div[style*="background: rgba(255,255,255,0.95)"] {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border: 1px solid #454d55 !important;
}

html.dark-mode div[style*="background: #f8f9fa"],
html.dark-mode div[style*="background: #f0f0f0"] {
  background: #2a2f36 !important;
  border-color: #454d55 !important;
}

html.dark-mode p[style*="color: #666"],
html.dark-mode p[style*="color: #999"] {
  color: var(--text-secondary) !important;
}

html.dark-mode input[type="text"] {
  background: #2a2f36 !important;
  color: var(--text-primary) !important;
  border-color: #454d55 !important;
}

html.dark-mode input[type="text"]:focus {
  border-color: var(--accent-color) !important;
  background: #2a2f36 !important;
}

html.dark-mode .ai-tab {
  color: var(--text-secondary) !important;
}

html.dark-mode .ai-tab.active {
  color: var(--accent-color) !important;
  border-bottom-color: var(--accent-color) !important;
}

html.dark-mode [style*="border-bottom: 2px solid #e0e0e0"] {
  border-bottom-color: #454d55 !important;
}

html.dark-mode .sample-question {
  background: transparent;
  border: 2px solid #454d55;
  color: var(--accent-color);
}

html.dark-mode .sample-question:hover {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

/* Dark mode for AI Recommendations blue gradient section */
html.dark-mode div[style*="background: linear-gradient(135deg, #1e88e5"] h4 {
  color: white !important;
}

html.dark-mode #vizIntentInput,
html.dark-mode #vizGenerateInput {
  background: #2a2f36 !important;
  color: var(--text-primary) !important;
  border-color: #454d55 !important;
}

html.dark-mode #vizIntentInput::placeholder,
html.dark-mode #vizGenerateInput::placeholder {
  color: #8a8f96 !important;
}

/* Dark mode for chart builder section */
html.dark-mode div[style*="background: #f0f0f0"] {
  background: #2a2f36 !important;
}

html.dark-mode div[style*="background: #f0f0f0"] h4 {
  color: var(--text-primary) !important;
}

html.dark-mode #generatedVizContainer {
  background: #2a2f36 !important;
  border-color: var(--accent-color) !important;
}

html.dark-mode #vizSuggestionsResponse {
  background: #2a2f36 !important;
  border-color: var(--accent-color) !important;
}

/* Ensure all buttons remain visible */
html.dark-mode button[style*="background: #1e88e5"] {
  background: #1e88e5 !important;
}

html.dark-mode button[style*="background: white"] {
  background: white !important;
  color: #1565c0 !important;
}

/* Mobile responsiveness for AI Panel and Charts */
@media (max-width: 768px) {
  .ai-tab {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.75rem !important;
    flex: 1 1 auto;
  }

  .ai-tabs-container {
    flex-direction: column !important;
  }

  .sample-question {
    flex: 1 1 calc(50% - 0.25rem);
    font-size: 0.8rem;
  }

  #plotly-time-series {
    min-height: 280px !important;
  }

  /* Chart builder buttons: 2 columns on mobile */
  div[style*="grid-template-columns: repeat(3"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }

  /* Ensure chart displays well on mobile */
  #generatedVizChart {
    min-height: 400px !important;
  }
}

/* AI Panel responsive layout */
@media (min-width: 769px) {
  div[style*="flex-direction: column"]:has(input#aiQueryInput) {
    flex-direction: row !important;
  }
  
  div[style*="flex-direction: column"] input#aiQueryInput {
    flex: 1;
    width: auto !important;
  }
  
  div[style*="flex-direction: column"] button#askButton {
    width: auto !important;
    white-space: nowrap;
  }
}

@media (max-width: 768px) {
  section[style*="linear-gradient"] {
    padding: 1rem !important;
    margin-top: 1rem !important;
    margin-bottom: 2rem !important;
  }
  
  div[style*="rgba(255,255,255,0.95)"] {
    padding: 1rem !important;
  }
  
  .ai-tab-content {
    padding: 0 !important;
  }
  
  .ai-tab-content p {
    margin-bottom: 0.75rem !important;
  }
  
  .sample-question {
    padding: 0.4rem 0.6rem !important;
  }
}

/* AI Panel responsive layout */
@media (min-width: 769px) {
  div[style*="flex-direction: column"]:has(input#aiQueryInput) {
    flex-direction: row !important;
  }
  
  div[style*="flex-direction: column"] input#aiQueryInput {
    flex: 1;
    width: auto !important;
  }
  
  div[style*="flex-direction: column"] button#askButton {
    width: auto !important;
    white-space: nowrap;
  }
}

@media (max-width: 768px) {
  section[style*="linear-gradient"] {
    padding: 1rem !important;
    margin-top: 1rem !important;
    margin-bottom: 2rem !important;
  }
  
  div[style*="rgba(255,255,255,0.95)"] {
    padding: 1rem !important;
  }
  
  .ai-tab-content {
    padding: 0 !important;
  }
  
  .ai-tab-content p {
    margin-bottom: 0.75rem !important;
  }
  
  .sample-question {
    padding: 0.4rem 0.6rem !important;
  }
}
