:root {
  color-scheme: light;
  --page-bg:        #ffffff;
  --surface-1:      #fcfcfb;
  --surface-2:      #f6f6f4;
  --surface-card:   #ffffff;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --border:         #e1e0d9;
  --border-strong:  #c3c2b7;

  --brand:          #2a78d6;
  --brand-dark:     #184f95;
  --sidebar-bg:     #10233f;
  --sidebar-bg-2:   #16304f;
  --sidebar-text:   #cfe0f5;
  --sidebar-text-active: #ffffff;

  --good:           #1baf7a;
  --bad:            #e34948;
  --warning:        #eda100;

  --cat-1: #2a78d6; --cat-2: #eb6834; --cat-3: #1baf7a; --cat-4: #eda100;
  --cat-5: #e87ba4; --cat-6: #008300; --cat-7: #4a3aa7; --cat-8: #e34948;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(11,11,11,0.06), 0 1px 12px rgba(11,11,11,0.04);
}

/* O tema escuro só é aplicado com data-theme="dark" explícito — a app não
   segue mais a preferência do sistema operativo, para manter o fundo
   sempre branco por omissão. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --page-bg:        #0d0d0d;
    --surface-1:      #1a1a19;
    --surface-2:      #0d0d0d;
    --surface-card:   #212120;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --border:         #2c2c2a;
    --border-strong:  #383835;

    --brand:          #3987e5;
    --sidebar-bg:     #0b1826;
    --sidebar-bg-2:   #0f2338;

    --good:           #199e70;
    --bad:            #e66767;
    --warning:        #c98500;

    --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70; --cat-4: #c98500;
    --cat-5: #d55181; --cat-6: #008300; --cat-7: #9085e9; --cat-8: #e66767;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-bg);
  color: var(--text-primary);
  font-size: 14px;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 1030;
  transition: transform .2s ease;
}

.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.25rem 1.25rem 1rem;
  font-weight: 700; font-size: 1.05rem;
  color: #fff;
}
.sidebar-brand i { font-size: 1.4rem; color: var(--brand); }

.sidebar-nav { flex: 1; padding: .5rem .75rem; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .8rem;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-weight: 500;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 1.3rem; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.sidebar-nav .nav-link.active { background: var(--brand); color: #fff; }

.sidebar-footer { padding: 1rem 1.1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-user { display: flex; align-items: center; gap: .6rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.sidebar-user-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.sidebar-user-info strong { font-size: .85rem; color: #fff; }
.sidebar-user-info small { font-size: .75rem; color: var(--sidebar-text); opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main-wrap { margin-left: 240px; flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--surface-card);
  border-bottom: 1px solid var(--border);
  padding: .9rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 1020;
}
.topbar-title { font-size: 1.25rem; font-weight: 700; margin: 0; flex: 1; }

.content { padding: 1.5rem; flex: 1; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

/* ---------- Stat tiles ---------- */
.stat-tile {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .35rem;
}
.stat-tile .stat-label { color: var(--text-secondary); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-tile .stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.stat-tile .stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #fff; margin-bottom: .25rem;
}
.stat-tile.good .stat-icon { background: var(--good); }
.stat-tile.bad .stat-icon { background: var(--bad); }
.stat-tile.brand .stat-icon { background: var(--brand); }
.stat-tile.neutral .stat-icon { background: var(--text-muted); }
.stat-tile .stat-value.text-good { color: var(--good); }
.stat-tile .stat-value.text-bad { color: var(--bad); }

/* ---------- Category dot / badge ---------- */
.cat-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .4rem; flex-shrink: 0; }
.cat-badge {
  display: inline-flex; align-items: center;
  padding: .2rem .55rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-primary);
}

/* ---------- Tables ---------- */
.table { color: var(--text-primary); }
.table thead th {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-muted); font-weight: 700; border-bottom-width: 1px;
  white-space: nowrap;
}
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--surface-2); }
.amount-in { color: var(--good); font-weight: 600; }
.amount-out { color: var(--bad); font-weight: 600; }

/* ---------- Forms / misc ---------- */
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.color-swatch-input { width: 46px; height: 38px; padding: 4px; }
.file-row { display: flex; align-items: center; gap: .6rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.file-row:last-child { border-bottom: none; }
.file-row .file-icon { font-size: 1.4rem; color: var(--brand); width: 1.8rem; text-align: center; }
.file-row .file-thumb { width: 150px; height: 150px; border-radius: 8px; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); }
.file-row .file-meta { color: var(--text-muted); font-size: .78rem; }
.file-thumb-sm { width: 150px; height: 150px; border-radius: 8px; object-fit: cover; vertical-align: middle; border: 1px solid var(--border); }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .75rem; opacity: .6; }
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--sidebar-bg), var(--sidebar-bg-2));
  padding: 1rem;
}
.login-card { width: 100%; max-width: 380px; color: var(--text-primary); }
.login-card .text-muted { color: var(--text-muted) !important; }
.login-card .form-label { color: var(--text-secondary); font-weight: 500; }
.chart-card canvas { max-height: 320px; }
.progress-thin { height: 6px; border-radius: 999px; }
