/* ==========================================================================
   Tema oficial do painel: "Fintech limpo" sóbrio (v2, mockup em mockups/fintech-limpo-v2.html).
   Grafite + verde-petróleo + areia, fonte Inter, cartões macios, contraste AA (texto ≥ 4,5:1; barras ≥ 3:1).
   Carregado por último: sobrescreve variáveis e componentes de styles.css e finance.css.
   ========================================================================== */

:root {
  --color-bg: #f4f4f1;
  --color-surface: #ffffff;
  --color-border: #e6e6e0;
  --color-text: #14181b;
  --color-text-muted: #5d656a;
  --color-primary: #14575a;
  --color-primary-dark: #0e3e40;
  --color-primary-light: #e6f0ef;
  --color-accent: #a8853f;
  --color-danger: #a63c25;
  --color-danger-light: #f8e5df;
  --color-success: #2a7d5e;
  --ink: #14181b;
  --track: #e4e4de;
  --hover: #f4f4f0;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20, 24, 27, 0.04), 0 10px 28px -18px rgba(20, 60, 60, 0.25);
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sidebar-width: 236px;
}

body { font-family: var(--font-ui); background: var(--color-bg); color: var(--color-text); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
h1, h2, h3, h4 { font-family: var(--font-ui); letter-spacing: -0.015em; }
h2 { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; }
h3 { font-size: 16px; font-weight: 700; }
a { color: var(--color-primary); }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ----- Estrutura e menu ----- */
.sidebar { background: var(--color-surface); border-right: 1px solid var(--color-border); padding: 22px 14px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { display: grid; grid-template-columns: 34px 1fr; column-gap: 10px; align-items: center; font-weight: 800; font-size: 15px; letter-spacing: -0.02em; color: var(--ink); border-bottom: 0; padding: 0 8px 18px; margin-bottom: 0; }
.sidebar .brand::before { grid-row: span 2; content: ""; width: 34px; height: 34px; border-radius: 10px; background: url("../img/logo.svg") center / cover no-repeat; }
.sidebar .brand small { font-weight: 500; font-size: 11.5px; margin-top: 1px; letter-spacing: 0; }
.nav-sec { font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-muted); padding: 14px 10px 6px; list-style: none; }
.nav-btn { border-left: 0; margin: 1px 0; width: 100%; padding: 9px 10px; border-radius: 10px; font-size: 14px; font-weight: 500; color: #333b40; transition: background 0.15s, color 0.15s; }
.nav-btn:hover { background: var(--hover); }
.nav-btn.active { background: var(--color-primary-light); color: var(--color-primary-dark); font-weight: 650; border-left: 0; }
.nav-icon svg { width: 18px; height: 18px; }
.sidebar-bot { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--color-text-muted); padding: 12px 10px 4px; margin-top: 12px; border-top: 1px solid var(--color-border); }
.sidebar-bot b { width: 8px; height: 8px; border-radius: 50%; background: #9aa19c; flex: none; }
.sidebar-bot.ok b { background: var(--color-success); box-shadow: 0 0 0 4px #e2f1ea; }
.sidebar-bot.bad b { background: var(--color-danger); box-shadow: 0 0 0 4px var(--color-danger-light); }
.main-content { max-width: 1220px; padding: 28px 40px 80px; min-width: 0; }
.view-header { align-items: flex-end; margin-bottom: 22px; }
.view-header p.description, .fin-head .description { color: var(--color-text-muted); font-size: 14px; }
.view { animation: rise 0.3s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ----- Cartões e números ----- */
.card { border: 0; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; background: var(--color-surface); }
.fin-card-head { margin-bottom: 14px; }
.fin-card-head h3 { font-size: 16px; font-weight: 700; }
.fin-sub { color: var(--color-text-muted); font-size: 12.5px; }
.stat-grid { gap: 14px; }
.stat-card, .fin-stat { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 6px; border: 0; border-radius: var(--radius); background: var(--color-surface); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.stat-card .stat-label { font-size: 12.5px; font-weight: 600; color: var(--color-text-muted); text-transform: none; letter-spacing: 0; }
.stat-card .stat-value { font-weight: 800; font-size: 28px; letter-spacing: -0.035em; line-height: 1.15; color: var(--ink); overflow-wrap: anywhere; }
.fin-stat .fin-hint { order: -1; margin: 0; }
.fin-stat.tone-success, .fin-stat.tone-warning, .fin-stat.tone-danger { border-left: 0; }
.fin-stat.tone-success .fin-hint { color: var(--color-success); font-weight: 600; }
.fin-stat.tone-warning .fin-hint { color: #8a6214; font-weight: 600; }
.fin-stat.tone-danger .fin-hint { color: var(--color-danger); font-weight: 600; }
.stat-grid > .fin-stat:first-child { background: linear-gradient(145deg, #0e3436 0%, #14575a 70%); }
.stat-grid > .fin-stat:first-child .stat-value { color: #fff; }
.stat-grid > .fin-stat:first-child .stat-label, .stat-grid > .fin-stat:first-child .fin-hint { color: rgba(255, 255, 255, 0.85); }
.fin-spark { display: block; width: 100%; height: 26px; order: -2; margin-top: 2px; }

/* ----- Resumo do mês em frase ----- */
.fin-insight { display: flex; gap: 16px; align-items: flex-start; background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 22px; border-left: 4px solid var(--color-primary); }
.fin-insight p { margin: 0; font-size: 15px; line-height: 1.6; }
.fin-insight strong { color: var(--color-primary-dark); }
.fin-insight .btn { margin-left: auto; white-space: nowrap; }

/* ----- Abas e mês ----- */
.fin-head h2 { font-size: 28px; }
.fin-month { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 999px; padding: 4px; }
.fin-month .btn { border-radius: 999px; border: 0; background: none; color: var(--ink); width: 32px; height: 32px; padding: 0; }
.fin-month .btn:hover { background: var(--hover); }
.fin-month-label { font-size: 14px; font-weight: 700; }
.fin-tabs { border-bottom: 1px solid var(--color-border); gap: 18px; margin: 14px 0 22px; align-items: center; }
.fin-tabgroup { display: flex; align-items: center; gap: 2px; }
.fin-tabgroup-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-muted); margin-right: 6px; white-space: nowrap; }
.fin-tab { font-weight: 600; font-size: 13.5px; padding: 12px 10px; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--color-text-muted); }
.fin-tab:hover { color: var(--ink); }
.fin-tab.active { color: var(--ink); border-bottom-color: var(--color-primary); font-weight: 650; }

/* ----- Formulários e botões ----- */
input[type="text"], input[type="number"], input[type="email"], input[type="search"], input[type="date"], input[type="password"], select, textarea,
.fin-panel input[type="number"], .fin-panel input[type="text"], .fin-panel input[type="date"], .fin-panel input[type="search"], .fin-panel select, .fin-panel textarea,
.table-toolbar select, .table-toolbar input { border: 1px solid #d6d6ce; border-radius: 12px; padding: 9px 12px; font-family: var(--font-ui); background: #fff; color: var(--ink); transition: border-color 0.15s, box-shadow 0.15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(20, 87, 90, 0.15); }
label { font-weight: 600; font-size: 12.5px; color: #3a4246; }
.btn { background: var(--color-primary); color: #fff; border: 1px solid var(--color-primary); border-radius: 10px; font-weight: 600; font-family: var(--font-ui); padding: 9px 16px; transition: background 0.15s, border-color 0.15s, transform 0.1s; }
.btn:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }
.btn:active { transform: translateY(1px); }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: #f8f8f5; border-color: #cfcfc7; }
.btn-danger { background: var(--color-danger); border-color: var(--color-danger); }
.btn-danger:hover { background: #87301d; border-color: #87301d; }
.btn-small { padding: 6px 12px; font-size: 13px; }

/* ----- Tabelas, etiquetas, alertas ----- */
.table-wrap { border: 0; border-radius: 0; }
thead th { background: transparent; font-size: 12px; font-weight: 650; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); padding: 10px 12px; text-transform: none; letter-spacing: 0; }
tbody td { padding: 12px; border-bottom: 1px solid var(--color-border); }
tbody tr:hover { background: #fafaf7; }
.badge { border-radius: 999px; font-weight: 650; font-size: 11.5px; padding: 3px 10px; }
.badge-neutral { background: #efefea; color: #4c5458; }
.badge-success { background: #e2f1ea; color: #1f6b4e; }
.badge-warning { background: #f7ecd4; color: #7a5712; }
.badge-danger { background: var(--color-danger-light); color: #8f2f1a; }
.badge-info { background: var(--color-primary-light); color: var(--color-primary-dark); }
.alert { border-radius: 14px; border: 1px solid transparent; }
.alert-info { background: #eef3f3; border-color: #dbe7e6; color: #1e4a4c; }
.alert-success { background: #e8f3ee; border-color: #cfe6da; color: #1f6b4e; }
.alert-error { background: #fbece7; border-color: #f1d3c9; color: #8f2f1a; }
.empty-state { border: 1px dashed #d6d6ce; border-radius: 14px; background: transparent; color: var(--color-text-muted); }

/* ----- Indicadores, progresso, calendário, chat ----- */
.fin-progress { height: 10px; background: var(--track); border-radius: 999px; }
.fin-progress-bar { background: var(--color-primary); border-radius: 999px; }
.fin-progress-bar.tone-warn { background: var(--color-accent); }
.fin-progress-bar.tone-bad { background: var(--color-danger); }
.fin-indicator { border-bottom-color: var(--color-border); }
.fin-goal, .fin-step { border-radius: 14px; border-color: var(--color-border); box-shadow: none; }
.fin-step.done { background: var(--color-primary-light); border-color: #bcd6d4; }
.level-1 { background: #e6f0ef; } .level-2 { background: #bcd6d4; } .level-3 { background: #6fa8a3; } .level-4 { background: #14575a; color: #fff; }
.level-4 .fin-cal-num { color: #e6f0ef; }
.fin-cal-day { border-radius: 12px; border-color: var(--color-border); transition: transform 0.1s, box-shadow 0.15s; }
.fin-cal-day:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.fin-cal-day.selected { outline: 2px solid var(--ink); }
.fin-cal-due { background: var(--color-accent); }
.fin-save { color: var(--color-primary); }
.fin-chat { background: #fafaf7; border-color: var(--color-border); border-radius: 14px; }
.fin-msg.user { background: var(--color-primary-light); }
.fin-toast { background: var(--ink); border-radius: 12px; }

/* ----- Lista de despesas, filtros, links ----- */
.fin-link { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: #c9c9c0; text-underline-offset: 3px; display: inline-flex; align-items: center; gap: 4px; }
.fin-link:hover { color: var(--color-primary); text-decoration-color: var(--color-primary); }
.fin-legend-btn { background: none; border: 0; border-bottom: 1px solid var(--color-border); width: 100%; font: inherit; color: inherit; cursor: pointer; text-align: left; border-radius: 8px; transition: background 0.15s; }
.fin-legend-btn:hover { background: var(--hover); }
.fin-eyebrow { font-size: 12px; font-weight: 650; color: var(--color-text-muted); margin: 0 0 4px; }
.fin-explist-card { scroll-margin-top: 16px; }
.fin-explist-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.fin-explist-bar input { max-width: 260px; }
.fin-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
.fin-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--ink); color: #fff; border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 12.5px; font-weight: 600; }
.fin-chip button { background: rgba(255, 255, 255, 0.2); color: #fff; border: 0; border-radius: 50%; width: 20px; height: 20px; cursor: pointer; line-height: 1; font-size: 14px; }
.fin-chip button:hover { background: rgba(255, 255, 255, 0.35); }
.fin-explist-sum { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--color-border); font-size: 13px; color: var(--color-text-muted); }
.fin-explist-sum strong { color: var(--color-text-muted); font-weight: 500; }
.fin-explist-sum span { font-size: 15px; font-weight: 800; color: var(--ink); }
.fin-exp-list { display: flex; flex-direction: column; margin-bottom: 12px; }
.fin-exp-day { font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-muted); padding: 14px 0 2px; }
.fin-exp-row { display: grid; grid-template-columns: 40px 1fr auto 140px; gap: 14px; align-items: center; padding: 10px 0; }
.fin-exp-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.fin-exp-main strong { font-weight: 600; font-size: 14.5px; }
.fin-exp-meta { font-size: 12.5px; color: var(--color-text-muted); margin-top: 1px; }
.fin-exp-amount { font-weight: 700; text-align: right; }
.fin-exp-action { text-align: right; }

/* ----- Pop-up ----- */
.fin-modal-back { position: fixed; inset: 0; background: rgba(20, 24, 27, 0.5); backdrop-filter: blur(3px); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade 0.15s ease both; }
.fin-modal { background: var(--color-surface); border-radius: 22px; width: min(540px, 100%); max-height: min(92vh, 720px); display: flex; flex-direction: column; box-shadow: 0 40px 90px -30px rgba(10, 40, 40, 0.55); animation: rise 0.25s ease both; overflow: hidden; }
.fin-modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 22px 24px 12px; flex: none; }
.fin-modal-head h3 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 2px; }
.fin-modal-x { background: #efefea; border: 0; width: 32px; height: 32px; border-radius: 50%; font-size: 18px; line-height: 1; cursor: pointer; color: var(--ink); }
.fin-modal-x:hover { background: #e4e4de; }
.fin-modal-body { overflow-y: auto; padding: 8px 24px 6px; flex: 1 1 auto; }
.fin-modal-body .form-group { margin-bottom: 12px; }
.fin-modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.fin-modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 24px 20px; flex: none; border-top: 1px solid var(--color-border); }
.fin-modal-foot .fin-status { margin-right: auto; font-size: 12.5px; }

/* ----- Login ----- */
.login-page { background: radial-gradient(900px 480px at 85% -10%, #dcebea 0%, transparent 60%), var(--color-bg); }
.login-card { border: 0; border-radius: 24px; box-shadow: var(--shadow); padding: 44px 40px; }
.login-card h1 { font-weight: 800; font-size: 26px; letter-spacing: -0.03em; }
.login-card .logo { width: 56px; height: 56px; margin: 0 auto 18px; }
.login-card .logo img { display: block; width: 56px; height: 56px; border-radius: 15px; box-shadow: 0 10px 24px -12px rgba(20, 87, 90, 0.6); }
.login-card .logo svg { width: 24px; height: 24px; stroke: #fff; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-google { border-radius: 12px; font-weight: 600; font-family: var(--font-ui); }

/* ----- Reativar o WhatsApp ----- */
.pairing-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.pairing-wrap { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; margin-top: 14px; }
.pairing-qr { border: 1px solid var(--color-border); border-radius: 16px; padding: 12px; background: #fff; box-shadow: var(--shadow); image-rendering: pixelated; }
.pairing-steps { margin: 0 0 12px; padding-left: 20px; line-height: 1.7; }

/* ----- Navegação inferior (celular) ----- */
.tabbar { display: none; }

@media (max-width: 1080px) { .main-content { padding: 24px 24px 80px; } }
@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  /* menu completo pelo "Mais": desfaz a barra horizontal antiga de styles.css */
  body.nav-open .sidebar { display: flex; flex-direction: column; align-items: stretch; position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100%; z-index: 70; padding: 22px 14px 14px; overflow-x: hidden; overflow-y: auto; border-right: 1px solid var(--color-border); border-bottom: 0; box-shadow: 0 0 0 100vmax rgba(20, 24, 27, 0.45); animation: fade 0.15s ease both; }
  body.nav-open .sidebar .brand { display: grid; }
  .nav-list { display: block; }
  .nav-btn, .nav-btn.active { border-bottom: 0; padding: 10px; white-space: normal; }
  .main-content { padding: 18px 16px 96px; max-width: none; }
  h2, .fin-head h2 { font-size: 24px; }
  .fin-tabgroup-label { display: none; }
  .fin-tabs { gap: 6px; }
  .fin-insight { flex-direction: column; }
  .fin-insight .btn { margin-left: 0; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card .stat-value { font-size: clamp(19px, 5.6vw, 24px); }
  .stat-card, .fin-stat { padding: 14px; }
  .fin-spark { display: none; }
  .card { padding: 16px; }
  .fin-exp-row { grid-template-columns: 40px 1fr auto; }
  .fin-exp-action { grid-column: 2 / -1; text-align: left; }
  .fin-modal-grid { grid-template-columns: 1fr; }
  .pairing-wrap { grid-template-columns: 1fr; justify-items: center; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(8px); border-top: 1px solid var(--color-border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar button { border: 0; background: none; display: grid; justify-items: center; gap: 2px; font: 600 11px var(--font-ui); color: var(--color-text-muted); padding: 6px 0; cursor: pointer; }
  .tabbar button.active { color: var(--color-primary); }
  .tabbar svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
}
@media (max-width: 360px) { .stat-grid { grid-template-columns: minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* A barra inferior só existe com o painel aberto (não na tela de carregamento nem no cadastro da família). */
.app-shell.hidden ~ .tabbar { display: none !important; }

/* Slogan (login e menu) */
.login-slogan { color: var(--color-primary); font-weight: 650; font-size: 14px; margin: -6px 0 12px; }
.sidebar .brand small { display: block; color: var(--color-text-muted); }

/* Marca no menu: ícone alinhado ao topo; "App Família" / nome da família / slogan em linhas próprias. */
.sidebar .brand { align-items: start; row-gap: 2px; line-height: 1.2; }
.sidebar .brand::before { align-self: start; margin-top: 1px; }
.sidebar .brand #brand-name { font-size: 15px; font-weight: 800; letter-spacing: -0.02em; }
.sidebar .brand .brand-family { display: block; font-weight: 700; color: var(--color-primary); overflow-wrap: anywhere; }
.sidebar .brand small { font-size: 11.5px; line-height: 1.35; margin-top: 3px; }
.sidebar .brand::before { grid-row: 1; }
.sidebar .brand small { grid-column: 1 / -1; margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
