@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* LIGHT THEME (Default) */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --bg-input: #ffffff;
  --glass-border: rgba(0, 0, 0, 0.06);
  --glass-border-hover: rgba(0, 0, 0, 0.12);
  
  --accent-primary: #3b82f6;
  --accent-primary-dim: rgba(59, 130, 246, 0.1);
  --accent-success: #0891b2;
  --accent-success-dim: rgba(8, 145, 178, 0.1);
  --accent-error: #dc2626;
  --accent-error-dim: rgba(220, 38, 38, 0.1);
  --accent-red: #dc2626;
  --accent-red-dim: rgba(220, 38, 38, 0.1);
  --accent-warning: #d97706;
  --accent-warning-dim: rgba(217, 119, 6, 0.1);
  --accent-amber: #d97706;
  --accent-amber-dim: rgba(217, 119, 6, 0.1);
  --accent-purple: #9333ea;
  --accent-purple-dim: rgba(147, 51, 234, 0.1);
  --accent-cyan: #0891b2;
  --accent-cyan-dim: rgba(8, 145, 178, 0.1);
  --accent-indigo: #4f46e5;
  --accent-indigo-dim: rgba(79, 70, 229, 0.1);
  --accent-pink: #db2777;
  --accent-pink-dim: rgba(219, 39, 119, 0.1);
  --accent-orange: #ea580c;
  --accent-orange-dim: rgba(234, 88, 12, 0.1);
  --accent-emerald: #059669;
  --accent-emerald-dim: rgba(5, 150, 105, 0.1);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --sidebar-width: 250px;
  /* ... radius and transition ... */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 20px;
  --transition: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-blur: blur(12px);
  --sidebar-blur: blur(20px);
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  --card-shadow-hover: 0 12px 30px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  /* DARK THEME */
  --bg-primary: #0a0a16;
  --bg-secondary: #0d0d1a;
  --bg-card: rgba(30, 30, 60, 0.4);
  --bg-card-hover: rgba(40, 40, 80, 0.6);
  --bg-input: rgba(255,255,255,0.03);
  --glass-border: rgba(255,255,255,0.06);
  --glass-border-hover: rgba(255,255,255,0.12);
  
  --accent-primary: #3b82f6;
  --accent-primary-dim: rgba(59,130,246,0.12);
  --accent-success: #06b6d4;
  --accent-success-dim: rgba(6,182,212,0.12);
  --accent-error: #ef4444;
  --accent-error-dim: rgba(239,68,68,0.12);
  --accent-red: #ef4444;
  --accent-red-dim: rgba(239,68,68,0.12);
  --accent-warning: #f59e0b;
  --accent-warning-dim: rgba(245,158,11,0.12);
  --accent-amber: #f59e0b;
  --accent-amber-dim: rgba(245,158,11,0.12);
  --accent-purple: #a855f7;
  --accent-purple-dim: rgba(168, 85, 247, 0.12);
  --accent-cyan: #22d3ee;
  --accent-cyan-dim: rgba(34, 211, 238, 0.12);
  --accent-indigo: #818cf8;
  --accent-indigo-dim: rgba(129, 140, 248, 0.12);
  --accent-pink: #f472b6;
  --accent-pink-dim: rgba(244, 114, 182, 0.12);
  --accent-orange: #fb923c;
  --accent-orange-dim: rgba(251, 146, 60, 0.12);
  --accent-emerald: #34d399;
  --accent-emerald-dim: rgba(52, 211, 153, 0.12);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --glass-bg: rgba(255, 255, 255, 0.03);
  --card-shadow: 0 4px 20px rgba(0,0,0,0.1);
  --card-shadow-hover: 0 12px 30px rgba(0,0,0,0.4);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--glass-border);
  display: none; /* Hidden by default */
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
body.logged-in .sidebar { display: flex; }
.sidebar-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 32px 0 24px 0;
  width: 100%;
}

.logo-rca-container {
  width: 210px;
  height: 105px;
  overflow: hidden;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: all 0.3s ease;
}

.logo-rca-container:hover .logo-edit-overlay {
  opacity: 1 !important;
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform var(--transition);
}
.logo-rca {
  display: none;
}
.logo-rca span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  border-radius: 4px;
}
.logo-r { background: #ea4335; }
.logo-c { background: #34a853; }
.logo-a { background: #4285f4; }
.brand-name {
  font-size: 22px;
  font-weight: 300;
  letter-spacing: -1px;
  color: var(--text-secondary);
}
.brand-name span { font-weight: 700; color: var(--text-primary); }

.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}
.nav-link:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}
.nav-link.active {
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
}
.nav-link.active svg { stroke: var(--accent-primary); }
.sidebar-bottom {
  padding: 12px 14px 20px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--glass-border);
}
.version {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== MAIN ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  padding: 32px;
  transition: margin var(--transition);
}
/* Modo Autenticação (Login) */
body.auth-mode .main-content {
  margin-left: 0;
  padding: 0;
}
body.auth-mode .sidebar {
  display: none !important;
}
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  animation: fadeIn 300ms ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes countUp {
  from { opacity: 0; filter: blur(4px); }
  to { opacity: 1; filter: blur(0); }
}

.animate-in {
  animation: fadeIn 500ms ease forwards;
}

.stagger-1 { animation-delay: 100ms; }
.stagger-2 { animation-delay: 200ms; }
.stagger-3 { animation-delay: 300ms; }
.stagger-4 { animation-delay: 400ms; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.page-header .subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ===== CARDS KPI ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transition: transform 300ms cubic-bezier(0.4,0,0.2,1), box-shadow 300ms cubic-bezier(0.4,0,0.2,1), border-color 300ms cubic-bezier(0.4,0,0.2,1);
}
.kpi-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 30px rgba(0,0,0,0.1);
}
.kpi-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
  font-weight: 700;
}
.kpi-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -1px;
}
.kpi-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.kpi-blue { color: var(--accent-primary); }
.kpi-blue .kpi-icon { background: var(--accent-primary-dim); }
.kpi-green { color: var(--accent-success); }
.kpi-green .kpi-icon { background: var(--accent-success-dim); }
.kpi-amber { color: var(--accent-amber); }
.kpi-amber .kpi-icon { background: var(--accent-amber-dim); }
.kpi-purple { color: var(--accent-purple); }
.kpi-purple .kpi-icon { background: rgba(168,85,247,0.12); }

/* ===== TABLE ===== */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: visible;
  backdrop-filter: blur(12px);
  position: relative;
}

.table-card:hover {
  z-index: 10;
}
.table-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}
.table-card-header h3 {
  font-size: 14px;
  font-weight: 600;
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--glass-border);
  white-space: nowrap;
}
tbody td {
  padding: 11px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--glass-border);
}
tbody tr {
  transition: var(--transition);
}
tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-blue { background: var(--accent-primary-dim); color: var(--accent-primary); }
.badge-green { background: var(--accent-success-dim); color: var(--accent-success); }
.badge-amber { background: var(--accent-amber-dim); color: var(--accent-amber); }
.badge-red { background: var(--accent-red-dim); color: var(--accent-red); }
.badge-muted { background: var(--glass-border); color: var(--text-secondary); }

/* ===== TOGGLE SWITCH ===== */
.toggle-row { display:flex; align-items:center; justify-content:space-between; padding:10px 0; border-bottom:1px solid var(--glass-border); }
.toggle-row:last-child { border-bottom:none; }
.toggle-label { font-size:13px; font-weight:500; }
.toggle-sub { font-size:11px; color:var(--text-secondary); margin-top:2px; }
.toggle-switch { position:relative; display:inline-block; width:40px; height:22px; flex-shrink:0; }
.toggle-switch input { opacity:0; width:0; height:0; }
.toggle-slider { position:absolute; cursor:pointer; top:0; left:0; right:0; bottom:0; background:var(--text-muted); border-radius:34px; transition:.3s; }
.toggle-slider:before { position:absolute; content:""; height:16px; width:16px; left:3px; bottom:3px; background:white; border-radius:50%; transition:.3s; }
input:checked + .toggle-slider { background:var(--accent-primary); }
input:checked + .toggle-slider:before { transform:translateX(18px); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  text-decoration: none;
}
.btn-primary {
  background: rgba(59,130,246,0.12);
  color: var(--accent-primary);
  border: 1px solid rgba(59,130,246,0.28);
}
.btn-primary:hover {
  background: rgba(59,130,246,0.2);
}
.btn-secondary {
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.09);
  color: var(--text-primary);
}
[data-theme="light"] .btn-secondary { background: var(--bg-secondary); border-color: rgba(0,0,0,0.15); }
[data-theme="light"] .btn-secondary:hover { background: var(--bg-primary); }
.btn-danger {
  background: var(--accent-red-dim);
  color: var(--accent-red);
}
.btn-danger:hover { background: rgba(234,67,53,0.2); }
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}
.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
.btn-icon:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }
.btn-group { display: flex; gap: 6px; }

/* ===== FORMS ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.form-group.full { grid-column: 1 / -1; }
.form-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-input, .form-select, .form-textarea {
  padding: 9px 13px;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  transition: var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.form-select { cursor: pointer; }
.form-select option { background: var(--bg-secondary); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--glass-border);
}
.form-preview {
  background: var(--accent-primary-dim);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-top: 12px;
}
.form-preview .label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; }
.form-preview .value { font-size: 22px; font-weight: 700; color: var(--accent-primary); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 150ms ease;
}
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border-hover) transparent;
  animation: slideUp 250ms ease;
}
.modal::-webkit-scrollbar {
  width: 6px;
}
.modal::-webkit-scrollbar-track {
  background: transparent;
}
.modal::-webkit-scrollbar-thumb {
  background: var(--glass-border-hover);
  border-radius: 4px;
}
.modal::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}
.modal-lg {
  max-width: 750px;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  animation: slideInRight 300ms ease;
  min-width: 280px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast-success { background: #0c4a6e; border: 1px solid rgba(59,130,246,0.3); color: var(--accent-primary); }
.toast-error { background: #3d1414; border: 1px solid rgba(234,67,53,0.3); color: var(--accent-red); }
.toast-info { background: #0d1e3d; border: 1px solid rgba(66,133,244,0.3); color: var(--accent-blue); }

/* ===== FILTERS ===== */
.filters-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filters-bar .form-input,
.filters-bar .form-select {
  min-width: 160px;
}

/* ===== TOTAL HIGHLIGHT ===== */
.total-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(59, 130, 246, 0.05) 100%);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-lg);
  padding: 24px 32px;
  text-align: center;
  margin-top: 20px;
}
.total-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.total-value { font-size: 36px; font-weight: 800; color: var(--accent-primary); letter-spacing: -1px; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 16px; opacity: 0.3; }
.empty-state p { font-size: 14px; margin-top: 8px; }

/* ===== SIDEBAR BOTTOM ===== */
.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.08);
  color: #ef4444;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  font-family: inherit;
}
.btn-logout:hover { background: rgba(239,68,68,0.16); }

/* ===== LOGIN ===== */
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  backdrop-filter: var(--glass-blur);
}
[data-theme="dark"] #login-logo-bg { background: rgba(255,255,255,0.08) !important; }

/* ===== SETTINGS ===== */
.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.settings-card-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.cfg-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 24px 0 12px;
}
.cfg-section-title:first-child { margin-top: 0; }

/* ===== TABS ===== */
.tabs-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  width: fit-content;
  background: rgba(255,255,255,0.03);
  padding: 6px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  border: 1px solid var(--glass-border);
}
.tab-link {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab-link:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}
.tab-link.active {
  background: var(--bg-card);
  color: var(--accent-primary);
  border-color: var(--glass-border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* ===== UTILITY ===== */
.text-blue { color: var(--accent-primary); }
.text-green { color: var(--accent-success); }
.text-amber { color: var(--accent-amber); }
.text-red { color: var(--accent-red); }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.currency::before { content: 'R$ '; font-weight: 400; font-size: 0.8em; opacity: 0.7; }

/* PRIVACY MODE MASKING */
/* PRIVACY MODE MASKING (Premium Blur Effect) */
body.privacy-active .currency,
body.privacy-active .kpi-value,
body.privacy-active .fin-kpi-value,
body.privacy-active .total-value,
body.privacy-active .form-preview .value,
body.privacy-active .chart-container canvas,
body.privacy-active .charts-grid canvas,
body.privacy-active .chart-wrapper canvas {
    filter: blur(10px) !important;
    pointer-events: none !important;
    user-select: none !important;
    transition: filter 0.3s ease;
}

/* Ocultar tooltips em modo privacidade */
body.privacy-active [data-tooltip]::after,
body.privacy-active [data-tooltip]::before {
    display: none !important;
}

body.privacy-active input.privacy-mask {
    -webkit-text-security: disc !important;
    filter: blur(4px);
}



/* ===== THEME SWITCHER ===== */
.theme-switch-container {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 8px;
}
.theme-switch-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.theme-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--text-muted);
  transition: .3s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .slider {
  background-color: var(--accent-primary);
}
input:checked + .slider:before {
  transform: translateX(16px);
}

/* Custom Badge for users */
.badge-user {
  background: rgba(168,85,247,0.1);
  color: #a855f7;
  border: 1px solid rgba(168,85,247,0.2);
}

/* ===== CUSTOM UI IMPROVEMENTS (SCREEN ONLY) ===== */
@media screen {
  /* Center Sidebar Logo */
  .sidebar-brand {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 32px 0 20px 0;
    width: 100%;
  }

  /* Better Contrast for Standard Nav Links */
  .nav-link {
    color: var(--text-secondary);
  }
  
  .nav-link:hover {
    color: var(--text-primary);
    background: var(--accent-primary-dim);
  }
}

/* Theme overrides for better contrast */
[data-theme="dark"] .nav-link.active {
  background: rgba(59, 130, 246, 0.2) !important;
  color: #ffffff !important;
}

[data-theme="light"] .nav-link.active {
  background: var(--accent-primary-dim) !important;
  color: var(--accent-primary) !important;
}

/* Adjust scrollbar for light mode */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ===== FINANCEIRO MODULE ===== */
.fin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.fin-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.fin-kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.fin-kpi-card:hover {
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.fin-kpi-card.fin-green::before { background: linear-gradient(90deg, #10b981, #34d399); }
.fin-kpi-card.fin-red::before { background: linear-gradient(90deg, #ef4444, #f87171); }
.fin-kpi-card.fin-blue::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.fin-kpi-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
  font-weight: 600;
}
.fin-kpi-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -1px;
}
.fin-kpi-value.fin-val-green { color: #10b981; }
.fin-kpi-value.fin-val-red   { color: #ef4444; }
.fin-kpi-value.fin-val-blue  { color: #60a5fa; }
.fin-kpi-value.fin-val-positive { color: #10b981; }
.fin-kpi-value.fin-val-negative { color: #ef4444; }

/* Toggle Tabs */
.fin-toggle {
  display: inline-flex;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 4px;
}
.fin-toggle-btn {
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  transition: var(--transition);
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
}
.fin-toggle-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.fin-toggle-btn.active {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(59,130,246,0.35);
}

/* Classification Badges */
.badge-impostos       { background: var(--accent-error-dim);   color: var(--accent-error); }
.badge-prolabore      { background: var(--accent-purple-dim);  color: var(--accent-purple); }
.badge-infra          { background: var(--accent-cyan-dim);    color: var(--accent-cyan); }
.badge-licenca        { background: var(--accent-indigo-dim);  color: var(--accent-indigo); }
.badge-contabilidade  { background: var(--accent-warning-dim);  color: var(--accent-warning); }
.badge-administrativo { background: rgba(156,163,175,0.12); color: var(--text-secondary); }
.badge-projetos       { background: var(--accent-emerald-dim); color: var(--accent-emerald); }
.badge-suporte        { background: var(--accent-pink-dim);    color: var(--accent-pink); }
.badge-consultoria    { background: var(--accent-indigo-dim);  color: var(--accent-indigo); }
.badge-saude          { background: var(--accent-cyan-dim);    color: var(--accent-cyan); }
.badge-viagem         { background: var(--accent-purple-dim);  color: var(--accent-purple); }
.badge-terceirizado   { background: var(--accent-orange-dim);  color: var(--accent-orange); }
.badge-receita        { background: var(--accent-emerald-dim); color: var(--accent-emerald); }

/* Status Badges for Financeiro */
.badge-pendente  { background: var(--accent-warning-dim); color: var(--accent-warning); }
.badge-pago      { background: var(--accent-emerald-dim); color: var(--accent-emerald); }
.badge-recebido  { background: var(--accent-emerald-dim); color: var(--accent-emerald); }
.badge-atrasado  { background: var(--accent-error-dim);   color: var(--accent-error); }

/* Action Buttons */
.btn-check {
  background: var(--accent-emerald-dim);
  color: var(--accent-emerald);
  border: 1px solid var(--accent-emerald-dim);
}
.btn-check:hover { background: var(--accent-emerald-dim); opacity: 0.8; }
.btn-edit {
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary-dim);
}
.btn-edit:hover { background: rgba(59,130,246,0.2); }
.btn-del {
  background: rgba(239,68,68,0.08);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.15);
}
.btn-del:hover { background: rgba(239,68,68,0.18); }

/* Dashboard Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
  .fin-kpi-grid { grid-template-columns: 1fr; }
}

/* Ícone do calendário Branco Aprovado (Seguro) */
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="month"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.8) contrast(1.2) !important;
  cursor: pointer !important;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
  cursor: pointer !important;
}

/* ===== STAGING BANNER ===== */
.staging-banner {
  background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
  color: #000;
  text-align: center;
  padding: 8px;
  font-size: 13px;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1100;
  box-shadow: 0 4px 12px rgba(245,158,11,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.staging-banner span { background: #000; color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 10px; text-transform: uppercase; }

.audit-alert-banner {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

/* ═══ PERIOD SELECTOR ═══ */
.period-selector {
  display: inline-flex;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
  border: 1px solid var(--border-color);
}

.period-btn {
  padding: 4px 14px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.period-btn:hover:not(.active) {
  background: rgba(var(--accent-primary-rgb), 0.1);
  color: var(--accent-primary);
}

.period-btn.active {
  background: var(--accent-primary);
  color: #fff;
  font-weight: 600;
}

[data-theme="dark"] .period-selector {
  background: rgba(255,255,255,0.03);
}

/* ═══════ TOOLTIP SYSTEM ═══════ */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  cursor: help;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.info-icon:hover {
  background: var(--accent-primary);
  color: #fff;
  transform: scale(1.1);
}

/* Base Tooltip Style */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #ffffff;
  color: #0f172a;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: normal;
  width: 200px;
  text-align: center;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.3), 0 0 1px 1px rgba(0,0,0,0.1);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2000;
  line-height: 1.4;
  border: 1px solid rgba(0,0,0,0.1);
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Tooltip Arrow */
[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: rgba(0,0,0,0.1) transparent transparent transparent;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 2000;
}

[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Adjustments for right-aligned tooltips if needed */
.table-card-header .info-icon {
  margin-left: 0; /* Already has gap from header flex */
}

/* ===== MOBILE RESPONSIVE (≤ 767px) ===== */
@media (max-width: 767px) {
  :root { --sidebar-width: 0px; }

  body { padding-bottom: 64px; }

  .sidebar {
    width: 100% !important;
    min-height: unset;
    height: 64px;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--glass-border);
    z-index: 200;
    background: var(--bg-secondary);
    padding: 0;
    backdrop-filter: blur(16px);
  }

  .sidebar-header,
  .sidebar-bottom { display: none !important; }

  .sidebar-nav {
    flex-direction: row;
    flex: 1;
    padding: 0;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    align-items: stretch;
  }
  .sidebar-nav::-webkit-scrollbar { display: none; }

  .nav-link {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 4px 6px;
    flex: 1;
    min-width: 50px;
    font-size: 9px;
    border-radius: 0;
    text-align: center;
    white-space: nowrap;
  }
  .nav-link svg { width: 20px; height: 20px; flex-shrink: 0; }
  .nav-link span { font-size: 9px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; max-width: 56px; }
  .nav-link.active {
    background: var(--accent-primary-dim);
    border-top: 2px solid var(--accent-primary);
  }

  .main-content {
    margin-left: 0 !important;
    padding: 16px 12px;
    min-height: unset;
  }

  /* KPI grid 2 colunas */
  .kpi-grid,
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }

  /* Page header */
  .page-header { margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
  .page-header h2 { font-size: 18px; }
  .page-actions { flex-wrap: wrap; gap: 6px; }
  .page-actions .btn { font-size: 12px; padding: 7px 10px; }

  /* Cards */
  .settings-card, .card, .table-card { padding: 14px; border-radius: var(--radius-md); }

  /* Tabelas scrolláveis */
  .table-wrap, .table-responsive, .table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 480px; }

  /* Formulários */
  .form-input, .form-select, select.form-input, input.form-input { width: 100%; }
  .btn { min-height: 44px; }
  .form-row { flex-direction: column !important; gap: 10px; }

  /* Modais full-screen */
  .modal-overlay > div,
  [id$="-modal"] > div,
  .modal > div {
    width: 96vw !important;
    max-width: 96vw !important;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--radius-md) !important;
  }

  /* Filters */
  .filters-bar, .filter-row { flex-direction: column !important; align-items: stretch; gap: 8px; }

  /* Charts */
  canvas { max-height: 220px !important; }

  /* Login */
  .login-card { padding: 24px 16px; }
}

/* ===== TABLET (768px–1024px) ===== */
@media (min-width: 768px) and (max-width: 1024px) {
  :root { --sidebar-width: 200px; }
  .main-content { padding: 20px 16px; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important; }
}

/* ===== PWA safe-area ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  @media (max-width: 767px) {
    .sidebar { padding-bottom: env(safe-area-inset-bottom); height: calc(64px + env(safe-area-inset-bottom)); }
  }
}
