/* =====================================================
   CasaGest — Design System
   Paleta: Dark Navy Theme
   ===================================================== */

:root {
  --bg-primary: #0F172A;
  --bg-card: #1E293B;
  --bg-card-hover: #263347;
  --bg-sidebar: #0D1B2E;
  --border: #2D3F55;
  --border-light: #374766;

  --accent: #6366F1;
  --accent-hover: #4F46E5;
  --accent-light: rgba(99,102,241,0.15);

  --success: #10B981;
  --success-light: rgba(16,185,129,0.15);
  --warning: #F59E0B;
  --warning-light: rgba(245,158,11,0.15);
  --danger: #EF4444;
  --danger-light: rgba(239,68,68,0.15);
  --info: #3B82F6;
  --info-light: rgba(59,130,246,0.15);

  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-card); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ===================== SIDEBAR ===================== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: var(--transition);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .user-info { display: none; }
.sidebar.collapsed .sidebar-brand { padding: 1.25rem 0.75rem; justify-content: center; }
.sidebar.collapsed .nav-item { padding: 0.75rem; justify-content: center; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-icon {
  width: 38px; height: 38px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-icon svg { width: 20px; height: 20px; color: white; }
.brand-text { flex: 1; min-width: 0; }
.brand-name { display: block; font-weight: 700; font-size: 0.95rem; color: var(--text-primary); }
.brand-sub { display: block; font-size: 0.7rem; color: var(--text-muted); }
.sidebar-toggle-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); padding: 4px;
  border-radius: 6px; flex-shrink: 0;
  transition: var(--transition);
}
.sidebar-toggle-btn:hover { color: var(--text-primary); background: var(--border); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  padding: 0.75rem 0.5rem 0.25rem;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: var(--accent-light); color: var(--accent); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
  background: var(--warning);
  color: #000;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: auto;
}
.nav-badge.danger { background: var(--danger); color: white; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 1rem;
  flex-shrink: 0;
}
.sidebar-user { display: flex; align-items: center; gap: 0.75rem; }
.user-avatar {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.875rem;
  flex-shrink: 0;
}
.user-name { display: block; font-size: 0.8rem; font-weight: 600; }
.user-role { display: block; font-size: 0.7rem; color: var(--text-muted); }

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

/* ===================== TOPBAR ===================== */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-menu-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); padding: 6px;
  border-radius: 6px; transition: var(--transition);
  display: none;
}
.topbar-menu-btn:hover { color: var(--text-primary); background: var(--border); }
.topbar-breadcrumb { display: flex; align-items: center; gap: 0.5rem; }
.breadcrumb-page { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }

.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-date { font-size: 0.8rem; color: var(--text-muted); }
.topbar-notifications {
  position: relative;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  color: var(--text-secondary);
  transition: var(--transition);
}
.topbar-notifications:hover { background: var(--border); color: var(--text-primary); }
.notif-badge {
  position: absolute;
  top: 4px; right: 4px;
  background: var(--danger);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.notif-dropdown {
  position: absolute;
  top: calc(var(--topbar-height) + 4px);
  right: 1rem;
  width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  max-height: 400px;
  overflow-y: auto;
}
.notif-item {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
.notif-item:last-child { border-bottom: none; }
.notif-icon { font-size: 1.25rem; }
.notif-text { font-size: 0.8rem; color: var(--text-secondary); }
.notif-text strong { color: var(--text-primary); display: block; margin-bottom: 2px; }

/* ===================== CONTENT AREA ===================== */
.content-area {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

/* ===================== MODULES ===================== */
.module { display: none; animation: fadeIn 0.3s ease; }
.module.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.module-title { font-size: 1.5rem; font-weight: 700; }
.module-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ===================== CARDS ===================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}
.card:hover { border-color: var(--border-light); }
.card-header {
  padding: 1.25rem 1.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}
.card-title { font-size: 0.95rem; font-weight: 600; }
.card-subtitle { font-size: 0.8rem; color: var(--text-muted); }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.kpi-card.accent::before { background: var(--accent); }
.kpi-card.success::before { background: var(--success); }
.kpi-card.warning::before { background: var(--warning); }
.kpi-card.danger::before { background: var(--danger); }
.kpi-card.info::before { background: var(--info); }

.kpi-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.kpi-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.kpi-value.success { color: var(--success); }
.kpi-value.warning { color: var(--warning); }
.kpi-value.danger { color: var(--danger); }
.kpi-meta { font-size: 0.75rem; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }
.kpi-icon {
  position: absolute; right: 1rem; top: 50%;
  transform: translateY(-50%);
  opacity: 0.15;
  font-size: 2.5rem;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.chart-card { }
.chart-card.large { grid-column: span 1; }
.chart-container { padding: 1rem 1.5rem 1.5rem; position: relative; }

/* Two Column Grid */
.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* ===================== ALERTS ===================== */
.alerts-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.alert {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
}
.alert.warning { background: var(--warning-light); border: 1px solid rgba(245,158,11,0.3); color: var(--warning); }
.alert.danger { background: var(--danger-light); border: 1px solid rgba(239,68,68,0.3); color: var(--danger); }
.alert.success { background: var(--success-light); border: 1px solid rgba(16,185,129,0.3); color: var(--success); }
.alert.info { background: var(--info-light); border: 1px solid rgba(59,130,246,0.3); color: var(--info); }

/* ===================== TABS ===================== */
.tabs-container { }
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab {
  padding: 0.625rem 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: var(--transition);
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===================== FORMS ===================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  padding: 1.5rem;
}
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-label { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); }
.form-input, .select-input {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.875rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  transition: var(--transition);
  width: 100%;
}
.form-input:focus, .select-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-input::placeholder { color: var(--text-muted); }
.select-input option { background: var(--bg-card); }

.search-input { max-width: 280px; }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #0DA974; }
.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover { background: #D97706; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 0.4rem 0.875rem; font-size: 0.8rem; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px;
  border-radius: 4px; transition: var(--transition);
}
.btn-icon:hover { color: var(--text-primary); }
.btn-icon.danger:hover { color: var(--danger); }

/* ===================== TABLES ===================== */
.table-filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table thead tr {
  background: rgba(255,255,255,0.03);
}
.data-table th {
  padding: 0.875rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.data-table .text-right { text-align: right; }

/* ===================== BADGES ===================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-accent { background: var(--accent-light); color: var(--accent); }

/* Stock status */
.stock-ok { color: var(--success); font-weight: 600; }
.stock-low { color: var(--warning); font-weight: 600; }
.stock-critical { color: var(--danger); font-weight: 600; }
.stock-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}
.dot-ok { background: var(--success); }
.dot-low { background: var(--warning); }
.dot-critical { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-light); }

/* ===================== MODALS ===================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  backdrop-filter: blur(4px);
}
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(640px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  z-index: 600;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1rem;
  padding: 4px 8px; border-radius: 4px;
  transition: var(--transition);
}
.modal-close:hover { color: var(--text-primary); background: var(--border); }
.modal-body { padding: 0; }
.modal-body .form-grid { padding: 1.5rem; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}
.hidden { display: none !important; }

/* ===================== PLANNING ===================== */
.checklist-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.progress-bar-label {
  display: flex; justify-content: space-between;
  font-size: 0.875rem; font-weight: 600;
  margin-bottom: 0.5rem;
}
.progress-bar-track {
  height: 10px;
  background: var(--bg-primary);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 999px;
  transition: width 0.5s ease;
}
.checklist-stats {
  display: flex; gap: 1.5rem;
  margin-top: 1rem;
}
.checklist-stat { font-size: 0.8rem; color: var(--text-muted); }
.checklist-stat strong { color: var(--text-primary); }

.checklist-group {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}
.checklist-group-header {
  padding: 1rem 1.5rem;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.checklist-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item:hover { background: var(--bg-card-hover); }
.checklist-check {
  width: 20px; height: 20px;
  border: 2px solid var(--border-light);
  border-radius: 4px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.checklist-check.done { background: var(--success); border-color: var(--success); }
.checklist-check.progress { background: var(--warning); border-color: var(--warning); }
.checklist-item-text { flex: 1; font-size: 0.875rem; }
.checklist-item-text.done { text-decoration: line-through; color: var(--text-muted); }
.checklist-status-select {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 3px 8px;
  cursor: pointer;
}

/* ===================== SIMULATOR ===================== */
.simulator-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.simulator-results {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1rem;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.result-label { font-size: 0.85rem; color: var(--text-secondary); }
.result-value { font-size: 1rem; font-weight: 700; }
.result-value.success { color: var(--success); }
.result-value.warning { color: var(--warning); }
.result-value.danger { color: var(--danger); }

/* ===================== PRICING ===================== */
.pricing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.pricing-result {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.price-result-main {
  text-align: center;
  padding: 1.5rem;
  background: var(--accent-light);
  border-radius: var(--radius);
  border: 1px solid rgba(99,102,241,0.3);
  margin-bottom: 0.5rem;
}
.price-result-main .label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }
.price-result-main .value { font-size: 2.5rem; font-weight: 800; color: var(--accent); }
.price-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.price-result-row:last-child { border-bottom: none; }

.scenarios-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}
.scenario-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}
.scenario-card.conservador { border-top: 3px solid var(--warning); }
.scenario-card.realista { border-top: 3px solid var(--accent); }
.scenario-card.otimista { border-top: 3px solid var(--success); }
.scenario-title { font-weight: 700; margin-bottom: 1rem; }
.scenario-price { font-size: 2rem; font-weight: 800; margin-bottom: 1rem; }
.scenario-detail { font-size: 0.8rem; color: var(--text-muted); margin: 0.25rem 0; }

/* ===================== INVENTORY ===================== */
.abc-legend { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ===================== SALES ===================== */
.sale-total-display {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--success);
  padding: 0.75rem 1rem;
  background: var(--success-light);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(16,185,129,0.3);
}

/* ===================== FINANCE ===================== */
.dre-container {
  max-width: 800px;
}
.dre-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  transition: var(--transition);
}
.dre-row:hover { background: var(--bg-card-hover); }
.dre-row.level1 { background: var(--bg-card); font-weight: 600; font-size: 0.95rem; }
.dre-row.level2 { padding-left: 2.5rem; color: var(--text-muted); }
.dre-row.total {
  background: var(--accent-light);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
}
.dre-row.total-positive { background: var(--success-light); font-weight: 700; }
.dre-row.total-negative { background: var(--danger-light); font-weight: 700; }
.dre-value { font-weight: 600; }
.dre-value.positive { color: var(--success); }
.dre-value.negative { color: var(--danger); }

.cashflow-in { color: var(--success); font-weight: 600; }
.cashflow-out { color: var(--danger); font-weight: 600; }

/* ===================== TOAST ===================== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInRight 0.3s ease;
  max-width: 360px;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.danger { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--info); }
@keyframes slideInRight {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutRight {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100px); opacity: 0; }
}

/* ===================== CASHFLOW ===================== */
.cashflow-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  padding: 1.5rem;
}
.cf-summary-item { text-align: center; }
.cf-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }
.cf-value { font-size: 1.25rem; font-weight: 700; margin-top: 0.25rem; }

/* ===================== BREAKEVEN ===================== */
.breakeven-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.breakeven-item:last-child { border-bottom: none; }
.be-label { font-size: 0.875rem; color: var(--text-secondary); }
.be-value { font-size: 1.1rem; font-weight: 700; color: var(--accent); }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1280px) {
  .charts-grid { grid-template-columns: 1fr; }
  .scenarios-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .two-col-grid { grid-template-columns: 1fr; }
  .simulator-grid { grid-template-columns: 1fr; }
  .pricing-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-wrapper { margin-left: 0 !important; }
  .topbar-menu-btn { display: flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .module-header { flex-direction: column; align-items: flex-start; }
  .content-area { padding: 1rem; }
  .charts-grid { grid-template-columns: 1fr; }
  .cashflow-summary { grid-template-columns: repeat(2, 1fr); }
  .topbar-date { display: none; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .tabs { flex-wrap: nowrap; }
}

/* ===================== UTILITIES ===================== */
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.w-full { width: 100%; }

/* Actions cell in tables */
.actions-cell { display: flex; gap: 0.375rem; align-items: center; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-state-text { font-size: 0.9rem; }

/* =====================================================
   NOVOS ESTILOS v2: Auth, AI, Bulk, Users, Audit
   ===================================================== */

/* ── BOTÃO LOGOUT SIDEBAR ─────────────────────────── */
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.btn-logout {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 8px; border-radius: 8px;
  transition: var(--transition); flex-shrink: 0;
}
.btn-logout:hover { color: var(--danger); background: var(--danger-light); }

/* ── TOPBAR EXTRAS ───────────────────────────────── */
.topbar-ai-btn {
  display: flex; align-items: center; gap: 0.4rem;
  background: var(--accent-light); border: 1px solid rgba(99,102,241,0.4);
  color: var(--accent); border-radius: 8px;
  padding: 0.45rem 0.875rem; font-size: 0.8rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
}
.topbar-ai-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.session-timer { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; white-space: nowrap; }

/* ── LOGIN SCREEN ────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary);
  z-index: 9000;
  overflow: hidden;
}
.login-bg-shapes { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.shape {
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: 0.12;
}
.shape-1 { width: 500px; height: 500px; background: var(--accent); top: -150px; left: -100px; }
.shape-2 { width: 400px; height: 400px; background: var(--success); bottom: -100px; right: -100px; }
.shape-3 { width: 300px; height: 300px; background: var(--warning); top: 50%; left: 50%; transform: translate(-50%,-50%); }

.login-container {
  width: 420px; max-width: 96vw;
  z-index: 1;
  display: flex; flex-direction: column; gap: 1.5rem;
}
.login-brand {
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}
.login-brand-icon {
  width: 64px; height: 64px; background: var(--accent);
  border-radius: 16px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 32px rgba(99,102,241,0.4);
}
.login-brand-name { font-size: 1.75rem; font-weight: 800; color: var(--text-primary); }
.login-brand-tagline { font-size: 0.85rem; color: var(--text-muted); }

.login-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 1rem;
}
.login-title { font-size: 1.25rem; font-weight: 700; text-align: center; }
.login-subtitle { font-size: 0.85rem; color: var(--text-muted); text-align: center; margin-top: -0.5rem; }
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-btn { height: 44px; font-size: 0.95rem; margin-top: 0.25rem; }
.login-error {
  background: var(--danger-light); border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger); padding: 0.625rem 0.875rem;
  border-radius: var(--radius-sm); font-size: 0.85rem;
}
.btn-link {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 0.85rem; font-family: inherit;
  text-align: center; padding: 0.25rem;
  transition: var(--transition);
}
.btn-link:hover { text-decoration: underline; }
.login-demo-hint {
  font-size: 0.75rem; color: var(--text-muted);
  text-align: center; padding: 0.75rem;
  background: rgba(255,255,255,0.03); border-radius: 8px;
  border: 1px solid var(--border);
}
.input-password-wrap { position: relative; }
.input-password-wrap .form-input { padding-right: 2.5rem; }
.btn-show-pass {
  position: absolute; right: 0.75rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 1rem; opacity: 0.6;
}
.btn-show-pass:hover { opacity: 1; }

/* ── AI PANEL ────────────────────────────────────── */
.ai-panel {
  position: fixed; right: -400px; top: 0; bottom: 0;
  width: 380px; max-width: 96vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 800;
  display: flex; flex-direction: column;
  transition: right 0.35s cubic-bezier(0.4,0,0.2,1);
  box-shadow: -8px 0 32px rgba(0,0,0,0.3);
}
.ai-panel.open { right: 0; }
.ai-panel-overlay {
  position: fixed; inset: 0; z-index: 799;
  background: rgba(0,0,0,0.5);
}
.ai-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  flex-shrink: 0;
}
.ai-status-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--success);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{box-shadow:0 0 0 0 rgba(16,185,129,0.4)} 50%{box-shadow:0 0 0 6px rgba(16,185,129,0)} }
.ai-panel-title { font-size: 1rem; font-weight: 700; }
.ai-panel-subtitle { font-size: 0.72rem; color: var(--text-muted); }
.ai-chat-messages {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: 1rem;
}
.ai-message {
  display: flex; gap: 0.75rem; align-items: flex-start;
  animation: fadeIn 0.25s ease;
}
.ai-user { flex-direction: row-reverse; }
.ai-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; flex-shrink: 0;
}
.ai-user .ai-avatar { background: var(--success); }
.ai-bubble {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: 12px; border-top-left-radius: 4px;
  padding: 0.75rem 1rem; font-size: 0.82rem; line-height: 1.6;
  color: var(--text-secondary); max-width: calc(100% - 48px);
}
.ai-user .ai-bubble { background: var(--accent-light); border-color: rgba(99,102,241,0.3); border-radius: 12px; border-top-right-radius: 4px; color: var(--text-primary); }
.ai-h3 { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); margin: 0.5rem 0 0.25rem; }
.ai-h4 { font-size: 0.82rem; font-weight: 600; color: var(--accent); margin: 0.25rem 0; }
.ai-hr { border: none; border-top: 1px solid var(--border); margin: 0.5rem 0; }
.ai-bubble ul { padding-left: 0; list-style: none; }
.ai-bubble li { padding: 0.125rem 0; }

/* Typing indicator */
.typing-dots { display: flex; gap: 4px; }
.typing-dots span { width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%; animation: bounce 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-6px)} }

.ai-quick-actions {
  display: flex; flex-wrap: wrap; gap: 0.375rem;
  padding: 0.75rem 1rem 0;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-quick-btn {
  background: var(--bg-primary); border: 1px solid var(--border);
  color: var(--text-secondary); border-radius: 999px;
  padding: 0.3rem 0.75rem; font-size: 0.72rem;
  cursor: pointer; transition: var(--transition);
  white-space: nowrap; font-family: inherit;
}
.ai-quick-btn:hover { border-color: var(--accent); color: var(--accent); }

.ai-input-row {
  display: flex; gap: 0.5rem; padding: 0.75rem 1rem;
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.ai-input {
  flex: 1; background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: 24px; padding: 0.6rem 1rem;
  color: var(--text-primary); font-size: 0.85rem; font-family: inherit;
  outline: none; transition: var(--transition);
}
.ai-input:focus { border-color: var(--accent); }
.ai-send-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: white; flex-shrink: 0; transition: var(--transition);
}
.ai-send-btn:hover { background: var(--accent-hover); transform: scale(1.05); }

/* ── BULK ACTIONS BAR ───────────────────────────── */
.bulk-bar {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--accent-light); border: 1px solid rgba(99,102,241,0.3);
  border-radius: var(--radius-sm); padding: 0.625rem 1rem;
  margin-bottom: 0.75rem; font-size: 0.85rem; font-weight: 600;
  color: var(--accent); flex-wrap: wrap;
}

/* ── CHECKBOXES IN TABLES ───────────────────────── */
.th-check { width: 40px; text-align: center; }
.bulk-check, .bulk-check-all {
  width: 16px; height: 16px; cursor: pointer;
  accent-color: var(--accent); border-radius: 4px;
}
.data-table tbody tr.selected { background: var(--accent-light); }

/* ── TABLE TH CHECK ALIGN ───────────────────────── */
.data-table th.th-check, .data-table td.th-check { text-align: center; padding: 0.75rem 0.5rem; }

/* ── AI SETTINGS GROUP ─────────────────────────── */
#aiKeyGroup { display: none; }

/* ── AI WELCOME CARD ──────────────────────────── */
.ai-welcome-card {
  background: linear-gradient(135deg, var(--accent-light), rgba(16,185,129,0.08));
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 0.5rem;
  text-align: center;
}
.ai-welcome-title { font-size: 1rem; font-weight: 700; color: var(--accent); margin-bottom: 0.25rem; }
.ai-welcome-text { font-size: 0.78rem; color: var(--text-muted); }

/* ── NAVIGATE GUARD OVERLAY ───────────────────── */
.perm-denied-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.8);
  display: flex; align-items: center; justify-content: center;
}
.perm-denied-box {
  background: var(--bg-card); border: 1px solid var(--danger);
  border-radius: var(--radius); padding: 2rem; text-align: center;
  max-width: 360px;
}

/* ── AUDIT TABLE IMPROVEMENTS ─────────────────── */
.audit-action-badge {
  font-size: 0.7rem; padding: 0.2rem 0.5rem;
  font-family: 'Inter', monospace; letter-spacing: 0.02em;
}

/* ── USER CARD ────────────────────────────────── */
.user-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem; background: var(--bg-card-hover);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  transition: var(--transition);
}
.user-card:hover { border-color: var(--accent); }

/* ── SMOOTH TRANSITION FOR MODULES ───────────── */
.module { animation: none; }
.module.active { animation: fadeIn 0.2s ease; }

/* ── ENHANCED TOPBAR AI BTN ───────────────────── */
.topbar-ai-btn {
  position: relative;
  overflow: visible;
}
.topbar-ai-btn::after {
  content: '';
  position: absolute; top: -2px; right: -2px;
  width: 8px; height: 8px;
  background: var(--success); border-radius: 50%;
  border: 2px solid var(--bg-primary);
  animation: pulse 2s infinite;
}

/* ── ENHANCED SESSION TIMER ───────────────────── */
.session-timer {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
}

/* ── RESPONSIVE IMPROVEMENTS ──────────────────── */
@media (max-width: 480px) {
  .topbar-ai-btn span { display: none; }
  .session-timer { display: none; }
  .topbar-date { display: none; }
}

/* ── PRINT STYLES ─────────────────────────────── */
@media print {
  .sidebar, .topbar, .ai-panel, .toast-container, .bulk-bar { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .content-area { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}

