/* =============================================
   DRE GRUPO SEJA — Enterprise Design System v3.0
   Layout: Top Navbar + Side Drawer
   Theme: Corporate Blue (#005A9C / #003F73)
   Font: Inter
   ============================================= */

/* ── TOKENS ─────────────────────────────────── */
:root {
  --blue-950: #001D3D;
  --blue-900: #003F73;
  --blue-800: #004D8E;
  --blue-700: #005A9C;
  --blue-600: #0066B3;
  --blue-500: #0072C6;
  --blue-400: #2589D4;
  --blue-300: #57A0E0;
  --blue-200: #9BC5EE;
  --blue-100: #DEEEFF;
  --blue-50:  #F0F7FF;

  --gray-950: #0D1117;
  --gray-900: #1A2332;
  --gray-800: #2D3748;
  --gray-700: #4A5568;
  --gray-600: #718096;
  --gray-500: #8FA3B8;
  --gray-400: #A0AEC0;
  --gray-300: #CBD5E0;
  --gray-200: #E2E8F0;
  --gray-100: #EDF2F7;
  --gray-50:  #F7F8FA;
  --white:    #FFFFFF;

  --success:       #059669;
  --success-light: #D1FAE5;
  --danger:        #DC2626;
  --danger-light:  #FEE2E2;
  --warning:       #D97706;
  --warning-light: #FEF3C7;
  --purple:        #7C3AED;
  --purple-light:  #EDE9FE;

  --navbar-h:    60px;
  --drawer-w:    268px;
  --pad:         24px;
  --radius-xl:   16px;
  --radius:      12px;
  --radius-sm:   8px;
  --radius-xs:   4px;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:   0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:   0 8px 28px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.06);
  --shadow-blue: 0 4px 16px rgba(0,90,156,.25), 0 1px 4px rgba(0,90,156,.15);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  --transition: all .18s cubic-bezier(.4,0,.2,1);
}

/* ── DARK THEME ──────────────────────────────── */
[data-theme="dark"] {
  --blue-50:  #0a1628;
  --blue-100: #0e2240;
  --gray-50:  #0f1520;
  --gray-100: #1a2233;
  --gray-200: #243047;
  --gray-300: #344260;
  --gray-400: #4a5e7a;
  --gray-500: #6a82a0;
  --gray-600: #8fa3b8;
  --gray-700: #b8ccdf;
  --gray-800: #d8e8f5;
  --gray-900: #eef4fb;
  --white:    #1a2233;
  --success-light: #064e3b;
  --danger-light:  #450a0a;
  --warning-light: #451a03;
  --purple-light:  #2e1065;
}

/* ── RESET ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
/* SVGs that are NOT inside a known icon context keep inline to avoid expanding */
svg { display: inline-block; flex-shrink: 0; vertical-align: middle; }

/* Contexts where block display is needed (flex row icons, etc.) */
.btn svg, .drawer-item svg, .navbar svg, .alert-icon svg,
.upload-icon svg, .insight-icon svg, .empty-icon svg,
.search-icon svg, .kpi-icon svg, .relatorio-icon svg,
.toast svg, .stat-icon svg, .page-icon svg { display: block; }
img { max-width: 100%; display: block; }

/* ── SCROLLBAR ───────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ── APP SHELL ───────────────────────────────── */
#app { min-height: 100vh; }

/* ══════════════════════════════════════════════
   COMPANY THEME TOKENS
══════════════════════════════════════════════ */
:root {
  --navbar-from:      #003F73;
  --navbar-to:        #005A9C;
  --company-accent:   #2589D4;
  --company-dot:      #57A0E0;
  --company-drawer:   #001D3D;
  --company-active:   rgba(255,255,255,.13);
  --kpi-from:         #004D8E;
  --kpi-to:           #0072C6;
}

/* Seja Pay — Azul */
[data-company="sejapay"] {
  --navbar-from:    #071E45;
  --navbar-to:      #0E5FAD;
  --company-accent: #0DC4E4;
  --company-dot:    #38BDF8;
  --company-drawer: #040E22;
  --kpi-from:       #0E5FAD;
  --kpi-to:         #0DC4E4;
}

/* CNF — Verde */
[data-company="cnf"] {
  --navbar-from:    #1B5E20;
  --navbar-to:      #2E7D32;
  --company-accent: #66BB6A;
  --company-dot:    #A5D6A7;
  --company-drawer: #0D3010;
  --kpi-from:       #2E7D32;
  --kpi-to:         #4CAF50;
}

/* Açaí da Barra — Roxo */
[data-company="acai"] {
  --navbar-from:    #3E0050;
  --navbar-to:      #7B1FA2;
  --company-accent: #CE93D8;
  --company-dot:    #E1BEE7;
  --company-drawer: #1E0028;
  --kpi-from:       #6A1280;
  --kpi-to:         #9C27B0;
}

/* ══════════════════════════════════════════════
   NAVBAR
══════════════════════════════════════════════ */
.navbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--navbar-h);
  background: linear-gradient(90deg, var(--navbar-from) 0%, var(--navbar-to) 100%);
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
  z-index: 900;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
  transition: background .35s ease;
}

.navbar-menu-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7);
  flex-shrink: 0;
  transition: var(--transition);
}
.navbar-menu-btn:hover { background: rgba(255,255,255,.12); color: white; }

.navbar-brand {
  display: flex; align-items: center; gap: 10px;
  flex: 1; justify-content: center;
  min-width: 0;
}

.navbar-logo {
  height: 30px; width: auto;
  object-fit: contain;
  border-radius: 5px;
  background: white;
  padding: 2px 5px;
}
.navbar-logo.hidden { display: none !important; }

.navbar-brand-name {
  font-size: 14px; font-weight: 700;
  color: white; letter-spacing: 0.2px;
  white-space: nowrap;
}

.navbar-links {
  display: flex; align-items: center; gap: 2px;
  background: rgba(0,0,0,.15);
  border-radius: 10px;
  padding: 3px;
}
.nav-link {
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,.72);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
}
.nav-link:hover { color: white; background: rgba(255,255,255,.1); }
.nav-link.active {
  background: white;
  color: var(--blue-900);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}

.navbar-actions {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}

.navbar-company-select {
  background: rgba(255,255,255,.12);
  border: 1.5px solid rgba(255,255,255,.3);
  border-radius: var(--radius-sm);
  color: white;
  padding: 6px 10px 6px 28px;
  font-size: 12.5px; font-weight: 600;
  cursor: pointer; outline: none;
  transition: var(--transition);
  max-width: 175px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(255,255,255,0.6)'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}
.navbar-company-select:hover { background-color: rgba(255,255,255,.18); }
.navbar-company-select option { background: var(--blue-900); color: white; }

/* Company color dot before the empresa select */
.navbar-company-wrap { position: relative; display: flex; align-items: center; }
.navbar-company-dot  {
  position: absolute; left: 9px; z-index: 1;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--company-dot, rgba(255,255,255,.5));
  pointer-events: none;
  transition: background .35s;
  flex-shrink: 0;
}

.navbar-period-select {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.85);
  padding: 6px 10px;
  font-size: 12.5px; cursor: pointer; outline: none;
}
.navbar-period-select option { background: var(--blue-900); color: white; }

.navbar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  border: 2px solid rgba(255,255,255,.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: white;
  cursor: pointer;
  transition: var(--transition);
}
.navbar-avatar:hover { background: rgba(255,255,255,.28); }

.navbar-icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; color: rgba(255,255,255,.7);
  transition: var(--transition);
}
.navbar-icon-btn:hover { background: rgba(255,255,255,.12); color: white; }

/* ══════════════════════════════════════════════
   SIDE DRAWER
══════════════════════════════════════════════ */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000; opacity: 0; pointer-events: none;
  transition: opacity .22s ease;
  backdrop-filter: blur(2px);
}
.drawer-overlay.open { opacity: 1; pointer-events: all; }

.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--drawer-w);
  background: var(--company-drawer, var(--blue-950));
  z-index: 1100;
  transform: translateX(-100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1), background .35s ease;
  display: flex; flex-direction: column;
  box-shadow: 6px 0 24px rgba(0,0,0,.35);
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  height: var(--navbar-h);
  display: flex; align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.drawer-header-title {
  flex: 1; font-size: 14px; font-weight: 700; color: white;
}
.drawer-close-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: rgba(255,255,255,.5); font-size: 16px;
  transition: var(--transition);
}
.drawer-close-btn:hover { background: rgba(255,255,255,.1); color: white; }

.drawer-nav { flex: 1; overflow-y: auto; padding: 8px 0 20px; }

.drawer-section {
  font-size: 10px; font-weight: 600; letter-spacing: 1.2px;
  color: rgba(255,255,255,.35); text-transform: uppercase;
  padding: 16px 20px 5px;
}

.drawer-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 20px;
  cursor: pointer; color: rgba(255,255,255,.65);
  font-size: 13.5px; font-weight: 500;
  transition: var(--transition);
  border-right: 3px solid transparent;
}
.drawer-item:hover { background: rgba(255,255,255,.07); color: white; }
.drawer-item.active {
  background: rgba(255,255,255,.1); color: white;
  border-right-color: var(--blue-300);
}
.drawer-item svg { width: 17px; height: 17px; }

/* ══════════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════════ */
.main-content {
  margin-top: var(--navbar-h);
  min-height: calc(100vh - var(--navbar-h));
  padding: var(--pad);
  box-sizing: border-box;
  width: 100%;
  overflow-x: hidden;
}

.page-content { animation: fadeSlide .22s ease; }

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

/* ══════════════════════════════════════════════
   KPI CARDS
══════════════════════════════════════════════ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: linear-gradient(135deg, var(--kpi-from, var(--blue-800)) 0%, var(--kpi-to, var(--blue-500)) 100%);
  border-radius: var(--radius);
  padding: 18px 16px 10px;
  color: white; position: relative; overflow: hidden;
  box-shadow: var(--shadow-blue);
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, background .35s ease;
}
.kpi-card::before {
  content: '';
  position: absolute; top: -20px; right: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 8px 28px rgba(0,0,0,.3); }
.kpi-card.negative {
  background: linear-gradient(135deg, #7f1d1d 0%, #b91c1c 100%) !important;
}
.kpi-card.neutral {
  background: linear-gradient(135deg, #1e3a5f 0%, #2d5986 100%) !important;
}

/* Legacy kpi-card color variants (used in Lançamentos) */
.kpi-card.green  { background: linear-gradient(135deg, #065f46 0%, #059669 100%) !important; }
.kpi-card.red    { background: linear-gradient(135deg, #7f1d1d 0%, #dc2626 100%) !important; }
.kpi-card.blue   { background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%) !important; }
.kpi-card.amber  { background: linear-gradient(135deg, #78350f 0%, #d97706 100%) !important; }
.kpi-card.purple { background: linear-gradient(135deg, #4c1d95 0%, #7c3aed 100%) !important; }
.kpi-card.cyan   { background: linear-gradient(135deg, #164e63 0%, #0891b2 100%) !important; }

/* Legacy kpi-card inner structure */
.kpi-grid { display: grid; gap: 14px; margin-bottom: 20px; }
.kpi-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi-icon { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: rgba(255,255,255,.15); color: white; flex-shrink: 0; }
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-trend { font-size: 13px; font-weight: 700; color: rgba(255,255,255,.8); }
.kpi-trend.up   { color: #6ee7b7; }
.kpi-trend.down { color: #fca5a5; }

/* Text color helpers */
.text-green { color: #6ee7b7 !important; }
.text-red   { color: #fca5a5 !important; }
.text-blue  { color: #93c5fd !important; }

/* Relatório card icon — constrain SVG to a readable size */
.relatorio-icon { display: flex; align-items: center; justify-content: center; height: 56px; margin-bottom: 10px; }
.relatorio-icon svg { width: 48px; height: 48px; }

.kpi-label {
  font-size: 10.5px; font-weight: 600;
  color: rgba(255,255,255,.72); letter-spacing: 0.3px;
  margin-bottom: 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.kpi-value {
  font-size: 19px; font-weight: 800;
  color: white; line-height: 1;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.kpi-sparkline {
  margin-top: 10px;
  height: 38px;
  position: relative;
}
.kpi-sparkline svg { width: 100%; height: 100%; overflow: visible; }

/* ══════════════════════════════════════════════
   FILTER BAR
══════════════════════════════════════════════ */
.filter-bar {
  display: flex; align-items: center; gap: 16px;
  background: white;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}
.filter-label {
  font-size: 10.5px; font-weight: 700;
  color: var(--gray-500); letter-spacing: 0.9px; text-transform: uppercase;
  white-space: nowrap;
}
.filter-select {
  padding: 6px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px; font-weight: 500;
  color: var(--gray-800); background: var(--gray-50);
  cursor: pointer; outline: none; transition: var(--transition);
}
.filter-select:hover { border-color: var(--blue-300); }
.filter-select:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(0,114,198,.1);
}

/* ══════════════════════════════════════════════
   DRE VERTICAL TABLE
══════════════════════════════════════════════ */
.dre-table-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}
.dre-table-wrap { overflow-x: auto; }

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

/* Month group headers */
.dre-v-table thead tr.dre-months th {
  background: var(--blue-900);
  color: white;
  font-size: 12px; font-weight: 700;
  padding: 10px 8px; text-align: center;
  border-right: 2px solid rgba(255,255,255,.08);
  letter-spacing: 0.4px;
  position: sticky; top: 0;
}
.dre-v-table thead tr.dre-months th.th-label {
  text-align: left; padding-left: 16px;
  width: 150px;
  position: sticky; top: 0; left: 0; z-index: 6;
  background: var(--blue-950);
  box-shadow: 3px 0 8px rgba(0,0,0,.3);
}

/* Sub-column headers (Realizado / AV / AH) */
.dre-v-table thead tr.dre-subcols th {
  background: var(--blue-800);
  color: rgba(255,255,255,.75);
  font-size: 10px; font-weight: 600;
  padding: 5px 6px; text-align: right;
  border-right: 1px solid rgba(255,255,255,.06);
  letter-spacing: 0.4px;
  white-space: nowrap;
  position: sticky; top: 38px;
}
.dre-v-table thead tr.dre-subcols th.th-label {
  text-align: left; padding-left: 16px;
  background: var(--blue-900);
  color: rgba(255,255,255,.5);
  font-size: 10px;
  position: sticky; top: 38px; left: 0; z-index: 5;
  box-shadow: 3px 0 6px rgba(0,0,0,.2);
}

/* Row types */
.dre-v-table tbody tr { transition: background .1s; }

/* Section (group header) */
.dre-v-table tbody tr.row-section { background: var(--gray-900); }
.dre-v-table tbody tr.row-section td {
  padding: 9px 8px 9px 16px;
  color: white; font-weight: 700; font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.dre-v-table tbody tr.row-section:hover { background: var(--gray-800) !important; }

/* Child rows */
.dre-v-table tbody tr.row-child { background: white; }
.dre-v-table tbody tr.row-child:nth-child(even) { background: var(--gray-50); }
.dre-v-table tbody tr.row-child:hover { background: var(--blue-50) !important; }
.dre-v-table tbody tr.row-child td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}
.dre-v-table tbody tr.row-child td.td-label {
  padding-left: 28px;
  color: var(--gray-800);
}

/* Subtotal rows */
.dre-v-table tbody tr.row-subtotal { background: var(--blue-50); }
.dre-v-table tbody tr.row-subtotal:hover { background: var(--blue-100) !important; }
.dre-v-table tbody tr.row-subtotal td {
  padding: 9px 8px;
  color: var(--blue-800); font-weight: 700; font-size: 12.5px;
  border-top: 2px solid var(--blue-200);
  border-bottom: 1px solid var(--blue-100);
}
.dre-v-table tbody tr.row-subtotal td.td-label { padding-left: 16px; }

/* Result rows (final totals) */
.dre-v-table tbody tr.row-result { background: var(--blue-900); }
.dre-v-table tbody tr.row-result:hover { background: var(--blue-800) !important; }
.dre-v-table tbody tr.row-result td {
  padding: 11px 8px;
  color: white; font-weight: 800; font-size: 13px;
}
.dre-v-table tbody tr.row-result td.td-label { padding-left: 16px; }

/* Separator */
.dre-v-table tbody tr.row-sep td { height: 6px; background: var(--gray-200); padding: 0; }

/* ── STICKY PRIMEIRA COLUNA ─────────────────── */
.dre-v-table tbody tr td.td-label {
  position: sticky; left: 0; z-index: 1;
  box-shadow: 2px 0 5px rgba(0,0,0,.07);
}
.dre-v-table tbody tr.row-section td.td-label       { background: var(--gray-900); }
.dre-v-table tbody tr.row-section:hover td.td-label  { background: var(--gray-800); }
.dre-v-table tbody tr.row-child td.td-label          { background: white; }
.dre-v-table tbody tr.row-child:nth-child(even) td.td-label { background: var(--gray-50); }
.dre-v-table tbody tr.row-child:hover td.td-label    { background: var(--blue-50); }
.dre-v-table tbody tr.row-subtotal td.td-label       { background: var(--blue-50); }
.dre-v-table tbody tr.row-subtotal:hover td.td-label { background: var(--blue-100); }
.dre-v-table tbody tr.row-result td.td-label         { background: var(--blue-900); }
.dre-v-table tbody tr.row-result:hover td.td-label   { background: var(--blue-800); }

/* Cell alignment */
.td-label { text-align: left; }
.td-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}
.td-av {
  text-align: right;
  color: var(--gray-500);
  font-size: 11px;
  white-space: nowrap;
}
.td-ah {
  text-align: right;
  font-size: 11px;
  white-space: nowrap;
  min-width: 52px;
}
.td-month-start { border-left: 2px solid var(--gray-200); }
.row-section .td-month-start { border-left-color: rgba(255,255,255,.1); }
.row-result  .td-month-start { border-left-color: rgba(255,255,255,.15); }

/* AH indicators */
.ah-up   { color: #10b981; font-weight: 600; }
.ah-down { color: #ef4444; font-weight: 600; }
.ah-neutral { color: var(--gray-400); }

/* ══════════════════════════════════════════════
   STANDARD CARDS
══════════════════════════════════════════════ */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
}
.card-title { font-size: 14px; font-weight: 700; color: var(--gray-900); }
.card-subtitle { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}

/* ══════════════════════════════════════════════
   SECTION HEADER
══════════════════════════════════════════════ */
.section-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px; gap: 12px;
}
.section-title { font-size: 20px; font-weight: 800; color: var(--gray-900); letter-spacing: -0.3px; }
.section-subtitle { font-size: 13px; color: var(--gray-500); margin-top: 3px; }

/* ══════════════════════════════════════════════
   TOOLBAR & SEARCH BAR (Lançamentos, etc.)
══════════════════════════════════════════════ */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.search-bar {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 200px; max-width: 400px;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  height: 38px;
  transition: border-color .15s;
}
.search-bar:focus-within { border-color: var(--blue-400); box-shadow: 0 0 0 3px rgba(0,90,156,.08); }
.search-icon { display: flex; align-items: center; flex-shrink: 0; color: var(--gray-400); }
.search-icon svg { width: 16px; height: 16px; display: block; }
.search-bar input {
  flex: 1; border: none; outline: none; background: none;
  font-size: 13px; color: var(--gray-800);
  padding: 0;
}

/* Icon-only (svg-only) buttons */
.btn-icon { padding: 6px; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon svg { width: 15px; height: 15px; }

/* Upload icon in upload zones */
.upload-icon { display: flex; align-items: center; justify-content: center; margin: 0 auto 10px; }
.upload-icon svg { width: 40px; height: 40px; }

/* Empty state icon */
.empty-state { text-align: center; padding: 48px 24px; color: var(--gray-500); }
.empty-icon  { width: 56px; height: 56px; margin: 0 auto 16px; opacity: .3;
               display: flex; align-items: center; justify-content: center; }
.empty-icon svg { width: 100%; height: 100%; }

/* ══════════════════════════════════════════════
   DATA TABLE (Lançamentos, Auditoria, etc.)
══════════════════════════════════════════════ */
.data-table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  background: var(--gray-50);
  padding: 10px 14px;
  text-align: left;
  font-size: 10.5px; font-weight: 700; color: var(--gray-500);
  letter-spacing: 0.5px; text-transform: uppercase;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-800); vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--blue-50); }
.data-table tbody tr:last-child td { border-bottom: none; }
.text-right { text-align: right; }

/* ══════════════════════════════════════════════
   LAYOUT GRIDS
══════════════════════════════════════════════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ══════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; font-family: var(--font);
  cursor: pointer; border: none;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--blue-700); color: white; }
.btn-primary:hover { background: var(--blue-900); }
.btn-secondary {
  background: var(--gray-100); color: var(--gray-800);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-900); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 24px; font-size: 15px; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: var(--radius-sm); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

/* ══════════════════════════════════════════════
   BADGES
══════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.2px;
}
.badge-blue   { background: var(--blue-100); color: var(--blue-700); }
.badge-green  { background: var(--success-light); color: var(--success); }
.badge-red    { background: var(--danger-light); color: var(--danger); }
.badge-amber  { background: var(--warning-light); color: var(--warning); }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }
.badge-purple { background: var(--purple-light); color: var(--purple); }

/* ══════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════ */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 12px; font-weight: 600; color: var(--gray-700);
  margin-bottom: 5px;
}
.form-control {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--gray-900); background: white;
  outline: none; transition: var(--transition);
}
.form-control:hover { border-color: var(--blue-300); }
.form-control:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(0,114,198,.1); }
textarea.form-control { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ══════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
  width: 100%; max-width: 560px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  transform: scale(.95) translateY(8px);
  transition: transform .22s ease;
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-100);
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.modal-close {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: 18px; color: var(--gray-400);
  transition: var(--transition);
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ══════════════════════════════════════════════
   ALERTS
══════════════════════════════════════════════ */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.5;
}
.alert-icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-info    { background: var(--blue-50); color: var(--blue-900); }
.alert-success { background: var(--success-light); color: #065f46; }
.alert-warning { background: var(--warning-light); color: #92400e; }
.alert-danger  { background: var(--danger-light); color: #991b1b; }
.mb-16 { margin-bottom: 16px; }

/* ══════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════ */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 3000;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: white;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--blue-500);
  font-size: 13.5px; font-weight: 500; color: var(--gray-900);
  min-width: 280px; max-width: 380px;
  animation: toastIn .25s ease;
  pointer-events: all;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ══════════════════════════════════════════════
   UPLOAD ZONE
══════════════════════════════════════════════ */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 32px 20px; text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--blue-400); background: var(--blue-50);
}
.upload-icon { width: 40px; height: 40px; margin: 0 auto 10px; color: var(--gray-400); }
.upload-title { font-size: 14px; font-weight: 600; color: var(--gray-700); margin-bottom: 4px; }
.upload-desc { font-size: 12.5px; color: var(--gray-500); }
.upload-formats { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.upload-format {
  padding: 2px 8px; background: var(--gray-100);
  border-radius: 4px; font-size: 11px; font-weight: 600;
  color: var(--gray-600);
}

/* ══════════════════════════════════════════════
   AI PROCESSING
══════════════════════════════════════════════ */
.ai-processing { display: none; text-align: center; padding: 32px 20px; }
.ai-processing.active { display: block; }
.ai-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--gray-200); border-top-color: var(--blue-500);
  border-radius: 50%; animation: spin .8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-bar { height: 6px; background: var(--gray-200); border-radius: 100px; overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: 100px;
  background: linear-gradient(90deg, var(--blue-700), var(--blue-400));
  transition: width .1s;
}

/* ══════════════════════════════════════════════
   DRE RESULT (vertical accordion — existing DRE page)
══════════════════════════════════════════════ */
.dre-summary { display: flex; flex-direction: column; }
.dre-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13.5px;
}
.dre-row:last-child { border-bottom: none; }
.dre-row.section { background: var(--gray-50); font-weight: 700; font-size: 12px; letter-spacing: 0.4px; text-transform: uppercase; color: var(--gray-600); }
.dre-row.result  { background: var(--blue-50); font-weight: 700; color: var(--blue-700); }
.dre-row.result.positive { color: var(--success); }
.dre-row.result.negative { color: var(--danger); }
.dre-label.indent { padding-left: 16px; font-size: 13px; color: var(--gray-700); }
.dre-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.dre-value.positive { color: var(--success); }
.dre-value.negative { color: var(--danger); }

/* ══════════════════════════════════════════════
   COMPANY CARDS
══════════════════════════════════════════════ */
.company-card {
  background: white; border-radius: var(--radius);
  padding: 20px; border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  cursor: pointer; transition: var(--transition);
}
.company-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.company-logo {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
}
.company-name { font-size: 15px; font-weight: 700; margin-top: 10px; }
.company-cnpj { font-size: 11px; color: var(--gray-500); margin-top: 3px; font-family: var(--font-mono); }

/* ══════════════════════════════════════════════
   STAT MINI
══════════════════════════════════════════════ */
.stat-mini {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}
.stat-mini:last-child { border-bottom: none; }
.stat-mini-label { color: var(--gray-700); }
.stat-mini-value { font-weight: 700; }
.text-green { color: var(--success); }
.text-red   { color: var(--danger); }
.text-amber { color: var(--warning); }
.text-blue  { color: var(--blue-700); }

/* ══════════════════════════════════════════════
   INSIGHT CARD
══════════════════════════════════════════════ */
.insight-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px; border-radius: var(--radius-sm);
  background: white; border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.insight-card.warning { border-left: 4px solid var(--warning); }
.insight-card.danger  { border-left: 4px solid var(--danger); }
.insight-card.success { border-left: 4px solid var(--success); }
.insight-card.info    { border-left: 4px solid var(--blue-500); }
.insight-icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.insight-title { font-size: 13.5px; font-weight: 700; color: var(--gray-900); }
.insight-text  { font-size: 12.5px; color: var(--gray-600); margin-top: 3px; line-height: 1.5; }

/* ══════════════════════════════════════════════
   SCORE ROW
══════════════════════════════════════════════ */
.score-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}
.score-ok strong   { color: var(--success); }
.score-warn strong { color: var(--warning); }

/* ══════════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════════ */
.empty-state { text-align: center; padding: 48px 24px; color: var(--gray-500); }
.empty-icon  { width: 48px; height: 48px; margin: 0 auto 16px; opacity: .35; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--gray-700); margin-bottom: 6px; }
.empty-desc  { font-size: 13px; }

/* ══════════════════════════════════════════════
   AVATAR
══════════════════════════════════════════════ */
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--blue-100); color: var(--blue-700);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}

/* ══════════════════════════════════════════════
   UTILITY
══════════════════════════════════════════════ */
.flex         { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.gap-4  { gap: 4px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-8   { margin-bottom: 8px; }
.mb-12  { margin-bottom: 12px; }
.mb-16  { margin-bottom: 16px; }
.mb-20  { margin-bottom: 20px; }
.mb-24  { margin-bottom: 24px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.text-sm   { font-size: 12px; }
.text-muted{ color: var(--gray-500); }
.text-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.hidden    { display: none !important; }

/* ══════════════════════════════════════════════
   DASHBOARD STAT CARDS
══════════════════════════════════════════════ */
.stat-card {
  background: white; border-radius: var(--radius);
  padding: 20px; border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 12px; font-weight: 600; color: var(--gray-500); margin-bottom: 6px; letter-spacing: 0.3px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--gray-900); letter-spacing: -0.5px; line-height: 1; }
.stat-change { font-size: 12px; margin-top: 6px; }
.stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}

/* ══════════════════════════════════════════════
   CHART CONTAINERS
══════════════════════════════════════════════ */
.chart-wrap { position: relative; height: 260px; }
.chart-wrap canvas { max-height: 100%; }

/* ══════════════════════════════════════════════
   IMPORT / TXT PREVIEW
══════════════════════════════════════════════ */
.import-preview {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 16px;
}
.import-preview-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
  font-size: 12.5px; font-weight: 600; color: var(--gray-700);
}
.import-preview-table { width: 100%; }
.import-preview-table th {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--gray-500);
  padding: 8px 12px; text-align: left;
  border-bottom: 1px solid var(--gray-200);
}
.import-preview-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px; color: var(--gray-800);
}

/* ══════════════════════════════════════════════
   TOPBAR COMPAT (legacy elements)
══════════════════════════════════════════════ */
.topbar-company-logo { display: none; }
.topbar-company-logo.visible { display: none; }

/* ══════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════ */

/* Prevent layout shift from scrollbar when drawer opens */
html { scrollbar-gutter: stable; }

@media (max-width: 1400px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1100px) {
  .navbar-links { display: none; }
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .main-content { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .dre-table-card { border-radius: var(--radius); }
  .dre-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .dre-v-table { min-width: 700px; }
  .filter-bar { flex-wrap: wrap; gap: 8px; }
  .navbar-actions .navbar-company-select { max-width: 120px; font-size: 11px; }
}
@media (max-width: 600px) {
  :root { --pad: 14px; --navbar-h: 56px; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .navbar-actions .navbar-period-select { display: none; }
  .navbar-actions .navbar-company-select { max-width: 100px; font-size: 11px; }
  .navbar-brand-name { font-size: 13px; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  .filter-bar { padding: 12px 14px; }
  .dre-v-table { min-width: 600px; }
  .kpi-value { font-size: 20px; }
}
@media (max-width: 400px) {
  .kpi-row { grid-template-columns: 1fr; }
  .navbar-actions .navbar-company-select { display: none; }
}

/* ══════════════════════════════════════════════
   PRINT — Relatório PDF
══════════════════════════════════════════════ */
@media print {
  body > *:not(#dreRelatorioPrint) { display: none !important; }
  #dreRelatorioPrint { display: block !important; }
  #dreRelatorioPrint td, #dreRelatorioPrint th {
    border: 1px solid #ddd !important;
    padding: 4px 6px !important;
  }
  #dreRelatorioPrint tr:nth-child(even) td { background: #f9f9f9 !important; }
  @page { margin: 15mm; }
}
