/* ═══════════════════════════════════════════════════════════════
   Fluxo de Caixa — styles.css
   Tema Claro (default) + Tema Escuro via [data-theme="dark"]
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg-app:        #f4f6fa;
  --bg-card:       #ffffff;
  --bg-sidebar:    #1e2a3a;
  --bg-header:     #ffffff;
  --bg-table-alt:  #f8f9fc;
  --bg-input:      #ffffff;
  --bg-badge:      #e8f0fe;

  --text-primary:  #1a202c;
  --text-secondary:#4a5568;
  --text-muted:    #718096;
  --text-sidebar:  #c8d6e5;
  --text-sidebar-active: #ffffff;
  --text-badge:    #3b6fd4;

  --border:        #e2e8f0;
  --border-focus:  #3b6fd4;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:     0 4px 12px rgba(0,0,0,.1);

  --accent:        #3b6fd4;
  --accent-hover:  #2d5bbf;
  --accent-light:  #e8f0fe;

  --success:       #22c55e;
  --success-light: #dcfce7;
  --danger:        #ef4444;
  --danger-light:  #fee2e2;
  --warning:       #f59e0b;
  --warning-light: #fef3c7;
  --info:          #06b6d4;
  --info-light:    #cffafe;

  --sidebar-w:     240px;
  --header-h:      60px;
  --radius:        8px;
  --radius-lg:     12px;
  --transition:    .2s ease;
}

[data-theme="dark"] {
  --bg-app:        #0f1117;
  --bg-card:       #1a1f2e;
  --bg-sidebar:    #111827;
  --bg-header:     #1a1f2e;
  --bg-table-alt:  #1e2535;
  --bg-input:      #1e2535;
  --bg-badge:      #1e3a5f;

  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:    #64748b;
  --text-sidebar:  #94a3b8;
  --text-sidebar-active: #ffffff;
  --text-badge:    #7db3f8;

  --border:        #2d3748;
  --border-focus:  #5b8dee;
  --shadow:        0 1px 3px rgba(0,0,0,.4);
  --shadow-md:     0 4px 12px rgba(0,0,0,.4);

  --accent:        #5b8dee;
  --accent-hover:  #4a7de0;
  --accent-light:  #1e3a5f;

  --success-light: #052e16;
  --danger-light:  #2d0707;
  --warning-light: #2d1a00;
  --info-light:    #042030;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: background var(--transition);
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo .logo-icon,
.sidebar-logo .sidebar-logo-img {
  width: 36px; height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
}

.sidebar-logo .logo-icon {
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.sidebar-logo .sidebar-logo-img {
  object-fit: contain;
  background: #ffffff;
  padding: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.sidebar-logo span {
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
}

.sidebar-logo small {
  color: var(--text-sidebar);
  font-size: 10px;
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 8px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 8px 4px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-sidebar);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 13px;
  font-weight: 500;
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

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

.nav-item.active {
  background: var(--accent);
  color: #fff;
}

.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ── Main Layout ───────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ────────────────────────────────────────────────── */
.header {
  height: var(--header-h);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

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

/* ── Theme Toggle ──────────────────────────────────────────── */
.theme-toggle {
  width: 40px; height: 22px;
  background: var(--border);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  border: none;
  transition: background var(--transition);
  flex-shrink: 0;
}

.theme-toggle::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

[data-theme="dark"] .theme-toggle { background: var(--accent); }
[data-theme="dark"] .theme-toggle::after { transform: translateX(18px); }

/* ── Page Content ──────────────────────────────────────────── */
.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.page { display: none; }
.page.active { display: block; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  transition: background var(--transition), border-color var(--transition);
}

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

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── KPI Cards ─────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: all var(--transition);
  min-width: 0;
}

.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.kpi-icon {
  width: 38px; height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.kpi-icon.green  { background: var(--success-light); }
.kpi-icon.red    { background: var(--danger-light); }
.kpi-icon.blue   { background: var(--accent-light); }
.kpi-icon.orange { background: var(--warning-light); }
.kpi-icon.purple { background: #f3e8ff; }

[data-theme="dark"] .kpi-icon.purple { background: #2d1b4e; }

.kpi-info { flex: 1; min-width: 0; }
.kpi-label { font-size: 10.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value {
  font-size: 16.5px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 3px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.02em;
}
.kpi-value.positive { color: var(--success); }
.kpi-value.negative { color: var(--danger); }
.kpi-meta  { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* ── Grid Layouts ──────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}

/* ── Chart Container ───────────────────────────────────────── */
.chart-wrap { position: relative; height: 260px; }
.chart-wrap canvas { max-height: 260px !important; }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

th {
  background: var(--bg-table-alt);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-table-alt); }

.td-right { text-align: right; font-variant-numeric: tabular-nums; }
.td-credit { color: var(--success); font-weight: 600; }
.td-debit  { color: var(--danger);  font-weight: 600; }

/* ── Demonstrativo Month Tabs / Pills ──────────────────────── */
.demo-month-pills-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  background: var(--bg-table-alt);
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.demo-pills-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.demo-pills-wrap {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.demo-pill {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .2s ease;
}
.demo-pill:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}
.demo-pill.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}

/* ── Demonstrativo Table ───────────────────────────────────── */
.demo-table th.month-col { min-width: 100px; }
.demo-table .row-total th,
.demo-table .row-total td { background: var(--accent-light); font-weight: 700; }
.demo-table .row-saldo th,
.demo-table .row-saldo td {
  background: linear-gradient(90deg, var(--accent-light), transparent);
  font-weight: 800;
  font-size: 13px;
}
.demo-table .section-header td {
  background: var(--bg-table-alt);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  padding: 12px 12px 8px;
}
.demo-table .cat-name { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo-table td.val-positive { color: var(--success); }
.demo-table td.val-negative { color: var(--danger); }

/* ── Árvore e Detalhamento Compacto (Card Scrollável) ──────── */
.tree-toggle-row {
  cursor: pointer;
  user-select: none;
}
.tree-toggle-row:hover td {
  background: var(--accent-light) !important;
}
.tree-chevron {
  display: inline-block;
  width: 14px;
  font-size: 9px;
  color: var(--text-muted);
  transition: transform .2s ease;
  margin-right: 4px;
  text-align: center;
}
.tree-toggle-row.expanded .tree-chevron {
  transform: rotate(90deg);
  color: var(--accent);
}
.tree-child-row {
  display: none;
}
.tree-child-row.show {
  display: table-row;
}
.tree-child-row td {
  padding: 6px 12px;
  border-bottom: 1px dashed var(--border);
}
.tree-child-name {
  padding-left: 36px !important;
  color: var(--text-secondary);
  font-size: 11.5px;
  max-width: 550px;
  white-space: nowrap;
}
.tree-item-desc {
  display: inline-block;
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.tree-branch {
  color: var(--text-muted);
  margin-right: 6px;
  font-family: monospace;
}
.tree-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--bg-table-alt);
  color: var(--text-muted);
  margin-left: 6px;
  font-weight: 500;
}
.tree-reclassify-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: #ffffff;
  background: var(--accent);
  border: 1px solid var(--accent);
  cursor: pointer;
  margin-left: 8px;
  vertical-align: middle;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.tree-reclassify-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.03);
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-backdrop.show {
  opacity: 1;
  pointer-events: all;
}
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 480px;
  padding: 24px;
  transform: translateY(20px);
  transition: transform 0.2s ease;
}
.modal-backdrop.show .modal-card {
  transform: translateY(0);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-table-alt); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-blue   { background: var(--bg-badge); color: var(--text-badge); }
.badge-green  { background: var(--success-light); color: #15803d; }
.badge-red    { background: var(--danger-light);  color: #dc2626; }
.badge-orange { background: var(--warning-light); color: #d97706; }
.badge-gray   { background: var(--bg-table-alt);  color: var(--text-muted); }

[data-theme="dark"] .badge-green { color: #86efac; }
[data-theme="dark"] .badge-red   { color: #fca5a5; }
[data-theme="dark"] .badge-orange{ color: #fcd34d; }

/* ── Forms & Inputs ────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color var(--transition);
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,111,212,.15);
}

select option { background: var(--bg-input); color: var(--text-primary); }

/* ── Upload Area ───────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-card);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-zone input[type="file"] { display: none; }

.upload-icon { font-size: 48px; margin-bottom: 12px; }

.upload-zone h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.upload-zone p {
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Category Color Dot ────────────────────────────────────── */
.color-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  flex-shrink: 0;
}

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.pagination-btns { display: flex; gap: 4px; }

/* ── Filter Bar ────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar select, .filter-bar input {
  width: auto;
  min-width: 120px;
  flex: 1;
  max-width: 180px;
}

/* ── Alerts / Toast ────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn .25s ease;
  pointer-events: all;
  max-width: 340px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger);  }
.toast.info    { border-left: 3px solid var(--info);    }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Loading Spinner ───────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

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

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }

/* ── Progress Bar ──────────────────────────────────────────── */
.progress-bar-wrap { background: var(--bg-table-alt); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; transition: width .4s ease; }

/* ── Category selector in table ───────────────────────────── */
.cat-select {
  width: auto;
  min-width: 160px;
  font-size: 12px;
  padding: 4px 8px;
  height: 28px;
}

/* ── Saldo Indicator ───────────────────────────────────────── */
.saldo-pos { color: var(--success); font-weight: 700; }
.saldo-neg { color: var(--danger);  font-weight: 700; }

/* ── Scrollable Table Fix ──────────────────────────────────── */
.table-scroll-container {
  overflow: auto;
  max-height: 600px;
}

/* ── Year Selector ─────────────────────────────────────────── */
.year-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}
.year-selector select { width: auto; min-width: 100px; }

/* ── Login Screen ──────────────────────────────────────────── */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-screen.hidden {
  display: none !important;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 380px;
  padding: 30px 26px;
  animation: modalIn .25s ease;
}
.login-logo-wrap {
  text-align: center;
  margin-bottom: 22px;
}
.login-logo-img {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  margin-bottom: 10px;
  background: #ffffff;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.login-logo-wrap h2 {
  font-size: 19px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 3px;
}
.login-logo-wrap p {
  font-size: 12px;
  color: var(--text-muted);
}
.login-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 14px;
}
.user-profile-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 6px;
}
.user-info {
  display: flex;
  flex-direction: column;
}
.user-info strong {
  font-size: 12px;
  color: var(--text-primary);
}
.user-role-tag {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
}
.btn-logout, .btn-logout-header {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .2s ease;
}
.btn-logout {
  padding: 4px 8px;
  font-size: 12px;
}
.btn-logout:hover, .btn-logout-header:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-color: var(--danger);
}
.btn-logout-header {
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
}
.header-user-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 6px;
  border-left: 1px solid var(--border);
  padding-left: 10px;
}
.header-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ── Mobile Menu & Bottom Nav ──────────────────────────────── */
.mobile-menu-btn {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.mobile-menu-btn:hover {
  background: var(--bg-table-alt);
}
.mobile-bottom-nav {
  display: none;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 105;
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.show {
  display: block;
}

/* ── Responsive Mobile Experience ─────────────────────────── */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 240px;
  }
  
  .sidebar {
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 110;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  
  .main {
    margin-left: 0 !important;
    width: 100% !important;
    padding-bottom: 64px; /* Space for bottom nav */
  }
  
  .mobile-menu-btn {
    display: flex;
  }
  
  .header {
    padding: 10px 14px;
  }
  .header-title {
    font-size: 16px;
  }
  .content {
    padding: 12px 10px;
  }
  
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }
  .kpi-card {
    padding: 12px;
  }
  .kpi-card .kpi-value {
    font-size: 16px;
  }
  .kpi-card .kpi-title {
    font-size: 10.5px;
  }
  
  .charts-grid {
    grid-template-columns: 1fr !important;
  }
  
  /* Mobile Bottom Navigation Bar */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 99;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    justify-content: space-around;
    align-items: center;
  }
  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    gap: 3px;
    cursor: pointer;
    padding: 6px 0;
    transition: all .2s ease;
  }
  .mobile-nav-item.active {
    color: var(--accent);
  }
  .mobile-nav-icon {
    font-size: 18px;
  }
  
  /* Mobile Horizontal Table Scrolling with sticky first col */
  .table-scroll-container,
  .demo-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .demo-table th:first-child,
  .demo-table td:first-child {
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 3;
    min-width: 120px;
    max-width: 145px;
    box-shadow: 2px 0 4px rgba(0,0,0,0.05);
  }
  .demo-table .cat-name {
    max-width: 135px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11.5px;
  }
  .demo-table .section-header td {
    white-space: normal;
    padding: 8px 10px;
    font-size: 11px;
    position: static;
  }
  .demo-table th, .demo-table td {
    white-space: nowrap;
    padding: 6px 8px;
    font-size: 11.5px;
  }
  
  .filter-bar select, .filter-bar input {
    max-width: 100%;
    min-width: 100px;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr 1fr !important;
  }
  .kpi-card .kpi-value {
    font-size: 14px;
  }
  .year-selector span {
    display: none;
  }
  .header-actions {
    gap: 6px;
  }
}
