/* ============================================================
   SANTAPIRA B.I — MASTER STYLESHEET
   Design: Black premium, high-contrast, solid colors
   ============================================================ */

/* ===== CSS VARIABLES — BLACK PREMIUM THEME ===== */
:root {
  --accent:       #E8FF00;
  --accent-light: #F5FF66;
  --accent-glow:  rgba(232,255,0,0.18);
  --accent-dark:  rgba(232,255,0,0.08);

  /* Core Black */
  --bg-primary:   #080808;
  --bg-secondary: #0E0E0E;
  --bg-card:      #121212;
  --bg-card-hover:#161616;
  --bg-input:     #0A0A0A;
  --bg-sidebar:   #050505;

  --text-primary:   #FFFFFF;
  --text-secondary: #A0A0A0;
  --text-muted:     #505050;

  --border:         rgba(255,255,255,0.07);
  --border-active:  rgba(232,255,0,0.4);
  --border-strong:  rgba(255,255,255,0.12);

  /* Solid semantic colors — sem pastéis */
  --success:    #00E676;
  --danger:     #FF1744;
  --warning:    #FF9100;
  --info:       #00B0FF;
  --purple:     #D500F9;

  --success-bg: rgba(0,230,118,0.10);
  --danger-bg:  rgba(255,23,68,0.10);
  --warning-bg: rgba(255,145,0,0.10);
  --info-bg:    rgba(0,176,255,0.10);
  --purple-bg:  rgba(213,0,249,0.10);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow:    0 4px 32px rgba(0,0,0,0.7);
  --shadow-lg: 0 12px 60px rgba(0,0,0,0.9);

  --sidebar-w: 240px;
  --topbar-h:  60px;

  --transition: 0.18s cubic-bezier(0.4,0,0.2,1);
  --transition-slow: 0.35s cubic-bezier(0.4,0,0.2,1);
}

/* LIGHT THEME */
[data-theme="light"] {
  --bg-primary:   #F0F0F0;
  --bg-secondary: #E8E8E8;
  --bg-card:      #FFFFFF;
  --bg-card-hover:#F8F8F8;
  --bg-input:     #EBEBEB;
  --bg-sidebar:   #0A0A0A;

  --text-primary:   #0A0A0A;
  --text-secondary: #444444;
  --text-muted:     #888888;

  --border:         rgba(0,0,0,0.08);
  --border-strong:  rgba(0,0,0,0.14);
  --shadow:    0 4px 24px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.14);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

/* ===================================================
   SIDEBAR
   =================================================== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition-slow);
  overflow: hidden;
}
.sidebar.collapsed { width: 58px; }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item > span:not(.nav-dot),
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .sidebar-footer .status-text { opacity: 0; width: 0; overflow: hidden; white-space: nowrap; }

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 14px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
  flex-shrink: 0;
}
.logo { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.logo-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-icon i { color: #000; font-size: 14px; }
.logo-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1.2;
}
.logo-text strong { color: var(--accent); display: block; font-size: 11px; font-weight: 500; letter-spacing: 2px; text-transform: uppercase; }

.sidebar-toggle {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  transition: var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--border); color: var(--text-primary); }

/* Sidebar Nav */
.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; overflow-x: hidden; }
.nav-section-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  padding: 0 8px;
  margin: 10px 0 4px;
  white-space: nowrap;
  transition: var(--transition);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  white-space: nowrap;
  margin-bottom: 1px;
  position: relative;
}
.nav-item:hover { background: var(--border); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-dark);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%; transform: translateY(-50%);
  width: 2px; height: 18px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-item i { width: 16px; text-align: center; flex-shrink: 0; font-size: 13px; }
.badge {
  background: var(--accent);
  color: #000;
  font-size: 8px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Sidebar Footer */
.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); flex-shrink: 0; }
.connection-status { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-dot.connected    { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.disconnected { background: var(--text-muted); }
.status-dot.loading      { background: var(--warning); animation: blink 1s ease infinite; }
@keyframes blink { 0%,100% { opacity:1 } 50% { opacity:0.3 } }
.status-text { font-size: 11px; color: var(--text-muted); white-space: nowrap; transition: var(--transition); }

/* Cloud badge */
.cloud-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 4px;
  white-space: nowrap;
  transition: var(--transition);
  width: 100%;
}
.cloud-badge.connected  { background: rgba(0,230,118,0.12); color: var(--success); border: 1px solid rgba(0,230,118,0.2); }
.cloud-badge.loading    { background: rgba(255,145,0,0.10);  color: var(--warning); border: 1px solid rgba(255,145,0,0.2); }
.cloud-badge.disconnected { background: rgba(255,255,255,0.04); color: var(--text-muted); border: 1px solid var(--border); }
.sidebar.collapsed .cloud-badge span { display: none; }
.sidebar.collapsed .cloud-badge { justify-content: center; padding: 4px 6px; }

/* Sync indicator no breadcrumb */
.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--warning);
  font-weight: 600;
  animation: fadeIn 0.3s ease;
}
.sync-indicator i { font-size: 10px; }

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

/* ===================================================
   TOPBAR
   =================================================== */
.topbar {
  position: sticky; top: 0;
  height: var(--topbar-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  z-index: 50;
  gap: 14px;
}
.topbar-left { flex-shrink: 0; }
.page-title { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
.breadcrumb { font-size: 11px; color: var(--text-muted); margin-top: 1px; display: flex; align-items: center; gap: 5px; }
.breadcrumb i { font-size: 9px; }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }

.period-selector {
  display: flex;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 1px;
  border: 1px solid var(--border);
}
.period-btn {
  padding: 5px 11px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.period-btn:hover { color: var(--text-primary); }
.period-btn.active { background: var(--accent); color: #000; font-weight: 700; }

.month-picker-wrap { display: flex; gap: 5px; }
.month-picker {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
}
.month-picker:focus { outline: none; border-color: var(--accent); }

.topbar-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  transition: var(--transition);
}
.topbar-btn:hover { border-color: var(--border-strong); color: var(--text-primary); }
.edit-mode-btn { width: auto; padding: 0 12px; gap: 7px; font-size: 12px; font-weight: 600; }
.edit-mode-btn.active { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 700; }

/* ===================================================
   CONTENT AREA & VIEWS
   =================================================== */
.content-area { flex: 1; padding: 20px; overflow-y: auto; }
.view { display: none; }
.view.active { display: block; animation: fadeUp 0.25s ease; }
@keyframes fadeUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ===================================================
   GRID STACK (DASHBOARD)
   =================================================== */
.grid-stack { min-height: 600px; }
.grid-stack-item-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) !important;
  overflow: hidden;
  transition: border-color var(--transition);
  height: 100%;
}
.grid-stack-item-content:hover { border-color: var(--border-strong); }
.grid-stack.edit-mode .grid-stack-item-content { border-color: rgba(232,255,0,0.15) !important; cursor: move; }
.grid-stack .grid-stack-item.ui-draggable-dragging > .grid-stack-item-content {
  box-shadow: 0 24px 80px rgba(0,0,0,0.9) !important;
  border-color: var(--accent) !important;
}
.grid-stack .grid-stack-item.ui-resizable-resizing > .grid-stack-item-content { border-color: var(--accent) !important; }

/* ===================================================
   WIDGET CARD
   =================================================== */
.widget-card { display: flex; flex-direction: column; height: 100%; }
.widget-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 0;
  flex-shrink: 0;
}
.widget-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  display: flex; align-items: center; gap: 6px;
}
.widget-title i { font-size: 11px; }
.widget-actions { display: flex; gap: 3px; }
.widget-action-btn {
  width: 24px; height: 24px;
  border-radius: 5px;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  transition: var(--transition);
  opacity: 0;
}
.widget-card:hover .widget-action-btn { opacity: 1; }
.widget-action-btn:hover { background: var(--border); color: var(--text-secondary); }
.widget-action-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

.widget-body { flex: 1; padding: 8px 16px 14px; display: flex; flex-direction: column; min-height: 0; }

/* KPI Widget */
.kpi-value {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1.5px;
  margin: 4px 0 3px;
  font-variant-numeric: tabular-nums;
}
.kpi-label { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.kpi-change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  margin-top: 6px;
}
.kpi-change.positive { color: var(--success); background: var(--success-bg); }
.kpi-change.negative { color: var(--danger);  background: var(--danger-bg); }
.kpi-change.neutral  { color: var(--text-muted); background: var(--border); }
.kpi-sparkline { margin-top: 8px; flex: 1; min-height: 0; max-height: 55px; }

/* Chart wrapper */
.widget-chart-wrap { flex: 1; position: relative; min-height: 0; }
.widget-chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* Table widget */
.widget-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.widget-table th {
  text-align: left; padding: 5px 8px;
  color: var(--text-muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px; font-size: 9px;
  border-bottom: 1px solid var(--border);
}
.widget-table td { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.02); }
.widget-table tr:last-child td { border-bottom: none; }
.widget-table tr:hover td { background: var(--bg-card-hover); }

/* Gauge */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: 2px; }
.gauge-value-text { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.gauge-label-text { font-size: 11px; color: var(--text-muted); }

/* ===================================================
   EDIT TOOLBAR
   =================================================== */
.edit-toolbar {
  margin-bottom: 14px;
  background: rgba(232,255,0,0.04);
  border: 1px solid rgba(232,255,0,0.2);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
}
.edit-toolbar-inner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.edit-label { font-size: 11px; font-weight: 700; color: var(--accent); white-space: nowrap; display: flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: 1px; }
.widget-buttons { display: flex; gap: 5px; flex-wrap: wrap; flex: 1; }
.add-widget-btn {
  padding: 5px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600;
  color: var(--text-secondary);
  display: flex; align-items: center; gap: 5px;
  transition: var(--transition);
}
.add-widget-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dark); }
.edit-actions { display: flex; gap: 6px; }
.btn-save-layout {
  padding: 7px 14px; background: var(--accent); color: #000;
  border-radius: var(--radius-sm); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; gap: 5px; transition: var(--transition);
}
.btn-save-layout:hover { opacity: 0.88; }
.btn-cancel-edit {
  padding: 7px 14px; background: var(--border); color: var(--text-secondary);
  border-radius: var(--radius-sm); font-size: 12px; font-weight: 600;
  display: flex; align-items: center; gap: 5px; transition: var(--transition);
}
.btn-cancel-edit:hover { background: var(--danger-bg); color: var(--danger); }

/* ===================================================
   ANALYTICS VIEW
   =================================================== */
.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: border-color var(--transition);
}
.analytics-card:hover { border-color: var(--border-strong); }
.analytics-card.full-width { grid-column: 1 / -1; }
.card-header { margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 7px; text-transform: uppercase; letter-spacing: 0.5px; }
.card-header h3 i { color: var(--accent); font-size: 12px; }
.chart-wrap { position: relative; }

/* ===================================================
   DRE VIEW
   =================================================== */
.dre-container { display: flex; flex-direction: column; gap: 16px; }

.dre-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.dre-title { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.dre-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.dre-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.dre-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  border-left: 3px solid transparent;
  transition: var(--transition);
}
.dre-kpi-card:hover { border-top-color: var(--border-strong); }
.dre-kpi-card.receita  { border-left-color: var(--success); }
.dre-kpi-card.despesa  { border-left-color: var(--danger); }
.dre-kpi-card.lucro    { border-left-color: var(--accent); }
.dre-kpi-card.margem   { border-left-color: var(--info); }
.dre-kpi-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 6px; }
.dre-kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.dre-kpi-value.positive { color: var(--success); }
.dre-kpi-value.negative { color: var(--danger); }
.dre-kpi-value.accent   { color: var(--accent); }
.dre-kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

.dre-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.dre-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.dre-table-header h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; display: flex; align-items: center; gap: 8px; }
.dre-table-header h3 i { color: var(--accent); }

.dre-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dre-table thead tr { background: var(--bg-secondary); }
.dre-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.dre-table th.text-right { text-align: right; }
.dre-table td { padding: 10px 16px; border-bottom: 1px solid rgba(255,255,255,0.03); vertical-align: middle; }
.dre-table tr:last-child td { border-bottom: none; }
.dre-table tr:hover td { background: var(--bg-card-hover); }

/* Conta Mãe row */
.dre-row-parent td { 
  font-weight: 700; 
  font-size: 13px;
  background: rgba(255,255,255,0.02);
  cursor: pointer;
  user-select: none;
}
.dre-row-parent:hover td { background: rgba(255,255,255,0.04) !important; }
.dre-row-parent td:first-child { padding-left: 14px; }

/* Conta Filha row */
.dre-row-child td { font-size: 12px; color: var(--text-secondary); }
.dre-row-child td:first-child { padding-left: 36px; color: var(--text-muted); }
.dre-row-child.hidden { display: none; }

/* Separador de grupo */
.dre-row-group-header td {
  background: var(--bg-secondary);
  font-size: 9px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 2px;
  color: var(--accent);
  padding: 7px 16px;
  border-bottom: 1px solid var(--border);
}

/* Total geral */
.dre-row-total td {
  font-size: 14px; font-weight: 800;
  border-top: 2px solid var(--border-strong);
  padding-top: 12px; padding-bottom: 12px;
}

.dre-toggle-icon { transition: transform 0.2s ease; display: inline-block; margin-right: 6px; font-size: 10px; color: var(--text-muted); }
.dre-row-parent.open .dre-toggle-icon { transform: rotate(90deg); }

.dre-valor-pos { color: var(--success); font-weight: 700; font-variant-numeric: tabular-nums; }
.dre-valor-neg { color: var(--danger);  font-weight: 700; font-variant-numeric: tabular-nums; }
.dre-valor-neu { color: var(--text-secondary); font-weight: 600; font-variant-numeric: tabular-nums; }
.text-right { text-align: right !important; }

/* DRE Gráfico */
.dre-charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dre-chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.dre-chart-card h4 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 12px; display: flex; align-items: center; gap: 7px; }
.dre-chart-card h4 i { color: var(--accent); }

/* ===================================================
   AI INSIGHTS VIEW
   =================================================== */
.ai-header {
  display: flex; align-items: center; gap: 18px;
  background: rgba(232,255,0,0.04);
  border: 1px solid rgba(232,255,0,0.12);
  border-radius: var(--radius-xl);
  padding: 20px 24px; margin-bottom: 20px;
}
.ai-avatar {
  width: 56px; height: 56px;
  border-radius: var(--radius-lg);
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.ai-avatar i { color: #000; }
.ai-intro { flex: 1; }
.ai-intro h2 { font-size: 18px; font-weight: 800; margin-bottom: 3px; letter-spacing: -0.3px; }
.ai-intro h2 strong { color: var(--accent); }
.ai-intro p { color: var(--text-secondary); font-size: 13px; }
.btn-analyze {
  padding: 10px 20px;
  background: var(--accent); color: #000;
  border-radius: var(--radius); font-size: 13px; font-weight: 700;
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
  transition: var(--transition);
}
.btn-analyze:hover { opacity: 0.85; }

.ai-loading { display: flex; flex-direction: column; align-items: center; padding: 40px; gap: 14px; color: var(--text-secondary); }
.ai-spinner { width: 42px; height: 42px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.insights-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; margin-bottom: 20px; }
.insight-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  display: flex; gap: 12px; transition: border-color var(--transition);
}
.insight-card:hover { border-color: var(--border-strong); }
.insight-icon { width: 40px; height: 40px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.insight-icon.danger  { background: var(--danger-bg);  color: var(--danger); }
.insight-icon.success { background: var(--success-bg); color: var(--success); }
.insight-icon.warning { background: var(--warning-bg); color: var(--warning); }
.insight-icon.info    { background: var(--info-bg);    color: var(--info); }
.insight-icon.accent  { background: var(--accent-dark);color: var(--accent); }
.insight-content { flex: 1; }
.insight-title { font-size: 12px; font-weight: 700; margin-bottom: 3px; }
.insight-desc  { font-size: 11px; color: var(--text-secondary); line-height: 1.5; }
.insight-value { font-size: 17px; font-weight: 800; margin-top: 5px; font-variant-numeric: tabular-nums; }

.ai-suggestions, .ai-predictions { margin-bottom: 20px; }
.ai-suggestions h3, .ai-predictions h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 7px; text-transform: uppercase; letter-spacing: 0.5px; }
.ai-suggestions h3 i { color: var(--warning); }
.ai-predictions h3 i { color: var(--info); }
.suggestions-list { display: flex; flex-direction: column; gap: 8px; }
.suggestion-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 12px; transition: border-color var(--transition);
}
.suggestion-item:hover { border-color: var(--border-strong); }
.suggestion-item i { color: var(--accent); margin-top: 1px; flex-shrink: 0; }
.suggestion-item p { color: var(--text-secondary); line-height: 1.6; }
.suggestion-item strong { color: var(--text-primary); }
.predictions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.prediction-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; text-align: center;
}
.prediction-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); font-weight: 700; }
.prediction-value { font-size: 26px; font-weight: 800; margin: 6px 0 3px; font-variant-numeric: tabular-nums; }
.prediction-trend { font-size: 11px; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; gap: 3px; }

/* ===================================================
   TRANSACTIONS VIEW
   =================================================== */
.transactions-toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.search-wrap { flex: 1; min-width: 200px; position: relative; }
.search-wrap i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 12px; }
.search-wrap input {
  width: 100%; padding: 9px 11px 9px 32px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary); font-size: 12px;
}
.search-wrap input:focus { outline: none; border-color: var(--accent); }
.search-wrap input::placeholder { color: var(--text-muted); }

.tx-filters { display: flex; gap: 6px; }
.filter-select {
  padding: 8px 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary); font-size: 12px; cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--accent); }

.tx-summary { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.tx-sum-item { font-size: 11px; color: var(--text-muted); }
.tx-sum-item.income strong  { color: var(--success); }
.tx-sum-item.expense strong { color: var(--danger); }
.tx-sum-item.balance strong { color: var(--accent); }

.transactions-table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.transactions-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.transactions-table thead tr { background: var(--bg-secondary); border-bottom: 1px solid var(--border); }
.transactions-table th {
  padding: 10px 14px; text-align: left;
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); cursor: pointer; white-space: nowrap; user-select: none;
}
.transactions-table th:hover { color: var(--text-secondary); }
.transactions-table td { padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,0.025); }
.transactions-table tr:last-child td { border-bottom: none; }
.transactions-table tr:hover td { background: var(--bg-card-hover); }

.badge-type {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 3px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-type.receita { background: var(--success-bg); color: var(--success); }
.badge-type.despesa { background: var(--danger-bg);  color: var(--danger); }
.cat-badge {
  display: inline-block; padding: 2px 7px; border-radius: 3px;
  font-size: 10px; font-weight: 600; background: rgba(255,255,255,0.05); color: var(--text-secondary);
}

.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 10px 14px; border-top: 1px solid var(--border); }
.page-btn {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: var(--bg-secondary); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; transition: var(--transition);
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 700; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ===================================================
   DATA SOURCE VIEW
   =================================================== */
.datasource-container { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 880px; }
.datasource-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.ds-icon {
  width: 48px; height: 48px; border-radius: var(--radius);
  background: #4285F4;
  display: flex; align-items: center; justify-content: center; font-size: 22px; color: white;
}
.ds-icon.demo { background: var(--warning); }
.datasource-card h2 { font-size: 16px; font-weight: 800; }
.datasource-card p { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }

.steps-guide { display: flex; flex-direction: column; gap: 10px; }
.step { display: flex; gap: 10px; align-items: flex-start; }
.step-num { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #000; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step-content strong { font-size: 12px; font-weight: 700; }
.step-content p { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }

.input-group { display: flex; flex-direction: column; gap: 5px; }
.input-group label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.input-group input {
  padding: 9px 11px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary); font-size: 12px;
}
.input-group input:focus { outline: none; border-color: var(--accent); }

.column-mapping { display: flex; flex-direction: column; gap: 6px; }
.mapping-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mapping-row span { font-size: 12px; color: var(--text-secondary); min-width: 130px; }
.mapping-row select {
  flex: 1; padding: 6px 8px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary); font-size: 11px;
}
.mapping-row select:focus { outline: none; border-color: var(--accent); }

/* Hint de tipo de dado */
.data-type-hint {
  font-size: 11px; color: var(--text-muted); padding: 10px 12px;
  background: rgba(232,255,0,0.04); border: 1px solid rgba(232,255,0,0.1);
  border-radius: var(--radius-sm); line-height: 1.5;
}
.data-type-hint strong { color: var(--accent); }

.ds-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-connect {
  flex: 1; padding: 10px 14px;
  background: var(--bg-secondary); border: 1px solid var(--border-strong);
  border-radius: var(--radius); color: var(--text-primary); font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 7px; transition: var(--transition);
}
.btn-connect:hover { border-color: var(--accent); color: var(--accent); }
.btn-connect.primary {
  background: var(--accent); border-color: var(--accent); color: #000; font-weight: 700;
}
.btn-connect.primary:hover { opacity: 0.88; }

.preview-table-container { overflow-x: auto; margin-top: 6px; max-height: 200px; overflow-y: auto; }

/* ===================================================
   SETTINGS VIEW
   =================================================== */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.settings-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.settings-card h3 { font-size: 13px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 7px; text-transform: uppercase; letter-spacing: 0.5px; }
.settings-card h3 i { color: var(--accent); }
.setting-item { margin-bottom: 14px; }
.setting-item label { display: block; font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 7px; }
.theme-btns { display: flex; gap: 5px; }
.theme-opt {
  flex: 1; padding: 7px 6px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-secondary);
  font-size: 11px; font-weight: 600; transition: var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.theme-opt:hover { border-color: var(--border-strong); color: var(--text-primary); }
.theme-opt.active { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 700; }

.accent-colors { display: flex; gap: 7px; }
.accent-opt { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; transition: var(--transition); }
.accent-opt.active, .accent-opt:hover { border-color: white; transform: scale(1.18); }

.export-btns { display: flex; flex-direction: column; gap: 7px; }
.btn-export {
  padding: 9px 12px; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-secondary);
  font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 7px; transition: var(--transition);
}
.btn-export:hover { border-color: var(--accent); color: var(--accent); }
.btn-export.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }
.refresh-status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-secondary); }
.refresh-status .status-dot { background: var(--success); box-shadow: 0 0 6px var(--success); }

/* ===================================================
   MODAL
   =================================================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl); width: 100%; max-width: 500px;
  box-shadow: var(--shadow-lg);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.modal-header h3 i { color: var(--accent); }
.modal-close { width: 28px; height: 28px; border-radius: var(--radius-sm); color: var(--text-muted); display: flex; align-items: center; justify-content: center; transition: var(--transition); }
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-body { padding: 22px; max-height: 58vh; overflow-y: auto; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; }
.form-group input, .form-group select {
  width: 100%; padding: 9px 11px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary); font-size: 12px;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--accent); }

.color-picker-row { display: flex; gap: 5px; flex-wrap: wrap; }
.color-swatch {
  width: 24px; height: 24px; border-radius: 5px; border: 2px solid transparent;
  cursor: pointer; transition: var(--transition);
}
.color-swatch:hover, .color-swatch.selected { border-color: white; transform: scale(1.18); }

.modal-footer { display: flex; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); justify-content: flex-end; }
.btn-modal-cancel {
  padding: 8px 16px; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-secondary); font-size: 13px; font-weight: 600; transition: var(--transition);
}
.btn-modal-cancel:hover { border-color: var(--danger); color: var(--danger); }
.btn-modal-save {
  padding: 8px 18px; background: var(--accent);
  border-radius: var(--radius); color: #000; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; gap: 5px; transition: var(--transition);
}
.btn-modal-save:hover { opacity: 0.88; }

/* ===================================================
   NOTIFICATIONS
   =================================================== */
.notification-container { position: fixed; top: 16px; right: 16px; z-index: 999; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.notification {
  background: var(--bg-card); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 10px 14px;
  display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500;
  box-shadow: var(--shadow); pointer-events: all;
  animation: slideIn 0.25s ease; min-width: 260px; max-width: 360px;
}
@keyframes slideIn { from { opacity:0; transform:translateX(16px); } to { opacity:1; transform:translateX(0); } }
.notification.success { border-left: 2px solid var(--success); }
.notification.error   { border-left: 2px solid var(--danger); }
.notification.warning { border-left: 2px solid var(--warning); }
.notification.info    { border-left: 2px solid var(--info); }

/* ===================================================
   EMPTY STATE
   =================================================== */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 50px 20px; text-align: center; gap: 10px; }
.empty-state i { font-size: 40px; color: var(--text-muted); margin-bottom: 6px; }
.empty-state h3 { font-size: 16px; font-weight: 700; color: var(--text-secondary); }
.empty-state p { font-size: 13px; color: var(--text-muted); max-width: 300px; line-height: 1.6; }
.empty-state .btn-go {
  margin-top: 6px; padding: 9px 18px; background: var(--accent); color: #000;
  border-radius: var(--radius); font-size: 13px; font-weight: 700;
  display: flex; align-items: center; gap: 7px; transition: var(--transition);
}
.empty-state .btn-go:hover { opacity: 0.88; }

/* ===================================================
   UTILITY
   =================================================== */
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-warning { color: var(--warning) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-accent  { color: var(--accent) !important; }
.fw-800 { font-weight: 800; }
.mono { font-family: 'JetBrains Mono', monospace; }
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, rgba(255,255,255,0.04) 50%, var(--border) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position:200% 0 } 100% { background-position:-200% 0 } }

/* ===================================================
   RESPONSIVE
   =================================================== */
@media (max-width: 1100px) {
  .analytics-grid { grid-template-columns: 1fr; }
  .datasource-container { grid-template-columns: 1fr; }
  .dre-charts-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 58px; }
  .sidebar { width: 58px; }
  .sidebar .logo-text, .sidebar .nav-item > span, .sidebar .nav-section-label, .sidebar .status-text { opacity:0; width:0; }
  .main-wrapper { margin-left: 58px; }
  .topbar { padding: 0 14px; }
  .period-selector, .month-picker-wrap { display: none; }
  .content-area { padding: 14px; }
  .widget-buttons { display: none; }
  .dre-kpi-row { grid-template-columns: 1fr 1fr; }
}
