/* =========================================================
   Finanças · Bruno & Hellen
   ========================================================= */

:root {
  --bg: oklch(0.985 0.008 80);
  --bg-raised: oklch(1 0 0);
  --bg-sunken: oklch(0.965 0.01 80);
  --bg-hover: oklch(0.955 0.012 80);
  --border: oklch(0.92 0.008 80);
  --border-strong: oklch(0.86 0.012 80);
  --text: oklch(0.22 0.015 60);
  --text-dim: oklch(0.48 0.012 60);
  --text-mute: oklch(0.65 0.01 60);
  --c-moradia:       oklch(0.75 0.14 75);
  --c-mercado:       oklch(0.70 0.14 145);
  --c-restaurantes:  oklch(0.68 0.16 35);
  --c-transporte:    oklch(0.65 0.13 240);
  --c-saude:         oklch(0.65 0.15 340);
  --c-lazer:         oklch(0.65 0.15 290);
  --c-assinaturas:   oklch(0.65 0.11 220);
  --c-educacao:      oklch(0.70 0.13 60);
  --c-pets:          oklch(0.58 0.08 50);
  --c-utilidades:    oklch(0.70 0.11 135);
  --c-viagem:        oklch(0.70 0.11 190);
  --c-outros:        oklch(0.65 0.005 80);
  --income: oklch(0.60 0.14 145);
  --income-bg: oklch(0.96 0.04 145);
  --expense: oklch(0.55 0.16 25);
  --expense-bg: oklch(0.96 0.03 25);
  --accent: oklch(0.55 0.17 255);
  --accent-bg: oklch(0.96 0.04 255);
  --user-bruno: oklch(0.60 0.14 250);
  --user-bruno-bg: oklch(0.95 0.04 250);
  --user-hellen: oklch(0.70 0.12 15);
  --user-hellen-bg: oklch(0.95 0.03 15);
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px;
  --f-display: 'Instrument Serif', 'Iowan Old Style', 'Georgia', serif;
  --f-ui: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --shadow-sm: 0 1px 2px oklch(0.22 0.015 60 / 0.04), 0 1px 1px oklch(0.22 0.015 60 / 0.03);
  --shadow-md: 0 4px 12px oklch(0.22 0.015 60 / 0.06), 0 2px 4px oklch(0.22 0.015 60 / 0.04);
  --shadow-lg: 0 12px 32px oklch(0.22 0.015 60 / 0.10), 0 4px 8px oklch(0.22 0.015 60 / 0.05);
}
[data-density="compact"] {
  --s3: 8px; --s4: 12px; --s5: 16px; --s6: 20px; --s7: 32px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--f-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}
#root { min-height: 100vh; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ── APP SHELL ── */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-sunken);
  border-right: 1px solid var(--border);
  padding: var(--s5) var(--s4);
  display: flex; flex-direction: column; gap: var(--s5);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s3); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--c-moradia), var(--c-restaurantes));
  display: grid; place-items: center; color: white; font-weight: 600; font-size: 14px;
}
.brand-name { font-family: var(--f-display); font-size: 22px; letter-spacing: -0.01em; }
.user-switcher {
  padding: var(--s3); background: var(--bg-raised);
  border-radius: var(--r-md); border: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--s3);
  cursor: pointer; transition: border-color .15s;
}
.user-switcher:hover { border-color: var(--border-strong); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 600; font-size: 13px; color: white; flex-shrink: 0;
}
.avatar.bruno  { background: var(--user-bruno); }
.avatar.hellen { background: var(--user-hellen); }
.avatar.sm { width: 22px; height: 22px; font-size: 11px; }
.avatar.xs { width: 18px; height: 18px; font-size: 9px; }
.avatar.lg { width: 72px; height: 72px; font-size: 28px; }
.user-info { min-width: 0; flex: 1; }
.user-info .name { font-weight: 600; font-size: 13px; }
.user-info .role { font-size: 11px; color: var(--text-mute); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: var(--s3);
  padding: 10px var(--s3); border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500; color: var(--text-dim);
  text-align: left; width: 100%; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--bg-raised); color: var(--text); box-shadow: var(--shadow-sm); }
.sidebar-footer { margin-top: auto; padding-top: var(--s4); border-top: 1px solid var(--border); }
.main { padding: var(--s5) var(--s6); max-width: 1400px; width: 100%; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: var(--s6); gap: var(--s4); flex-wrap: wrap;
}
.page-title { font-family: var(--f-display); font-size: 42px; line-height: 1; letter-spacing: -0.02em; margin: 0; font-weight: 400; }
.page-subtitle { color: var(--text-dim); margin-top: var(--s2); font-size: 14px; }
.page-actions { display: flex; gap: var(--s3); align-items: center; }

/* ── CARDS ── */
.card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s5); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s4); gap: var(--s3); }
.card-title { font-size: 13px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; margin: 0; }
.card-title-lg { font-family: var(--f-display); font-size: 22px; font-weight: 400; color: var(--text); letter-spacing: -0.01em; margin: 0; text-transform: none; }

/* ── KPI CARDS ── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s4); margin-bottom: var(--s5); }
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s5);
  position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.06em; display: flex; align-items: center; gap: var(--s2); }
.kpi-dot { width: 8px; height: 8px; border-radius: 50%; }
.kpi-value { font-family: var(--f-display); font-size: 40px; line-height: 1.1; letter-spacing: -0.02em; font-weight: 400; margin-top: var(--s3); display: flex; align-items: baseline; gap: 4px; }
.kpi-value .currency { font-size: 18px; color: var(--text-mute); font-family: var(--f-ui); font-weight: 500; }
.kpi-value .cents { font-size: 22px; color: var(--text-dim); }
.kpi-meta { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s3); font-size: 12px; color: var(--text-dim); }
.delta { display: inline-flex; align-items: center; gap: 2px; padding: 2px 6px; border-radius: 4px; font-weight: 600; font-size: 11px; }
.delta.up   { color: var(--income);  background: var(--income-bg); }
.delta.down { color: var(--expense); background: var(--expense-bg); }
.kpi-spark { position: absolute; bottom: 0; right: 0; width: 120px; height: 44px; opacity: 0.9; }

/* ── TABLES ── */
.tx-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tx-table thead th {
  text-align: left; font-weight: 600; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: 0.05em; font-size: 11px;
  padding: var(--s3); border-bottom: 1px solid var(--border);
}
.tx-table tbody td { padding: var(--s3); border-bottom: 1px solid var(--border); vertical-align: middle; }
.tx-table tbody tr { transition: background .1s; }
.tx-table tbody tr:hover { background: var(--bg-hover); }
.tx-table tbody tr:last-child td { border-bottom: none; }
.tx-amount { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; white-space: nowrap; }
.tx-amount.income { color: var(--income); }
.tx-amount.expense { color: var(--text); }
.balance-cell { font-variant-numeric: tabular-nums; text-align: right; color: var(--text-dim); font-weight: 500; white-space: nowrap; }
.day-header td { background: var(--bg-sunken); font-weight: 600; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; padding: var(--s3) !important; }

/* Pills */
.tag-pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.tag-pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.shared-mark { display: inline-flex; align-items: center; gap: 2px; background: var(--bg-sunken); border: 1px solid var(--border); padding: 2px 6px 2px 3px; border-radius: 999px; font-size: 10px; color: var(--text-dim); font-weight: 500; }
.shared-mark .avatars { display: inline-flex; }
.shared-mark .avatars .avatar { border: 1.5px solid var(--bg-raised); }
.shared-mark .avatars .avatar + .avatar { margin-left: -5px; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: var(--s2); padding: 9px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; transition: background .12s, transform .08s, box-shadow .12s; border: 1px solid transparent; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { background: oklch(0.30 0.02 60); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-lg { padding: 12px 18px; font-size: 14px; border-radius: 12px; }
.chip-select { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 10px; }
.chip-select button { padding: 6px 12px; border-radius: 7px; font-size: 12px; font-weight: 500; color: var(--text-dim); }
.chip-select button.active { background: var(--bg-raised); color: var(--text); box-shadow: var(--shadow-sm); }

/* ── SEGMENTED ── */
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; background: var(--bg-sunken); border-radius: 12px; border: 1px solid var(--border); }
.segmented button { padding: 10px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-mute); display: flex; align-items: center; justify-content: center; gap: var(--s2); }
.segmented button.active-income  { background: var(--income-bg);  color: var(--income); }
.segmented button.active-expense { background: var(--expense-bg); color: var(--expense); }

/* ── FORM ── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s4); }
.field label { font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.input, .select { padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-raised); font-size: 14px; transition: border-color .12s, box-shadow .12s; width: 100%; }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.input-lg { font-family: var(--f-display); font-size: 40px; line-height: 1; letter-spacing: -0.02em; padding: var(--s3) 0; border: none; border-bottom: 2px solid var(--border); border-radius: 0; background: transparent; }
.input-lg:focus { outline: none; border-bottom-color: var(--accent); box-shadow: none; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.tag-picker { display: flex; flex-wrap: wrap; gap: var(--s2); }
.tag-option { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--bg-sunken); border: 1px solid var(--border); color: var(--text-dim); transition: all .12s; }
.tag-option:hover { border-color: var(--border-strong); }
.tag-option.selected { background: var(--bg-raised); border-color: currentColor; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: var(--s3) 0; border-top: 1px solid var(--border); }
.toggle { position: relative; width: 40px; height: 22px; background: var(--border-strong); border-radius: 999px; transition: background .15s; flex-shrink: 0; }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: white; transition: transform .15s; box-shadow: var(--shadow-sm); }
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(18px); }

/* ── MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: oklch(0.22 0.015 60 / 0.4); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 100; padding: var(--s4); animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--bg-raised); border-radius: var(--r-xl); padding: var(--s6); width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: slideUp .2s ease; }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── WELCOME ── */
.welcome { min-height: 100vh; display: grid; place-items: center; padding: var(--s6); background: radial-gradient(circle at 20% 20%, oklch(0.95 0.05 15 / 0.5), transparent 50%), radial-gradient(circle at 80% 70%, oklch(0.95 0.05 250 / 0.5), transparent 50%), var(--bg); }
.welcome-inner { text-align: center; max-width: 560px; }
.welcome h1 { font-family: var(--f-display); font-size: 72px; line-height: 0.95; letter-spacing: -0.03em; margin: 0 0 var(--s4); font-weight: 400; }
.welcome h1 em { font-style: italic; color: var(--c-restaurantes); }
.welcome .sub { font-size: 16px; color: var(--text-dim); margin-bottom: var(--s7); }
.user-picks { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.user-pick { padding: var(--s6) var(--s5); background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r-xl); display: flex; flex-direction: column; align-items: center; gap: var(--s4); transition: transform .15s, box-shadow .15s, border-color .15s; cursor: pointer; }
.user-pick:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.user-pick.bruno:hover  { border-color: var(--user-bruno); }
.user-pick.hellen:hover { border-color: var(--user-hellen); }
.user-pick .name { font-family: var(--f-display); font-size: 28px; letter-spacing: -0.01em; }
.user-pick .role { font-size: 12px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.06em; }

/* ── PROGRESS ── */
.progress { height: 8px; background: var(--bg-sunken); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--text); transition: width .3s; }
.goal-card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s5); position: relative; overflow: hidden; }
.goal-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.goal-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }

/* ── RESPONSIVE ── */
.mobile-nav  { display: none; }
.mobile-head { display: none; }
@media (max-width: 840px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: var(--s4) var(--s4) 100px; }
  .page-head { margin-bottom: var(--s5); }
  .page-title { font-size: 30px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: var(--s3); }
  .kpi { padding: var(--s4); }
  .kpi-value { font-size: 28px; }
  .kpi-spark { width: 80px; height: 32px; }
  .mobile-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s4); background: var(--bg-raised); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
  .mobile-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-raised); border-top: 1px solid var(--border); padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0)); z-index: 20; box-shadow: 0 -4px 16px oklch(0.22 0.015 60 / 0.06); }
  .mobile-nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 8px; font-size: 10px; font-weight: 500; color: var(--text-mute); }
  .mobile-nav-item.active { color: var(--text); }
  .mobile-nav-item.fab { background: var(--text); color: var(--bg); border-radius: 12px; transform: translateY(-8px); box-shadow: var(--shadow-md); }
  .welcome h1 { font-size: 44px; }
  .user-picks { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr !important; }
  .tx-table .col-tags { display: none; }
  .tx-table .col-date { display: none; }
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--s4); }

/* Density panel */
.tweak-panel { position: fixed; bottom: var(--s5); right: var(--s5); background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: var(--s4); z-index: 50; min-width: 240px; }
@media (max-width: 840px) { .tweak-panel { bottom: 80px; right: var(--s4); left: var(--s4); } }

/* Utility */
.hstack { display: flex; align-items: center; gap: var(--s3); }
.vstack { display: flex; flex-direction: column; gap: var(--s3); }
.spacer { flex: 1; }
.muted { color: var(--text-mute); }
.dim { color: var(--text-dim); }
.num { font-variant-numeric: tabular-nums; }
.display { font-family: var(--f-display); font-weight: 400; letter-spacing: -0.01em; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }
