/* ============================================================
   FINANCEIRO — PEDREIRAS FC
   Mesmos temas claro/escuro do /torneio/ (variáveis e tipografia).
   ============================================================ */

:root {
  --bg-primary: #080b11;
  --bg-surface: #101522;
  --bg-elevated: #182032;
  --border: rgba(255, 255, 255, 0.09);
  --gold: #f59e0b;
  --gold-soft: rgba(245, 158, 11, 0.14);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.16);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.16);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.18);
  --orange: #fb923c;
  --orange-soft: rgba(251, 146, 60, 0.18);
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, 0.18);
  --purple: #c084fc;
  --purple-soft: rgba(192, 132, 252, 0.18);
  --grey-soft: rgba(148, 163, 184, 0.12);
  --text: #f8fafc;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --font: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-elevated: #f8fafc;
  --border: rgba(0, 0, 0, 0.09);
  --gold: #d97706;
  --gold-soft: rgba(217, 119, 6, 0.12);
  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.13);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.11);
  --amber: #b45309;
  --amber-soft: rgba(217, 119, 6, 0.15);
  --orange: #c2410c;
  --orange-soft: rgba(234, 88, 12, 0.13);
  --blue: #1d4ed8;
  --blue-soft: rgba(37, 99, 235, 0.12);
  --purple: #7e22ce;
  --purple-soft: rgba(147, 51, 234, 0.12);
  --grey-soft: rgba(100, 116, 139, 0.12);
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; font-weight: 700; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Cabeçalho ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.brand-badge {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
  background: var(--gold-soft); border: 1px solid var(--gold); font-size: 1.15rem;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 800; font-size: 1.05rem; letter-spacing: .2px; }
.brand-sub { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg-elevated); cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.icon-btn:hover { border-color: var(--gold); }
.role-badge {
  font-size: .7rem; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold);
}

.container { max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); }

/* ---------- Entrar / estados ---------- */
.login-card {
  max-width: 400px; margin: 40px auto 0; padding: 24px;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.login-card h1 { font-size: 1.4rem; margin-bottom: 4px; }
.login-card form { display: grid; gap: 6px; margin-top: 16px; }
.login-card label { font-size: .8rem; font-weight: 600; color: var(--text-2); margin-top: 8px; }
input[type="email"], input[type="password"], input[type="search"], input[type="text"], input[type="tel"], select {
  width: 100%; padding: 11px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elevated);
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.form-erro { margin: 8px 0 0; padding: 9px 11px; border-radius: var(--radius-sm); background: var(--red-soft); color: var(--red); font-size: .85rem; }
.btn-primary {
  margin-top: 14px; padding: 12px 16px; border: 0; border-radius: var(--radius-sm); cursor: pointer;
  font-weight: 700; color: #1a1205; background: linear-gradient(135deg, #fbbf24, #d97706);
}
.btn-primary:disabled { opacity: .6; cursor: wait; }
.state-box { text-align: center; padding: 60px 16px; color: var(--muted); }
.spinner {
  width: 34px; height: 34px; margin: 0 auto 12px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--gold); animation: gira .8s linear infinite;
}
@keyframes gira { to { transform: rotate(360deg); } }

/* ---------- Abas ---------- */
.tabs {
  display: flex; gap: 6px; padding: 4px; margin-bottom: 16px; overflow-x: auto;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.tab {
  flex: 1 0 auto; padding: 10px 16px; border: 0; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--muted); font-weight: 700; white-space: nowrap;
}
.tab[aria-selected="true"] { background: var(--gold-soft); color: var(--gold); }

/* ---------- Cartões ---------- */
.grid { display: grid; gap: 12px; }
.grid.c2 { grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid.c2 { grid-template-columns: repeat(2, 1fr); } }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 760px) { .grid.c4 { grid-template-columns: repeat(4, 1fr); } }
.card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); min-width: 0;
}
.card .label { font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.card .valor { font-size: 1.45rem; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card .detalhe { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.card.destaque { background: linear-gradient(135deg, var(--gold-soft), var(--bg-surface)); border-color: var(--gold); }
.card.destaque .valor { font-size: 2rem; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 0 10px; flex-wrap: wrap; }
.chart-box { position: relative; height: 260px; }
.chart-box.alto { height: 320px; }
.bar-list { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 8px; align-items: center; font-size: .85rem; }
.bar-row .nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bar-row .trilho { display: block; height: 10px; border-radius: 999px; background: var(--grey-soft); overflow: hidden; }
.bar-row .barra { display: block; height: 100%; border-radius: 999px; }
.bar-row .v { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- Filtros ---------- */
.filtros { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.filtros .largo { grid-column: 1 / -1; }
@media (min-width: 760px) { .filtros { grid-template-columns: 2fr 1fr 1fr 1fr 1fr; } .filtros .largo { grid-column: auto; } }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: .72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }
.linha-opcoes { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: center; margin-bottom: 12px; }
.btn-sec {
  padding: 9px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-elevated); cursor: pointer; font-weight: 600;
}
.btn-sec:hover { border-color: var(--gold); }

/* ---------- Extrato ---------- */
.resumo-filtro { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .88rem; color: var(--text-2); margin-bottom: 10px; }
.lista { display: grid; gap: 8px; }
.mov {
  display: grid; gap: 4px 12px; padding: 12px 14px;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
  grid-template-columns: 1fr auto;
  grid-template-areas: "det valor" "quem saldo" "meta meta";
}
.mov.entrada { border-left: 4px solid var(--green); }
.mov.saida { border-left: 4px solid var(--red); }
.mov .det { grid-area: det; min-width: 0; }
.mov .desc { font-weight: 600; overflow-wrap: anywhere; }
.mov .quem { grid-area: quem; font-size: .85rem; color: var(--text-2); overflow-wrap: anywhere; }
.mov .quem small { color: var(--muted); }
.mov .valor { grid-area: valor; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mov .saldo { grid-area: saldo; text-align: right; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mov .saldo b { color: var(--text-2); }
.mov .meta { grid-area: meta; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .78rem; color: var(--muted); }
@media (min-width: 900px) {
  .mov {
    grid-template-columns: 96px minmax(0, 2.2fr) minmax(0, 1.5fr) 70px 120px 130px; align-items: center;
    grid-template-areas: "data det quem forma valor saldo";
  }
  .mov .meta { display: contents; }
  .mov .meta .data { grid-area: data; }
  .mov .meta .forma { grid-area: forma; }
  .mov .meta .extra { display: none; }
  .lista-cab {
    display: grid; grid-template-columns: 96px minmax(0, 2.2fr) minmax(0, 1.5fr) 70px 120px 130px; gap: 12px; padding: 0 14px 4px;
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--muted);
  }
  .lista-cab span:nth-child(5), .lista-cab span:nth-child(6) { text-align: right; }
}
@media (max-width: 899px) { .lista-cab { display: none; } }
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700;
  background: var(--grey-soft); color: var(--text-2); white-space: nowrap;
}
.chip.cat { background: var(--gold-soft); color: var(--gold); }
.vazio { padding: 36px 12px; text-align: center; color: var(--muted); }

/* ---------- Grade de mensalidades ---------- */
.grade-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-surface); max-height: 70vh; }
table.grade { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .82rem; }
.grade th, .grade td { padding: 7px 8px; text-align: center; border-bottom: 1px solid var(--border); white-space: nowrap; }
.grade thead th {
  position: sticky; top: 0; z-index: 3; background: var(--bg-elevated);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .3px; color: var(--muted);
}
.grade .nome { position: sticky; left: 0; z-index: 2; text-align: left; background: var(--bg-surface); min-width: 150px; max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.grade thead .nome { z-index: 4; background: var(--bg-elevated); }
.grade .nome small { display: block; color: var(--muted); font-size: .7rem; }
.grade tfoot td { background: var(--bg-elevated); font-weight: 700; border-top: 1px solid var(--border); }
.grade tfoot .nome { background: var(--bg-elevated); z-index: 2; }
.sit { display: inline-block; min-width: 54px; padding: 3px 7px; border-radius: 8px; font-size: .72rem; font-weight: 700; }
.sit.pago { background: var(--green-soft); color: var(--green); }
.sit.pendente { background: var(--amber-soft); color: var(--amber); }
.sit.atrasado { background: var(--red-soft); color: var(--red); }
.sit.parcial { background: var(--orange-soft); color: var(--orange); }
.sit.isento { background: var(--blue-soft); color: var(--blue); }
.sit.afastado { background: var(--purple-soft); color: var(--purple); }
.sit.dispensado, .sit.nao_cobrado { background: transparent; color: var(--muted); font-weight: 400; }
.legenda { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 10px 0 0; font-size: .78rem; color: var(--muted); align-items: center; }
.rodape { margin-top: 28px; text-align: center; font-size: .78rem; }

/* ---------- Aviso ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: min(92vw, 460px); padding: 11px 16px; border-radius: 12px; z-index: 50;
  background: var(--text); color: var(--bg-surface); font-size: .88rem; box-shadow: var(--shadow);
}
.toast.erro { background: var(--red); color: #fff; }

@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.troca-modo { margin: 18px 0 0; text-align: center; }
.link-btn { background: none; border: 0; padding: 6px; color: var(--gold); font-weight: 600; cursor: pointer; text-decoration: underline; }

/* setinha que expande os meses anteriores (à esquerda dos meses) */
.grade th.seta, .grade td.seta { width: 36px; min-width: 36px; padding: 0 2px; }
.seta-btn {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-surface);
  color: var(--gold); font-size: 1.15rem; font-weight: 800; line-height: 1; cursor: pointer;
}
.seta-btn:hover { border-color: var(--gold); background: var(--gold-soft); }

.grade thead .nome .seta-btn { float: right; width: 26px; height: 26px; font-size: 1rem; }
