/* Cores e medidas. Despesa aparece na cor do texto, com o sinal; o verde é da receita e o vermelho fica para o
   que pede atenção (saldo negativo, atraso, erro). */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e8ebf0;
  --border: #e4e7ec;
  --border-strong: #cdd3dc;
  --text: #141820;
  --text-2: #3b4351;
  --muted: #677285;
  --accent: #2557d6;
  --accent-hover: #1d47b5;
  --accent-soft: #e9effd;
  --accent-contrast: #ffffff;
  --positive: #0f7b55;
  --positive-soft: #e3f4ec;
  --negative: #c3311e;
  --negative-soft: #fdecea;
  --warning: #9a5b00;
  --warning-soft: #fdf3e1;
  --notice-bg: var(--positive-soft);
  --alert-bg: var(--negative-soft);
  --planned-bg: #fffbf2;
  --series-income: #2f9e6e;
  --series-expense: #d9574a;
  --series-balance: #2557d6;
  --hero-from: #2557d6;
  --hero-to: #3f73ec;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 5%);
  --shadow: 0 1px 3px rgb(16 24 40 / 8%), 0 1px 2px rgb(16 24 40 / 4%);
  --shadow-lg: 0 12px 32px rgb(16 24 40 / 14%);
  --radius: 14px;
  --radius-sm: 10px;
  --tabbar-height: 64px;
  --sidebar-width: 240px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1f242c;
    --surface-3: #282e38;
    --border: #2a3039;
    --border-strong: #3a424e;
    --text: #e9ecf1;
    --text-2: #c4cad4;
    --muted: #8d97a7;
    --accent: #7f9eff;
    --accent-hover: #98b1ff;
    --accent-soft: #1d2747;
    --accent-contrast: #0b1020;
    --positive: #4fd3a2;
    --positive-soft: #11302a;
    --negative: #ff8b7d;
    --negative-soft: #3b1d1a;
    --warning: #f1b85e;
    --warning-soft: #372b14;
    --planned-bg: #1d1b15;
    --series-income: #4fd3a2;
    --series-expense: #ff8b7d;
    --series-balance: #7f9eff;
    --hero-from: #1f3f9e;
    --hero-to: #2c53c4;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow: 0 1px 3px rgb(0 0 0 / 40%);
    --shadow-lg: 0 12px 32px rgb(0 0 0 / 50%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a.plain { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -.02em; font-weight: 700; margin: 0 0 1rem; }
h2 { font-size: 1rem; font-weight: 650; margin: 1.5rem 0 .75rem; }
.card > h2:first-child, .card h2:first-child, aside.card h2 { margin-top: 0; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { flex: none; display: inline-block; vertical-align: middle; }

.turbo-progress-bar { height: 3px; background-color: var(--accent); }

/* Navegação: barra lateral no computador, barra de baixo no celular */
.sidebar { display: none; }
.tabbar { display: none; }

.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.05rem; color: var(--text); padding: .25rem .5rem; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 8px; }

.sidenav { display: grid; gap: 2px; }
.sidenav a, .nav-button {
  display: flex; align-items: center; gap: .7rem; width: 100%; min-height: 40px; padding: .45rem .65rem;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-2); font: inherit; font-weight: 500;
  text-align: left; justify-content: flex-start; cursor: pointer;
}
.sidenav a .i, .nav-button .i { color: var(--muted); }
.sidenav a:hover, .nav-button:hover { background: var(--surface-2); text-decoration: none; }
.sidenav a.active { background: var(--accent-soft); color: var(--accent); }
.sidenav a.active .i { color: var(--accent); }
.sidenav a { min-height: 36px; padding-block: .35rem; }
.nav-group { margin-top: .3rem; }
.nav-group > summary {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: 0; padding: .4rem .65rem;
  border-radius: var(--radius-sm); color: var(--muted); font-size: .72rem; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; list-style: none; cursor: pointer;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { background: var(--surface-2); color: var(--text-2); }
.nav-group > summary .i { transition: transform .2s; }
.nav-group:not([open]) > summary .i { transform: rotate(-90deg); }
.sidebar-foot { margin-top: auto; display: grid; gap: 2px; padding-top: .75rem; border-top: 1px solid var(--border); }
.sidebar-foot form.button_to { display: block; }

@media (min-width: 900px) {
  body.signed-in { padding-left: var(--sidebar-width); }
  .sidebar {
    display: flex; flex-direction: column; gap: 1rem; position: fixed; inset: 0 auto 0 0; z-index: 20;
    width: var(--sidebar-width); padding: 1.1rem .8rem; overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--border); view-transition-name: sidebar; scrollbar-width: thin;
  }
}

.page { max-width: 1240px; margin: 0 auto; padding: 1.75rem 2rem 3rem; }

/* Cabeçalho da página */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.eyebrow { margin: 0 0 .15rem; color: var(--muted); font-size: .85rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Esconder os valores */
.privacy-toggle .i + .i { display: none; }
.hide-values .privacy-toggle .i:first-of-type { display: none; }
.hide-values .privacy-toggle .i + .i { display: inline-block; }
.hide-values .money { filter: blur(7px); user-select: none; }
/* Os campos de valor também, até a pessoa tocar neles para editar, e o valor que o gráfico mostra ao passar o mouse. */
.hide-values input[inputmode="decimal"]:not(:focus) { color: transparent; text-shadow: 0 0 7px var(--text); }
.hide-values .column-chart rect { pointer-events: none; }

/* Mensagens */
.flash { display: flex; align-items: flex-start; gap: .6rem; padding: .75rem .9rem; border-radius: var(--radius-sm); margin: 0 0 1rem; }
.flash-notice { background: var(--notice-bg); }
.flash-alert { background: var(--alert-bg); color: var(--text); border: 1px solid color-mix(in srgb, var(--negative) 35%, transparent); }
.flash-alert:not(:has(.errors)) { display: block; }
.errors { margin: 0; padding-left: 1.2rem; }

.toasts {
  position: fixed; z-index: 50; top: calc(env(safe-area-inset-top) + .75rem); left: 50%; transform: translateX(-50%);
  display: grid; gap: .5rem; width: min(92vw, 460px); pointer-events: none;
}
.toasts .flash {
  pointer-events: auto; margin: 0; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: toast-in .25s ease-out;
}
.toasts .flash-notice .i { color: var(--positive); margin-top: 2px; }
.toasts .flash.leaving { animation: toast-out .3s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* Blocos */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.card-link { font-size: .875rem; font-weight: 500; }
.stack { display: grid; gap: .75rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.spread { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; }
.spread > h1 { margin-bottom: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.nowrap { white-space: nowrap; }
.empty { color: var(--muted); padding: .75rem 0; text-align: center; margin: 0; }
.hint { color: var(--muted); font-size: .85rem; margin: .9rem .25rem 0; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 1.25rem; align-items: start; }
/* Sem largura para a lista e os saldos lado a lado, os saldos saem (o início já mostra) */
@media (max-width: 1359px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .layout > aside { display: none; }
}

.home-grid, .menu-grid, .widget-grid, .statement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 1rem;
  align-items: start;
}
.home-grid { grid-auto-flow: dense; }
.home-grid .span-2 { grid-column: span 2; }
@media (max-width: 760px) { .home-grid .span-2 { grid-column: auto; } }
.statement-grid { margin-bottom: 1rem; }
.table-wrap + .statement-grid { margin-top: 1.25rem; }

/* Resumo do início */
.hero {
  position: relative; overflow: hidden; margin-bottom: 1rem; padding: 1.25rem 1.35rem 1.1rem; border-radius: 18px;
  color: #fff; background: linear-gradient(135deg, var(--hero-from), var(--hero-to)); box-shadow: var(--shadow);
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%;
  background: rgb(255 255 255 / 8%); pointer-events: none;
}
.hero .money, .hero .money.positive, .hero .money.negative { color: inherit; }
.hero .signed .money.negative { color: #ffd2cc; }
.hero-label { display: block; font-size: .85rem; opacity: .85; }
.hero-value { display: block; font-size: 2.1rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin: .15rem 0 .9rem; }
.hero-caption { margin: 0 0 .35rem; font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; opacity: .75; }
.hero-month { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin: 0; }
/* No celular estreito os três valores não cabem lado a lado: receitas e despesas numa linha, o resultado embaixo */
@media (max-width: 480px) {
  .hero-month { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: .55rem; }
  .hero-month > div:last-child { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
}
.hero-month dt { font-size: .75rem; opacity: .8; }
.hero-month dd { margin: 0; font-weight: 600; font-size: 1rem; }
.hero-note { margin: .9rem 0 0; padding-top: .75rem; border-top: 1px solid rgb(255 255 255 / 18%); font-size: .82rem; opacity: .9; }

.shortcuts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin: 0 0 1.25rem; max-width: 560px; }
.shortcut { display: grid; justify-items: center; gap: .35rem; color: var(--text-2); font-size: .8rem; font-weight: 500; text-align: center; }
.shortcut:hover { text-decoration: none; color: var(--text); }
.shortcut-icon {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border); color: var(--accent); box-shadow: var(--shadow-sm);
}
.shortcut:hover .shortcut-icon { background: var(--accent-soft); }
@media (min-width: 900px) {
  .shortcuts { display: flex; flex-wrap: wrap; max-width: none; }
  .shortcut {
    display: inline-flex; align-items: center; gap: .5rem; min-height: 40px; padding: 0 .9rem 0 .7rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-sm); font-size: .9rem;
  }
  .shortcut:hover { background: var(--surface-2); }
  .shortcut-icon, .shortcut:hover .shortcut-icon { width: auto; height: auto; border: 0; background: none; box-shadow: none; }
}

/* Linhas de lista (contas, cartões, vencimentos, lançamentos) */
.rows { list-style: none; margin: 0 -.5rem; padding: 0; }
.rows > li + li { border-top: 1px solid var(--border); }
.row-link, .row-static {
  display: flex; align-items: center; gap: .75rem; min-height: 54px; padding: .55rem .5rem;
  color: inherit; border-radius: var(--radius-sm);
}
.row-link:hover { background: var(--surface-2); text-decoration: none; }
.row-link > .i:last-child { color: var(--muted); }
.row-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: .82rem; color: var(--muted); }
.row-meta .badge { margin-right: .25rem; }

.avatar {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  font-size: .85rem; font-weight: 650; background: hsl(var(--hue, 220) 70% 93%); color: hsl(var(--hue, 220) 55% 33%);
}
.avatar-neutral { background: var(--surface-2); color: var(--text-2); }
.avatar-transfer { background: var(--accent-soft); color: var(--accent); }
.avatar-none { background: var(--surface-2); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .avatar { background: hsl(var(--hue, 220) 35% 22%); color: hsl(var(--hue, 220) 75% 78%); }
  .avatar-neutral, .avatar-none { background: var(--surface-3); color: var(--text-2); }
  .avatar-transfer { background: var(--accent-soft); color: var(--accent); }
}

.date-chip {
  flex: none; display: grid; place-items: center; align-content: center; width: 42px; height: 42px; border-radius: 12px;
  background: var(--surface-2); line-height: 1.1;
}
.date-chip strong { font-size: 1rem; }
.date-chip span { font-size: .65rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.date-chip.is-overdue { background: var(--negative-soft); color: var(--negative); }
.date-chip.is-overdue span { color: inherit; }

/* Formulários */
.field { display: grid; gap: .3rem; min-width: 0; align-content: start; }
.field > span:first-child, .field > label { font-size: .82rem; font-weight: 500; color: var(--text-2); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.card-fields { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .75rem; }
.card-fields legend { font-weight: 600; padding: 0; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: .5rem .7rem;
  min-height: 42px;
  min-width: 0;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input[type="checkbox"], input[type="radio"] { width: 1.1rem; height: 1.1rem; min-height: 0; padding: 0; accent-color: var(--accent); }
textarea { min-height: 5rem; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input::placeholder { color: var(--muted); opacity: .8; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 2.1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23778294' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .65rem center;
}
input[type="date"] { -webkit-appearance: none; appearance: none; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: .9rem; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; }

/* Escolha entre dois (despesa ou receita) */
.kind-toggle { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.kind-toggle label { padding: .4rem .9rem; border-radius: 9px; cursor: pointer; font-weight: 500; color: var(--muted); text-align: center; }
.kind-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.kind-toggle label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.kind-toggle label:has(input[value="expense"]:checked) { color: var(--negative); }
.kind-toggle label:has(input[value="income"]:checked) { color: var(--positive); }
.kind-toggle label:has(input:focus-visible) { outline: 2px solid var(--accent); }

/* Etiquetas do lançamento: um campo baixo, com as escolhidas em fichas e a busca das outras ao lado */
.tag-field { max-width: 560px; }
.tag-input {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; min-height: 38px; padding: .2rem .35rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: text;
}
.tag-input:hover { border-color: var(--muted); }
.tag-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.tag-chips { display: contents; }
.tag-chip {
  display: inline-flex; align-items: center; gap: .1rem; min-height: 26px; padding: 0 .15rem 0 .6rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: .82rem; font-weight: 500; white-space: nowrap;
}
.tag-chip-remove {
  width: 22px; height: 22px; min-height: 0; padding: 0; border: 0; border-radius: 50%; background: none; color: inherit;
  font-size: 1rem; line-height: 1;
}
.tag-chip-remove:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.tag-input .tag-search {
  flex: 1 1 140px; width: auto; min-width: 120px; min-height: 30px; padding: .1rem .35rem; border: 0; border-radius: 6px;
  background: none; box-shadow: none; font-size: .9rem;
}
.tag-options {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; max-height: 260px; overflow-y: auto;
  margin: 0; padding: .25rem; list-style: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
}
.tag-options li { padding: .45rem .6rem; border-radius: 8px; cursor: pointer; font-size: .9rem; }
.tag-options li[aria-selected="true"], .tag-options li[role="option"]:hover { background: var(--accent-soft); color: var(--accent); }
.tag-options .tag-option-empty { color: var(--muted); cursor: default; }

.check { display: inline-flex; gap: .45rem; align-items: center; }
/* O texto longo quebra em várias linhas sem espremer a caixa de seleção. */
.check > input { flex-shrink: 0; }
/* A explicação embaixo da opção, alinhada com o texto dela (a caixa, a margem padrão dela e o espaço). */
.check-hint { margin: .3rem 0 0 2rem; }

.chip {
  min-height: 30px; padding: 0 .75rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); font-size: .82rem; font-weight: 500;
}
.chip:hover { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.date-chips { display: none; gap: .35rem; }

.money-input { position: relative; display: block; }
.money-prefix { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 500; pointer-events: none; }
.money-input input { padding-left: 2.6rem; }

/* Lançamento rápido da listagem: duas linhas, os campos alinhados pela base e com o mesmo espaço entre eles. Quando
   falta largura, a linha quebra em vez de um campo passar por cima do outro. */
.quick { margin-bottom: 1.25rem; container-type: inline-size; }
.quick-grid { display: grid; gap: .85rem; }
.quick-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .85rem .75rem; }
.quick-row > * { flex: 1 1 130px; min-width: 0; }
.quick-row > .kind-toggle { flex: none; height: 42px; }
.quick-row > .kind-toggle label { display: flex; align-items: center; }
.quick-row > .field-description { flex: 3 1 200px; }
.quick-row > .field-amount { flex: 1 1 130px; max-width: 180px; }
.quick-row > .field-date { flex: 1 1 150px; max-width: 190px; }
.quick-row > .btn-submit { flex: 0 0 auto; min-width: 140px; min-height: 42px; margin-left: auto; }
/* Cartão estreito: o tipo e a descrição numa linha, valor e data na outra; as escolhas de duas em duas */
@container (max-width: 719px) {
  .quick-row > .field-description { flex-basis: calc(100% - 200px); }
  .quick-row > .field-amount, .quick-row > .field-date { flex: 1 1 140px; max-width: none; }
  .quick-row-details > * { flex-basis: calc(50% - .75rem); }
  .quick-row > .btn-submit { flex: 1 1 100%; }
}
/* No computador, a categoria e a conta ficam numa linha só; o liquidar vira o círculo com o visto */
@media (min-width: 761px) {
  .entries-table .cell-date { width: 80px; color: var(--text-2); }
  .entries-table .cell-amount { font-weight: 600; }
  .entries-table .cell-desc { min-width: 240px; }
  .entries-table .cell-category, .entries-table .cell-account {
    max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2);
  }
  .entries-table .btn-confirm { width: 34px; min-height: 34px; padding: 0; border-radius: 50%; }
  .entries-table .btn-confirm:hover { border-color: var(--positive); background: var(--positive-soft); }
  .entries-table .btn-confirm span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
/* A coluna da conta só cabe em tela larga; nas outras a conta vai para a linha de baixo da descrição */
.meta-account { display: none; }
@media (min-width: 761px) and (max-width: 1599px) {
  .entries-table .cell-account { display: none; }
  .entries-table .meta-account { display: inline; }
}

/* Tela de lançar: uma grade de duas colunas, sem as linhas da listagem */
.quick-page { max-width: 560px; margin: 0 auto; }
.quick-page .quick { padding: 1.1rem; }
.quick-page .quick-grid { grid-template-columns: 1fr 1fr; gap: .9rem; align-items: end; }
.quick-page .quick-row { display: contents; }
.quick-page .quick-row > * { max-width: none; }
.quick-page .quick-row > .kind-toggle { height: auto; }
.quick-page .quick-row > .btn-submit { min-width: 0; }
.quick-page .quick-grid .kind-toggle, .quick-page .quick-grid .span-2, .quick-page .field-amount, .quick-page .field-date,
.quick-page .quick-grid .btn-submit { grid-column: 1 / -1; }
.quick-page .kind-toggle { display: grid; grid-template-columns: 1fr 1fr; justify-self: stretch; }
.quick-page .kind-toggle label { padding: .55rem; }
.quick-page .amount-input { font-size: 1.75rem; font-weight: 650; text-align: right; min-height: 58px; letter-spacing: -.01em; }
.quick-page .money-prefix { font-size: 1.1rem; }
.quick-page .field-date { grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: .5rem; }
.quick-page .field-date > label { grid-column: 1 / -1; }
.quick-page .date-chips { display: flex; }
.quick-page .btn-submit { min-height: 50px; font-size: 1.05rem; }
/* No celular, conta e categoria ocupam a linha inteira para o nome não ser cortado */
@media (max-width: 480px) {
  .quick-page .field-account, .quick-page .field-category { grid-column: 1 / -1; }
}

.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: .75rem; align-items: end; margin-bottom: 1rem; }
.filters .wide { grid-column: 1 / -1; }
@media (min-width: 761px) { .filters-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.filters-actions {
  grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: .5rem; margin-top: .15rem; padding-top: .85rem;
  border-top: 1px solid var(--border);
}
.filters-actions > * { width: auto; min-width: 110px; }
@media (max-width: 760px) { .filters-actions > * { flex: 1; } }
.filters-toggle { margin-bottom: 1rem; }
.filters-toggle > summary {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 36px; margin: 0 0 .75rem; padding: 0 .85rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2);
  font-weight: 500; list-style: none;
}
.filters-toggle > summary::-webkit-details-marker { display: none; }
.filters-toggle[open] > summary { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.list-tools { display: flex; align-items: center; gap: .5rem; margin: 0 0 .75rem; }
.search-box { position: relative; flex: 1; min-width: 0; max-width: 360px; }
.search-box .i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box input { min-height: 38px; padding-left: 2.2rem; border-radius: 999px; border-color: var(--border); }
.list-tools > .mobile-only { flex: 0 1 auto; min-width: 0; max-width: 48%; }
.list-tools .sort-select, .list-tools .sort-select select { max-width: 100%; }
.month-nav {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; width: 100%; max-width: 360px; margin: 0 0 .75rem;
  padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
}
.month-nav strong { flex: 1; text-align: center; font-weight: 600; }

/* Barra da listagem de lançamentos: mês, busca e filtros numa linha, todos da mesma altura */
.list-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .6rem; margin: 0 0 .9rem; }
.list-bar .month-nav { flex: 0 1 290px; margin: 0; padding: 0 2px; min-height: 42px; }
.list-bar .search-box { flex: 1 1 220px; max-width: none; }
.list-bar .search-box input { min-height: 42px; }
.list-bar > .mobile-only { flex: 0 1 auto; min-width: 0; max-width: 48%; }
.list-bar .sort-select, .list-bar .sort-select select { max-width: 100%; }
.filter-button {
  min-height: 42px; padding: 0 1rem; border-radius: 999px; border-color: var(--border); background: var(--surface);
  color: var(--text-2);
}
.filter-button[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
@media (max-width: 760px) {
  .list-bar .month-nav { flex: 1 1 100%; }
  .list-bar .search-box { flex-basis: 0; }
  .filter-button { width: 46px; padding: 0; }
  .filter-button .filter-label, .filter-button .badge { display: none; }
  .filter-button:has(.badge) { box-shadow: inset 0 0 0 2px var(--accent); }
}

/* Totais da listagem numa faixa só, divididos por linhas, e o número de lançamentos logo abaixo */
.totals.totals-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 0 0 .45rem; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.totals-strip .total { border: 0; border-radius: 0; box-shadow: none; padding: .75rem 1rem; }
.totals-strip .total + .total { border-left: 1px solid var(--border); }
.totals-strip .money { font-size: clamp(.95rem, 3.4vw, 1.25rem); }
.list-note { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .5rem; margin: 0 .2rem .9rem; color: var(--muted); font-size: .82rem; }
.list-note strong { color: var(--text-2); font-weight: 600; }
@media (max-width: 760px) { .totals-strip .total { padding: .6rem .7rem; } }
/* No celular estreito, três valores lado a lado cortam "-R$ 1.500,00": o resultado desce para uma linha só dele. */
@media (max-width: 480px) {
  .totals.totals-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .totals-strip .total:last-child { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--border); }
}
.account-checks .row { gap: .25rem .9rem; }
.statement-controls { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem 1rem; margin-bottom: .75rem; }
.statement-controls .field { flex: 1 1 220px; max-width: 360px; }
.statement-controls .month-nav { flex: 1 1 260px; margin: 0; }

/* Botões */
.btn, .btn-link, button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 0 .9rem;
  white-space: nowrap;
}
.btn, button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 38px; font-weight: 500; }
.btn:hover, button:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary, button.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow-sm); }
.btn-primary:hover, button.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--negative); }
.btn-danger:hover { background: var(--negative-soft); }
.btn-small { min-height: 32px; padding: 0 .65rem; font-size: .85rem; }
.btn-block { display: flex; width: 100%; }
.btn-link { display: inline; min-height: 0; border: 0; background: none; color: var(--accent); padding: 0; font-weight: inherit; }
.btn-link:hover { background: none; text-decoration: underline; }
.btn-confirm .i { color: var(--positive); }
form.button_to { display: inline-flex; }
form[aria-busy="true"] [type="submit"] { opacity: .6; pointer-events: none; }

.icon-button {
  display: inline-grid; place-items: center; flex: none; width: 38px; height: 38px; min-height: 0; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-2);
}
.icon-button:hover { background: var(--surface-2); color: var(--text); }
.icon-button-check { width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--border-strong); color: var(--muted); }
.icon-button-check:hover { border-color: var(--positive); background: var(--positive-soft); color: var(--positive); }
.icon-button-danger:hover { background: var(--negative-soft); color: var(--negative); }

.check-button { border-radius: 999px; width: 2rem; height: 2rem; min-height: 0; padding: 0; color: var(--muted); }
.check-button.is-cleared { color: var(--positive); border-color: var(--positive); font-weight: 700; }

/* Totais */
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: .75rem; margin: 1rem 0; }
.total { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .7rem .9rem; box-shadow: var(--shadow-sm); }
.total .label { display: block; font-size: .8rem; color: var(--muted); }
.total .money { font-size: 1.15rem; font-weight: 650; }
.totals-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: .25rem 0 .5rem; }
.totals-compact .money { font-size: clamp(.9rem, 3.4vw, 1.15rem); }

/* Valores */
.money { font-variant-numeric: tabular-nums; white-space: nowrap; transition: filter .2s; }
.money.positive { color: var(--positive); }
.money.negative { color: inherit; }
.signed .money.negative, .signed.money.negative, tr.day-end .money.negative { color: var(--negative); }
.rows .signed .money.positive { color: inherit; }

/* Tabelas */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.table-wrap.compact { border: 0; box-shadow: none; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .85rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: .75rem; color: var(--muted); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; background: var(--surface); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; white-space: nowrap; }
td.actions { white-space: nowrap; text-align: right; }
td.actions > * + * { margin-left: .25rem; }
tr.planned td { background: var(--planned-bg); }
tr.inactive td { opacity: .65; }
tr.day-end td { background: var(--surface-2); font-size: .85rem; }
tr.locked td:first-child::before { content: "✓ "; color: var(--positive); }
.cell-date-inline, .cell-account-inline { display: none; }
.cell-sub { display: none; }
/* Colunas de apoio que saem quando a tela não é larga */
@media (max-width: 1199px) { .hide-narrow { display: none; } }
.category-group { margin-bottom: 1rem; }
.category-group .card-head { flex-wrap: wrap; }
.category-group .card-head .row { gap: .25rem; }

/* Ordenação: o cabeçalho da coluna no computador, o menu no celular */
.sort-link { display: inline-flex; align-items: center; gap: .3rem; color: inherit; }
.sort-link .i { opacity: .4; }
.sort-link:hover { color: var(--text); text-decoration: none; }
.sort-link:hover .i, .sort-link.active .i { opacity: 1; }
.sort-link.active { color: var(--accent); }
.sort-select { position: relative; display: inline-flex; align-items: center; color: var(--text-2); }
.sort-select .i { position: absolute; left: .8rem; pointer-events: none; }
.sort-select select { width: auto; min-height: 36px; padding-left: 2.2rem; border-radius: 999px; border-color: var(--border); font-weight: 500; }
.mobile-only { display: none; }

tr.day-head th {
  position: static; padding: .45rem .85rem; background: var(--surface-2); color: var(--text-2);
  font-size: .8rem; font-weight: 600; letter-spacing: 0; text-transform: none;
}
tr.day-head:hover th { background: var(--surface-2); }

/* Lançamento numa linha: categoria, descrição e o que mais houver */
.tx { display: flex; align-items: center; gap: .75rem; }
.tx-main { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; column-gap: .4rem; row-gap: 1px; }
.tx-title { color: var(--text); font-weight: 500; }
.tx-title:hover { text-decoration: none; color: var(--accent); }
.tx-badges { display: inline-flex; gap: .3rem; }
.tx-badges:empty { display: none; }
.tx-meta { display: block; font-size: .82rem; color: var(--muted); }
.tx-main .tx-meta { flex-basis: 100%; }
.meta-mobile { display: none; }

/* Matriz (demonstrativo, etiquetas, fluxo): rola de lado dentro da caixa, com a primeira coluna fixa */
.scroll-x { overflow-x: auto; }
.matrix th, .matrix td { white-space: nowrap; }
.matrix .sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.matrix thead .sticky-col { background: var(--surface); z-index: 2; }
.matrix .kind-row th, .matrix .kind-row td { background: var(--surface-2); font-weight: 600; }
.matrix .group-row th, .matrix .group-row td { font-weight: 600; }
.matrix .indent { padding-left: 1.4rem; }
.matrix tr.current-month th, .matrix tr.current-month td { box-shadow: inset 0 -2px 0 var(--accent); }

.badge {
  display: inline-flex; align-items: center; gap: .25rem; padding: .05rem .5rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; vertical-align: middle;
}
.badge-planned { background: var(--warning-soft); color: var(--warning); }
.badge.status-open { background: var(--accent-soft); color: var(--accent); }
.badge.status-closed { background: var(--warning-soft); color: var(--warning); }
.badge.status-overdue { background: var(--negative-soft); color: var(--negative); }
.badge.status-paid { background: var(--positive-soft); color: var(--positive); }

.balances { display: grid; gap: .25rem; }
.balances .item { display: flex; justify-content: space-between; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.balances .item:last-child { border-bottom: 0; }
.total-line { font-weight: 600; }

.card-summary { padding: .4rem 0; border-bottom: 1px solid var(--border); }
.card-summary:last-child { border-bottom: 0; }
.card-summary .item { display: flex; justify-content: space-between; gap: .5rem; padding: .2rem 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list li.overdue { color: var(--negative); }
.list.card li { padding: .55rem .2rem; }

.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list li a { display: block; padding: .65rem .2rem; border-bottom: 1px solid var(--border); }
.menu-list li:last-child a { border-bottom: 0; }

.report-link { display: grid; gap: .35rem; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.report-link:hover { border-color: var(--accent); box-shadow: var(--shadow); text-decoration: none; }

.tabs { display: flex; gap: .4rem; overflow-x: auto; margin: 0 0 1rem; padding-bottom: .25rem; }
.tabs a { padding: .4rem .9rem; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; color: var(--text-2); background: var(--surface); font-weight: 500; }
.tabs a:hover { text-decoration: none; background: var(--surface-2); }
.tabs a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

/* Barras e gráficos */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.bars.card { padding: 1rem; }
.bar-link { display: block; margin: 0 -.5rem; padding: .4rem .5rem; border-radius: var(--radius-sm); color: inherit; }
.bar-link:hover { background: var(--surface-2); text-decoration: none; }
.bar-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: .92rem; }
.bar-label { min-width: 0; }
.bar { display: block; height: 6px; border-radius: 999px; background: var(--surface-2); margin-top: .35rem; overflow: hidden; }
.bar-link .bar { background: var(--surface-3); }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar.negative > span { background: var(--series-expense); }
.bar.positive > span { background: var(--series-income); }

.column-chart { width: 100%; height: 160px; display: block; }
.column-chart .series-income { fill: var(--series-income); }
.column-chart .series-expense { fill: var(--series-expense); }
.column-chart .series-balance { fill: var(--series-balance); }
.column-chart .axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-labels { display: flex; justify-content: space-around; font-size: .7rem; color: var(--muted); margin: .25rem 0 .5rem; }
.chart-card { margin-bottom: 1rem; }

.widget-head h2 { margin: 0; }
.widget-tools { gap: .25rem; }

/* Liquidar o mês */
.confirm-list { display: grid; gap: .75rem; }
.confirm-item { display: grid; gap: .6rem; }
.confirm-item.overdue { border-color: color-mix(in srgb, var(--negative) 45%, var(--border)); box-shadow: inset 3px 0 0 var(--negative); }
.confirm-item.confirmed { opacity: .7; border-style: dashed; }
.confirm-head { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.confirm-fields { display: grid; grid-template-columns: 1fr 1fr auto; gap: .6rem; align-items: end; }
.confirm-fields.with-installments { grid-template-columns: 1fr 1fr 6rem auto; }

/* Liquidar no cartão e as parcelas da compra */
.settle-form { max-width: 34rem; }
.installment-list { display: grid; gap: .75rem; }
.installment-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: .6rem;
  border-top: 1px solid var(--border); padding-top: .75rem;
}
.installment-row:first-child { border-top: 0; padding-top: 0; }
.installment-head { grid-column: 1 / -1; display: flex; align-items: center; gap: .5rem; }
.installment-sum { margin: 1rem 0 .25rem; font-weight: 500; }

/* Extrato do banco (CSV): o botão que escolhe o arquivo e já importa, o aviso do que falta revisar e a revisão */
.upload-form { display: inline-flex; }
.upload-form label { cursor: pointer; }
.upload-form label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.upload-form[aria-busy="true"] label { opacity: .6; pointer-events: none; }
.flash-pending { display: flex; align-items: center; background: var(--accent-soft); color: var(--text); }
.flash-pending .i { color: var(--accent); }
.bank-lines { display: grid; gap: .75rem; }
.bank-actions { display: grid; gap: .4rem; margin-top: .5rem; }
.bank-create { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; padding-left: 1.6rem; }
.reconcile-box { margin-bottom: 1rem; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0; margin-top: 0; }

.copy-box { display: block; padding: .6rem .8rem; background: var(--surface-2); border-radius: var(--radius-sm); overflow-wrap: anywhere; }

.pagination { display: flex; gap: .5rem; justify-content: center; margin: 1.25rem 0; }

.login { max-width: 400px; margin: 12vh auto 2rem; padding: 1.75rem; text-align: center; }
.login .stack { text-align: left; margin-top: 1.25rem; }
.login h1 { margin: .75rem 0 .25rem; font-size: 1.4rem; }
.login p { margin: 0; }
.login-logo { border-radius: 14px; box-shadow: var(--shadow); }
.login-recovery { text-align: left; margin-top: 1rem; }
.login-recovery .stack { margin-top: .5rem; }
.login > .small { margin-top: 1rem; }

/* Verificação em duas etapas. O código fica grande (e com 16px ou mais, sem o zoom do Safari) e o QR code fica
   sempre preto no branco, também no tema escuro, para a câmera ler. */
.code-input { font-size: 1.3rem; letter-spacing: .2em; font-variant-numeric: tabular-nums; }
.login .code-input { text-align: center; }
.two-factor, .settings-page { max-width: 640px; }
.two-factor p, .settings-page p { margin: 0; }
.two-factor .field, .settings-page .field { max-width: 22rem; }
.two-factor h2 { margin: .75rem 0 0; }
.two-factor .card h2 { margin: 0; }
.first-account { margin-bottom: 1rem; }
.first-account h2, .first-account p { margin: 0; }
.first-account .btn { justify-self: start; }
.qr-code { width: 216px; max-width: 100%; padding: 12px; background: #fff; border-radius: var(--radius-sm); line-height: 0; }
.qr-code svg { width: 100%; height: auto; }
.recovery-codes {
  display: grid; grid-template-columns: repeat(2, max-content); gap: .35rem 2rem; margin: 0; padding: .75rem 1rem;
  list-style: none; background: var(--surface-2); border-radius: var(--radius-sm);
  font: 1.05rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; user-select: all;
}

details > summary { cursor: pointer; color: var(--accent); margin: .5rem 0; }
.splits { display: grid; gap: .5rem; max-width: 520px; }
.split-row { display: grid; grid-template-columns: 1fr 130px auto; gap: .5rem; align-items: center; }

/* Esportes: o escudo, o placar no meio dos dois times e as listas de jogos e notícias */
.crest { flex: none; width: var(--size, 24px); height: var(--size, 24px); object-fit: contain; }
.crest-text {
  display: inline-grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--text-2);
  font-size: calc(var(--size, 24px) * .32); font-weight: 700; letter-spacing: -.02em; line-height: 1;
}
@media (prefers-color-scheme: dark) {
  /* Escudo escuro (preto e branco, por exemplo) não some no fundo escuro */
  img.crest { filter: drop-shadow(0 0 1px rgb(255 255 255 / 45%)); }
}
turbo-frame.card { display: block; }
.sports-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 1rem; align-items: start;
}
.sports-empty { display: grid; justify-items: center; gap: .6rem; max-width: 520px; padding: 2rem 1.25rem; text-align: center; }
.sports-empty h2, .sports-empty p { margin: 0; }
.sports-empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); }
.sports-today { margin: 0 0 1.25rem; }
.team-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .85rem; margin: 0 0 1rem; }
.team-head-main { flex: 1 1 160px; min-width: 0; }
.team-head h2 { margin: 0; font-size: 1.2rem; }
.team-head p { margin: 0; }
.badge-live { background: var(--negative-soft); color: var(--negative); }
.badge.result-win { background: var(--positive-soft); color: var(--positive); min-width: 1.6rem; justify-content: center; }
.badge.result-draw { background: var(--surface-2); color: var(--text-2); min-width: 1.6rem; justify-content: center; }
.badge.result-loss { background: var(--negative-soft); color: var(--negative); min-width: 1.6rem; justify-content: center; }

.scoreline { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: .6rem; }
.scoreline .side { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.scoreline .side-home { justify-content: flex-end; text-align: right; }
.scoreline .team-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scoreline .is-followed .team-name { font-weight: 650; }
.scoreline .score { min-width: 3.4rem; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.scoreline .score small { font-size: .75em; font-weight: 500; color: var(--muted); }
.score-sep { margin: 0 .3rem; color: var(--muted); font-weight: 500; }
.scoreline-big { gap: .75rem; margin: .9rem 0 .6rem; }
.scoreline-big .side, .scoreline-big .side-home { flex-direction: column; justify-content: flex-start; gap: .45rem; text-align: center; }
.scoreline-big .side-home { flex-direction: column-reverse; justify-content: flex-end; }
.scoreline-big .team-name { white-space: normal; overflow-wrap: anywhere; font-weight: 600; }
.scoreline-big .score { font-size: 2rem; letter-spacing: -.02em; }
.scoreline-big .score-time { font-size: 1.35rem; }
.match-card .match-meta, .match-card .match-status, .match-card .match-venue { margin: 0; text-align: center; }
.match-card .match-meta { font-size: .82rem; color: var(--muted); }
.match-card .match-status { font-weight: 600; }
.match-card.is-live .match-status { color: var(--negative); }
.match-card .match-venue { margin-top: .2rem; font-size: .8rem; color: var(--muted); }
.match-list { list-style: none; margin: 0; padding: 0; }
.match-list > li { display: grid; gap: .3rem; padding: .65rem 0; }
.match-list > li:first-child { padding-top: .25rem; }
.match-list > li + li { border-top: 1px solid var(--border); }
.match-line { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .8rem; color: var(--muted); }
/* O placar que acabou de mudar fica em destaque por alguns segundos (controller score) */
.scoreline .score, .sports-today .score { border-radius: 8px; transition: background-color .6s, color .6s; }
.score.score-changed { background: var(--accent-soft); color: var(--accent); }
.sports-today .score { padding: 0 .2rem; }
.match-card .match-stale { margin: .5rem 0 0; font-size: .8rem; color: var(--warning); text-align: center; }
/* Tabela de classificação: o time seguido em destaque e a zona de rebaixamento marcada na posição */
.standings-name { margin: -.25rem 0 .5rem; font-size: .82rem; color: var(--muted); }
.standings-wrap { margin: 0 -.5rem; overflow-x: auto; }
.standings { font-size: .88rem; font-variant-numeric: tabular-nums; }
.standings th, .standings td { padding: .4rem .45rem; background: none; }
.standings th { font-size: .7rem; }
.standings abbr { text-decoration: none; }
.standings tbody tr:hover td { background: none; }
.standings-team { width: 100%; }
.standings-team-name { display: flex; align-items: center; gap: .45rem; min-width: 0; white-space: nowrap; }
.standings-team-name > span { overflow: hidden; text-overflow: ellipsis; }
.standings-rank { width: 2.2rem; color: var(--muted); }
.standings-points { font-weight: 650; }
.standings tr.is-followed td { background: var(--accent-soft); font-weight: 600; }
.standings tr.is-followed .standings-rank { color: var(--accent); }
.standings tr.is-relegated .standings-rank { box-shadow: inset 3px 0 0 var(--negative); color: var(--negative); }
/* A divisória da zona vai na linha de cima: na tabela, a borda sólida dela ganharia da tracejada. */
.standings tr:has(+ tr.relegation-start) td { border-bottom: 1px dashed color-mix(in srgb, var(--negative) 60%, transparent); }
.standings-gap td { padding: .1rem; text-align: center; color: var(--muted); line-height: 1; }
.standings-legend { display: flex; align-items: center; gap: .45rem; margin: .6rem 0 0; font-size: .78rem; color: var(--muted); }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; background: var(--negative); }
@media (max-width: 760px) { .standings .wide-only { display: none; } }

/* Notificações: o interruptor do time, o quadro de ativar no aparelho e o aviso do jogo parado */
.team-head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.switch-button {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 32px; padding: 0 .4rem 0 .6rem; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: .85rem; font-weight: 500;
}
.switch-button .switch {
  position: relative; width: 32px; height: 18px; border-radius: 999px; background: var(--surface-3); transition: background-color .2s;
}
.switch-button .switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-sm); transition: transform .2s;
}
.switch-button[aria-checked="true"] { color: var(--accent); }
.switch-button[aria-checked="true"] .switch { background: var(--accent); }
.switch-button[aria-checked="true"] .switch::after { transform: translateX(14px); }
.push-card { margin: 0 0 1rem; }
.push-card p { margin: 0; }
.push-state { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; }
.push-state[hidden] { display: none; }
.push-state > p { flex: 1 1 240px; }
.push-on { display: inline-flex; align-items: center; gap: .45rem; color: var(--positive); font-weight: 500; }
.push-error { margin-top: .6rem !important; color: var(--negative); font-size: .85rem; }
.match-stopped { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .25rem .6rem; margin-top: .6rem; font-size: .82rem; color: var(--muted); }
.news-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; font-weight: 500; }
.news-link > .i:last-child { color: var(--muted); align-self: flex-start; margin-top: .2rem; }

/* Transição entre telas (Turbo com View Transitions): só o conteúdo troca, as barras ficam */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; }

/* Celular e tablet */
@media (max-width: 899px) {
  .page {
    padding: calc(env(safe-area-inset-top) + .9rem) 16px calc(var(--tabbar-height) + 1.5rem + env(safe-area-inset-bottom));
  }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px); border-top: 1px solid var(--border); view-transition-name: tabbar;
  }
  .tabbar a { display: grid; place-items: center; align-content: center; gap: 3px; font-size: .68rem; font-weight: 500; color: var(--muted); }
  .tabbar a.active { color: var(--accent); }
  /* O botão que acompanha a rolagem fica acima da barra de abas, e não atrás dela. */
  .sticky-actions { bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom)); }
  .tabbar a:hover { text-decoration: none; }
  .tabbar .fab {
    display: grid; place-items: center; width: 52px; height: 52px; margin-top: -32px; border-radius: 50%;
    background: var(--accent); color: var(--accent-contrast); box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 40%, transparent);
  }
  .tabbar .tab-add.active { color: var(--accent); }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  /* 16px nos campos evita o zoom automático do Safari ao tocar */
  input, select, textarea { font-size: 16px; min-height: 46px; }
  .btn, button { min-height: 44px; }
  .btn-small { min-height: 36px; }
  .icon-button { width: 44px; height: 44px; }
  .icon-button-check { width: 38px; height: 38px; }
  .btn-icon-mobile { width: 44px; padding: 0; }
  .btn-icon-mobile span { display: none; }

  .desktop-only { display: none !important; }
  .mobile-only { display: revert; }
  .sort-select.mobile-only { display: inline-flex; }
  h1 { font-size: 1.55rem; }
  .page-head { align-items: center; margin-bottom: 1rem; }
  .card { padding: .9rem 1rem; }
  .hero-value { font-size: 1.9rem; }
  .month-nav { max-width: none; }

  /* Tabela vira lista de cartões: descrição e valor na primeira linha, data, categoria e conta embaixo */
  table.cards-on-mobile thead { display: none; }
  table.cards-on-mobile, table.cards-on-mobile tbody { display: block; }
  table.cards-on-mobile tr {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "check desc amount" "check meta extra" "check actions actions";
    column-gap: .75rem;
    padding: .7rem .9rem;
    border-bottom: 1px solid var(--border);
  }
  table.cards-on-mobile tr:last-child { border-bottom: 0; }
  table.cards-on-mobile td { display: block; padding: 0; border: 0; background: none; }
  table.cards-on-mobile tbody tr:hover td { background: none; }
  table.cards-on-mobile tr.planned { background: var(--planned-bg); }
  table.cards-on-mobile .cell-check { grid-area: check; align-self: center; }
  table.cards-on-mobile .cell-desc { grid-area: desc; min-width: 0; overflow-wrap: anywhere; }
  table.cards-on-mobile .cell-amount { grid-area: amount; font-weight: 600; }
  table.cards-on-mobile .cell-meta { grid-area: meta; display: block; font-size: .85rem; color: var(--muted); }
  table.cards-on-mobile .cell-extra { grid-area: extra; text-align: right; font-size: .85rem; }
  table.cards-on-mobile .cell-status { grid-area: extra; text-align: right; }
  table.cards-on-mobile .cell-date-inline, table.cards-on-mobile .cell-account-inline { display: inline; }
  table.cards-on-mobile .cell-date, table.cards-on-mobile .cell-account { display: none; }
  table.cards-on-mobile .actions { grid-area: actions; text-align: left; }
  table.cards-on-mobile .actions:empty { display: none; }
  table.cards-on-mobile .cell-desc .muted.small { display: none; }
  table.cards-on-mobile td[colspan] { grid-column: 1 / -1; }
  table.cards-on-mobile .stretched::after { content: ""; position: absolute; inset: 0; }
  table.cards-on-mobile .actions form, table.cards-on-mobile .actions a { position: relative; z-index: 1; }
  .statements-table .cell-status { grid-area: extra; }
  .statements-table .cell-extra { display: none; }
  .statements-table .tx-meta { display: none; }

  /* Lançamentos: avatar, descrição e o resto embaixo; o valor à direita, o liquidar logo abaixo dele */
  table.entries-table tr.entry-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "desc amount" "desc actions"; align-items: center; row-gap: .3rem; }
  table.entries-table tr.day-head { display: block; padding: 0; border-bottom: 0; }
  table.entries-table tr.day-head th { display: block; padding: .5rem .9rem; }
  table.entries-table .cell-category { display: none; }
  table.entries-table .actions { text-align: right; }
  table.entries-table .meta-mobile { display: inline; }
  table.entries-table .meta-desktop { display: none; }
  table.entries-table .tx-title { overflow-wrap: anywhere; }

  /* Cadastros: o nome com o resumo embaixo, o valor e os ícones de editar e excluir na mesma linha */
  table.simple-on-mobile thead { display: none; }
  table.simple-on-mobile, table.simple-on-mobile tbody { display: block; }
  table.simple-on-mobile tr { display: flex; align-items: center; gap: .5rem; padding: .5rem .5rem .5rem .9rem; border-bottom: 1px solid var(--border); }
  table.simple-on-mobile tr:last-child { border-bottom: 0; }
  table.simple-on-mobile td { display: block; padding: 0; border: 0; background: none; }
  table.simple-on-mobile tbody tr:hover td { background: none; }
  table.simple-on-mobile .cell-main { flex: 1; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
  table.simple-on-mobile .cell-sub { display: block; font-size: .82rem; font-weight: 400; color: var(--muted); }
  table.simple-on-mobile .hide-mobile { display: none; }
  table.simple-on-mobile td.actions > * + * { margin-left: 0; }
  .table-wrap.compact table.simple-on-mobile tr { padding-left: 0; padding-right: 0; }

  .confirm-fields, .confirm-fields.with-installments { grid-template-columns: 1fr 1fr; }
  .confirm-fields .field-installments { grid-column: 1 / -1; }
  .confirm-fields .btn, .confirm-fields button { grid-column: 1 / -1; }
  .bank-create { grid-template-columns: 1fr; padding-left: 0; }
  .split-row { grid-template-columns: 1fr 110px; }
  .split-row > :last-child { grid-column: 1 / -1; }
  .tag-input .tag-search { font-size: 16px; min-height: 36px; }
}

/* Extrato até o tablet: descrição e valor, com a data e a categoria embaixo; o saldo do dia numa faixa entre os
   dias. A tabela de seis colunas só cabe em tela larga. */
@media (max-width: 1100px) {
  table.statement-table thead { display: none; }
  table.statement-table, table.statement-table tbody { display: block; }
  table.statement-table td { display: block; padding: 0; border: 0; background: none; }
  table.statement-table tbody tr:hover td { background: none; }
  table.statement-table tr.entry-row {
    position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "desc amount" "meta meta";
    column-gap: .75rem; padding: .6rem .9rem; border-bottom: 1px solid var(--border);
  }
  table.statement-table .cell-desc { grid-area: desc; min-width: 0; overflow-wrap: anywhere; }
  table.statement-table .cell-meta { grid-area: meta; font-size: .82rem; color: var(--muted); }
  table.statement-table .cell-amount { grid-area: amount; font-weight: 600; }
  table.statement-table .cell-date-inline { display: inline; }
  table.statement-table .entry-row .cell-date, table.statement-table .entry-row .cell-balance,
  table.statement-table .entry-row .actions { display: none; }
  table.statement-table .stretched::after { content: ""; position: absolute; inset: 0; }
  table.statement-table tr.day-end {
    display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .75rem; padding: .45rem .9rem;
    background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: .82rem;
  }
  table.statement-table tr.day-end .cell-label { flex: 1 1 auto; white-space: nowrap; }
  table.statement-table tr.day-end .cell-balance { font-weight: 600; }
  table.statement-table tr.day-end > td:empty { display: none; }
  table.statement-table tr:last-child { border-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
    animation: none !important; transition: none !important;
  }
}
