/* ============================================================================
   Augusta — Finanças. Sistema de design.
   UI de ferramenta (não documento): resumo antes do detalhe, estado em forma
   (chips/pills/cores semânticas), números como protagonistas (tabular-nums).
   Neutros quentes escolhidos; cores de dado herdadas dos PNGs e validadas
   (dataviz). Cor semântica (verde/vermelho/âmbar) separada do acento.
   ========================================================================== */
:root {
  /* neutros quentes */
  --paper: #faf9f6;
  --card: #ffffff;
  --card-2: #f5f4ef;
  --ink: #1a1917;
  --ink2: #57554e;
  --muted: #8f8d83;
  --line: #eceae3;
  --line2: #e1dfd6;
  --field: #ffffff;
  --btn-fg: #ffffff;
  /* dado (validado p/ daltonismo) */
  --azul: #2a78d6;
  --azul-soft: rgba(42, 120, 214, 0.26);
  --verde: #008300;
  --pos: #006b31;
  --neg: #d03b3b;
  --neg-soft: rgba(208, 59, 59, 0.15);
  /* semântico */
  --warn: #b0741a;
  --warn-bg: rgba(176, 116, 26, 0.12);
  --good-bg: rgba(0, 107, 49, 0.10);
  --neg-bg: rgba(208, 59, 59, 0.10);
  --info-bg: rgba(42, 120, 214, 0.10);
  /* efeitos */
  --shadow: 0 1px 2px rgba(26, 25, 23, 0.05), 0 1px 3px rgba(26, 25, 23, 0.04);
  --shadow-lg: 0 2px 6px rgba(26, 25, 23, 0.06), 0 12px 32px rgba(26, 25, 23, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --paper: #131210;
  --card: #1c1b18;
  --card-2: #24231e;
  --ink: #f4f2ec;
  --ink2: #b8b5ab;
  --muted: #8b887e;
  --line: #2a2823;
  --line2: #35332c;
  --field: #26251f;
  --btn-fg: #131210;
  --azul: #4a90db;
  --azul-soft: rgba(74, 144, 219, 0.32);
  --verde: #46a758;
  --pos: #54b869;
  --neg: #ef6b66;
  --neg-soft: rgba(239, 107, 102, 0.20);
  --warn: #e0a94a;
  --warn-bg: rgba(224, 169, 74, 0.15);
  --good-bg: rgba(84, 184, 105, 0.13);
  --neg-bg: rgba(239, 107, 102, 0.13);
  --info-bg: rgba(74, 144, 219, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.4), 0 14px 34px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.hidden { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }
h1, h2, h3 { text-wrap: balance; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--azul); outline-offset: 2px; border-radius: 6px; }

/* ---------- LOGIN ---------- */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 350px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 36px 26px; display: flex; flex-direction: column; gap: 14px;
}
.brand-mark { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; text-align: center; }
.login-sub { color: var(--muted); text-align: center; margin: -8px 0 10px; font-size: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--ink2); font-weight: 500; }
.login-card input {
  font-size: 16px; padding: 13px 14px; border: 1px solid var(--line2);
  border-radius: var(--radius-sm); background: var(--field); color: var(--ink);
}
.login-card input:focus { outline: 2px solid var(--azul); border-color: var(--azul); }
#login-btn {
  margin-top: 8px; padding: 14px; border: none; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--btn-fg); font-size: 16px; font-weight: 650; cursor: pointer;
  transition: transform 0.08s var(--ease), opacity 0.15s;
}
#login-btn:hover { opacity: 0.92; }
#login-btn:active { transform: translateY(1px); }
.login-erro { color: var(--neg); font-size: 13px; min-height: 18px; text-align: center; }

/* ---------- APP SHELL ---------- */
.app { max-width: 760px; margin: 0 auto; padding: 0 14px calc(48px + env(safe-area-inset-bottom)); }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 4px 12px; position: sticky; top: 0; z-index: 20;
  background: var(--paper); /* fallback p/ navegadores sem color-mix */
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}
.brand { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; display: flex; align-items: baseline; gap: 5px; }
.brand-dot { color: var(--azul); }
.brand-sub { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.quem { color: var(--muted); font-size: 13px; text-transform: capitalize; }
.linklike { background: none; border: none; color: var(--ink2); text-decoration: underline; cursor: pointer; font-size: 13px; padding: 0; }
.iconbtn {
  background: var(--card); border: 1px solid var(--line2); cursor: pointer; font-size: 15px;
  line-height: 1; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  transition: transform 0.15s var(--ease), background 0.15s;
}
.iconbtn:hover { background: var(--card-2); }
.iconbtn:active { transform: scale(0.94); }

/* ---------- CARDS ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 17px; margin-bottom: 14px;
}
.card-head { display: flex; align-items: baseline; gap: 9px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { font-size: 14px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.card-sub { color: var(--muted); font-size: 12.5px; }
.eyebrow { font-size: 11.5px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* ---------- SALDO STRIP ---------- */
.saldo-strip { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 18px; }
.saldo-main { display: flex; flex-direction: column; gap: 3px; margin-right: auto; }
.saldo-num { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.saldo-accounts { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 6px; background: var(--card-2);
  border: 1px solid var(--line2); border-radius: 999px; padding: 5px 12px; font-size: 12.5px;
}
.chip .nome { color: var(--ink2); text-transform: capitalize; }
.chip .val { font-weight: 650; font-variant-numeric: tabular-nums; }
.chip.padrao { border-color: color-mix(in srgb, var(--azul) 55%, var(--line2)); }

/* ---------- CONTROLS ---------- */
.controls { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 16px; }
.seg { display: inline-flex; background: var(--card-2); border: 1px solid var(--line2); border-radius: 13px; padding: 3px; gap: 2px; }
.seg-btn {
  border: none; background: none; color: var(--ink2); padding: 8px 15px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: color 0.18s, background 0.18s var(--ease);
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.periodo-presets { margin-bottom: 16px; }

/* nav de mês */
.mes-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.navbtn {
  width: 42px; height: 42px; border-radius: var(--radius-sm); border: 1px solid var(--line2);
  background: var(--card); color: var(--ink); font-size: 22px; cursor: pointer; line-height: 1;
  transition: background 0.15s, transform 0.1s var(--ease);
}
.navbtn:hover:not(:disabled) { background: var(--card-2); }
.navbtn:active:not(:disabled) { transform: scale(0.95); }
.navbtn:disabled { opacity: 0.35; cursor: default; }
.mes-sel {
  flex: 1; height: 42px; border-radius: var(--radius-sm); border: 1px solid var(--line2);
  background: var(--card); color: var(--ink); font-size: 15px; font-weight: 650;
  padding: 0 12px; text-align: center; text-align-last: center; cursor: pointer;
}

/* ---------- HERO ---------- */
.hero { position: relative; overflow: hidden; padding: 20px 18px 18px; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hero-num { font-size: clamp(2.1rem, 9vw, 2.7rem); font-weight: 820; letter-spacing: -0.03em; line-height: 1.05; margin: 8px 0 2px; font-variant-numeric: tabular-nums; }
.hero-num.pos { color: var(--pos); }
.hero-num.neg { color: var(--neg); }
.hero-take { color: var(--ink2); font-size: 14px; max-width: 46ch; }
.hero-take strong { color: var(--ink); font-weight: 700; }
.trend {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.trend.up { background: var(--neg-bg); color: var(--neg); }
.trend.down { background: var(--good-bg); color: var(--pos); }
.trend.flat { background: var(--card-2); color: var(--ink2); }

/* ---------- INSIGHTS ---------- */
.insights { display: flex; gap: 9px; overflow-x: auto; padding: 2px 2px 12px; margin: -4px 0 2px; scrollbar-width: none; }
.insights::-webkit-scrollbar { display: none; }
.insight {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px;
  border-radius: 12px; font-size: 12.8px; font-weight: 550; border: 1px solid transparent; line-height: 1.25;
}
.insight .dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; background: var(--muted); }
.insight .tx b { font-weight: 750; }
.insight.info { background: var(--info-bg); } .insight.info .dot { background: var(--azul); }
.insight.good { background: var(--good-bg); } .insight.good .dot { background: var(--pos); }
.insight.warn { background: var(--warn-bg); } .insight.warn .dot { background: var(--warn); }
.insight.neutral { background: var(--card-2); } .insight.neutral .dot { background: var(--muted); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; box-shadow: var(--shadow); }
.kpi .lbl { color: var(--ink2); font-size: 12px; font-weight: 500; }
.kpi .val { font-size: 21px; font-weight: 800; letter-spacing: -0.01em; margin-top: 3px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.kpi .val.pos { color: var(--pos); }
.kpi .val.neg { color: var(--neg); }

/* ---------- CHARTS ---------- */
.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.legenda { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 12px; font-size: 12.5px; color: var(--ink2); }
.legenda .item { display: inline-flex; align-items: center; gap: 6px; }
.legenda .swatch { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

/* ---------- POR TITULAR ---------- */
.titular-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.titular-box { border: 1px solid var(--line2); border-radius: var(--radius-sm); padding: 13px; background: var(--card-2); }
.titular-box .nome { font-weight: 700; text-transform: capitalize; margin-bottom: 7px; }
.titular-box .linha { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink2); margin-top: 2px; }
.titular-box .linha .v { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- LANÇAMENTOS ---------- */
.filter-pill {
  display: inline-flex; align-items: center; gap: 7px; margin-left: auto; background: var(--info-bg);
  border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 12.5px; color: var(--ink); font-weight: 600;
}
.filter-pill button { background: var(--card); border: none; border-radius: 50%; width: 20px; height: 20px; cursor: pointer; color: var(--ink2); font-size: 13px; line-height: 1; }
.lancs { display: flex; flex-direction: column; }
.lanc { display: grid; grid-template-columns: auto 1fr auto; gap: 11px; align-items: center; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.lanc:last-child { border-bottom: none; }
.lanc .dia { color: var(--muted); font-size: 12px; width: 42px; font-variant-numeric: tabular-nums; }
.lanc .desc { overflow: hidden; }
.lanc .desc .t { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; }
.lanc .desc .m { color: var(--muted); font-size: 12px; text-transform: capitalize; }
.lanc .cat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--azul); margin-right: 7px; flex: 0 0 auto; }
.lanc .vlr { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lanc .vlr.rec { color: var(--verde); }
.badge-titular { font-size: 10px; color: var(--muted); border: 1px solid var(--line2); border-radius: 6px; padding: 1px 6px; margin-left: 7px; text-transform: capitalize; }

.vazio { color: var(--muted); text-align: center; padding: 22px; font-size: 14px; }
.rodape { text-align: center; color: var(--muted); font-size: 12px; padding: 22px 0 6px; }

/* ---------- TOOLTIP ---------- */
.tooltip {
  position: fixed; z-index: 60; pointer-events: none; background: #201f1c; color: #fff;
  font-size: 12.5px; padding: 9px 11px; border-radius: 10px; box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
  max-width: 230px; line-height: 1.4;
}
.tooltip .tt-t { font-weight: 700; margin-bottom: 4px; }
.tooltip .tt-l { display: flex; justify-content: space-between; gap: 14px; }
.tooltip .tt-l .k { color: #cfcdc7; }

/* ---------- SVG classes ---------- */
.tick-label { fill: var(--muted); font-size: 11px; }
.cat-label { fill: var(--ink2); font-size: 12px; }
.bar-label { fill: var(--ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.bar-label.neg { fill: var(--neg); }
.bar-label.muted { fill: var(--muted); }
.gridline { stroke: var(--line); stroke-width: 1; }
.baseline { stroke: var(--line2); stroke-width: 1; }

/* ---------- ANIMAÇÕES ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.reveal { animation: fadeUp 0.5s var(--ease) both; }
#view-mes .reveal:nth-child(2) { animation-delay: 0.04s; }
#view-mes .reveal:nth-child(3) { animation-delay: 0.08s; }
#view-mes .reveal:nth-child(4) { animation-delay: 0.12s; }
#view-mes .reveal:nth-child(5) { animation-delay: 0.16s; }
#view-mes .reveal:nth-child(6) { animation-delay: 0.20s; }
#view-mes .reveal:nth-child(7) { animation-delay: 0.24s; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-delay: 0ms !important; transition-duration: 0.001ms !important; }
}

@media (min-width: 580px) {
  body { font-size: 15.5px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
}
