:root {
  --red: #a61b1b;
  --red-strong: #861414;
  --red-soft: #fbeaea;
  --ink: #1f2328;
  --ink-2: #4a5159;
  --muted: #6b7280;
  --line: #e4e4e2;
  --bg: #f4f4f2;
  --card: #ffffff;
  --ok: #1d7a46;
  --ok-soft: #e6f4ec;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --red: #e05252;
    --red-strong: #f06b6b;
    --red-soft: #3a1d1d;
    --ink: #eceef0;
    --ink-2: #c3c8ce;
    --muted: #949ba3;
    --line: #2f3439;
    --bg: #15181b;
    --card: #1e2226;
    --ok: #5cc98a;
    --ok-soft: #1a3326;
    --warn: #e9b35c;
    --warn-soft: #3a2e1a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: var(--red); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.05rem; }
.container { max-width: 760px; margin: 0 auto; padding: 16px; }

/* topo */
.topbar { background: var(--red); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 760px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { color: #fff; text-decoration: none; display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.brand-mark { font-size: 1.3rem; }
.nav { display: none; gap: 4px; }
.nav a { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 8px; opacity: .85; font-size: .95rem; }
.nav a.active, .nav a:hover { background: rgba(255, 255, 255, .16); opacity: 1; }

/* barra inferior (celular) */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { flex: 1; text-align: center; padding: 8px 4px 10px; color: var(--muted); text-decoration: none; font-size: .72rem; }
.tabbar a .ico { display: block; font-size: 1.25rem; line-height: 1.4; }
.tabbar a.active { color: var(--red); font-weight: 600; }

@media (min-width: 720px) {
  .nav { display: flex; }
  .tabbar { display: none !important; }
  body { padding-bottom: 24px; }
}

/* cartões */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; border: 1px solid var(--line); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.balance { background: linear-gradient(135deg, var(--red), var(--red-strong)); color: #fff; border: 0; }
.balance .label { opacity: .85; font-size: .9rem; }
.balance .value { font-size: 2.1rem; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 10px; font-variant-numeric: tabular-nums; }
.balance .meta { font-size: .88rem; opacity: .9; }
.progress { height: 8px; background: rgba(255, 255, 255, .25); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; background: #fff; border-radius: 99px; }

.muted { color: var(--muted); }
.small { font-size: .86rem; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack > * + * { margin-top: 10px; }

/* listas */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .main { min-width: 0; }
.list .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.list .sub { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.amount { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.amount.in { color: var(--ok); }
.amount.out { color: var(--red); }
.clickable { cursor: pointer; }

/* selos */
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.badge.neutral { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

.months { display: flex; flex-wrap: wrap; gap: 6px; }
.month-chip { font-size: .78rem; padding: 4px 9px; border-radius: 8px; border: 1px solid var(--line); }
.month-chip.paid { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.month-chip.open { background: var(--red-soft); color: var(--red); border-color: transparent; }
.month-chip.partial { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

/* Pix */
.pix { background: var(--bg); border: 1px dashed var(--line); border-radius: 12px; padding: 12px; }
.pix-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .95rem; overflow-wrap: anywhere; }
.trigram-tag { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; background: var(--red-soft); color: var(--red); padding: 1px 6px; border-radius: 6px; }

/* formulários */
form .field { margin-bottom: 12px; }
label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 4px; color: var(--ink-2); }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: 0; border-color: transparent; }
input.upper { text-transform: uppercase; letter-spacing: .08em; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 16px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--red); color: #fff;
}
.btn:hover { background: var(--red-strong); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.block { width: 100%; padding: 12px 16px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.btn.link { background: none; color: var(--red); padding: 0; border: 0; font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.error { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin-bottom: 12px; }
.success { background: var(--ok-soft); color: var(--ok); border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin-bottom: 12px; }

/* login */
.auth { max-width: 400px; margin: 6vh auto 0; }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand .logo { font-size: 2.6rem; }
.auth-brand h1 { margin: 6px 0 2px; }

/* abas do admin */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; }
.tabs a { white-space: nowrap; padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); text-decoration: none; font-size: .9rem; }
.tabs a.active { background: var(--ink); color: var(--card); border-color: var(--ink); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; flex: 1; min-width: 140px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat .k { font-size: .78rem; color: var(--muted); }
.stat .v { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* diálogo e aviso */
dialog { border: 0; border-radius: var(--radius); padding: 18px; width: min(460px, calc(100vw - 32px)); background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--card); padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: calc(100vw - 32px);
  font-size: .92rem; box-shadow: 0 6px 24px rgba(0, 0, 0, .2);
}
@media (min-width: 720px) { .toast { bottom: 24px; } }

.empty { text-align: center; color: var(--muted); padding: 18px 0; }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }
