﻿/* ---------- Tema ---------- */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f1f2f5;
  --border: #e3e5ea;
  --text: #161a26;
  --text-soft: #3f4557;
  --muted: #6b7183;
  --brand: #5138ed;
  --brand-hover: #4329d8;
  --brand-tint: #eeebff;
  --on-brand: #ffffff;
  --income: #13805a;
  --expense: #c43c2c;
  --left-over: #cfe9dc;
  --danger-bg: #fcefed;
  --shadow: 0 1px 2px #161a260a;
  --overlay: #10131c80;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1117;
  --surface: #171a22;
  --surface-2: #1f232d;
  --border: #2a2f3b;
  --text: #e9ebf2;
  --text-soft: #c1c5d2;
  --muted: #8d93a6;
  --brand: #6a57ff;
  --brand-hover: #7b6bff;
  --brand-tint: #262248;
  --on-brand: #ffffff;
  --income: #3cc48f;
  --expense: #ff7b68;
  --left-over: #1e4a39;
  --danger-bg: #3a1d1b;
  --shadow: none;
  --overlay: #000000a6;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
button, input, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }
.auth-checking body { visibility: hidden; }
body:has(dialog[open]) { overflow: hidden; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.muted { color: var(--muted); }
.empty-state { padding: 16px 0; color: var(--muted); font-size: 14px; }
.storage-message, .form-error, .auth-error { padding: 10px 12px; border-radius: 8px; background: var(--danger-bg); color: var(--expense); font-size: 13.5px; line-height: 1.5; }
.storage-message { margin-bottom: 12px; }
.income-amount { color: var(--income); }

/* ---------- Barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1200px; height: 56px; margin: 0 auto; padding: 0 16px; }
.brand { font-size: 19px; font-weight: 800; letter-spacing: -.6px; }
.brand > span { color: var(--brand); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-button { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text-soft); }
.icon-button .icon { width: 18px; height: 18px; }
.icon-sun, [data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
#logout { height: 40px; padding: 0 14px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text-soft); font-size: 14px; font-weight: 500; }
#logout:disabled { cursor: wait; opacity: .6; }

/* ---------- Estrutura ---------- */
.dashboard { max-width: 1200px; margin: 0 auto; padding: 16px 16px 40px; }
.panel { min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.layout, .sidebar { display: grid; gap: 12px; align-content: start; }
.layout { margin-top: 12px; }
h2 { font-size: 16px; font-weight: 650; letter-spacing: -.1px; }

/* ---------- Resumo do mês (topo) ---------- */
.overview { display: grid; grid-template-areas: "month" "kpis" "bar" "caption" "action"; align-items: center; }
.month-selector { grid-area: month; justify-self: start; }
.month-selector, .period-selector { display: flex; align-items: center; margin-left: -8px; }
.month-selector button, .period-selector button { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text-soft); font-size: 22px; line-height: 1; }
.month-selector p, .period-selector p { min-width: 9.5em; text-align: center; font-size: 14px; font-weight: 600; white-space: nowrap; }
.kpis { grid-area: kpis; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.kpi-balance { grid-column: 1 / -1; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.kpi h1, .kpi h2, .total p { font-size: 13px; font-weight: 500; color: var(--muted); }
.balance-value { margin-top: 2px; font-size: 30px; font-weight: 650; line-height: 1.15; letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.balance-value .currency { margin-right: .15em; font-size: .6em; font-weight: 600; letter-spacing: 0; color: var(--text-soft); }
.balance-value .cents { font-size: .6em; color: var(--muted); }
.balance-value.is-negative, .balance-value.is-negative .currency, .balance-value.is-negative .cents { color: var(--expense); }
.total strong { display: block; margin-top: 2px; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
/* A régua do mês: cada trecho é uma categoria de despesa; o verde-claro é o que sobrou. */
.month-bar { grid-area: bar; display: flex; gap: 2px; height: 8px; margin-top: 16px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.month-bar:not(:empty) { background: transparent; }
.month-bar span { flex: 0 1 0; min-width: 3px; }
.month-bar .month-bar-left { background: var(--left-over); }
.month-bar-caption { grid-area: caption; min-height: 1.4em; margin-top: 8px; font-size: 13px; color: var(--muted); }
.new-transaction { grid-area: action; display: flex; align-items: center; justify-content: center; gap: 8px; height: 44px; margin-top: 14px; padding: 0 18px; border: 0; border-radius: 8px; background: var(--brand); color: var(--on-brand); font-size: 14.5px; font-weight: 600; }
.new-transaction > span { font-size: 20px; font-weight: 400; line-height: 1; }
.new-transaction:disabled { cursor: wait; opacity: .6; }

/* ---------- Movimentações ---------- */
.transactions-tools { display: grid; gap: 10px; margin-top: 12px; }
.search-preview { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--muted); }
.search-preview .icon { width: 18px; height: 18px; }
.search-preview input { width: 100%; min-width: 0; height: 40px; border: 0; background: transparent; font-size: 16px; }
.search-preview input:focus-visible { outline: 0; }
.search-preview:focus-within { outline: 2px solid var(--brand); outline-offset: 1px; }
.search-preview input::placeholder { color: var(--muted); opacity: 1; }
.transaction-filters { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; border-radius: 8px; background: var(--surface-2); }
.transaction-filters button { height: 36px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 13.5px; font-weight: 500; }
.transaction-filters button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px #0000001a; }
[data-theme="dark"] .transaction-filters button[aria-pressed="true"] { background: var(--border); }
.date-group { margin-top: 14px; }
.date-group h3 { padding: 5px 10px; border-radius: 6px; background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--muted); }
.transaction-list li { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 56px; padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: pointer; }
.transaction-list li:last-child { border-bottom: 0; }
.transaction-list li:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; border-radius: 8px; }
.transaction-icon { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); color: var(--text-soft); }
.transaction-icon::after { content: ''; position: absolute; right: 0; bottom: 0; width: 9px; height: 9px; border: 2px solid var(--surface); border-radius: 50%; background: var(--category, var(--muted)); }
.transaction-icon .icon { width: 18px; height: 18px; }
.transaction-description { min-width: 0; }
.transaction-description h4 { overflow: hidden; font-size: 14.5px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.transaction-description p { font-size: 13px; color: var(--muted); }
.transaction-list strong { font-size: 14.5px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.more-transactions { width: 100%; height: 40px; margin-top: 10px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--text-soft); font-size: 14px; font-weight: 500; }

/* ---------- Categorias ---------- */
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chart-total { margin-top: 2px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-total:empty { display: none; }
.categories { margin-top: 10px; }
.categories li { display: grid; grid-template-columns: minmax(0, 1fr) auto 2.8em; align-items: baseline; gap: 5px 10px; padding: 7px 0; }
.category-name { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.categories strong { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.categories small { font-size: 12.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.category-bar { grid-column: 1 / -1; display: block; height: 4px; border-radius: 2px; background: var(--surface-2); }
.category-bar i { display: block; height: 100%; min-width: 3px; border-radius: 2px; background: var(--category); }
.categories .empty-state { display: block; }

/* ---------- Resumo do mês ---------- */
.insights { display: grid; grid-template-columns: 1fr 1fr; margin-top: 10px; border: 1px solid var(--border); border-radius: 8px; }
.insight { min-width: 0; padding: 10px 12px; }
.insight:nth-child(odd) { border-right: 1px solid var(--border); }
.insight:nth-child(n + 3) { border-top: 1px solid var(--border); }
.insight h3 { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.insight strong { display: block; margin-top: 2px; font-size: 14.5px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.insight p { font-size: 12.5px; color: var(--text-soft); }
.insight p.muted { color: var(--muted); }

/* ---------- Abas: Mês, Ano e Simular ---------- */
.view-tabs { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 12px; padding: 3px; border-radius: 8px; background: var(--surface-2); }
.view-tabs button { height: 36px; padding: 0 18px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; }
.view-tabs button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px #0000001a; }
[data-theme="dark"] .view-tabs button[aria-pressed="true"] { background: var(--border); }
.panel-hint { margin-top: 2px; font-size: 13px; color: var(--muted); }

/* ---------- Relatório do ano ---------- */
.year-overview .kpis { margin-top: 12px; }
.period-selector p { min-width: 4em; }
/* --zero (definido pelo JavaScript) é a altura da linha do zero dentro do gráfico. */
.year-chart { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; margin-top: 14px; }
.year-column { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; padding: 0; border: 0; border-radius: 6px; background: transparent; }
.year-column:disabled { cursor: default; }
.year-column-area { position: relative; width: 100%; height: 140px; }
.year-column-area::after { content: ''; position: absolute; top: var(--zero); left: -2px; right: -2px; border-top: 1px solid var(--border); }
.year-column-area i { position: absolute; bottom: calc(100% - var(--zero)); left: 18%; right: 18%; min-height: 2px; border-radius: 3px 3px 0 0; background: var(--income); }
.year-column.is-negative .year-column-area i { top: var(--zero); bottom: auto; border-radius: 0 0 3px 3px; background: var(--expense); }
.year-column:disabled .year-column-area i { display: none; }
.year-column-label { font-size: 11.5px; color: var(--muted); }
.year-column:disabled .year-column-label { opacity: .55; }
.year-column:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Tabelas (mês a mês e evolução) ---------- */
.table-scroll { overflow-x: auto; margin-top: 8px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 9px 4px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.data-table th:first-child { padding-left: 0; text-align: left; }
.data-table td:last-child { padding-right: 0; font-weight: 600; }
.data-table thead th { font-size: 12px; font-weight: 500; color: var(--muted); }
.data-table tbody th { font-weight: 600; }
.data-table tfoot th, .data-table tfoot td { border-bottom: 0; border-top: 2px solid var(--border); font-weight: 650; }
.data-table .is-negative { color: var(--expense); }
.data-table tr.is-empty th, .data-table tr.is-empty td { color: var(--muted); font-weight: 400; }
.data-table tbody tr[data-month] { cursor: pointer; }
.link-button { padding: 0; border: 0; background: transparent; font-weight: 600; text-align: left; }

/* ---------- Simulador ---------- */
.simulator-form .form-columns { margin-top: 0; }
.simulator-result .balance-value { margin-top: 8px; }
.simulator-result .month-bar { margin-top: 14px; }
.sim-bar-invested { background: var(--brand); }
.sim-bar-earnings { background: var(--income); }
.sim-kpis { grid-template-columns: 1fr 1fr; margin-top: 14px; }
.legend-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; vertical-align: 1px; }
.legend-dot.invested { background: var(--brand); }
.legend-dot.earnings { background: var(--income); }
#sim-yearly { margin-top: 16px; }
.disclaimer { margin-top: 16px; font-size: 12.5px; color: var(--muted); }

/* ---------- Movimentações fixas e cadastro rápido ---------- */
.recurring-badge { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 4px; background: var(--brand-tint); color: var(--brand); font-size: 11.5px; font-weight: 600; line-height: 18px; vertical-align: 1px; }
[data-theme="dark"] .recurring-badge { color: var(--brand-hover); }
.projected { margin-top: 18px; }
.projected h3 { padding: 5px 10px; border-radius: 6px; background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--muted); }
.projected .panel-hint { margin: 6px 0 2px; }
.transaction-list li.is-projected { cursor: default; opacity: .72; }
.transaction-list li.is-projected:hover { background: transparent; }
.suggestion-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.suggestion-chips button { max-width: 100%; height: 32px; padding: 0 12px; overflow: hidden; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--text-soft); font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
#category-hint { color: var(--brand); }
[data-theme="dark"] #category-hint { color: var(--brand-hover); }

/* Interruptor "Repetir todo mês" no formulário */
#transaction-form .switch-field { position: relative; display: flex; align-items: center; gap: 12px; margin: 16px 0 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-weight: 500; cursor: pointer; }
#transaction-form .switch-field input { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; }
.switch { position: relative; flex-shrink: 0; width: 38px; height: 22px; border-radius: 11px; background: var(--border); transition: background-color .15s ease; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px #00000033; transition: transform .15s ease; }
.switch-field input:checked + .switch { background: var(--brand); }
.switch-field input:checked + .switch::after { transform: translateX(16px); }
.switch-field input:focus-visible + .switch { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch-text { font-size: 14px; }
.switch-text small { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); }

/* ---------- Modal de movimentação ---------- */
/* O dialog ocupa só a área visível (no iPhone, acima do teclado; ver fitModalToVisibleArea);
   o formulário é a "gaveta" que sobe de baixo no celular e o cartão central no computador. */
#transaction-modal { position: fixed; inset: auto; top: var(--visible-top, 0px); left: 0; width: 100%; max-width: none; height: var(--visible-height, 100%); max-height: none; margin: 0; padding: 0; border: 0; background: transparent; color: var(--text); overflow: visible; }
#transaction-modal[open] { display: flex; align-items: flex-end; justify-content: center; }
#transaction-modal::backdrop { background: var(--overlay); }
#transaction-form { width: 100%; max-height: calc(100% - 40px + var(--covered-bottom, 0px)); margin-bottom: calc(-1 * var(--covered-bottom, 0px)); overflow-y: auto; overscroll-behavior: contain; padding: 20px 16px calc(20px + var(--covered-bottom, 0px)); border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; background: var(--surface); box-shadow: 0 -12px 40px #00000026; }
.modal-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.modal-heading h2 { font-size: 18px; }
.close-modal { width: 36px; height: 36px; margin-right: -6px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; }
#transaction-form label, .simulator-form label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 600; color: var(--text-soft); }
#transaction-form input, .simulator-form input { display: block; width: 100%; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 16px; color: var(--text); }
#transaction-form #transaction-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
#amount-hint, .field-hint { display: block; margin-top: 5px; color: var(--muted); font-size: 12.5px; }
.form-columns { display: grid; gap: 0 12px; }
.form-columns > div { min-width: 0; }
.form-error { margin-top: 14px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-actions button { height: 42px; padding: 0 16px; border: 1px solid transparent; border-radius: 8px; font-size: 14px; font-weight: 600; }
.cancel-modal { border-color: var(--border) !important; background: transparent; color: var(--text-soft); }
.save-transaction { background: var(--brand); color: var(--on-brand); }
#delete-transaction { margin-right: auto; background: var(--danger-bg); color: var(--expense); }
#transaction-form [disabled] { cursor: wait; opacity: .65; }

/* ---------- Select e calendário próprios ---------- */
.select-control { position: relative; min-width: 0; }
.select-compact { flex-shrink: 0; }
/* Telas de toque usam os selects e o calendário nativos do sistema (ver usesCustomControls em script.js). */
select { -webkit-appearance: none; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) calc(50% + 1px), calc(100% - 13px) calc(50% + 1px); background-size: 5px 5px; background-repeat: no-repeat; }
#transaction-form select, .simulator-form select { display: block; width: 100%; min-width: 0; height: 44px; padding: 0 36px 0 12px; border: 1px solid var(--border); border-radius: 8px; background-color: var(--surface); font-size: 16px; color: var(--text); }
.expense-selector { height: 36px; padding: 0 32px 0 12px; border: 1px solid var(--border); border-radius: 8px; background-color: var(--surface); color: var(--text-soft); font-size: 16px; font-weight: 500; }
input[type="date"] { -webkit-appearance: none; appearance: none; min-width: 0; line-height: 42px; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { margin: 0; text-align: left; }
.search-preview input { -webkit-appearance: none; appearance: none; }
.search-preview input::-webkit-search-decoration { -webkit-appearance: none; }
select.native-select, #transaction-form select.native-select { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; pointer-events: none; }
.select-trigger { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 16px; text-align: left; }
.select-trigger::after { content: ''; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); color: var(--muted); flex-shrink: 0; }
.select-trigger[aria-expanded="true"] { border-color: var(--brand); }
.select-trigger[aria-expanded="true"]::after { transform: rotate(225deg) translate(-2px, -1px); color: var(--brand); }
.select-compact .select-trigger { height: 34px; gap: 10px; padding: 0 10px; font-size: 13px; font-weight: 500; color: var(--text-soft); }
.control-menu { position: fixed; inset: auto; margin: 0; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); box-shadow: 0 10px 28px #00000026; overflow: auto; overscroll-behavior: contain; font-family: inherit; }
.control-menu::backdrop { background: transparent; }
.select-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; padding: 8px 10px; border-radius: 6px; font-size: 14px; cursor: pointer; }
.select-option[aria-selected="true"] { color: var(--brand); font-weight: 600; }
[data-theme="dark"] .select-option[aria-selected="true"] { color: var(--brand-hover); }
.select-option[aria-selected="true"]::after { content: '✓'; }
.select-option.is-active { background: var(--surface-2); }
.date-control { position: relative; }
#transaction-form .date-control input { padding-right: 44px; font-variant-numeric: tabular-nums; }
.date-control input::-webkit-calendar-picker-indicator { display: none; }
.date-control input::-webkit-datetime-edit { padding: 0; }
.date-trigger { position: absolute; top: 1px; right: 1px; display: grid; place-items: center; width: 42px; height: calc(100% - 2px); border: 0; border-radius: 0 7px 7px 0; background: transparent; color: var(--muted); }
.date-trigger .icon { width: 18px; height: 18px; }
.date-trigger[aria-expanded="true"] { color: var(--brand); }
.date-menu { padding: 10px; }
.date-menu-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.date-menu-heading strong { font-size: 14px; font-weight: 600; text-transform: capitalize; }
.date-menu-heading button { width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text-soft); font-size: 20px; }
.calendar-weekdays, .calendar-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.calendar-weekdays span { padding: 6px 0; text-align: center; font-size: 12px; color: var(--muted); }
.calendar-days button { min-height: 36px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.calendar-days button[aria-current="date"] { border-color: var(--border); font-weight: 700; }
.calendar-days button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }
.calendar-days button:disabled, .date-menu-heading button:disabled { opacity: .35; cursor: default; }

/* ---------- Login e nova senha ---------- */
.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 32px 16px; }
.auth-shell { width: 100%; max-width: 400px; }
.auth-brand { margin-bottom: 20px; text-align: center; }
.auth-brand .brand { font-size: 24px; }
.auth-card { padding: 24px 20px 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.auth-intro h1 { font-size: 21px; font-weight: 650; line-height: 1.3; letter-spacing: -.3px; }
.auth-intro p { margin-top: 6px; color: var(--muted); font-size: 14px; }
.auth-fields label { display: block; margin: 16px 0 6px; font-size: 13px; font-weight: 600; color: var(--text-soft); }
.auth-fields input { display: block; width: 100%; min-width: 0; height: 46px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 16px; }
.auth-fields input::placeholder { color: var(--muted); opacity: 1; }
.auth-recovery { display: flex; justify-content: flex-end; margin: 2px 0 10px; }
.auth-link { min-height: 40px; padding: 8px 0; border: 0; background: transparent; color: var(--brand); font-size: 13.5px; font-weight: 600; }
[data-theme="dark"] .auth-link { color: var(--brand-hover); }
.auth-link:disabled { cursor: wait; opacity: .7; }
.auth-submit { width: 100%; height: 46px; padding: 0 20px; border: 0; border-radius: 8px; background: var(--brand); color: var(--on-brand); font-size: 15px; font-weight: 600; }
.auth-submit:disabled { cursor: wait; opacity: .7; }
.auth-error { margin: 0 0 12px; }
.auth-error.auth-success { background: var(--brand-tint); color: var(--text); }
#reset-password-form #confirm-password { margin-bottom: 20px; }
#reset-password-form .auth-recovery { justify-content: center; margin: 10px 0 0; }
#reset-password-form .auth-link { display: inline-flex; align-items: center; text-decoration: none; }
.auth-caption { margin-top: 18px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Interação ---------- */
button, .transaction-list li { transition: background-color .15s ease, color .15s ease, border-color .15s ease; }
@media (hover: hover) {
  #logout:hover, .icon-button:hover, .more-transactions:hover, .cancel-modal:hover, .select-trigger:hover { background: var(--surface-2); }
  .month-selector button:hover, .period-selector button:hover, .close-modal:hover, .date-menu-heading button:not(:disabled):hover, .date-trigger:hover { background: var(--surface-2); color: var(--text); }
  .transaction-filters button:not([aria-pressed="true"]):hover { color: var(--text); }
  .new-transaction:hover, .save-transaction:hover, .auth-submit:hover { background: var(--brand-hover); }
  .suggestion-chips button:hover { border-color: var(--text-soft); color: var(--text); }
  .transaction-list li:hover, .data-table tbody tr[data-month]:hover { background: var(--surface-2); }
  .view-tabs button:not([aria-pressed="true"]):hover { color: var(--text); }
  .year-column:not(:disabled):hover .year-column-area i { opacity: .8; }
  .select-option:hover { background: var(--surface-2); }
  .calendar-days button:not(:disabled):not([aria-pressed="true"]):hover { background: var(--surface-2); }
  .auth-link:hover { text-decoration: underline; text-underline-offset: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  button, .transaction-list li, .switch, .switch::after { transition: none; }
}

/* ---------- Telas maiores ---------- */
@media (min-width: 480px) {
  .form-columns { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 640px) and (hover: hover) and (pointer: fine) {
  .search-preview input { font-size: 14px; }
  #transaction-form input, .simulator-form input, .select-trigger, .auth-fields input { font-size: 14.5px; }
}
@media (min-width: 640px) {
  .topbar-inner { padding: 0 24px; }
  .dashboard { padding: 20px 24px 48px; }
  .panel { padding: 20px; }
  .overview { grid-template-columns: 1fr auto; grid-template-areas: "month action" "kpis kpis" "bar bar" "caption caption"; }
  .new-transaction { margin-top: 0; }
  .kpis { grid-template-columns: 1.4fr 1fr 1fr; gap: 0; margin-top: 16px; }
  .kpi { padding: 0 20px; border-left: 1px solid var(--border); }
  .kpi-balance { grid-column: auto; padding: 0 20px 0 0; border: 0; }
  .balance-value { font-size: 28px; }
  .total strong { margin-top: 6px; font-size: 20px; }
  .transactions-tools { grid-template-columns: 1fr auto; }
  .transaction-filters { grid-template-columns: repeat(3, auto); }
  .view-tabs { display: inline-grid; grid-template-columns: repeat(3, auto); }
  .sim-kpis { grid-template-columns: 1fr 1fr; }
  .sim-kpis .kpi:first-child { padding-left: 0; border-left: 0; }
  .data-table { font-size: 14px; }
  .data-table th, .data-table td { padding: 10px 8px; }
  #transaction-modal[open] { align-items: center; }
  #transaction-form { width: min(460px, calc(100% - 48px)); max-height: calc(100% - 48px); margin-bottom: 0; padding: 24px; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 48px #0000002e; }
  .auth-card { padding: 28px 24px 22px; }
}
@media (min-width: 1000px) {
  .dashboard { padding-top: 24px; }
  .layout { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 16px; margin-top: 16px; }
  .sidebar { gap: 16px; }
  .year-layout { grid-template-areas: "chart highlights" "table highlights"; grid-template-rows: auto 1fr; }
  .year-chart-panel { grid-area: chart; }
  .year-highlights { grid-area: highlights; align-self: start; }
  .year-table-panel { grid-area: table; }
  .year-column-area { height: 180px; }
  .simulate-layout { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
}
