/* ============================================================
   FinanceApp — Design System
   Dark theme · DM Sans · Mobile-first
   ============================================================ */

/* ── Reset & Tokens ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Colors */
  --bg:        #0f172a;
  --bg-2:      #131c2f;
  --surface:   #1e293b;
  --surface-2: #273549;
  --border:    #2d3e55;
  --border-2:  #374a65;

  --text:      #e2e8f0;
  --text-2:    #94a3b8;
  --text-3:    #64748b;

  --primary:   #6366f1;
  --primary-h: #5558e8;
  --accent:    #06b6d4;

  --green:     #22c55e;
  --red:       #ef4444;
  --yellow:    #f59e0b;
  --purple:    #8b5cf6;
  --orange:    #f97316;

  /* Sizing */
  --sidebar-w: 240px;
  --topbar-h:  60px;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 4px 24px rgba(0,0,0,.35);

  /* Type */
  --font:      'DM Sans', system-ui, sans-serif;
  --mono:      'DM Mono', monospace;
}

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-h); }
img { max-width: 100%; }
code { font-family: var(--mono); font-size: .875rem; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

/* ── Layout ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .25s ease;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--text) !important;
  font-weight: 600;
  font-size: 1.05rem;
}
.logo-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
}
.logo-text { color: var(--text); }

.sidebar-close {
  display: none;
  background: none; border: none; color: var(--text-2);
  font-size: 1.1rem; cursor: pointer; padding: .25rem;
}

.sidebar-nav {
  flex: 1;
  padding: .75rem 0;
  overflow-y: auto;
}

.nav-section {
  padding: .9rem 1rem .3rem;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1rem;
  color: var(--text-2);
  font-size: .875rem;
  transition: background .15s, color .15s;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
  text-align: left;
  border-radius: 0;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--primary)18; color: var(--primary); font-weight: 500; }
.nav-icon { width: 20px; text-align: center; font-size: 1rem; flex-shrink: 0; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: .5rem 0;
}
.nav-logout { color: var(--text-3) !important; }
.nav-logout:hover { color: var(--red) !important; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 199;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  position: sticky; top: 0; z-index: 100;
}

.menu-toggle {
  display: none;
  flex-direction: column; gap: 4px;
  background: none; border: none; cursor: pointer; padding: .25rem;
  flex-shrink: 0;
}
.menu-toggle span {
  display: block; width: 22px; height: 2px;
  background: var(--text-2); border-radius: 2px; transition: .2s;
}

.topbar-center { flex: 1; }
.topbar-title { font-weight: 600; font-size: 1rem; }

.topbar-actions { display: flex; align-items: center; gap: .75rem; }

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1280px;
  width: 100%;
}

/* ── Flash Messages ─────────────────────────────────────────── */
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.25rem;
  font-size: .875rem; font-weight: 500;
  animation: slideDown .25s ease;
}
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } }
.flash-success { background: #14532d; color: #86efac; border-bottom: 1px solid #166534; }
.flash-error   { background: #7f1d1d; color: #fca5a5; border-bottom: 1px solid #991b1b; }
.flash-warning { background: #78350f; color: #fde68a; border-bottom: 1px solid #92400e; }
.flash-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: inherit; opacity: .7; padding: 0 .25rem; }

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.page-header h1 { font-size: 1.5rem; font-weight: 600; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  font-family: var(--font); font-size: .875rem; font-weight: 500;
  border: none; cursor: pointer; transition: background .15s, opacity .15s, transform .1s;
  white-space: nowrap; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); color: #fff; }
.btn-accent   { background: var(--accent); color: #fff; }
.btn-accent:hover { opacity: .9; color: #fff; }
.btn-outline  { background: transparent; color: var(--text); border: 1px solid var(--border-2); }
.btn-outline:hover { background: var(--surface); color: var(--text); }
.btn-ghost    { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-danger-outline { background: transparent; color: var(--red); border: 1px solid var(--red)44; }
.btn-danger-outline:hover { background: var(--red)11; }
.btn-sm  { padding: .38rem .85rem; font-size: .8rem; }
.btn-lg  { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  color: var(--text-2); font-size: 1rem; padding: .3rem .5rem;
  border-radius: 6px; transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon.btn-danger:hover { color: var(--red); background: var(--red)11; }

/* ── Cards Summary ──────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}
.card-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 700; flex-shrink: 0;
}
.card-income .card-icon  { background: var(--green)22;  color: var(--green);  }
.card-expense .card-icon { background: var(--red)22;    color: var(--red);    }
.card-invest .card-icon  { background: var(--purple)22; color: var(--purple); }
.card-balance .card-icon { background: var(--accent)22; color: var(--accent); }
.card-label { font-size: .78rem; color: var(--text-2); margin-bottom: .2rem; }
.card-value { font-size: 1.2rem; font-weight: 600; }

/* ── Section Cards ──────────────────────────────────────────── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.section-card h3 { font-size: .95rem; font-weight: 600; margin-bottom: 1rem; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.section-header h3 { margin-bottom: 0; }
.highlight-card { border-color: var(--green)44; background: var(--green)08; }

.link-sm { font-size: .8rem; color: var(--text-2); }
.link-sm:hover { color: var(--primary); }

/* ── Dashboard Grid ─────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.col-span-2 { grid-column: span 2; }

/* ── Daily Banner ───────────────────────────────────────────── */
.daily-banner {
  background: linear-gradient(135deg, #1e1b4b 0%, #1e293b 100%);
  border: 1px solid var(--primary)33;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.daily-banner-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.daily-label { font-size: .78rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
.daily-amount { font-size: 2rem; font-weight: 700; color: var(--green); line-height: 1.2; }
.daily-sub { font-size: .78rem; color: var(--text-2); margin-top: .2rem; }
.daily-source { font-size: .72rem; color: var(--text-2); margin-top: .15rem; opacity: .8; }

/* ── PWA install button ────────────────────────────────────────────────── */
.install-btn {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    z-index: 1000;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 24px;
    padding: .6rem 1.1rem;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(99, 102, 241, .4);
    transition: transform .15s, box-shadow .15s;
}
.install-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(99, 102, 241, .5); }
@media (display-mode: standalone) { .install-btn { display: none; } }

/* ── Page help (botão ? + painel) ──────────────────────────────────────── */
.page-help { margin: 0 0 1rem; }
.page-help-btn { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .7rem; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; color: var(--text-2); font-size: .78rem; cursor: pointer; transition: all .15s; }
.page-help-btn:hover { background: var(--bg); color: var(--text); border-color: var(--primary); }
.page-help-btn[aria-expanded="true"] { background: var(--primary); color: white; border-color: var(--primary); }
.phb-icon { width: 18px; height: 18px; border-radius: 50%; background: currentColor; color: var(--surface); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .72rem; }
.page-help-btn[aria-expanded="true"] .phb-icon { color: var(--primary); background: white; }
.page-help-panel { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: var(--radius); padding: 1rem 1.25rem; margin-top: .5rem; font-size: .85rem; line-height: 1.55; animation: phpSlide .2s ease-out; }
.page-help-panel.hidden { display: none; }
.page-help-panel h4 { margin: .75rem 0 .35rem; font-size: .88rem; color: var(--text); }
.page-help-panel h4:first-child { margin-top: 0; }
.page-help-panel p { margin: .35rem 0; color: var(--text-2); }
.page-help-panel ul, .page-help-panel ol { margin: .35rem 0 .6rem; padding-left: 1.3rem; color: var(--text-2); }
.page-help-panel li { margin: .15rem 0; }
.page-help-panel strong { color: var(--text); }
.page-help-panel code { background: var(--bg); padding: .1rem .35rem; border-radius: 3px; font-size: .76rem; }
.page-help-panel a { color: var(--accent); }
@keyframes phpSlide { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.daily-source a { color: var(--accent); text-decoration: none; }
.daily-source a:hover { text-decoration: underline; }

/* ── Transactions ───────────────────────────────────────────── */
.transactions-list { display: flex; flex-direction: column; gap: .25rem; }
.tx-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .5rem; border-radius: 8px;
  transition: background .15s; color: var(--text);
}
.tx-row:hover { background: var(--surface-2); }
.tx-cat {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.tx-info { flex: 1; min-width: 0; }
.tx-desc { display: block; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { display: block; font-size: .75rem; color: var(--text-2); }
.tx-amount { font-size: .9rem; font-weight: 600; white-space: nowrap; }
.tx-desc-cell { display: flex; align-items: center; gap: .4rem; }

/* ── Category Bars ──────────────────────────────────────────── */
.category-bars { display: flex; flex-direction: column; gap: .75rem; }
.cat-bar-row { display: flex; align-items: center; gap: .75rem; }
.cat-bar-label { display: flex; justify-content: space-between; min-width: 180px; font-size: .8rem; }
.cat-bar-value { font-weight: 500; color: var(--text-2); }
.cat-bar-track { flex: 1; height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.cat-bar-fill  { height: 100%; border-radius: 4px; transition: width .6s ease; }
.cat-bar-pct   { font-size: .75rem; color: var(--text-3); width: 32px; text-align: right; }

/* ── Accounts ───────────────────────────────────────────────── */
.accounts-list { display: flex; flex-direction: column; gap: .5rem; }
.account-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem; border-radius: 8px;
}
.account-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.account-dot-lg { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
.account-info { flex: 1; }
.account-name { display: block; font-size: .875rem; font-weight: 500; }
.account-type { font-size: .75rem; color: var(--text-2); }
.account-balance { font-weight: 600; font-size: .95rem; }
.account-balance-lg { font-size: 1.8rem; font-weight: 700; margin: 1rem 0 .25rem; }
.account-meta { font-size: .78rem; color: var(--text-2); margin-bottom: .75rem; }
.account-card-header { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: .5rem; }
.account-actions { display: flex; gap: .5rem; margin-top: .75rem; }
.account-card { display: flex; flex-direction: column; }

/* ── Dreams ─────────────────────────────────────────────────── */
.dreams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.dream-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex; flex-direction: column; gap: .75rem;
}
.dream-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.dream-card-header h3 { font-size: 1rem; font-weight: 600; }
.dream-description { font-size: .83rem; color: var(--text-2); line-height: 1.4; }
.dream-progress-section { display: flex; flex-direction: column; gap: .4rem; }
.dream-progress-labels { display: flex; justify-content: space-between; font-size: .75rem; color: var(--text-2); }
.dream-meta { display: flex; flex-wrap: wrap; gap: .5rem; font-size: .78rem; color: var(--text-2); }
.dream-actions { display: flex; gap: .5rem; margin-top: auto; }
.dream-priority { font-size: .75rem; color: var(--text-3); }

/* Dream detail */
.dream-hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1rem;
}
.dream-hero-stats { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.dream-stat { text-align: center; }
.dream-stat-value { font-size: 1.4rem; font-weight: 700; }
.dream-stat-label { font-size: .75rem; color: var(--text-2); }
.dream-stat-center { flex: 1; display: flex; justify-content: center; }
.dream-hero-meta { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; font-size: .83rem; color: var(--text-2); }
.dream-desc-text { font-size: .9rem; color: var(--text-2); margin-top: .75rem; line-height: 1.5; }

/* Progress Circle */
.progress-circle { position: relative; width: 80px; height: 80px; }
.progress-circle svg { width: 100%; height: 100%; }
.progress-circle-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; font-weight: 700;
}

/* ── Progress Bars ──────────────────────────────────────────── */
.progress-track {
  height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden;
}
.progress-track.large { height: 12px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 4px; transition: width .6s ease; }
.progress-label { font-size: .78rem; color: var(--text-2); }
.mini-progress { height: 5px; width: 80px; background: var(--surface-2); border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: .4rem; }
.mini-fill { height: 100%; border-radius: 3px; }

/* ── Investments ────────────────────────────────────────────── */
.invest-summary { display: flex; flex-direction: column; gap: .5rem; }
.invest-row { display: flex; justify-content: space-between; align-items: center; padding: .4rem 0; font-size: .875rem; border-bottom: 1px solid var(--border); }
.invest-row:last-child { border-bottom: none; font-weight: 600; }

/* ── Recommendations ────────────────────────────────────────── */
.recs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.rec-card {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 1rem;
  border-left: 3px solid var(--primary);
  display: flex; flex-direction: column; gap: .5rem;
}
.rec-card.rec-alert  { border-left-color: var(--red); }
.rec-card.rec-investment { border-left-color: var(--purple); }
.rec-card.rec-saving { border-left-color: var(--green); }
.rec-card.rec-dream  { border-left-color: var(--yellow); }
.rec-title { font-size: .875rem; font-weight: 600; }
.rec-desc  { font-size: .8rem; color: var(--text-2); line-height: 1.45; }
.rec-action { font-size: .78rem; color: var(--primary); font-weight: 500; align-self: flex-start; }

/* ── Pending List ───────────────────────────────────────────── */
.pending-list { display: flex; flex-direction: column; gap: .5rem; }
.pending-item { display: flex; justify-content: space-between; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--border); font-size: .875rem; }
.pending-info { display: flex; align-items: center; gap: .5rem; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1rem;
}
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
  text-align: left; padding: .75rem 1rem;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: .75rem; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap;
}
.data-table td { padding: .7rem 1rem; border-bottom: 1px solid var(--border)55; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }
.row-overdue td { background: var(--red)08; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.action-btns { display: flex; justify-content: center; gap: .25rem; }
.date-cell { white-space: nowrap; color: var(--text-2); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .55rem;
  border-radius: 20px; font-size: .7rem; font-weight: 600;
}
.badge-paid      { background: var(--green)22;  color: var(--green); }
.badge-pending   { background: var(--yellow)22; color: var(--yellow); }
.badge-planned   { background: var(--accent)22; color: var(--accent); }
.badge-overdue   { background: var(--red)22;    color: var(--red); }
.badge-cancelled { background: var(--text-3)22; color: var(--text-3); }
.badge-muted     { background: var(--surface-2); color: var(--text-2); }
.badge-green     { background: var(--green)22;  color: var(--green); }
.badge-red       { background: var(--red)22;    color: var(--red); }
.badge-small     { font-size: .65rem; padding: .1rem .4rem; border-radius: 4px; background: var(--surface-2); color: var(--text-2); }
.cat-pill { display: inline-flex; align-items: center; gap: .25rem; padding: .2rem .55rem; border-radius: 20px; font-size: .75rem; }

/* ── Summary Bar ────────────────────────────────────────────── */
.summary-bar {
  display: flex; flex-wrap: wrap; gap: .75rem 1.5rem;
  padding: .75rem 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 1rem;
  font-size: .83rem;
}
.summary-item { display: flex; align-items: center; gap: .4rem; }
.summary-item.danger { color: var(--red); }
.summary-item.muted  { color: var(--text-2); }

/* ── Filters ────────────────────────────────────────────────── */
.filters-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: .875rem 1rem;
  margin-bottom: 1rem;
}
.filters-form { width: 100%; }
.filter-row {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end;
}
.field-search { flex: 1; min-width: 140px; }
.field-search input { width: 100%; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.75rem;
  margin-bottom: 1rem;
}
.form-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1.25rem; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.form-grid-profile { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

.field { display: flex; flex-direction: column; gap: .4rem; }
.field label { font-size: .8rem; font-weight: 500; color: var(--text-2); }
.field-hint { font-size: .72rem; color: var(--text-3); }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="file"],
select, textarea {
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font); font-size: .875rem;
  padding: .6rem .85rem;
  transition: border .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary)22;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 70px; }
input[type="color"] { padding: .25rem; height: 40px; cursor: pointer; }
input[type="file"] { cursor: pointer; }

.input-sm { padding: .45rem .7rem; font-size: .82rem; }

.field-inline { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field-inline label { font-size: .75rem; color: var(--text-2); white-space: nowrap; }

.input-prefix-wrap { position: relative; display: flex; align-items: center; }
.input-prefix {
  position: absolute; left: .75rem;
  color: var(--text-2); font-size: .85rem; font-weight: 500;
  pointer-events: none; user-select: none;
}
.with-prefix { padding-left: 2.5rem !important; }

.form-row-inline { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.form-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

.section-divider {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem; margin-top: 1.25rem; margin-bottom: 1rem;
}
.section-divider h3 { font-size: .9rem; font-weight: 600; color: var(--text-2); }
.toggle-label { display: flex; align-items: center; gap: .6rem; cursor: pointer; font-size: .875rem; font-weight: 500; }
.toggle-label input { width: auto; accent-color: var(--primary); }

.collapsible-section { display: none; padding: 1rem; background: var(--surface-2); border-radius: 8px; margin-bottom: 1rem; }
.collapsible-section.open { display: block; }

/* Checkbox grid */
.checkbox-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.checkbox-item { display: flex; align-items: center; gap: .4rem; cursor: pointer; font-size: .875rem; padding: .45rem .75rem; background: var(--surface-2); border-radius: 8px; border: 1px solid var(--border); }
.checkbox-item:hover { border-color: var(--primary); }
.checkbox-item input { accent-color: var(--primary); }

/* Budget items */
.budget-item-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; flex-wrap: wrap; }

/* ── Quick Launch ────────────────────────────────────────────── */
.quick-container { max-width: 520px; margin: 0 auto; padding-bottom: 2rem; }
.quick-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.75rem;
}
.quick-title { font-size: 1.3rem; font-weight: 600; margin-bottom: 1.5rem; }

.type-toggle { display: flex; gap: .5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.type-opt {
  flex: 1; min-width: 90px;
  display: flex; align-items: center; justify-content: center;
  padding: .6rem .75rem;
  border: 1.5px solid var(--border-2); border-radius: 8px;
  cursor: pointer; font-size: .83rem; font-weight: 500;
  transition: border-color .15s, background .15s;
  white-space: nowrap; gap: .3rem;
}
.type-opt input { display: none; }
.type-opt:hover { border-color: var(--border); background: var(--surface-2); }
.type-opt.selected, .expense-opt.selected  { border-color: var(--red);    background: var(--red)11;    color: var(--red); }
.income-opt.selected  { border-color: var(--green);  background: var(--green)11;  color: var(--green); }
.invest-opt.selected  { border-color: var(--purple); background: var(--purple)11; color: var(--purple); }
.transfer-opt.selected{ border-color: var(--accent); background: var(--accent)11; color: var(--accent); }

.amount-field {
  display: flex; align-items: center;
  background: var(--bg); border: 2px solid var(--border-2);
  border-radius: 10px; margin-bottom: 1rem;
  transition: border-color .15s;
}
.amount-field:focus-within { border-color: var(--primary); }
.currency-prefix { padding: 0 .75rem; color: var(--text-2); font-size: 1.1rem; font-weight: 600; }
.amount-input {
  flex: 1; background: none; border: none !important; box-shadow: none !important;
  font-size: 2rem !important; font-weight: 700 !important; padding: .75rem .5rem !important;
  color: var(--text); text-align: right;
}
.amount-input:focus { outline: none; border: none; box-shadow: none; }
.desc-input { font-size: 1rem; padding: .75rem !important; }

.quick-cats { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.quick-cat-btn {
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  padding: .5rem .65rem; border: 1.5px solid var(--border);
  border-radius: 10px; background: none; cursor: pointer; color: var(--text-2);
  font-size: .72rem; min-width: 58px; transition: border-color .15s, background .15s;
  font-family: var(--font);
}
.quick-cat-btn span:first-child { font-size: 1.2rem; }
.quick-cat-btn:hover { border-color: var(--border-2); background: var(--surface-2); color: var(--text); }
.quick-cat-btn.active { border-color: var(--cat-color, var(--primary)); background: var(--cat-color, var(--primary))22; color: var(--cat-color, var(--primary)); }

.cat-suggestion {
  margin-top: .4rem; padding: .4rem .75rem;
  background: var(--surface-2); border-radius: 6px;
  font-size: .8rem; color: var(--primary); cursor: pointer;
}
.cat-suggestion:hover { background: var(--primary)22; }

.all-cats-panel {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: .75rem; margin-bottom: 1rem;
}
.cat-search { margin-bottom: .5rem; }
.all-cats-list { display: flex; flex-direction: column; gap: .25rem; max-height: 200px; overflow-y: auto; }
.cat-list-btn {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .75rem;
  background: none; border: none; border-left: 3px solid transparent;
  color: var(--text-2); font-family: var(--font); font-size: .83rem;
  cursor: pointer; text-align: left; border-radius: 0 6px 6px 0;
  transition: background .1s, color .1s;
}
.cat-list-btn:hover { background: var(--surface); color: var(--text); }

.quick-details-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.quick-details-row .field-inline { flex: 1; min-width: 140px; }

.extra-opts { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.extra-opt-btn {
  padding: .4rem .85rem; border-radius: 8px;
  border: 1px solid var(--border); background: none;
  color: var(--text-2); font-size: .8rem; cursor: pointer;
  font-family: var(--font); transition: background .15s, color .15s; text-decoration: none;
  display: inline-flex; align-items: center; gap: .3rem;
}
.extra-opt-btn:hover, .extra-opt-btn.active { background: var(--primary)11; border-color: var(--primary); color: var(--primary); }
.extra-panel {
  background: var(--surface-2); border-radius: 8px; padding: 1rem;
  margin-bottom: 1rem; border: 1px solid var(--border);
}
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.field-row .field-inline { flex: 1; }

/* ── Categories Grid ────────────────────────────────────────── */
.categories-grid { display: flex; flex-direction: column; gap: .5rem; }
.cat-item-card {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .75rem; background: var(--surface-2);
  border-radius: 8px;
}
.cat-item-card.cat-child { margin-left: 2rem; opacity: .9; }
.cat-icon-lg {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.cat-info { flex: 1; }
.cat-name { font-size: .875rem; font-weight: 500; }
.cat-actions { display: flex; gap: .25rem; }

/* ── Danger Zone ────────────────────────────────────────────── */
.danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination { display: flex; gap: .25rem; padding: .75rem 1rem; justify-content: center; }
.page-btn {
  min-width: 32px; height: 32px; padding: 0 .5rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: .83rem;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border); transition: background .15s;
}
.page-btn:hover, .page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Inline form ────────────────────────────────────────────── */
.inline-form .form-row-inline { align-items: flex-end; }

/* ── Chart ──────────────────────────────────────────────────── */
.chart-wrap { position: relative; width: 100%; }
.chart-donut { max-width: 260px; margin: 0 auto; }
.chart-legend { display: flex; flex-direction: column; gap: .4rem; margin-top: 1rem; }
.legend-item { display: flex; align-items: center; gap: .5rem; font-size: .8rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-val { margin-left: auto; font-weight: 500; color: var(--text-2); }

/* ── Auth ───────────────────────────────────────────────────── */
.auth-body { background: radial-gradient(ellipse at top, #1e1b4b 0%, var(--bg) 60%); }
.auth-container {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 2rem 1rem;
}
.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-brand .logo-icon { width: 52px; height: 52px; font-size: 1.6rem; border-radius: 14px; margin: 0 auto .75rem; }
.auth-brand h1 { font-size: 1.6rem; font-weight: 700; }
.auth-brand p  { color: var(--text-2); font-size: .9rem; }
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2rem;
}
.auth-card h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: .25rem; }
.auth-sub { color: var(--text-2); font-size: .875rem; margin-bottom: 1.5rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: .875rem; color: var(--text-2); }
.auth-demo { text-align: center; margin-top: .5rem; }
.auth-demo code { background: var(--surface-2); padding: .1rem .4rem; border-radius: 4px; }

/* ── FAB ────────────────────────────────────────────────────── */
.fab {
  display: none;
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 1.8rem; line-height: 1;
  align-items: center; justify-content: center;
  box-shadow: 0 4px 20px var(--primary)66;
  z-index: 300; transition: transform .15s;
  text-decoration: none;
}
.fab:hover { transform: scale(1.08); color: #fff; }

/* ── Utility ────────────────────────────────────────────────── */
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.muted    { color: var(--text-2); }
.small    { font-size: .78rem; }
.hidden   { display: none !important; }
.empty-state { color: var(--text-3); font-size: .875rem; text-align: center; padding: 1.5rem 0; }
.empty-state-lg {
  text-align: center; padding: 4rem 2rem;
  display: flex; flex-direction: column; align-items: center; gap: .75rem;
}
.empty-state-lg .empty-icon { font-size: 3rem; }
.empty-state-lg h3 { font-size: 1.15rem; }
.empty-state-lg p  { color: var(--text-2); }

/* ── Fatura nav (shared with category plan) ─────────────────── */
.fatura-nav { display:flex; gap:.4rem; overflow-x:auto; padding-bottom:.5rem; flex-wrap:wrap; }
.fatura-month-btn { padding:.35rem .85rem; border-radius:20px; font-size:.8rem; background:var(--surface); border:1px solid var(--border); color:var(--text-2); white-space:nowrap; transition:border-color .15s,color .15s; }
.fatura-month-btn:hover { border-color:var(--primary); color:var(--primary); }
.fatura-month-btn.active { background:var(--primary); border-color:var(--primary); color:#fff; font-weight:600; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .col-span-2 { grid-column: span 1; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .sidebar-overlay.visible { display: block; }

  .main-wrapper { margin-left: 0; }
  .menu-toggle { display: flex; }
  .quick-btn { display: none; }
  .fab { display: flex; }

  .main-content { padding: 1rem; }
  .cards-grid { grid-template-columns: 1fr 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3 { grid-column: span 1; }
  .form-grid-profile { grid-template-columns: 1fr; }
  .daily-banner-inner { flex-direction: column; align-items: flex-start; }
  .daily-amount { font-size: 1.5rem; }
  .recs-grid { grid-template-columns: 1fr; }
  .dreams-grid { grid-template-columns: 1fr; }
  .dream-hero-stats { gap: .5rem; }
  .cat-bar-label { min-width: 120px; }
  .filter-row { flex-direction: column; }
  .filter-row .field-inline { width: 100%; }
  .summary-bar { flex-direction: column; gap: .5rem; }

  .quick-title { font-size: 1.1rem; }
  .amount-input { font-size: 1.6rem !important; }

  .data-table th, .data-table td { padding: .6rem .75rem; }
  .form-row-inline { flex-direction: column; }
  .form-row-inline .field-inline { width: 100%; }
  .budget-item-row { flex-direction: column; align-items: stretch; }
  .budget-item-row > * { width: 100% !important; }
}

@media (max-width: 480px) {
  .cards-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .type-toggle { gap: .35rem; }
  .type-opt { padding: .5rem .5rem; font-size: .75rem; }
  .auth-card { padding: 1.5rem 1.25rem; }
}
