/* ==========================================================================
   Design System: Topic Modelling Studio (Modern Dark/Light Slate Theme)
   ========================================================================== */

:root {
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* Color Palette - Deep Slate & Vibrant Accents */
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --bg-input: #1f2937;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.3);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-faint: #6b7280;
  
  --accent-primary: #6366f1;       /* Indigo */
  --accent-primary-hover: #4f46e5;
  --accent-secondary: #06b6d4;     /* Cyan */
  --accent-success: #10b981;       /* Emerald */
  --accent-warning: #f59e0b;       /* Amber */
  --accent-danger: #ef4444;        /* Rose */
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.25);
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header & Navbar */
.app-header {
  height: 64px;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-sidebar-toggle {
  display: none; /* Hidden on desktop */
  align-items: center;
  gap: 8px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #e0e7ff;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-sidebar-toggle:hover {
  background: rgba(99, 102, 241, 0.28);
  border-color: var(--accent-primary);
}

.sidebar-mobile-header {
  display: none; /* Hidden on desktop */
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: rgba(17, 24, 39, 0.95);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

.sidebar-mobile-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.btn-sidebar-close {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-sidebar-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: var(--accent-danger);
}

.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1040;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-fab-btn {
  display: none; /* Hidden on desktop */
  position: fixed;
  bottom: 22px;
  right: 18px;
  z-index: 990;
  background: linear-gradient(135deg, var(--accent-primary), #4338ca);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  padding: 12px 18px;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5);
  cursor: pointer;
  transition: var(--transition);
}

.mobile-fab-btn:hover {
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.65);
}

.mobile-fab-btn:active {
  transform: scale(0.95);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.brand-icon svg {
  width: 20px;
  height: 20px;
  fill: white;
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text span {
  font-size: 0.75rem;
  color: var(--accent-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Layout */
.app-container {
  display: flex;
  flex: 1;
  height: calc(100vh - 64px);
  overflow: hidden;
}

/* Sidebar (Left Controls) */
.sidebar {
  width: 380px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  justify-content: space-between;
}

.form-label span.value-badge {
  color: var(--accent-secondary);
  font-family: monospace;
}

.form-control {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 9px 12px;
  transition: var(--transition);
  outline: none;
  width: 100%;
}

.form-control:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

input[type="date"].form-control::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
  cursor: pointer;
}

textarea.form-control {
  resize: vertical;
  min-height: 60px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Preset Cards */
.preset-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.preset-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-muted);
}

.preset-btn:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.4);
}

.preset-btn.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.preset-btn .p-name {
  font-size: 0.8rem;
  font-weight: 600;
}

.preset-btn .p-time {
  font-size: 0.65rem;
  opacity: 0.7;
}

/* Accordion for Advanced Parameters */
.accordion {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: rgba(31, 41, 55, 0.3);
  overflow: hidden;
}

.accordion-header {
  padding: 12px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  background: transparent;
  user-select: none;
  transition: var(--transition);
}

.accordion-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.accordion-content {
  padding: 14px;
  display: none;
  flex-direction: column;
  gap: 14px;
  border-top: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.4);
}

.accordion.open .accordion-content {
  display: flex;
}

.accordion.open .accordion-header svg {
  transform: rotate(180deg);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

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

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.775rem;
}

.btn-block {
  width: 100%;
}

/* Main Dashboard Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

/* Tabs Bar */
.tabs-nav {
  height: 48px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: white;
  background: rgba(99, 102, 241, 0.15);
  border-bottom: 2px solid var(--accent-primary);
}

/* Tab Panels */
.tab-content-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 24px;
  max-width: 1300px;
  margin: 0 auto;
}

.tab-panel.active {
  display: flex;
}

/* Live Progress Banner */
.progress-banner {
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-glow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.progress-title {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-bar-container {
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  transition: width 0.3s ease;
}

.progress-log {
  font-size: 0.825rem;
  color: var(--text-muted);
  font-family: monospace;
}

/* Comparative Metric Cards */
.metrics-comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.model-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.model-card.lda-border {
  border-top: 4px solid var(--accent-primary);
}

.model-card.bertopic-border {
  border-top: 4px solid var(--accent-secondary);
}

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

.model-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.model-badge {
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
}

.metric-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 10px;
}

.stat-box {
  background: rgba(0, 0, 0, 0.25);
  padding: 12px;
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 4px;
  font-family: monospace;
}

.stat-value.highlight-green {
  color: var(--accent-success);
}

.stat-value.highlight-cyan {
  color: var(--accent-secondary);
}

/* Topics Columns */
.topics-columns-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.topics-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topic-item-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: var(--transition);
}

.topic-item-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(99, 102, 241, 0.3);
}

.topic-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.topic-item-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.topic-item-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.keywords-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.keyword-pill {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.12);
  color: #cbd5e1;
  border: 1px solid rgba(99, 102, 241, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.keyword-pill .kw-weight {
  font-size: 0.65rem;
  opacity: 0.6;
  font-family: monospace;
}

/* Visualization Containers */
.viz-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  min-height: 550px;
  display: flex;
  flex-direction: column;
}

.viz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.viz-title {
  font-size: 1rem;
  font-weight: 600;
}

.viz-iframe {
  width: 100%;
  height: 650px;
  border: none;
  border-radius: var(--radius-md);
  background: white;
}

/* Visualization Empty / Placeholder State */
.viz-placeholder-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  background: rgba(15, 23, 42, 0.4);
  border: 1px dashed rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-md);
  margin: auto 0;
  min-height: 280px;
}

.viz-placeholder-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.viz-placeholder-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.viz-placeholder-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 600px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.viz-placeholder-tip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  padding: 8px 16px;
  border-radius: var(--radius-full);
}

/* Interactive Table */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-toolbar {
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.table-search {
  max-width: 300px;
}

.table-actions {
  display: flex;
  gap: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  background: rgba(0, 0, 0, 0.3);
  text-align: left;
  padding: 12px 16px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.article-title-cell a {
  color: var(--text-main);
  text-decoration: none;
  font-weight: 500;
}

.article-title-cell a:hover {
  color: var(--accent-primary);
  text-decoration: underline;
}

.topic-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
}

.topic-tag.lda {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
}

.topic-tag.bertopic {
  background: rgba(6, 182, 212, 0.15);
  color: #67e8f9;
}

.topic-tag.ground-truth {
  background: rgba(234, 179, 8, 0.15);
  color: #fde047;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 550px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-card.modal-card-lg {
  max-width: 620px;
  max-height: 92vh;
  overflow-y: auto;
}

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

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

/* ==========================================================================
   Responsive & Dynamic View System (Mobile, Tablet, Desktop)
   ========================================================================== */

/* Tablet & Mobile Screens (<= 1024px) */
@media (max-width: 1024px) {
  .app-header {
    padding: 0 16px;
    height: 58px;
  }
  
  .btn-sidebar-toggle {
    display: flex;
  }

  .mobile-fab-btn {
    display: flex;
  }

  .app-container {
    display: block;
    height: calc(100vh - 58px);
    position: relative;
    overflow: hidden;
  }

  /* Off-canvas slide-out drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(380px, 88vw);
    max-width: 100%;
    height: 100%;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
    background: var(--bg-secondary);
  }

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

  .sidebar-mobile-header {
    display: flex;
  }

  .main-content {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Responsive Touch-friendly Tabs Nav */
  .tabs-nav {
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 12px;
    gap: 4px;
    height: 48px;
  }

  .tabs-nav::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 0.8rem;
    min-height: 42px;
  }

  /* Content area with bottom padding for FAB */
  .tab-content-area {
    padding: 16px 14px 85px;
  }

  .metrics-comparison-grid,
  .topics-columns-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Responsive Table Container */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
  }

  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
  }

  .table-search {
    max-width: 100%;
    width: 100%;
  }

  .table-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
  }

  /* Visualization container */
  .viz-container {
    padding: 14px;
    min-height: 440px;
  }

  .viz-iframe {
    height: 520px;
  }

  /* Modal cards */
  .modal-card {
    width: 94%;
    max-width: 94%;
    padding: 20px 16px;
  }

  .modal-card.modal-card-lg {
    max-width: 94%;
    max-height: 90vh;
  }
}

/* Smartphone Screens (<= 640px) */
@media (max-width: 640px) {
  .app-header {
    padding: 0 12px;
    height: 56px;
  }

  .brand-text h1 {
    font-size: 0.95rem;
  }

  .brand-text span {
    display: none; /* Save space on small header */
  }

  .brand-icon {
    width: 30px;
    height: 30px;
  }

  .brand-icon svg {
    width: 16px;
    height: 16px;
  }

  .btn-sidebar-toggle {
    padding: 7px 9px;
  }

  .btn-sidebar-toggle .toggle-text {
    display: none; /* Icon only */
  }

  .header-actions {
    gap: 6px;
  }

  .header-actions .btn {
    padding: 7px 10px;
    font-size: 0.75rem;
  }

  .header-actions .btn-text {
    display: none; /* Icon only on tiny screens */
  }

  /* Prevent iOS zoom on inputs */
  .form-control,
  input[type="text"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Form rows become single column */
  .form-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Preset buttons in column */
  .preset-selector {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .preset-btn {
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
  }

  .preset-name {
    font-size: 0.85rem;
  }

  .preset-desc {
    margin-top: 0;
    font-size: 0.72rem;
  }

  /* Stats row becomes 2x2 grid */
  .metric-stats-row {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }

  .stat-box {
    padding: 10px 6px;
  }

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

  .stat-value {
    font-size: clamp(1.05rem, 4.5vw, 1.25rem);
  }

  /* Overview report action bar */
  #panel-overview > div:first-child {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  #btn-overview-export-pdf {
    width: 100%;
    justify-content: center;
    padding: 10px 14px;
  }

  /* Visualizations */
  .viz-container {
    padding: 10px;
    min-height: 380px;
  }

  .viz-iframe {
    height: 440px;
  }

  /* Table styling */
  .data-table th,
  .data-table td {
    padding: 8px 10px;
    font-size: 0.76rem;
  }

  .data-table th:first-child,
  .data-table td:first-child {
    padding-left: 8px;
  }

  .table-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
  }

  .table-actions .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  /* Runs history cards */
  .model-card-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 8px;
  }

  .model-card-header > div:last-child {
    width: 100%;
    justify-content: space-between;
  }

  /* Progress banner */
  .progress-banner {
    padding: 12px 14px;
  }

  .progress-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .progress-header > div:last-child {
    width: 100%;
    justify-content: space-between;
  }
}
