/* ═══════════════════════════════════════════════════
   CSV Analytics — style.css
   Telemetry-inspired dark terminal analytics UI
═══════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  --bg:         #0d0d0f;
  --bg-2:       #111114;
  --bg-3:       #18181c;
  --bg-4:       #1e1e24;
  --card:       rgba(20, 20, 26, 0.9);
  --border:     rgba(255, 255, 255, 0.07);
  --border-2:   rgba(255, 255, 255, 0.12);
  --text:       #e8e8ea;
  --text-2:     #9999a8;
  --text-muted: #5c5c6e;
  --primary:    #f59e0b;
  --primary-2:  #d97706;
  --green:      #22c55e;
  --green-dim:  rgba(34, 197, 94, 0.15);
  --red:        #ef4444;
  --red-dim:    rgba(239, 68, 68, 0.15);
  --blue:       #3b82f6;
  --blue-dim:   rgba(59, 130, 246, 0.12);
  --cyan:       #06b6d4;
  --purple:     #8b5cf6;
  --amber:      #f59e0b;
  --sidebar-w:  200px;
  --topbar-h:   48px;
  --radius:     6px;
  --radius-sm:  4px;
  --font:       'Inter', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;
  --transition: 0.2s ease;
  --shadow:     0 4px 24px rgba(0, 0, 0, 0.6);
}

[data-theme="light"] {
  --bg:         #f5f5f7;
  --bg-2:       #ececef;
  --bg-3:       #e2e2e8;
  --bg-4:       #d8d8e0;
  --card:       rgba(255, 255, 255, 0.9);
  --border:     rgba(0, 0, 0, 0.08);
  --border-2:   rgba(0, 0, 0, 0.14);
  --text:       #111118;
  --text-2:     #44444f;
  --text-muted: #888899;
  --shadow:     0 2px 12px rgba(0, 0, 0, 0.12);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 13px;
  line-height: 1.5;
}

/* ── Utilities ── */
.hidden   { display: none !important; }
.mb-3     { margin-bottom: 1.5rem; }

/* ════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
  overflow: hidden;
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-icon {
  color: var(--primary);
  font-size: 1rem;
  display: flex;
  align-items: center;
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  flex: 1;
}

.brand-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
}

.brand-version {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  flex-shrink: 0;
  animation: blink 3s ease-in-out infinite;
}
.status-dot.busy { background: var(--amber); box-shadow: 0 0 6px var(--amber); }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Nav Groups */
.nav-group {
  padding: 1rem 0 0.5rem;
}

.nav-group-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 0 1rem 0.4rem;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 1rem;
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 400;
  transition: all var(--transition);
  cursor: pointer;
  border-left: 2px solid transparent;
  white-space: nowrap;
}

.nav-item i {
  font-size: 0.88rem;
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: var(--primary);
  background: rgba(245, 158, 11, 0.08);
  border-left-color: var(--primary);
  font-weight: 500;
}

.nav-item.disabled {
  opacity: 0.3;
  pointer-events: none;
  cursor: default;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border-2);
  color: var(--text-2);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.theme-toggle:hover { background: var(--bg-4); color: var(--text); }

/* ════════════════════════════════════════
   MAIN WRAPPER
════════════════════════════════════════ */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0.2rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.sidebar-toggle:hover { color: var(--text); }

/* Breadcrumb */
.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.bc-seg {
  color: var(--text-muted);
}

.bc-sep {
  color: var(--border-2);
}

.bc-active {
  color: var(--text-2);
  font-weight: 500;
}

.topbar-spacer { flex: 1; }

/* Pills */
.topbar-pills {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-pill {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.pill-label { color: var(--text-muted); }
.pill-val   { color: var(--text-2); }

/* Import button */
.btn-import {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 500;
  font-family: var(--font);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-import:hover {
  background: var(--bg-3);
  border-color: var(--border-2);
}

.import-badge {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 3px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-left: 0.1rem;
}

/* ── Pages ── */
.page {
  display: none;
  flex: 1;
  animation: fadeIn 0.25s ease;
}
.page.active { display: flex; flex-direction: column; }

/* ════════════════════════════════════════
   OVERVIEW PAGE
════════════════════════════════════════ */
.page-content {
  padding: 1.75rem 2rem;
  max-width: 1200px;
  width: 100%;
}

.page-heading {
  margin-bottom: 1.25rem;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.page-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Drop Zone */
.drop-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  padding: 0.9rem 1.25rem;
  background: rgba(255, 255, 255, 0.015);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 1.75rem;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.03);
}

.drop-zone-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.drop-arrow-icon {
  width: 34px;
  height: 34px;
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.drop-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.drop-main {
  font-size: 0.82rem;
  color: var(--text-2);
}

.drop-hint {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.link-btn {
  background: none;
  border: none;
  color: var(--blue);
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
}
.link-btn:hover { color: #60a5fa; }

/* Browse Files button */
.btn-browse {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  color: var(--text);
  font-size: 0.78rem;
  font-family: var(--font);
  font-weight: 500;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  flex-shrink: 0;
}
.btn-browse:hover { background: var(--bg-3); }

.browse-badge {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 3px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Alert */
.alert-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.82rem;
}

/* ── Section Blocks (Recent Runs / Schema) ── */
.section-block {
  margin-bottom: 2rem;
}

.section-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.section-block-title {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.section-block-meta {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Runs Table */
.data-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-2);
}

.runs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.runs-table th {
  background: var(--bg-3);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.7rem;
  padding: 0.5rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.runs-table td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}

.runs-table tr:last-child td {
  border-bottom: none;
}

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

.runs-table .file-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 0.4rem;
}

.file-dot.ready  { background: var(--green); }
.file-dot.error  { background: var(--red); }
.file-dot.active { background: var(--amber); }

.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
}

.badge-ready  { background: var(--green-dim); color: var(--green); }
.badge-error  { background: var(--red-dim);   color: var(--red); }
.badge-over   { background: var(--red-dim);   color: var(--red); border: 1px solid rgba(239,68,68,0.3); }

.action-link {
  color: var(--primary);
  background: none;
  border: none;
  font-size: 0.75rem;
  font-family: var(--font);
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  transition: color var(--transition);
}
.action-link:hover { color: var(--primary-2); }
.action-link + .action-link { margin-left: 0.75rem; }

/* Empty row */
.empty-row td {
  padding: 2rem !important;
  text-align: center;
}

.empty-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* Schema block */
.schema-meta-row {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}

.schema-params-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  align-items: center;
}

.schema-param {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.sp-label { color: var(--text-muted); }
.sp-val   { color: var(--text-2); font-weight: 500; }

/* Preview table inside schema */
#preview-table-wrap .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

#preview-table-wrap .data-table th {
  background: var(--bg-3);
  padding: 0.5rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
  font-size: 0.72rem;
  white-space: nowrap;
}

#preview-table-wrap .data-table th .col-name {
  color: var(--text);
  display: block;
}

#preview-table-wrap .data-table th .col-type {
  color: var(--primary);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

#preview-table-wrap .data-table td {
  padding: 0.45rem 0.85rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#preview-table-wrap .data-table tr:last-child td { border-bottom: none; }
#preview-table-wrap .data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* Row numbers */
#preview-table-wrap .data-table td.row-num,
#preview-table-wrap .data-table th.row-num {
  color: var(--text-muted);
  font-size: 0.65rem;
  width: 32px;
  text-align: right;
  padding-right: 0.5rem;
}

.schema-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.9rem;
  border-top: 1px solid var(--border);
  background: var(--bg-3);
}

.schema-hint {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  font-style: italic;
}

.schema-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.link-btn-sm {
  background: none;
  border: none;
  font-size: 0.72rem;
  font-family: var(--font);
  color: var(--text-2);
  cursor: pointer;
  padding: 0;
  transition: color var(--transition);
}
.link-btn-sm:hover { color: var(--text); }
.link-btn-sm.primary { color: var(--blue); }
.link-btn-sm.primary:hover { color: #60a5fa; }

/* ════════════════════════════════════════
   LOADING PAGE
════════════════════════════════════════ */
.loading-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 0.75rem;
  text-align: center;
  padding: 2rem;
}

.loader-ring {
  width: 48px;
  height: 48px;
  position: relative;
  margin-bottom: 0.5rem;
}
.loader-ring div {
  position: absolute;
  width: 100%; height: 100%;
  border: 3px solid transparent;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
.loader-ring div:nth-child(2) { animation-delay: -0.25s; border-top-color: var(--blue); }
.loader-ring div:nth-child(3) { animation-delay: -0.5s; border-top-color: var(--cyan); width:75%;height:75%;top:12.5%;left:12.5%; }
.loader-ring div:nth-child(4) { animation-delay: -0.75s; border-top-color: var(--green); width:50%;height:50%;top:25%;left:25%; }

#loading-heading {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
}

#loading-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.loading-steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 1rem;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  color: var(--text-muted);
  transition: all var(--transition);
}

.step.active {
  background: rgba(245,158,11,0.1);
  border-color: rgba(245,158,11,0.3);
  color: var(--primary);
}

.step.done {
  background: var(--green-dim);
  border-color: rgba(34,197,94,0.3);
  color: var(--green);
}

/* ════════════════════════════════════════
   DASHBOARD PAGE
════════════════════════════════════════ */
.dash-section { display: none; }
.dash-section.active { display: block; animation: fadeIn 0.25s ease; }

.dash-section-inner {
  padding: 1.75rem 2rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-header h2 i { color: var(--primary); }

.header-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Dataset Info Row */
.dataset-info-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.info-chip {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.info-chip .chip-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.info-chip .chip-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
}

.kpi-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  position: relative;
  overflow: hidden;
  cursor: default;
  transition: border-color var(--transition), transform var(--transition);
}

.kpi-card::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--kpi-color, var(--primary));
  opacity: 0.7;
}

.kpi-card:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
}

.kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: rgba(255,255,255,0.05);
  color: var(--kpi-color, var(--primary));
}

.kpi-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

/* Glass Card */
.glass-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color var(--transition);
}
.glass-card:hover { border-color: var(--border-2); }

/* Health Card */
.health-card {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
}

.health-score-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: 80px;
}

.health-score-number {
  font-family: var(--font-mono);
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1;
}

.health-score-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.health-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 200px;
}

.health-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-4);
  padding: 0.38rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-2);
}

.health-row .badge-val {
  background: var(--blue-dim);
  color: var(--blue);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

.health-actions {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 200px;
}

.suggestion-item {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-2);
  background: var(--green-dim);
  border: 1px solid rgba(34,197,94,0.15);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
}

.suggestion-item i { color: var(--green); margin-top: 1px; flex-shrink: 0; font-size: 0.75rem; }

/* Preview Table in dashboard */
.table-wrap { overflow-x: auto; }

.card-title {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.9rem;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.card-title i { color: var(--primary); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.data-table th {
  background: var(--bg-4);
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.5rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 0.68rem;
  letter-spacing: 0.3px;
}

.data-table td {
  padding: 0.45rem 0.8rem;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* Chart Grid */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
  gap: 1rem;
}

.chart-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  box-shadow: var(--shadow);
  min-height: 400px;
  min-width: 0;
  transition: border-color var(--transition);
}

.chart-card:hover { border-color: var(--border-2); }
.chart-card.full-width { grid-column: 1 / -1; }

/* Stats Table */
.stats-content { overflow-x: auto; }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.73rem;
  font-family: var(--font-mono);
}

.stats-table th {
  background: var(--bg-4);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.68rem;
  letter-spacing: 0.3px;
  padding: 0.5rem 0.75rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.stats-table th:first-child { text-align: left; color: var(--primary); }

.stats-table td {
  padding: 0.42rem 0.75rem;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  text-align: right;
}

.stats-table td:first-child { text-align: left; color: var(--text); font-weight: 500; }
.stats-table tr:hover td { background: rgba(255,255,255,0.02); }

/* Insights */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 1rem;
}

.insight-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: border-color var(--transition);
}
.insight-card:hover { border-color: var(--border-2); border-left-color: var(--primary); }

.insight-section-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  color: var(--primary);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.insight-row { display: flex; flex-direction: column; gap: 0.15rem; }

.insight-row-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.insight-row-text { font-size: 0.8rem; color: var(--text-2); line-height: 1.5; }

.insight-risk .insight-row-text {
  color: #fca5a5;
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,0.2);
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-sm);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 500;
  font-size: 0.75rem;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.7rem; }

.btn-primary {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-2);
}
.btn-outline:hover { border-color: var(--text-muted); color: var(--text); background: var(--bg-4); }

.btn-danger {
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,0.2);
  color: var(--red);
}
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* ════════════════════════════════════════
   ANIMATIONS
════════════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

/* ════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════ */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-200px); }
  .sidebar.open { transform: translateX(0); width: 200px; }
  .main-wrapper { margin-left: 0; }
  .chart-grid { grid-template-columns: 1fr; }
  .insights-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .page-content, .dash-section-inner { padding: 1.25rem 1rem; }
  .topbar-pills { display: none; }
  .topbar-breadcrumb { display: none; }
}
