/* =====================================================
   Caderno Financeiro — Modern Financial Dashboard
   ===================================================== */

:root {
  --primary:        #4f6ef7;
  --primary-dark:   #3a57e8;
  --primary-light:  #eef1fe;
  --primary-glow:   rgba(79,110,247,.18);
  --secondary:      #10b981;
  --secondary-light:#d1fae5;
  --danger:         #f43f5e;
  --danger-light:   #ffe4e8;
  --warning:        #f59e0b;
  --warning-light:  #fef3c7;
  --info:           #06b6d4;
  --info-light:     #cffafe;

  --badge-green-text:   #065f46;
  --badge-red-text:     #9f1239;
  --badge-yellow-text:  #92400e;
  --badge-blue-text:    #1e3a8a;
  --badge-teal-text:    #164e63;

  --bg:             #f6f7fb;
  --bg-card:        #ffffff;
  --bg-sidebar:     #0d0d0d;
  --bg-sidebar2:    #181818;

  --text:           #0f0f0f;
  --text-muted:     #6b7280;
  --text-light:     #9ca3af;
  --text-sidebar:   #a0a0a0;

  --border:         #e5e7eb;
  --border-light:   #f3f4f6;

  --shadow-sm:  0 1px 2px rgba(0,0,0,.05);
  --shadow:     0 4px 20px rgba(0,0,0,.06), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:  0 20px 60px rgba(0,0,0,.1), 0 4px 16px rgba(0,0,0,.06);
  --shadow-card:0 2px 8px rgba(0,0,0,.04), 0 0 0 1px rgba(0,0,0,.04);

  --sidebar-w:         256px;
  --sidebar-collapsed: 68px;
  --topbar-h:          60px;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-2xl:28px;

  --font-main: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', 'Roboto Mono', monospace;

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

[data-theme="dark"] {
  --bg:             #111111;
  --bg-card:        #1c1c1c;
  --bg-sidebar:     #080808;
  --bg-sidebar2:    #161616;
  --text:           #efefef;
  --text-muted:     #888888;
  --text-light:     #555555;
  --border:         #2a2a2a;
  --border-light:   #222222;
  --shadow:         0 4px 20px rgba(0,0,0,.4);
  --shadow-card:    0 2px 8px rgba(0,0,0,.3), 0 0 0 1px rgba(255,255,255,.04);
  --primary-light:  rgba(79,110,247,.15);
  --secondary-light:rgba(16,185,129,.15);
  --danger-light:   rgba(244,63,94,.15);
  --warning-light:  rgba(245,158,11,.15);
  --info-light:     rgba(6,182,212,.15);
  --badge-green-text:   #6ee7b7;
  --badge-red-text:     #fda4af;
  --badge-yellow-text:  #fcd34d;
  --badge-blue-text:    #93c5fd;
  --badge-teal-text:    #67e8f9;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width .22s var(--ease), transform .22s var(--ease);
  overflow: hidden;
  border-right: 1px solid rgba(255,255,255,.04);
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 16px;
  min-height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.brand-logo {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(79,110,247,.2);
}
.brand-text { flex: 1; overflow: hidden; }
.brand-name { display: block; font-size: 14px; font-weight: 700; color: #fff; white-space: nowrap; letter-spacing: -.01em; }
.brand-sub  { display: block; font-size: 10.5px; color: #555; white-space: nowrap; }

.sidebar-toggle-btn {
  background: none; border: none; color: #444; cursor: pointer;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: var(--transition); flex-shrink: 0; font-size: 13px;
}
.sidebar-toggle-btn:hover { background: rgba(255,255,255,.06); color: #fff; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; flex-shrink: 0;
}
.user-info { overflow: hidden; }
.user-name { display: block; font-size: 12.5px; font-weight: 600; color: #e0e0e0; white-space: nowrap; }
.user-role { display: block; font-size: 10.5px; color: #555; white-space: nowrap; }

.sidebar-nav {
  flex: 1; overflow-y: auto;
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 1px;
}
.nav-section {
  font-size: 9.5px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: #3a3a3a;
  padding: 12px 8px 4px; white-space: nowrap; overflow: hidden;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: #666; font-size: 13px; font-weight: 500;
  white-space: nowrap; transition: var(--transition); position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #ccc; }
.nav-item.active { background: rgba(79,110,247,.15); color: var(--primary); }

.nav-icon { width: 16px; text-align: center; flex-shrink: 0; font-size: 13px; }
.nav-label { flex: 1; }
.nav-badge {
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 99px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.nav-logout { margin-top: auto; color: #4a2a2a !important; }
.nav-logout:hover { background: rgba(244,63,94,.08) !important; color: #f87171 !important; }

.sidebar.collapsed .brand-text,
.sidebar.collapsed .sidebar-toggle-btn,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 18px 0; }
.sidebar.collapsed .sidebar-user  { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-icon { width: auto; }

/* ── Layout ── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left .22s var(--ease);
  display: flex; flex-direction: column;
}
.main-wrapper.collapsed { margin-left: var(--sidebar-collapsed); }

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-menu-btn {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  width: 36px; height: 36px;
  display: none; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: var(--transition); font-size: 16px; flex-shrink: 0;
}
.topbar-menu-btn:hover { background: var(--border-light); color: var(--text); }
.topbar-title h1 { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.2; letter-spacing: -.02em; }
.topbar-subtitle { display: block; font-size: 11.5px; color: var(--text-muted); }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.topbar-date {
  font-size: 12px; color: var(--text-muted);
  background: var(--border-light); padding: 5px 12px;
  border-radius: 99px; font-weight: 500;
}
.topbar-theme-btn, .topbar-settings {
  width: 34px; height: 34px;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: var(--transition); font-size: 14px;
}
.topbar-theme-btn:hover, .topbar-settings:hover { background: var(--border-light); color: var(--text); }

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

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: none;
}
.card-header h5, .card-header h6 {
  font-weight: 600; color: var(--text); margin: 0;
  font-size: 13.5px; letter-spacing: -.01em;
}
.card-body { padding: 18px; }

/* ── Stat Cards ── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative; overflow: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow-card);
}
.stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.stat-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: var(--card-accent, var(--primary)); opacity: .7;
}
.stat-card::after {
  content: ''; position: absolute;
  top: -20px; right: -20px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: var(--card-accent, var(--primary));
  opacity: .04; pointer-events: none;
}
.stat-card-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; margin-bottom: 14px;
  background: var(--card-icon-bg, var(--primary-light));
  color: var(--card-icon-color, var(--primary));
}
.stat-card-label {
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px;
}
.stat-card-value {
  font-size: 20px; font-weight: 700; color: var(--text);
  font-family: var(--font-mono); line-height: 1.15; letter-spacing: -.02em;
}
.stat-card-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }

.stat-card.green { --card-accent: var(--secondary);  --card-icon-bg: var(--secondary-light); --card-icon-color: var(--secondary); }
.stat-card.red   { --card-accent: var(--danger);     --card-icon-bg: var(--danger-light);    --card-icon-color: var(--danger); }
.stat-card.orange{ --card-accent: var(--warning);    --card-icon-bg: var(--warning-light);   --card-icon-color: var(--warning); }
.stat-card.teal  { --card-accent: var(--info);       --card-icon-bg: var(--info-light);      --card-icon-color: var(--info); }

/* ── Tables ── */
.table-responsive { border-radius: var(--radius); overflow: hidden; }
.table {
  font-size: 13px; color: var(--text);
  --bs-table-bg: var(--bg-card);
  --bs-table-striped-bg: var(--border-light);
  --bs-table-hover-bg: var(--primary-light);
  --bs-table-border-color: var(--border);
  margin: 0;
}
.table thead th {
  font-size: 10.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-muted);
  background: var(--border-light); border: none; padding: 10px 14px;
}
.table tbody td { padding: 11px 14px; vertical-align: middle; border-color: var(--border); }

/* ── Badges ── */
.badge-status {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600;
  padding: 3px 9px; border-radius: var(--radius-xs); letter-spacing: .02em;
}
.badge-pago          { background: var(--secondary-light); color: var(--badge-green-text); }
.badge-pendente      { background: var(--warning-light);   color: var(--badge-yellow-text); }
.badge-vencido       { background: var(--danger-light);    color: var(--badge-red-text); }
.badge-receita       { background: var(--secondary-light); color: var(--badge-green-text); }
.badge-despesa       { background: var(--danger-light);    color: var(--badge-red-text); }
.badge-transferencia { background: var(--info-light);      color: var(--badge-teal-text); }

/* ── Forms ── */
.form-label { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 5px; letter-spacing: .01em; }
.form-control, .form-select {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 13px; padding: 8px 12px; transition: var(--transition);
  font-family: var(--font-main);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-card); color: var(--text);
}
.form-control::placeholder { color: var(--text-light); }
.input-group-text {
  background: var(--border-light); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 13px; font-weight: 600;
}

/* ── Buttons ── */
.btn {
  font-size: 13px; font-weight: 600; border-radius: var(--radius);
  padding: 8px 16px; transition: var(--transition); border: none;
  letter-spacing: -.01em; font-family: var(--font-main);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-primary {
  background: var(--primary); color: #fff;
  box-shadow: 0 1px 3px rgba(79,110,247,.3);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(79,110,247,.35); color: #fff; }
.btn-success { background: var(--secondary); color: #fff; }
.btn-success:hover { background: #0ea572; color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #e11d48; color: #fff; }
.btn-outline-secondary { border: 1px solid var(--border); color: var(--text-muted); background: transparent; }
.btn-outline-secondary:hover { background: var(--border-light); color: var(--text); }
.btn-outline-primary { border: 1px solid var(--primary); color: var(--primary); background: transparent; }
.btn-outline-primary:hover { background: var(--primary-light); }

/* ── Progress ── */
.progress { height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; }
.progress-bar { border-radius: 99px; background: var(--primary); transition: width .6s var(--ease); }

/* ── Alerts ── */
.alert { border: none; border-radius: var(--radius); font-size: 13px; }
.alert-success { background: var(--secondary-light); color: var(--badge-green-text); }
.alert-danger  { background: var(--danger-light);    color: var(--badge-red-text); }
.alert-info    { background: var(--info-light);      color: var(--badge-teal-text); }
.alert-warning { background: var(--warning-light);   color: var(--badge-yellow-text); }
.btn-close { filter: none; }

/* ── Modals ── */
.modal-content {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
}
.modal-header { border-bottom: 1px solid var(--border); padding: 16px 22px; }
.modal-header .modal-title { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -.02em; }
.modal-body   { padding: 22px; }
.modal-footer { border-top: 1px solid var(--border); padding: 14px 22px; }
.btn-close { color: var(--text-muted); }

/* ── Login ── */
.login-page {
  min-height: 100vh; background: var(--bg-sidebar);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-box {
  width: 100%; max-width: 400px; background: var(--bg-card);
  border-radius: var(--radius-2xl); padding: 40px 36px;
  box-shadow: var(--shadow-lg); border: 1px solid rgba(255,255,255,.06);
}
.login-logo {
  width: 52px; height: 52px; background: var(--primary);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px; margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(79,110,247,.4);
}
.login-title { font-size: 20px; font-weight: 700; color: var(--text); text-align: center; margin-bottom: 5px; letter-spacing: -.03em; }
.login-sub   { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 26px; }

/* ── Section Headers ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-header h2 { font-size: 14px; font-weight: 700; color: var(--text); margin: 0; letter-spacing: -.01em; }

/* ── Meta Cards ── */
.meta-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px;
  transition: var(--transition); box-shadow: var(--shadow-card);
}
.meta-card:hover { box-shadow: var(--shadow); }
.meta-card-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 10px; }
.meta-card-title  { font-size: 13.5px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.meta-card-pct    { font-size: 18px; font-weight: 700; color: var(--primary); font-family: var(--font-mono); }
.meta-card-values { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-muted); margin-top: 7px; }

/* ── Sidebar Overlay ── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 1050; cursor: pointer;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── Responsive ── */
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed; width: var(--sidebar-w) !important;
    transform: translateX(-110%);
    transition: transform .25s var(--ease);
    z-index: 1100;
  }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: 4px 0 32px rgba(0,0,0,.5); }
  .main-wrapper { margin-left: 0 !important; }
  .topbar-menu-btn { display: flex !important; }
  .page-content { padding: 16px; }
  .sidebar-toggle-btn { display: none !important; }
}
@media (max-width: 575.98px) {
  .topbar { padding: 0 14px; }
  .topbar-date { display: none; }
  .page-content { padding: 12px; }
  .sidebar { width: 280px !important; }
}
@media (max-width: 991.98px) {
  .sidebar.collapsed { width: var(--sidebar-w) !important; }
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .user-info,
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .nav-section,
  .sidebar.collapsed .nav-badge { display: revert !important; }
  .sidebar.collapsed .sidebar-brand { justify-content: flex-start !important; padding: 18px 16px !important; }
  .sidebar.collapsed .sidebar-user  { justify-content: flex-start !important; padding: 12px 16px !important; }
  .sidebar.collapsed .nav-item { justify-content: flex-start !important; padding: 8px 10px !important; }
  .sidebar.collapsed .nav-icon { width: 16px !important; }
  .sidebar-overlay { z-index: 1099 !important; }
  .sidebar { z-index: 1100 !important; }
}

/* ── Values ── */
.valor-positivo { color: var(--secondary); font-family: var(--font-mono); font-weight: 600; }
.valor-negativo { color: var(--danger);    font-family: var(--font-mono); font-weight: 600; }
.valor-neutro   { color: var(--text-muted);font-family: var(--font-mono); font-weight: 600; }
.valor-mono     { font-family: var(--font-mono); font-weight: 600; }

/* ── Balance Sheet ── */
.balanco-table th { background: var(--primary-light); color: var(--badge-blue-text); }
.balanco-group th { background: var(--border-light);  color: var(--text-muted); }
.balanco-total    { font-weight: 700; background: var(--primary); color: #fff !important; }

/* ── Misc ── */
.rounded-pill { border-radius: 99px !important; }
.text-money   { font-family: var(--font-mono); font-weight: 600; }
.bg-card      { background: var(--bg-card) !important; }
.spinner-wrap { display: flex; align-items: center; justify-content: center; min-height: 200px; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i  { font-size: 36px; margin-bottom: 12px; display: block; opacity: .3; }
.empty-state h6 { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 5px; }
.empty-state p  { font-size: 13px; }

@media print {
  .sidebar, .topbar, .btn, .page-content .alert { display: none !important; }
  .main-wrapper { margin: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}

/* ════ DARK MODE OVERRIDES ════ */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select { background: var(--bg-card); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus { background: var(--bg-card); color: var(--text); }
[data-theme="dark"] .form-control::placeholder { color: var(--text-light); }
[data-theme="dark"] .input-group-text { background: var(--bg-sidebar2); border-color: var(--border); color: var(--text-muted); }
[data-theme="dark"] .form-check-label { color: var(--text); }
[data-theme="dark"] .form-check-input { background-color: var(--bg-sidebar2); border-color: var(--border); }
[data-theme="dark"] .form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
[data-theme="dark"] .form-label { color: var(--text); }
[data-theme="dark"] .modal-content { background: var(--bg-card); color: var(--text); }
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { border-color: var(--border); }
[data-theme="dark"] .modal-title { color: var(--text); }
[data-theme="dark"] .btn-close { filter: invert(1); }
[data-theme="dark"] .table {
  color: var(--text); --bs-table-bg: var(--bg-card);
  --bs-table-striped-bg: #232323;
  --bs-table-hover-bg: rgba(79,110,247,.08);
  --bs-table-border-color: var(--border);
}
[data-theme="dark"] .table thead th { background: var(--bg-sidebar2); color: var(--text-muted); border-color: var(--border); }
[data-theme="dark"] .table tbody td { border-color: var(--border); color: var(--text); }
[data-theme="dark"] .table tfoot td,
[data-theme="dark"] .table tfoot th { border-color: var(--border); color: var(--text); }
[data-theme="dark"] .topbar { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .topbar-date { background: var(--bg-sidebar2); color: var(--text-muted); }
[data-theme="dark"] .topbar-title h1 { color: var(--text); }
[data-theme="dark"] .topbar-subtitle { color: var(--text-muted); }
[data-theme="dark"] .btn-outline-secondary { border-color: var(--border); color: var(--text-muted); }
[data-theme="dark"] .btn-outline-secondary:hover { background: var(--bg-sidebar2); color: var(--text); }
[data-theme="dark"] .btn-outline-primary { border-color: var(--primary); color: #93c5fd; }
[data-theme="dark"] .btn-outline-primary:hover { background: var(--primary-light); color: #fff; }
[data-theme="dark"] .btn-outline-danger { color: #fda4af; border-color: rgba(244,63,94,.4); }
[data-theme="dark"] .btn-outline-danger:hover { background: var(--danger-light); color: #fda4af; }
[data-theme="dark"] .card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .meta-card { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .card-header { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .card-header h5,
[data-theme="dark"] .card-header h6 { color: var(--text); }
[data-theme="dark"] .progress { background: var(--bg-sidebar2); }
[data-theme="dark"] select option { background: var(--bg-card); color: var(--text); }
[data-theme="dark"] .cat-label-color { filter: brightness(1.6) saturate(0.7); }
[data-theme="dark"] span[style*="border-radius:99px"] { filter: brightness(1.5); }
[data-theme="dark"] .badge-pago          { background: var(--secondary-light); color: var(--badge-green-text); }
[data-theme="dark"] .badge-pendente      { background: var(--warning-light);   color: var(--badge-yellow-text); }
[data-theme="dark"] .badge-vencido       { background: var(--danger-light);    color: var(--badge-red-text); }
[data-theme="dark"] .badge-receita       { background: var(--secondary-light); color: var(--badge-green-text); }
[data-theme="dark"] .badge-despesa       { background: var(--danger-light);    color: var(--badge-red-text); }
[data-theme="dark"] .badge-transferencia { background: var(--info-light);      color: var(--badge-teal-text); }
[data-theme="dark"] .alert-success { background: var(--secondary-light); color: var(--badge-green-text); }
[data-theme="dark"] .alert-danger  { background: var(--danger-light);    color: var(--badge-red-text); }
[data-theme="dark"] .alert-info    { background: var(--info-light);      color: var(--badge-teal-text); }
[data-theme="dark"] .alert-warning { background: var(--warning-light);   color: var(--badge-yellow-text); }
[data-theme="dark"] .balanco-table th { background: var(--primary-light); color: var(--badge-blue-text); }
[data-theme="dark"] .balanco-group th { background: var(--bg-sidebar2);   color: var(--text-muted); }
[data-theme="dark"] .form-control-color { border-color: var(--border); }
[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--bg-card); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--border); }
[data-theme="dark"] .empty-state h6 { color: var(--text); }
[data-theme="dark"] .login-title { color: var(--text); }
[data-theme="dark"] .login-sub   { color: var(--text-muted); }

/* ════ INVESTIMENTOS ════ */
.inv-ticker { font-family: var(--font-mono); font-weight: 500; font-size: 14px; color: var(--primary); letter-spacing: .02em; }
.inv-tipo-badge { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: var(--radius-xs); text-transform: uppercase; letter-spacing: .05em; }
.inv-tipo-acao   { background: var(--primary-light);   color: var(--badge-blue-text); }
.inv-tipo-fii    { background: var(--secondary-light); color: var(--badge-green-text); }
.inv-tipo-rf     { background: var(--warning-light);   color: var(--badge-yellow-text); }
.inv-tipo-etf    { background: var(--info-light);      color: var(--badge-teal-text); }
.inv-tipo-cripto { background: var(--danger-light);    color: var(--badge-red-text); }
.inv-tipo-outro  { background: var(--border-light);    color: var(--text-muted); }
.inv-variacao-pos { color: var(--secondary); font-family: var(--font-mono); font-weight: 600; }
.inv-variacao-neg { color: var(--danger);    font-family: var(--font-mono); font-weight: 600; }
.provento-row-div  { border-left: 2px solid var(--secondary); }
.provento-row-jcp  { border-left: 2px solid var(--info); }
.provento-row-rend { border-left: 2px solid var(--warning); }
.provento-row-amort{ border-left: 2px solid var(--text-light); }
.inv-card-total {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-lg); color: #fff; padding: 22px;
  position: relative; overflow: hidden;
}
.inv-card-total::before {
  content: ''; position: absolute; top: -40px; right: -40px;
  width: 140px; height: 140px; border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.inv-card-total .label { font-size: 11px; font-weight: 600; opacity: .75; text-transform: uppercase; letter-spacing: .06em; }
.inv-card-total .value { font-size: 26px; font-weight: 700; font-family: var(--font-mono); margin-top: 6px; letter-spacing: -.02em; }
.inv-card-total .sub   { font-size: 12px; opacity: .65; margin-top: 4px; }

/* ════ NOTIFICAÇÕES ════ */
.notif-wrap {
  position: static;
}

.notif-btn {
  position: relative;
}

.notif-dot {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px; height: 16px;
  border-radius: 99px;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  pointer-events: none;
  border: 2px solid var(--bg-card);
  line-height: 1;
}
.notif-dot-red    { background: var(--danger);  color: #fff; }
.notif-dot-yellow { background: var(--warning); color: #fff; }

/* Panel — posicionado fixo abaixo da topbar */
.notif-panel {
  display: none;
  position: fixed;
  top: var(--topbar-h);
  right: 12px;
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  overflow: hidden;
  animation: notifFadeIn .15s var(--ease);
}
.notif-panel.open { display: flex; flex-direction: column; }

@keyframes notifFadeIn {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.notif-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.notif-panel-title {
  font-size: 13px; font-weight: 700; color: var(--text);
}
.notif-panel-count {
  background: var(--danger);
  color: #fff;
  font-size: 10px; font-weight: 700;
  min-width: 20px; height: 20px;
  border-radius: 99px;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}

.notif-panel-body {
  overflow-y: auto;
  max-height: 380px;
}

.notif-group-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase;
  padding: 10px 16px 6px;
  position: sticky; top: 0;
  backdrop-filter: blur(8px);
}
.notif-group-red    { color: var(--danger);  background: rgba(244,63,94,.06); }
.notif-group-yellow { color: var(--warning); background: rgba(245,158,11,.06); }

/* Item */
.notif-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition);
  text-decoration: none; color: inherit;
  cursor: default;
}
a.notif-item { cursor: pointer; }
a.notif-item:hover { background: var(--border-light); color: inherit; }
.notif-item-red { background: rgba(244,63,94,.03); }
.notif-item-red:hover { background: rgba(244,63,94,.07) !important; }

.notif-item-icon {
  width: 34px; height: 34px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
}
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-desc {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.notif-item-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 2px;
}
.notif-item-date {
  font-size: 11px; color: var(--text-muted);
}
.notif-item-days {
  font-size: 10.5px; font-weight: 600;
  padding: 1px 6px; border-radius: var(--radius-xs);
}
.notif-days-red    { background: var(--danger-light);  color: var(--badge-red-text); }
.notif-days-yellow { background: var(--warning-light); color: var(--badge-yellow-text); }
.notif-days-green  { background: var(--secondary-light); color: var(--badge-green-text); }

.notif-item-value {
  font-size: 12.5px; font-weight: 700;
  font-family: var(--font-mono);
  color: var(--danger);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Empty */
.notif-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
}
.notif-empty i { font-size: 28px; color: var(--secondary); margin-bottom: 10px; display: block; }
.notif-empty p { font-size: 13px; line-height: 1.5; }

/* Footer */
.notif-panel-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.notif-panel-footer a {
  font-size: 12px; font-weight: 600; color: var(--primary);
}
.notif-panel-footer a:hover { color: var(--primary-dark); }

/* Mobile */
@media (max-width: 575.98px) {
  .notif-panel {
    width: calc(100vw - 24px);
    right: 8px;
  }
}

/* ════ CARDS DE CONTA FINANCEIRA ════ */
.conta-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow-card);

  /* Barra lateral colorida */
  border-left: 3px solid var(--conta-cor, var(--primary));
}
.conta-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: var(--conta-cor, var(--primary));
  opacity: .05;
  pointer-events: none;
}
.conta-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.conta-card-inativa {
  opacity: .5;
  filter: grayscale(.4);
}

/* Topo */
.conta-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.conta-card-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--conta-cor, var(--primary)) 14%, transparent);
  color: var(--conta-cor, var(--primary));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.conta-card-meta {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.conta-card-tipo {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--conta-cor, var(--primary));
  background: color-mix(in srgb, var(--conta-cor, var(--primary)) 12%, transparent);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
}
.conta-card-inativa-badge {
  font-size: 10px; font-weight: 600;
  color: var(--text-muted);
  background: var(--border);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Ações */
.conta-card-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.conta-card:hover .conta-card-actions { opacity: 1; }
.conta-action-btn {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}
.conta-action-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.conta-action-danger:hover {
  background: var(--danger-light) !important;
  border-color: var(--danger) !important;
  color: var(--danger) !important;
}

/* Nome e banco */
.conta-card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conta-card-bank {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Saldo em destaque */
.conta-card-saldo {
  margin: 14px 0 16px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--conta-cor, var(--primary)) 6%, transparent);
  border-radius: var(--radius);
}
.conta-card-saldo-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.conta-card-saldo-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -.02em;
  line-height: 1;
}
.conta-saldo-pos { color: var(--secondary); }
.conta-saldo-neg { color: var(--danger); }

/* Rodapé */
.conta-card-footer {
  display: flex;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  gap: 12px;
}
.conta-card-footer-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.conta-footer-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-light);
}
.conta-footer-value {
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-muted);
}
.conta-var-pos { color: var(--secondary) !important; }
.conta-var-neg { color: var(--danger) !important; }

/* Dark mode fallback para color-mix (Safari antigo) */
[data-theme="dark"] .conta-card-saldo {
  background: rgba(255,255,255,.04);
}

/* ════ FAIXA DE FLUXO PREVISTO ════ */
.previsao-strip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 22px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
}

.previsao-strip-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  width: 100%;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.previsao-strip-items {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  flex-wrap: wrap;
  row-gap: 12px;
}

.previsao-item {
  flex: 1;
  min-width: 110px;
  padding: 0 16px;
}

.previsao-item-resultado {
  background: var(--border-light);
  border-radius: var(--radius);
  padding: 10px 16px;
  border-left: 2px solid var(--primary);
}

.previsao-item-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
  white-space: nowrap;
}

.previsao-item-value {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -.02em;
  line-height: 1.1;
  white-space: nowrap;
}

.previsao-item-sub {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
}

.previsao-sep {
  font-size: 20px;
  font-weight: 300;
  color: var(--text-light);
  padding: 0 4px;
  flex-shrink: 0;
  align-self: center;
  margin-bottom: 4px;
}

/* Dark mode */
[data-theme="dark"] .previsao-item-resultado {
  background: rgba(255,255,255,.04);
  border-color: var(--primary);
}

/* Mobile: empilha */
@media (max-width: 767px) {
  .previsao-strip { padding: 14px 16px; }
  .previsao-strip-items { gap: 4px; }
  .previsao-sep { display: none; }
  .previsao-item {
    flex: 0 0 calc(50% - 8px);
    padding: 8px 12px;
    background: var(--border-light);
    border-radius: var(--radius);
  }
  .previsao-item-resultado {
    flex: 0 0 100%;
  }
  [data-theme="dark"] .previsao-item {
    background: rgba(255,255,255,.03);
  }
}

/* ════ RECORRÊNCIA ════ */
.recorr-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--bg);
}
.recorr-box-header { display: flex; align-items: center; }

.recorr-fields { padding-top: 4px; }

.recorr-preview {
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-top: 4px;
}
.recorr-preview-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.recorr-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.recorr-pill {
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--primary);
  color: #fff;
  padding: 2px 7px;
  border-radius: 99px;
}

/* Badge na tabela */
.recorr-badge {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 1px 7px;
  border-radius: 99px;
  white-space: nowrap;
  letter-spacing: .02em;
}

/* ════ RELATÓRIOS ════ */
.rel-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px 8px;
  box-shadow: var(--shadow-card);
}
.rel-tab {
  display: flex;
  align-items: center;
  padding: 6px 13px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
}
.rel-tab:hover { background: var(--border-light); color: var(--text); }
.rel-tab-ativo { background: var(--primary-light); color: var(--primary); }
.rel-nav-period {
  margin-left: auto;
  display: flex;
  align-items: center;
}

/* Destaques do ano */
.rel-destaque {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.rel-destaque-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.rel-destaque-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.rel-destaque-val {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1.1;
}
.rel-destaque-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Heatmap fluxo anual */
.fluxo-heatmap {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.fluxo-heatmap-cell {
  border-radius: var(--radius);
  padding: 10px 8px;
  text-align: center;
  border: 1px solid var(--border-light);
}
.fluxo-heatmap-mes {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.fluxo-heatmap-val {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1.2;
}
.fluxo-heatmap-sub {
  margin-top: 4px;
  display: flex;
  justify-content: center;
  gap: 4px;
}

@media (max-width: 575px) {
  .fluxo-heatmap { grid-template-columns: repeat(3, 1fr); }
  .rel-nav { gap: 2px; padding: 4px 6px; }
  .rel-tab { padding: 5px 8px; font-size: 11px; }
}

/* ════ DARK MODE — garantir herança de cor em todos os elementos ════ */
[data-theme="dark"] strong,
[data-theme="dark"] b,
[data-theme="dark"] .card-body strong,
[data-theme="dark"] td strong,
[data-theme="dark"] th,
[data-theme="dark"] .card-header h5,
[data-theme="dark"] .card-header h6,
[data-theme="dark"] .modal-title,
[data-theme="dark"] label,
[data-theme="dark"] .form-label {
  color: var(--text);
}

[data-theme="dark"] .table thead th {
  color: var(--text-muted);
  border-color: var(--border);
}

[data-theme="dark"] .table tbody tr td,
[data-theme="dark"] .table tfoot tr td,
[data-theme="dark"] .table tfoot tr th {
  color: var(--text);
  border-color: var(--border-light);
}

[data-theme="dark"] .table tbody tr:hover td {
  background: rgba(255,255,255,.03);
}

[data-theme="dark"] .progress {
  background: rgba(255,255,255,.08);
}

/* Dark mode — herança de cor abrangente para todos os elementos de texto */
[data-theme="dark"] .card-body {
  color: var(--text);
}
[data-theme="dark"] .table td,
[data-theme="dark"] .table th {
  color: var(--text);
}
[data-theme="dark"] .table td small,
[data-theme="dark"] .table td span:not([class*="badge"]):not([class*="valor"]):not([class*="inv-"]):not([class*="cat-"]) {
  color: var(--text-muted);
}
[data-theme="dark"] small.text-muted,
[data-theme="dark"] .text-muted {
  color: var(--text-muted) !important;
}
