/* =====================================================================
   Aguiar Finance — tema visual (claro e escuro)
   ===================================================================== */

:root,
[data-bs-theme="light"] {
  --af-bg: #f3f5fa;
  --af-surface: #ffffff;
  --af-surface-2: #f8fafc;
  --af-border: #e5e9f2;
  --af-text: #0f172a;
  --af-muted: #64748b;
  --af-primary: #2563eb;
  --af-accent: #06b6d4;
  --af-primary-soft: rgba(37, 99, 235, .09);
  --af-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px -12px rgba(15, 23, 42, .12);
  --af-topbar: rgba(243, 245, 250, .82);

  --bs-body-bg: var(--af-bg);
  --bs-body-color: var(--af-text);
  --bs-border-color: var(--af-border);
  --bs-secondary-color: var(--af-muted);
  --bs-primary: #2563eb;
  --bs-primary-rgb: 37, 99, 235;
  --bs-link-color: #2563eb;
  --bs-link-color-rgb: 37, 99, 235;
}

[data-bs-theme="dark"] {
  --af-bg: #080d17;
  --af-surface: #0f1726;
  --af-surface-2: #0b1220;
  --af-border: #1c2638;
  --af-text: #e2e8f0;
  --af-muted: #8b9ab0;
  --af-primary: #3b82f6;
  --af-accent: #22d3ee;
  --af-primary-soft: rgba(59, 130, 246, .14);
  --af-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 32px -14px rgba(0, 0, 0, .6);
  --af-topbar: rgba(8, 13, 23, .78);

  --bs-body-bg: var(--af-bg);
  --bs-body-color: var(--af-text);
  --bs-border-color: var(--af-border);
  --bs-secondary-color: var(--af-muted);
  --bs-secondary-bg: #131d2f;
  --bs-tertiary-bg: #0d1524;
  --bs-primary: #3b82f6;
  --bs-primary-rgb: 59, 130, 246;
  --bs-link-color: #60a5fa;
  --bs-link-color-rgb: 96, 165, 250;
  --bs-emphasis-color: #f8fafc;
  --bs-heading-color: #f1f5f9;
}

/* ---------- base ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--af-bg);
  color: var(--af-text);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, h4, h5, h6 { letter-spacing: -.02em; }
h3 { font-weight: 750; }
.text-muted, .text-secondary, .text-muted-soft { color: var(--af-muted) !important; }
[data-bs-theme="dark"] .text-dark { color: var(--af-text) !important; }
::selection { background: rgba(59, 130, 246, .28); }

/* ---------- estrutura ---------- */
.app-sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 1045;
  width: 268px; display: flex; flex-direction: column;
  padding: 18px 14px 14px;
  background: #0a101c;
  background-image: radial-gradient(420px 260px at 0% 0%, rgba(37, 99, 235, .18), transparent 60%);
  border-right: 1px solid rgba(255, 255, 255, .06);
  color: #cbd5e1; overflow-y: auto; scrollbar-width: thin;
  transition: transform .28s cubic-bezier(.2, .7, .2, 1);
}
.app-main { margin-left: 268px; min-height: 100vh; display: flex; flex-direction: column; }
.app-content { padding: 24px 32px 40px; width: 100%; max-width: 1640px; flex: 1; }

/* marca */
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; text-decoration: none; color: #fff; }
.brand:hover { color: #fff; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  box-shadow: 0 10px 24px -8px rgba(37, 99, 235, .7);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-name { font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.brand-sub { font-size: .74rem; color: #64748b; }

.btn-launch {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 0 4px 14px; padding: 11px 14px; border-radius: 12px;
  font-weight: 650; color: #fff; text-decoration: none;
  background: linear-gradient(135deg, #2563eb, #0891b2);
  box-shadow: 0 10px 24px -10px rgba(37, 99, 235, .9), inset 0 1px 0 rgba(255, 255, 255, .15);
  transition: transform .15s, box-shadow .15s;
}
.btn-launch:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 14px 28px -10px rgba(37, 99, 235, 1); }

.nav-group { margin-bottom: 10px; }
.nav-group-title {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: #475569; padding: 10px 12px 6px;
}
.side-link {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; margin-bottom: 2px; border-radius: 10px;
  color: #94a3b8; text-decoration: none; font-size: .9rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.side-link i { font-size: 1.05rem; width: 20px; text-align: center; opacity: .9; }
.side-link:hover { background: rgba(255, 255, 255, .05); color: #e2e8f0; }
.side-link.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(59, 130, 246, .24), rgba(59, 130, 246, .05));
}
.side-link.active::before {
  content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: linear-gradient(#22d3ee, #3b82f6);
}
.side-link.active i { color: #60a5fa; opacity: 1; }
.side-link .tag-new {
  margin-left: auto; font-size: .62rem; font-weight: 700; padding: 2px 6px; border-radius: 6px;
  background: rgba(34, 211, 238, .14); color: #67e8f9; letter-spacing: .04em;
}

.sidebar-footer {
  margin-top: auto; padding: 12px; border-radius: 14px;
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .06);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; color: #fff;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
}
.sidebar-footer .nome { color: #e2e8f0; font-weight: 600; font-size: .86rem; line-height: 1.2; }
.sidebar-footer .email { color: #64748b; font-size: .72rem; }
.sidebar-footer a { color: #94a3b8; }
.sidebar-footer a:hover { color: #fff; }

/* topbar */
.app-topbar {
  position: sticky; top: 0; z-index: 1030;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 32px; min-height: 72px;
  background: var(--af-topbar); backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--af-border);
}
.page-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-icon {
  width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: var(--af-primary-soft); color: var(--af-primary); font-size: 1.15rem;
}
.page-kicker { font-size: .74rem; color: var(--af-muted); font-weight: 500; line-height: 1.2; }
.page-title { font-size: 1.28rem; font-weight: 800; margin: 0; letter-spacing: -.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; display: inline-grid; place-items: center;
  border: 1px solid var(--af-border); background: var(--af-surface); color: var(--af-text);
  font-size: 1.05rem; transition: border-color .15s, background .15s, color .15s;
}
.icon-btn:hover { border-color: var(--af-primary); color: var(--af-primary); }
.menu-toggle { display: none; }

.user-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px;
  border-radius: 12px; border: 1px solid var(--af-border); background: var(--af-surface);
  color: var(--af-text); font-weight: 600; font-size: .86rem;
}
.user-chip .avatar { width: 30px; height: 30px; border-radius: 8px; font-size: .75rem; }
.user-chip::after { margin-left: 2px; }
.dropdown-menu {
  --bs-dropdown-bg: var(--af-surface); --bs-dropdown-border-color: var(--af-border);
  --bs-dropdown-link-hover-bg: var(--af-primary-soft); --bs-dropdown-link-color: var(--af-text);
  border-radius: 14px; padding: 6px; box-shadow: var(--af-shadow);
}
.dropdown-item { border-radius: 9px; padding: 8px 12px; font-size: .9rem; }

/* ---------- componentes ---------- */
.card {
  --bs-card-bg: var(--af-surface);
  --bs-card-border-color: var(--af-border);
  --bs-card-cap-bg: transparent;
  border-radius: 18px;
  box-shadow: var(--af-shadow);
}
.card .card { box-shadow: none; }

.alert { border-radius: 14px; border: 1px solid transparent; }
.alert-success { --bs-alert-bg: rgba(34, 197, 94, .1); --bs-alert-color: #15803d; --bs-alert-border-color: rgba(34, 197, 94, .25); }
[data-bs-theme="dark"] .alert-success { --bs-alert-color: #4ade80; }

.btn { border-radius: 11px; font-weight: 600; padding: .55rem 1rem; }
.btn-sm { border-radius: 9px; padding: .3rem .7rem; }
.btn-primary {
  --bs-btn-bg: #2563eb; --bs-btn-border-color: #2563eb;
  --bs-btn-hover-bg: #1d4ed8; --bs-btn-hover-border-color: #1d4ed8;
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .12), transparent);
  box-shadow: 0 6px 16px -8px rgba(37, 99, 235, .8);
}
.btn-light { --bs-btn-bg: var(--af-surface-2); --bs-btn-border-color: var(--af-border); --bs-btn-color: var(--af-text); }

.form-control, .form-select {
  border-radius: 11px; border-color: var(--af-border);
  background-color: var(--af-surface); color: var(--af-text);
  padding: .6rem .85rem;
}
.form-control::placeholder { color: var(--af-muted); opacity: .7; }
.form-control:focus, .form-select:focus {
  border-color: var(--af-primary);
  box-shadow: 0 0 0 .22rem var(--af-primary-soft);
}
.form-label { font-weight: 600; font-size: .86rem; margin-bottom: .35rem; }
.input-group-text { border-color: var(--af-border); background: var(--af-surface-2); border-radius: 11px; }

.table {
  --bs-table-bg: transparent;
  --bs-table-hover-bg: var(--af-primary-soft);
  --bs-table-striped-bg: var(--af-surface-2);
  --bs-table-border-color: var(--af-border);
  vertical-align: middle; font-variant-numeric: tabular-nums;
}
.table > thead th {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--af-muted); background: transparent; white-space: nowrap;
}
.table-light, .table > thead.table-light th { --bs-table-bg: var(--af-surface-2); --bs-table-color: var(--af-muted); }

.badge { font-weight: 600; letter-spacing: .01em; }
.badge-soft {
  background: var(--af-primary-soft); color: var(--af-primary);
  border: 1px solid color-mix(in srgb, var(--af-primary) 22%, transparent);
  border-radius: 999px; padding: .42rem .65rem;
}
[data-bs-theme="dark"] .text-bg-light { background: var(--bs-secondary-bg) !important; color: var(--af-text) !important; }

.list-group { --bs-list-group-bg: var(--af-surface); --bs-list-group-border-color: var(--af-border); }
.nav-tabs, .nav-pills { --bs-nav-link-color: var(--af-muted); }

.categoria-badge {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  border-radius: 999px; padding: .32rem .62rem; font-weight: 650; font-size: .8rem;
  color: var(--cat-color);
  background: color-mix(in srgb, var(--cat-color) 12%, var(--af-surface));
  border: 1px solid color-mix(in srgb, var(--cat-color) 25%, var(--af-surface));
}
[data-bs-theme="dark"] .categoria-badge { color: color-mix(in srgb, var(--cat-color) 70%, white); }

.metric-card, .finance-card { overflow: hidden; position: relative; }
.metric-card::after {
  content: ""; position: absolute; right: -28px; top: -28px; width: 96px; height: 96px; border-radius: 50%;
  background: var(--af-primary-soft);
}
.metric-icon, .finance-icon {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  background: var(--af-primary-soft); color: var(--af-primary); font-size: 1.2rem;
}
[data-bs-theme="dark"] .dashboard-filter-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, .12), var(--af-surface)) !important;
  border-color: rgba(59, 130, 246, .2) !important;
}
[data-bs-theme="dark"] .saldo-positivo { color: #4ade80 !important; }
[data-bs-theme="dark"] .saldo-negativo { color: #f87171 !important; }
.empty-state { text-align: center; padding: 34px 18px; color: var(--af-muted); }

.icon-preview-pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--af-border); border-radius: 999px; padding: .45rem .7rem; background: var(--af-surface); font-weight: 700; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 8px; }
.icon-option { border: 1px solid var(--af-border); background: var(--af-surface); border-radius: 12px; height: 42px; display: grid; place-items: center; cursor: pointer; transition: .15s ease; }
.icon-option:hover, .icon-option.active { border-color: var(--af-primary); color: var(--af-primary); background: var(--af-primary-soft); transform: translateY(-1px); }

.app-footer { padding: 18px 32px 26px; font-size: .78rem; color: var(--af-muted); }

/* entrada suave do conteúdo */
.app-content > * { animation: af-in .35s ease both; }
@keyframes af-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- barra inferior (celular) ---------- */
.bottom-nav { display: none; }
.sidebar-backdrop {
  position: fixed; inset: 0; z-index: 1040; background: rgba(2, 6, 23, .55);
  backdrop-filter: blur(2px); opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s;
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); box-shadow: 20px 0 60px rgba(0, 0, 0, .4); }
  .app-sidebar.show { transform: none; }
  .app-main { margin-left: 0; }
  .menu-toggle { display: inline-grid; }
  .app-topbar { padding: 12px 20px; }
  .app-content { padding: 20px; }
}

@media (max-width: 767.98px) {
  :root { --bottom-h: 68px; }
  body { padding-bottom: calc(var(--bottom-h) + 22px + env(safe-area-inset-bottom)); }
  .menu-toggle, .topbar-actions .btn-nova, .user-chip .nome-chip { display: none !important; }
  .app-topbar { padding: 10px 14px; min-height: 62px; }
  .page-icon { width: 36px; height: 36px; font-size: 1rem; }
  .page-title { font-size: 1.1rem; }
  .app-content { padding: 14px; }
  .app-footer { display: none; }

  .card { border-radius: 16px; }
  .card.p-4 { padding: 16px !important; }
  .table-responsive { border-radius: 12px; }
  .table { min-width: 720px; font-size: .85rem; }
  .form-control, .form-select, .btn { min-height: 44px; }
  form.row.g-3 > div, form.row.g-3 [class*="col-md-"] { flex: 0 0 auto; width: 100%; }
  .chart-box, .dashboard-chart-box { min-height: 260px; }

  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
    position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 1035;
    height: var(--bottom-h); border-radius: 22px;
    background: color-mix(in srgb, var(--af-surface) 90%, transparent);
    backdrop-filter: saturate(160%) blur(16px);
    border: 1px solid var(--af-border); box-shadow: 0 16px 40px -10px rgba(2, 6, 23, .35);
  }
  .bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: 100%; border: 0; background: none; text-decoration: none;
    color: var(--af-muted); font-size: .66rem; font-weight: 650;
  }
  .bottom-nav i { font-size: 1.2rem; }
  .bottom-nav .active { color: var(--af-primary); }
  .bottom-nav .active i { transform: translateY(-1px); }
  .bottom-nav .fab {
    width: 54px; height: 54px; margin: -26px auto 0; border-radius: 18px; color: #fff; font-size: 1.5rem;
    background: linear-gradient(135deg, #2563eb, #06b6d4);
    box-shadow: 0 12px 26px -8px rgba(37, 99, 235, .9), 0 0 0 5px var(--af-bg);
  }
  .bottom-nav .fab i { font-size: 1.5rem; }
}

/* ---------- impressão ---------- */
@media print {
  .app-sidebar, .app-topbar, .bottom-nav, .app-footer, .sidebar-backdrop, .no-print { display: none !important; }
  .app-main { margin: 0 !important; }
  .app-content { padding: 0 !important; max-width: none; }
  body { background: #fff !important; padding: 0 !important; }
  .card { box-shadow: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Título da página já aparece na barra superior: esconde o h3 repetido das telas */
.view-root > h3:first-child,
.view-root > .d-flex:first-child > h3:first-child,
.view-root > .d-flex:first-child > div:first-child > h3:first-child { display: none; }
.view-root > .d-flex.mb-4:first-child:has(> h3:only-child) { display: none; }
.view-root > .d-flex:first-child > div:first-child > .text-muted { font-size: .92rem; }
