/* =========================================================================
   Controle Financeiro · design system
   Mobile-first. Tema claro/escuro (automático ou escolhido pelo usuário).
   ========================================================================= */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f3;
  --border: #e6e8ec;
  --border-strong: #d4d8de;
  --text: #14171c;
  --text-2: #4b525c;
  --muted: #737b86;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-soft: #e7f0fc;
  --on-accent: #ffffff;
  --pos: #0f7b3f;
  --neg: #c4312f;
  --warn: #9a5b00;
  --warn-soft: #fff4e0;
  --ok-soft: #e6f6ec;
  --ref: rgba(42, 120, 214, .07);
  --sel: rgba(42, 120, 214, .12);
  --chart-pos: #2a78d6;
  --chart-neg: #e34948;
  --chart-grid: #e9ebee;
  --glass: rgba(244, 245, 247, .82);
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-2: 0 4px 16px rgba(16, 24, 40, .08), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-3: 0 18px 48px rgba(16, 24, 40, .18);
  --r: 14px;
  --r-lg: 20px;
  --sidebar: 256px;
  --appbar: 56px;
  --tabbar: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0f1115; --surface: #171a20; --surface-2: #1d2128; --surface-3: #252a33;
    --border: #2a2f38; --border-strong: #3a404b; --text: #eef0f3; --text-2: #b9c0ca; --muted: #8b939e;
    --accent: #3987e5; --accent-ink: #8cb8f0; --accent-soft: #1a2a44; --pos: #4ade80; --neg: #f87171;
    --warn: #fbbf24; --warn-soft: #33290f; --ok-soft: #12301f; --ref: rgba(57, 135, 229, .10); --sel: rgba(57, 135, 229, .18);
    --chart-pos: #3987e5; --chart-neg: #e66767; --chart-grid: #262b33;
    --glass: rgba(15, 17, 21, .78);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 4px 18px rgba(0, 0, 0, .45); --shadow-3: 0 18px 48px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115; --surface: #171a20; --surface-2: #1d2128; --surface-3: #252a33;
  --border: #2a2f38; --border-strong: #3a404b; --text: #eef0f3; --text-2: #b9c0ca; --muted: #8b939e;
  --accent: #3987e5; --accent-ink: #8cb8f0; --accent-soft: #1a2a44; --pos: #4ade80; --neg: #f87171;
  --warn: #fbbf24; --warn-soft: #33290f; --ok-soft: #12301f; --ref: rgba(57, 135, 229, .10); --sel: rgba(57, 135, 229, .18);
  --chart-pos: #3987e5; --chart-neg: #e66767; --chart-grid: #262b33;
  --glass: rgba(15, 17, 21, .78);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 4px 18px rgba(0, 0, 0, .45); --shadow-3: 0 18px 48px rgba(0, 0, 0, .6);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 15px/1.45 var(--font); background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font-size: 22px; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0; font-weight: 650; }
h3 { font-size: 12px; margin: 0; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
code { font-size: 12px; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.sm { gap: 8px; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.splash { min-height: 100vh; display: grid; place-items: center; }
.splash img { border-radius: 16px; animation: pulso 1.2s ease-in-out infinite; }
@keyframes pulso { 50% { transform: scale(.94); opacity: .7; } }
.ico { width: 20px; height: 20px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ico.sm { width: 16px; height: 16px; }
.ico.lg { width: 24px; height: 24px; }

/* ---------- estrutura: computador ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; z-index: 30;
}
.brand { font-weight: 750; font-size: 16px; padding: 4px 10px 16px; display: flex; align-items: center; gap: 10px; letter-spacing: -.01em; }
.brand img { width: 30px; height: 30px; border-radius: 9px; }
.nav-title { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px; color: var(--text-2); font-size: 14px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.ativo { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.sidebar-footer { margin-top: auto; padding: 12px 6px 4px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.main { margin-left: var(--sidebar); min-width: 0; }
.appbar {
  position: sticky; top: 0; z-index: 20; background: var(--glass); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border); padding: 10px 24px; display: flex; gap: 12px; align-items: center; min-height: 62px;
}
.appbar .titulo { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.content { padding: 20px 24px 64px; max-width: 1600px; }
.tabbar, .appbar .voltar { display: none; }

/* ---------- estrutura: celular / tablet ---------- */
@media (max-width: 1023px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding-bottom: calc(var(--tabbar) + var(--safe-bottom)); }
  .appbar { padding: calc(8px + var(--safe-top)) 10px 8px; min-height: calc(var(--appbar) + var(--safe-top)); gap: 4px; flex-wrap: wrap; }
  .appbar .voltar { display: inline-grid; }
  .appbar .titulo { font-size: 17px; }
  .content { padding: 14px 14px 28px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tabbar) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
    background: var(--glass); backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--border);
  }
  .tabbar.quatro { grid-template-columns: repeat(4, 1fr); }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none;
    color: var(--muted); font-size: 11px; font-weight: 600; text-decoration: none; cursor: pointer; padding: 0;
  }
  .tabbar .ativo { color: var(--accent); }
  .tabbar .ativo .ico { stroke-width: 2.3; }
  .tabbar .bolha {
    width: 50px; height: 50px; border-radius: 17px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center;
    box-shadow: 0 6px 18px rgba(42, 120, 214, .38); margin-top: -20px;
  }
  .tabbar .bolha .ico { width: 26px; height: 26px; stroke-width: 2.4; }
  input, select, textarea { font-size: 16px !important; } /* evita zoom automático no iPhone */
}
@media (min-width: 1024px) { .so-mobile { display: none !important; } }
@media (max-width: 1023px) { .so-desktop { display: none !important; } }

/* ---------- superfícies ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-1); padding: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; flex-wrap: wrap; }
.sec-title { display: flex; align-items: center; gap: 8px; margin: 8px 4px -4px; min-height: 30px; }
.sec-title h3 { flex: 1; }
.sec-title .num { font-weight: 650; font-size: 13px; color: var(--text-2); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
@media (max-width: 1023px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* número principal da tela */
.hero .rotulo { font-size: 13px; color: var(--text-2); font-weight: 550; }
.hero .valor { font-size: 40px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 4px 0 2px; }
.hero .valor .cent { font-size: .55em; font-weight: 650; letter-spacing: 0; }
@media (max-width: 480px) { .hero .valor { font-size: 34px; } }
.metricas { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; margin-top: 14px; }
.metrica { background: var(--surface-2); border-radius: 12px; padding: 9px 12px; min-width: 0; }
.metrica .l { font-size: 12px; color: var(--muted); }
.metrica .v { font-size: 15.5px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* carrossel com encaixe (cartões das pessoas no celular) */
.carrossel { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 2px 6px; scrollbar-width: none; }
.carrossel::-webkit-scrollbar { display: none; }
.carrossel > * { scroll-snap-align: start; }
@media (max-width: 1023px) { .carrossel { grid-auto-columns: 82%; margin: 0 -14px; padding: 2px 14px 6px; scroll-padding: 0 14px; } }
a.card { color: inherit; text-decoration: none; display: block; transition: transform .1s, box-shadow .15s; }
a.card:hover { box-shadow: var(--shadow-2); }
a.card:active { transform: scale(.99); }

/* ---------- listas ---------- */
.list { display: flex; flex-direction: column; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 58px; position: relative;
  color: inherit; text-decoration: none; background: none; border: 0; width: 100%; text-align: left; font-size: 15px;
}
.item + .item::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--border); }
.item.av + .item.av::before { left: 66px; }
a.item, button.item, .item.clicavel { cursor: pointer; }
a.item:hover, button.item:hover, .item.clicavel:hover { background: var(--surface-2); text-decoration: none; }
a.item:active, button.item:active, .item.clicavel:active { background: var(--surface-3); }
.item .corpo { flex: 1; min-width: 0; }
.item .t { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.item .fim { text-align: right; flex-shrink: 0; }
.item .fim .v { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item .fim .s { justify-content: flex-end; }
.item .chev { color: var(--border-strong); }
.item.feito .t, .item.feito .fim .v { color: var(--muted); }
.avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0; letter-spacing: .02em; }
.avatar.cartao { border-radius: 8px; width: 38px; height: 27px; font-size: 9.5px; position: relative; }
.avatar.cartao::after { content: ""; position: absolute; left: 5px; top: 7px; width: 8px; height: 6px; border-radius: 2px; background: rgba(255,255,255,.65); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.vazio { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- controles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--border-strong); background: var(--surface);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap; line-height: 1.25; font-weight: 580; min-height: 38px; font-size: 14px;
  transition: background .12s, transform .08s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.btn.danger { color: var(--neg); }
.btn.sm { padding: 5px 10px; font-size: 13px; min-height: 32px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  border: 0; background: transparent; cursor: pointer; width: 40px; height: 40px; border-radius: 11px; color: var(--text-2);
  display: inline-grid; place-items: center; flex-shrink: 0; padding: 0;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 8px; }
.icon-btn.on { background: var(--accent-soft); color: var(--accent-ink); }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=month], input[type=search], select, textarea {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 10px; padding: 8px 11px; min-width: 0; min-height: 40px; width: 100%;
}
input[type=color] { width: 100%; height: 40px; border: 1px solid var(--border-strong); border-radius: 10px; padding: 3px; background: var(--surface); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.busca { position: relative; flex: 1; min-width: 150px; }
.busca .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; width: 18px; height: 18px; }
.busca input { padding-left: 36px; }
.campo { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-2); font-weight: 580; min-width: 0; }
.campo > input, .campo > select, .campo > textarea { font-size: 15px; color: var(--text); font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.span-2 { grid-column: span 2; }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .span-2, .form-grid .full { grid-column: 1 / -1; } }
.chk { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; user-select: none; }
.chk input { width: 18px; height: 18px; accent-color: var(--accent); }

/* botão redondo de pago / recebido */
.check-circ {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; flex-shrink: 0;
  background: none; cursor: pointer; color: transparent; padding: 0; transition: background .12s, border-color .12s;
}
.check-circ:hover { border-color: var(--pos); }
.check-circ.on { background: var(--pos); border-color: var(--pos); color: var(--surface); }
.check-circ .ico { width: 16px; height: 16px; stroke-width: 3; }
.check-circ:disabled { cursor: default; opacity: .6; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: 12px; font-weight: 580;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 18px;
}
.chip.rateio { background: transparent; border: 1px dashed var(--border-strong); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip .dot { width: 8px; height: 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 1px; }
.chips::-webkit-scrollbar { display: none; }
.chips button { border: 0; cursor: pointer; padding: 7px 13px; font-size: 13px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-weight: 580; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.chips button.on { background: var(--text); color: var(--surface); }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 5px; background: var(--surface-3); color: var(--muted); font-weight: 580; white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--pos); }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; border-radius: 8px; font-size: 13px; font-weight: 580; color: var(--text-2); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.seg.full { display: flex; } .seg.full button { flex: 1; justify-content: center; }

/* ---------- faixa de meses ---------- */
.faixa-meses { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.meses {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 2px; flex: 1; min-width: 0; scroll-behavior: smooth;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent);
}
.meses::-webkit-scrollbar { display: none; }
.meses button {
  border: 0; background: transparent; color: var(--text-2); border-radius: 10px; padding: 5px 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; line-height: 1.15; min-width: 52px; flex-shrink: 0; position: relative;
}
.meses button .m { font-weight: 650; font-size: 14px; }
.meses button .a { font-size: 10.5px; color: var(--muted); }
.meses button:hover { background: var(--surface-3); }
.meses button.on { background: var(--text); color: var(--surface); }
.meses button.on .a { color: inherit; opacity: .7; }
.meses button.ref:not(.on) .m { color: var(--accent-ink); }
.meses button.ref::after { content: ""; position: absolute; bottom: 1px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
.meses button.on.ref::after { background: var(--surface); }
@media (max-width: 1023px) { .faixa-meses { order: 10; flex-basis: 100%; } .faixa-meses .icon-btn { display: none; } }

/* ---------- barra empilhada (quem paga a fatura) ---------- */
.stackbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; }
.stackbar span { display: block; min-width: 3px; }
.legenda { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 16px; margin-top: 12px; }
.legenda button { display: flex; align-items: center; gap: 8px; font-size: 13.5px; border: 0; background: none; padding: 5px 6px; margin: 0 -6px; border-radius: 8px; cursor: pointer; text-align: left; color: var(--text); }
.legenda button:hover { background: var(--surface-2); }
.legenda button.on { background: var(--accent-soft); }
.legenda .nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.legenda .v { font-variant-numeric: tabular-nums; font-weight: 650; }
.barra-h { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 7px; }
.barra-h span { display: block; height: 100%; border-radius: 3px; }

/* ---------- gráfico de colunas ---------- */
.grafico { position: relative; margin-top: 10px; user-select: none; -webkit-user-select: none; }
.grafico svg { display: block; width: 100%; overflow: visible; }
.grafico .grade line { stroke: var(--chart-grid); stroke-width: 1; }
.grafico .zero { stroke: var(--border-strong); stroke-width: 1; }
.grafico text { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.grafico text.on { fill: var(--text); font-weight: 700; }
.grafico text.rotulo { fill: var(--text); font-size: 11.5px; font-weight: 650; }
.grafico .alvo { fill: transparent; cursor: pointer; }
@media (hover: hover) { .grafico .alvo:hover { fill: var(--ref); } }
.grafico .marca { fill: var(--text); }
.dica {
  position: absolute; pointer-events: none; background: var(--text); color: var(--surface); padding: 6px 10px; border-radius: 8px; font-size: 12px;
  white-space: nowrap; transform: translate(-50%, calc(-100% - 6px)); box-shadow: var(--shadow-2); z-index: 5; font-variant-numeric: tabular-nums;
}

/* ---------- planilha (visão de grade) ---------- */
.sheet-wrap { overflow: auto; max-height: calc(100vh - 220px); -webkit-overflow-scrolling: touch; }
@media (max-width: 1023px) { .sheet-wrap { max-height: calc(100dvh - 250px - var(--tabbar) - var(--safe-bottom)); } }
table.sheet { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 13.5px; }
table.sheet th, table.sheet td { border-bottom: 1px solid var(--border); padding: 0 10px; height: 34px; }
table.sheet thead th {
  position: sticky; top: 0; z-index: 3; background: var(--surface-2); font-size: 11.5px; font-weight: 650; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; text-align: right; border-bottom: 1px solid var(--border-strong);
}
table.sheet thead th.l, table.sheet td.l { text-align: left; }
table.sheet .fix { position: sticky; left: 0; z-index: 2; background: var(--surface); border-right: 1px solid var(--border); }
table.sheet thead .fix { z-index: 4; background: var(--surface-2); }
table.sheet td.m { min-width: 96px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.sheet td.m.edit { cursor: cell; }
table.sheet td.m.edit:hover { background: var(--sel); }
table.sheet td.m input { width: 100%; border: 0; outline: 2px solid var(--accent); border-radius: 4px; text-align: right; padding: 4px 6px; background: var(--surface); min-height: 0; }
table.sheet th.ref, table.sheet td.ref { background-image: linear-gradient(var(--ref), var(--ref)); }
table.sheet tr.sec td { background: var(--surface-2); font-weight: 650; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); height: 30px; }
table.sheet tr.tot td { font-weight: 650; background: var(--surface-2); }
table.sheet tr.tot.forte td { border-top: 1px solid var(--border-strong); }
table.sheet tr.saldo td { font-weight: 750; font-size: 14.5px; background: var(--accent-soft); }
table.sheet tbody tr:hover td { background-color: var(--surface-2); }
table.sheet td.desc { min-width: 230px; max-width: 290px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1023px) { table.sheet td.desc { min-width: 140px; max-width: 160px; } }
table.sheet td.resp { min-width: 150px; max-width: 240px; cursor: pointer; }
table.sheet td.acoes { white-space: nowrap; width: 1%; }
.cel-pago { font-size: 11px; margin-left: 3px; color: var(--pos); }
.aj { box-shadow: inset 3px 0 0 var(--warn); }

/* ---------- modal / folha inferior ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 14, 20, .45); z-index: 60; display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
@keyframes sobe { from { transform: translateY(24px); opacity: .3; } }
@keyframes sobeTudo { from { transform: translateY(100%); } }
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-3); width: min(620px, 100%); max-height: calc(100vh - 32px);
  display: flex; flex-direction: column; animation: sobe .18s ease-out; overflow: hidden;
}
.modal.lg { width: min(820px, 100%); }
.modal.sm { width: min(440px, 100%); }
.modal-head { padding: 16px 18px 10px; display: flex; align-items: center; gap: 8px; }
.modal-head h2 { flex: 1; font-size: 17px; }
.modal-body { padding: 4px 18px 18px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; overscroll-behavior: contain; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.alca { display: none; }
@media (max-width: 1023px) {
  .overlay { place-items: end stretch; padding: 0; }
  .modal, .modal.lg, .modal.sm {
    width: 100%; max-height: calc(100dvh - 20px - var(--safe-top)); border-radius: var(--r-lg) var(--r-lg) 0 0;
    animation: sobeTudo .24s cubic-bezier(.2, .8, .2, 1); touch-action: pan-y;
  }
  .alca { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 8px auto 0; flex-shrink: 0; }
  .modal-head { padding: 6px 16px 6px; cursor: grab; }
  .modal-body { padding: 4px 16px 16px; }
  .modal-foot { padding: 10px 16px calc(10px + var(--safe-bottom)); }
  .modal-foot .btn { flex: 1; min-height: 48px; font-size: 15px; }
  .modal-foot .btn.danger { flex: 0 0 auto; }
}
.acoes-folha { display: flex; flex-direction: column; margin: 0 -18px; }
.acoes-folha button { display: flex; align-items: center; gap: 14px; border: 0; background: none; padding: 14px 20px; font-size: 16px; cursor: pointer; text-align: left; color: var(--text); }
.acoes-folha button:hover { background: var(--surface-2); }
.acoes-folha button.danger { color: var(--neg); }
.acoes-folha button .ico { color: var(--text-2); }
.acoes-folha button.danger .ico { color: var(--neg); }
.pop { position: fixed; z-index: 70; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-3); padding: 14px; width: 330px; animation: sobe .12s ease-out; }

.divisao-lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.divisao-lista label { display: flex; align-items: center; gap: 9px; border: 1.5px solid var(--border); border-radius: 12px; padding: 8px 10px; cursor: pointer; min-height: 50px; }
.divisao-lista label.on { border-color: var(--accent); background: var(--accent-soft); }
.divisao-lista input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.divisao-lista input[type=text] { width: 58px; margin-left: auto; padding: 4px 6px; text-align: right; min-height: 32px; }
.preview { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-size: 13.5px; }
.valor-grande { font-size: 26px !important; font-weight: 700; font-variant-numeric: tabular-nums; min-height: 54px !important; }

/* ---------- avisos ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 24px); pointer-events: none; }
@media (max-width: 1023px) { .toasts { bottom: calc(var(--tabbar) + var(--safe-bottom) + 12px); } }
.toast { background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow-2); font: inherit; font-size: 14px; animation: sobe .18s ease-out;
  border: 0; pointer-events: auto; cursor: pointer; display: flex; align-items: flex-start; gap: 8px; text-align: left; max-width: 520px; line-height: 1.35; }
.toast .ico { flex-shrink: 0; margin-top: 1px; }
.toast.erro { background: #b42318; color: #fff; }
.faixa-versao { position: fixed; top: calc(10px + var(--safe-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 101; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-2); border-radius: 14px; padding: 8px 8px 8px 14px; font-size: 14px; width: max-content; max-width: calc(100vw - 24px); }
.alerta { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 11px 14px; font-size: 13.5px; }

/* ---------- carregamento ---------- */
.skel { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: brilho 1.3s ease infinite; border-radius: var(--r); }
@keyframes brilho { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.carregando-linha { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 90; pointer-events: none; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 40% 100%; background-repeat: no-repeat; animation: carrega .9s linear infinite; }
@keyframes carrega { from { background-position: -40% 0; } to { background-position: 140% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
  background:
    radial-gradient(700px 420px at 12% -8%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(620px 420px at 100% 108%, color-mix(in srgb, #1baf7a 16%, transparent), transparent 70%),
    var(--bg); }
.login { width: min(410px, 100%); display: flex; flex-direction: column; gap: 18px; }
.login-marca { text-align: center; }
.login-marca .logo { width: 76px; height: 76px; border-radius: 22px; margin: 0 auto 14px; display: block;
  box-shadow: 0 14px 34px color-mix(in srgb, var(--accent) 38%, transparent); animation: flutua 5s ease-in-out infinite; }
.login-marca h1 { font-size: 26px; letter-spacing: -.02em; margin: 0; }
.login-marca p { margin: 6px auto 0; color: var(--muted); font-size: 14.5px; max-width: 300px; line-height: 1.45; }
.login .card { padding: 24px; border-radius: 22px; box-shadow: var(--shadow-2); border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); }
.login .btn { min-height: 50px; font-size: 15.5px; border-radius: 14px; width: 100%; justify-content: center; }
.login .btn.bio { font-weight: 650; gap: 10px; }
.login .btn.bio .ico { width: 22px; height: 22px; }
.login .bio-quem { text-align: center; margin-bottom: 12px; font-size: 15px; }
.login .ou { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; margin: 16px 0 12px; }
.login .ou::before, .login .ou::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.login .versao-rodape { margin-top: 0; }
@keyframes flutua { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .login-marca .logo { animation: none; } }
/* campo com ícone (e botão de mostrar senha) */
.campo-ic { position: relative; display: flex; align-items: center; }
.campo-ic > .ico { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.campo-ic input { padding-left: 38px !important; width: 100%; }
.campo-ic .olho { position: absolute; right: 4px; background: none; border: 0; color: var(--muted); padding: 8px; cursor: pointer; border-radius: 8px; display: inline-flex; }
.campo-ic .olho:hover { color: var(--text); }
.campo-ic:has(.olho) input { padding-right: 40px !important; }

/* ---------- tabelas simples e abas ---------- */
table.simples { width: 100%; border-collapse: collapse; }
table.simples th, table.simples td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; }
table.simples th { font-size: 11.5px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
table.simples td.num, table.simples th.num { text-align: right; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: var(--surface-3); padding: 8px 14px; cursor: pointer; border-radius: 999px; color: var(--text-2); font-weight: 580; white-space: nowrap; font-size: 14px; }
.tabs button.on { background: var(--text); color: var(--surface); }

/* linha editável (controle, anotações, rateio) */
.linha-edit { display: flex; gap: 8px; align-items: center; padding: 8px 14px; }
.linha-edit + .linha-edit { border-top: 1px solid var(--border); }
.linha-edit input.valor { width: 130px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.linha-edit input[type=date] { width: 160px; flex-shrink: 0; }
.linha-edit.feito input[type=text] { color: var(--muted); text-decoration: line-through; }
@media (max-width: 560px) {
  .linha-edit { flex-wrap: wrap; }
  .linha-edit input[type=text]:not(.valor) { flex: 1 1 55%; }
  .linha-edit input.valor { flex: 1; width: auto; }
  .linha-edit input[type=date] { width: 100%; }
}
.membro-rateio { display: grid; grid-template-columns: 1.4fr .6fr .8fr 1.2fr .8fr auto; gap: 8px; align-items: end; padding: 10px 0; border-bottom: 1px solid var(--border); }
@media (max-width: 760px) { .membro-rateio { grid-template-columns: 1fr 1fr; } .membro-rateio > :first-child { grid-column: 1 / -1; } }
.cab { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.cab > h2 { flex: 1 0 auto; }
@media (max-width: 1023px) { .appbar .titulo { flex: 1 1 auto !important; max-width: none !important; } }

/* =====================================================================
   v4 · dashboard pessoal, mini cartões, ícones e planilha com mais contraste
   ===================================================================== */
:root { --zebra: #f8f9fb; --ref-forte: rgba(42, 120, 214, .11); --grade: #e3e6ea; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) { --zebra: #1b1f26; --ref-forte: rgba(57, 135, 229, .16); --grade: #2e343e; --border: #2f353f; } }
:root[data-theme="dark"] { --zebra: #1b1f26; --ref-forte: rgba(57, 135, 229, .16); --grade: #2e343e; --border: #2f353f; }

/* cartão de crédito em miniatura */
.mini-cartao {
  --c: #64748b; position: relative; display: inline-block; flex-shrink: 0; width: 44px; height: 30px; border-radius: 7px; vertical-align: middle;
  background: linear-gradient(135deg, var(--c) 0%, color-mix(in srgb, var(--c) 58%, #000) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22), 0 2px 6px rgba(15, 20, 30, .22);
}
.mini-cartao::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(160deg, rgba(255,255,255,.28), transparent 45%); }
.mini-cartao i { position: absolute; left: 6px; top: 8px; width: 9px; height: 7px; border-radius: 2px; background: linear-gradient(135deg, #f6dd8f, #c9a24a); }
.mini-cartao b { position: absolute; right: 5px; bottom: 3px; font-size: 9px; font-weight: 800; color: #fff; letter-spacing: .04em; text-shadow: 0 1px 1px rgba(0,0,0,.35); }
.mini-cartao.lg { width: 66px; height: 44px; border-radius: 9px; }
.mini-cartao.lg i { left: 9px; top: 12px; width: 13px; height: 10px; }
.mini-cartao.lg b { font-size: 12px; right: 8px; bottom: 5px; }
.mini-cartao.sm { width: 34px; height: 23px; border-radius: 5px; }
.mini-cartao.sm i { left: 4px; top: 6px; width: 7px; height: 5px; }
.mini-cartao.sm b { font-size: 7.5px; right: 3px; bottom: 2px; }
.mini-cartao.xs { width: 24px; height: 16px; border-radius: 4px; margin-right: 4px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.mini-cartao.xs i { left: 3px; top: 4px; width: 5px; height: 4px; border-radius: 1px; }
.mini-cartao.xs b { display: none; }

/* ícone redondo da conta */
.ic { width: 38px; height: 38px; border-radius: 12px; display: inline-grid; place-items: center; flex-shrink: 0; background: var(--surface-3); color: var(--text-2); }
.ic .ico { width: 19px; height: 19px; }
.ic.receita { background: var(--ok-soft); color: var(--pos); }
.ic.despesa { background: var(--accent-soft); color: var(--accent-ink); }
.ic.xs { width: 22px; height: 22px; border-radius: 7px; vertical-align: middle; margin-right: 4px; }
.ic.xs .ico { width: 13px; height: 13px; }

/* blocos do dashboard */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1023px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow-1); min-width: 0; }
.tile .ic { width: 32px; height: 32px; border-radius: 10px; margin-bottom: 8px; }
.tile .ic .ico { width: 17px; height: 17px; }
.tile .l { font-size: 12.5px; color: var(--text-2); font-weight: 580; }
.tile .v { font-size: 18px; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.tile .s { font-size: 12px; color: var(--muted); }
.progresso { height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; margin-top: 12px; }
.progresso span { display: block; height: 100%; border-radius: 5px; transition: width .4s ease; }
.data-venc { width: 42px; height: 44px; border-radius: 11px; background: var(--surface-3); display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; line-height: 1; }
.data-venc b { font-size: 17px; font-weight: 750; }
.data-venc small { font-size: 10px; color: var(--muted); text-transform: uppercase; margin-top: 2px; font-weight: 650; }
.data-venc.atraso { background: var(--warn-soft); color: var(--warn); }
.data-venc.atraso small { color: inherit; }
.item .fim .v.pos { color: var(--pos); }

/* planilha com mais contraste */
table.sheet { font-size: 14px; color: var(--text); }
table.sheet th, table.sheet td { border-bottom-color: var(--grade); }
table.sheet td.m, table.sheet th { border-left: 1px solid var(--grade); }
table.sheet td.m { font-weight: 560; color: var(--text); }
table.sheet thead th { background: var(--surface-3); color: var(--text-2); font-size: 12px; height: 38px; border-bottom: 2px solid var(--border-strong); }
table.sheet thead .fix { background: var(--surface-3); }
table.sheet thead th.ref { color: var(--accent-ink); box-shadow: inset 0 -3px 0 var(--accent); }
table.sheet th.ref, table.sheet td.ref { background-image: linear-gradient(var(--ref-forte), var(--ref-forte)); }
table.sheet tbody tr:nth-child(even) > td { background-color: var(--zebra); }
table.sheet tbody tr:nth-child(even) > td.fix { background-color: var(--zebra); }
table.sheet tbody tr:hover > td, table.sheet tbody tr:hover > td.fix { background-color: var(--sel); }
table.sheet .fix { box-shadow: 1px 0 0 var(--border-strong); border-right: 0; font-weight: 560; }
table.sheet tr.sec td, table.sheet tr.sec td.fix { background: var(--surface-3) !important; color: var(--text-2); letter-spacing: .06em; border-top: 1px solid var(--border-strong); }
table.sheet tr.tot td, table.sheet tr.tot td.fix { background: var(--surface-3) !important; font-weight: 750; }
table.sheet tr.saldo td, table.sheet tr.saldo td.fix { background: var(--accent-soft) !important; }
table.sheet td.m.pos, table.sheet td.m.neg { font-weight: 700; }
table.sheet td.m.edit:hover { background-color: var(--sel) !important; box-shadow: inset 0 0 0 2px var(--accent); }
table.sheet a { color: var(--text); font-weight: 600; }
table.sheet a:hover { color: var(--accent-ink); }

/* =====================================================================
   v5 · pago x falta pagar, meses fechados
   ===================================================================== */
.st {
  width: 18px; height: 18px; border-radius: 50%; border: 1.8px solid var(--border-strong); background: var(--surface);
  display: inline-grid; place-items: center; padding: 0; cursor: pointer; color: transparent; flex-shrink: 0; transition: background .12s, border-color .12s;
}
.st .ico { width: 11px; height: 11px; stroke-width: 3.2; }
.st:hover { border-color: var(--pos); color: var(--pos); }
.st.on { background: var(--pos); border-color: var(--pos); color: var(--surface); }
.st:disabled { cursor: default; opacity: .6; }
.cel-st { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cel-st > span { flex: 1; text-align: right; }
table.sheet td.futuro .st:not(.on) { opacity: 0; }
table.sheet tr:hover td.futuro .st { opacity: 1; }
table.sheet td.cel-pago { color: var(--pos); }
table.sheet td.cel-pago > .cel-st > span { color: var(--text-2); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--pos) 60%, transparent); text-decoration-thickness: 1.5px; }
table.sheet tr.linha-pago td { color: var(--pos); font-weight: 650; background: var(--ok-soft) !important; }
table.sheet tr.linha-falta td { font-weight: 750; background: var(--warn-soft) !important; }
table.sheet tr.linha-falta td.neg { color: var(--neg); }
table.sheet th.fechado { color: var(--text-2); }
.cad { width: 11px !important; height: 11px !important; vertical-align: -1px; margin-right: 3px; opacity: .8; }
.meses button .a .cad { margin-right: 1px; }
.legenda-st { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.legenda-st .st { cursor: default; width: 15px; height: 15px; }
.legenda-st .st .ico { width: 9px; height: 9px; }
.tag .cad { margin-right: 3px; }

/* =====================================================================
   v6 · planilha do cartão como no Excel: uma linha por pessoa, compra dividida agrupada
   ===================================================================== */
.tag-grupo {
  display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; padding: 1px 6px 1px 4px; border-radius: 5px;
  background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap; vertical-align: 1px; font-variant-numeric: tabular-nums;
}
.tag-grupo .ico { width: 12px; height: 12px; stroke-width: 2.2; }
/* colchete à esquerda ligando as linhas da mesma compra */
table.sheet tr.grupo td.fix { position: sticky; }
table.sheet tr.grupo td.fix::before {
  content: ""; position: absolute; left: 3px; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: .55;
}
table.sheet tr.grupo.g-ini td.fix::before { top: 7px; border-radius: 3px 3px 0 0; }
table.sheet tr.grupo.g-fim td.fix::before { bottom: 7px; border-radius: 0 0 3px 3px; }
table.sheet tr.grupo:not(.g-fim) > td { border-bottom-style: dashed; }
table.sheet tr.grupo.g-hover > td, table.sheet tr.grupo.g-hover > td.fix { background-color: var(--sel) !important; }
table.sheet tr.grupo.g-hover td.fix::before { opacity: 1; }
.list .item.grupo { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
.list .item.grupo:not(.g-fim)::after { content: ""; position: absolute; left: 16px; right: 0; bottom: 0; border-bottom: 1px dashed var(--border); }
.list .item.grupo:not(.g-ini)::before { display: none; }
.list .item.grupo.g-hover { background: var(--sel); }
/* resumo por pessoa no rodapé (fixo embaixo no computador) */
table.sheet tfoot tr.sec td { border-top: 2px solid var(--border-strong); }
table.sheet tfoot td { background: var(--surface-2); font-weight: 650; }
table.sheet tfoot td.fix { background: var(--surface-2); }
table.sheet tfoot tr.tot td { background: var(--surface-3) !important; }
table.sheet tfoot tr.linha-filtro td { color: var(--accent-ink); }



/* =====================================================================
   v7 · mais espaço no computador, menu recolhível, ações por linha
   ===================================================================== */
@media (min-width: 1024px) {
  .content { max-width: none; padding: 14px 18px 24px; }
  .appbar { padding: 8px 18px; min-height: 56px; }
  .sheet-wrap { max-height: calc(100vh - 140px); }
  table.sheet th, table.sheet td { height: 31px; padding: 0 9px; }
  table.sheet thead th { height: 34px; }
  table.sheet td.m { min-width: 88px; }
}
table.sheet tfoot tr.sec td { height: 30px; }
table.sheet td.acoes { padding: 0 4px; }
table.sheet td.acoes .icon-btn { width: 28px; height: 28px; opacity: .45; }
table.sheet tr:hover td.acoes .icon-btn { opacity: 1; }
.icon-btn.perigo:hover { color: var(--neg); background: color-mix(in srgb, var(--neg) 12%, transparent); }
@media (hover: none) { table.sheet td.acoes .icon-btn { opacity: 1; } }

/* menu lateral recolhível */
.sidebar { transition: width .18s ease; }
.main { transition: margin-left .18s ease; }
.brand .recolher { margin-left: auto; }
.av-menu { width: 20px; height: 20px; border-radius: 6px; display: inline-grid; place-items: center; font-size: 9px; font-weight: 750; flex-shrink: 0; }
.app.recolhido { --sidebar: 64px; }
.app.recolhido .sidebar { padding: 14px 8px; overflow-x: hidden; }
.app.recolhido .rot { display: none !important; }
.app.recolhido .brand { flex-direction: column; gap: 8px; padding: 2px 0 12px; }
.app.recolhido .brand .recolher { margin: 0; }
.app.recolhido .nav a { justify-content: center; padding: 8px 0; }
.app.recolhido .nav-title { padding: 8px 0 4px; margin: 0 8px; border-top: 1px solid var(--border); height: 1px; overflow: hidden; }
.app.recolhido .sidebar-footer { flex-direction: column; padding: 10px 0 2px; }
.app.recolhido .mini-cartao.xs { margin: 0; width: 26px; height: 18px; }

/* ---------- v8: lançamento rápido pelo teclado ---------- */
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface); color: var(--text-2);
  font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; flex-shrink: 0; }
.seg button kbd { margin-right: 6px; }
.zona-divisao { border-radius: 14px; outline: none; }
.zona-divisao.atalhos:focus-within { box-shadow: 0 0 0 2px var(--accent); background: var(--accent-soft); padding: 8px; margin: -8px; }
.lancadas { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.lancada { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.lancada .ico { color: var(--pos); flex-shrink: 0; }
.lancada .num { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.dica-teclado { font-size: 12px; color: var(--muted); line-height: 1.9; }
.dica-teclado kbd { height: 18px; min-width: 18px; font-size: 10.5px; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.list.aparelhos { border: 1px solid var(--border); border-radius: 12px; }
.list.aparelhos .item { padding: 8px 12px; min-height: 0; }

/* ---------- v9: instalar o app ---------- */
.instalar-ic { color: var(--accent-ink); }
.instalar-ic.grande { width: 24px; display: inline-flex; justify-content: center; }
.instalar-cartao { display: flex; align-items: center; gap: 12px; border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--accent-soft); }
.instalar-cartao img { border-radius: 12px; flex-shrink: 0; }
@media (max-width: 520px) { .instalar-cartao { flex-wrap: wrap; } .instalar-cartao .btn { flex: 1; } }
.passos { margin: 0 0 12px; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.45; }
.brand img { transition: transform .25s ease; }
.brand img:hover { transform: rotate(-8deg) scale(1.08); }

/* ---------- v10: número da versão ---------- */
.brand .versao { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .02em; margin-top: 1px; }
.versao-rodape { text-align: center; font-size: 12px; color: var(--muted); margin-top: 14px; font-variant-numeric: tabular-nums; }


/* ---------- v11: ações de receitas/despesas ---------- */
.acoes-linha { display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; }
.acoes-linha .icon-btn { color: var(--muted); }
.acoes-linha .icon-btn:hover { color: var(--text); }
@media (hover: hover) { .list .item .acoes-linha .so-desktop { opacity: .45; } .list .item:hover .acoes-linha .so-desktop { opacity: 1; } }
.acao-cel { background: none; border: 0; padding: 2px 4px; margin-left: 4px; color: var(--muted); cursor: pointer; border-radius: 6px; vertical-align: middle; display: inline-flex; }
.acao-cel:hover { color: var(--text); background: var(--sel); }
@media (hover: hover) { table.sheet tr .acao-cel { opacity: 0; } table.sheet tr:hover .acao-cel, .acao-cel:focus-visible { opacity: 1; } }

/* ---------- v12: extrato em planilha com seções destacadas ---------- */
.g-cartao { --g: #2a78d6; } .g-rateio { --g: #1baf7a; } .g-cobertura { --g: #c98500; } .g-fixa { --g: #eb6834; } .g-receita { --g: #008300; }
:root[data-theme="dark"] .g-receita { --g: #4ade80; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .g-receita { --g: #4ade80; } }
table.sheet.extrato tr.sec td, table.sheet.extrato tr.sec td.fix {
  background: color-mix(in srgb, var(--g, var(--muted)) 17%, var(--surface)) !important;
  color: color-mix(in srgb, var(--g, var(--text)) 75%, var(--text)); font-size: 12px; font-weight: 750; height: 34px; border-top: 10px solid var(--bg); }
table.sheet.extrato tr.sec td.fix .ico { vertical-align: -3px; margin-right: 7px; }
table.sheet.extrato tr[class*="g-"] > td.fix { box-shadow: inset 4px 0 0 var(--g), 1px 0 0 var(--border-strong); padding-left: 14px; }
table.sheet.extrato tr.subtot td, table.sheet.extrato tr.subtot td.fix {
  background: color-mix(in srgb, var(--g) 8%, var(--surface)) !important; font-weight: 720; color: var(--text);
  border-top: 1px solid color-mix(in srgb, var(--g) 40%, transparent); }
table.sheet.extrato tr.subtot td.fix { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
table.sheet.extrato tr.tot.forte td { border-top: 10px solid var(--bg); }

/* ---------- v12: controle (como na planilha) ---------- */
.controle-topo { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 18px; padding: 14px 16px; align-items: start; }
.controle-topo .res { border-right: 1px solid var(--border); padding-right: 18px; }
.controle-topo .rotulo { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.controle-topo .valor.md { font-size: 28px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin: 4px 0 2px; }
.controle-topo .valor.md .cent { font-size: .6em; }
.bancos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 10px; }
.banco { display: flex; align-items: center; gap: 4px; border: 1px solid var(--border); border-radius: 10px; padding: 2px 4px 2px 8px; background: var(--surface-2); }
.banco input { border: 0; background: transparent; min-height: 32px; padding: 4px; font-size: 13.5px; min-width: 0; }
.banco input.nome { flex: 1; font-weight: 600; text-transform: uppercase; }
.banco .cel-rs { width: 110px; flex-shrink: 0; }
.banco .icon-btn { color: var(--muted); opacity: .5; }
.banco:hover .icon-btn { opacity: 1; }
.cel-rs { display: inline-flex; align-items: center; gap: 3px; width: 100%; color: var(--muted); font-size: 12px; font-weight: 600; }
.cel-rs input { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); width: 100%; }
@media (max-width: 760px) {
  .controle-topo { grid-template-columns: 1fr; }
  .controle-topo .res { border-right: 0; padding-right: 0; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
}
table.controle-grade { min-width: 620px; }
table.controle-grade th.grp { text-align: left; font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; }
table.controle-grade th.g-rec { background: color-mix(in srgb, #1baf7a 16%, var(--surface)) !important; color: color-mix(in srgb, #1baf7a 70%, var(--text)); }
table.controle-grade th.g-pag { background: color-mix(in srgb, #eb6834 16%, var(--surface)) !important; color: color-mix(in srgb, #eb6834 70%, var(--text)); border-left: 3px solid var(--border-strong); }
table.controle-grade .sep { border-left: 3px solid var(--border-strong) !important; }
table.controle-grade td.chk, table.controle-grade th.chk { width: 34px; text-align: center; padding: 0 4px; }
table.controle-grade td.cel-in { padding: 0; position: relative; }
table.controle-grade td.cel-in input { border: 0; background: transparent; width: 100%; min-height: 34px; padding: 4px 10px; font-size: 13.5px; border-radius: 0; }
table.controle-grade td.cel-in input:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface); }
table.controle-grade td.l.cel-in input { text-transform: uppercase; padding-right: 30px; }
table.controle-grade td.m.cel-in { width: 150px; min-width: 130px; }
table.controle-grade td.m.cel-in .cel-rs { padding-left: 8px; }
table.controle-grade td.m.cel-in input { padding-left: 2px; }
table.controle-grade td.cel-in .acao-cel { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
table.controle-grade td.feito input { color: var(--muted); text-decoration: line-through; }
table.controle-grade tfoot td { font-weight: 750; background: var(--surface-3); height: 36px; padding: 0 10px; }
table.controle-grade tfoot td.m { text-align: right; }
.tabela-simples { width: 100%; border-collapse: collapse; }
.tabela-simples td { padding: 9px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
.tabela-simples td.m { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.tabela-simples td.a { width: 1%; white-space: nowrap; padding-left: 0; }
.tabela-simples td.vazio { color: var(--muted); text-align: center; }
table.controle-grade { width: 100%; }
table.controle-grade td.m input, table.controle-grade td.cel-in input { outline: none; box-shadow: none; }
table.controle-grade td.cel-in input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
table.controle-grade td.m.cel-in { width: 22%; }
.bancos-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

/* ---------- v13: aviso de atualização vinda de outro aparelho ---------- */
.chip-sync { position: fixed; top: calc(12px + var(--safe-top)); right: 16px; z-index: 102; display: flex; align-items: center; gap: 8px;
  background: var(--surface); color: var(--text-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-2);
  border-radius: 999px; padding: 7px 14px 7px 10px; font-size: 13px; font-weight: 560; max-width: calc(100vw - 32px); }
.chip-sync .ico { color: var(--accent-ink); }
@media (max-width: 1023px) { .chip-sync { left: 50%; right: auto; transform: translateX(-50%); } }
.sync-enter-active, .sync-leave-active { transition: opacity .25s, translate .25s; }
.sync-enter-from, .sync-leave-to { opacity: 0; translate: 0 -8px; }

/* ---------- v14: alça de preencher (arrastar como no Excel) ---------- */
table.sheet td.m { position: relative; }
.alca-fill { position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; background: var(--accent); border: 2px solid var(--surface);
  border-radius: 2px; cursor: crosshair; z-index: 3; touch-action: none; opacity: .75; }
table.sheet tr:hover .alca-fill, .alca-fill:hover { opacity: 1; transform: scale(1.25); }
@media (pointer: coarse) { .alca-fill { width: 16px; height: 16px; opacity: 1; } }
table.sheet td.fill-mais { background: color-mix(in srgb, var(--accent) 22%, var(--surface)) !important; box-shadow: inset 0 0 0 1px var(--accent); }
table.sheet td.fill-menos { background: color-mix(in srgb, var(--neg) 18%, var(--surface)) !important; box-shadow: inset 0 0 0 1px var(--neg); text-decoration: line-through; }
body.arrastando-fill, body.arrastando-fill * { cursor: crosshair !important; user-select: none !important; }

/* ---------- v15: linha livre no fim da planilha do cartão (como no Excel) ---------- */
table.sheet tr.linha-nova td { background: color-mix(in srgb, var(--accent) 6%, var(--surface)) !important; border-top: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); padding: 0; height: 36px; }
table.sheet tr.linha-nova td.fix { background: color-mix(in srgb, var(--accent) 8%, var(--surface)) !important; }
table.sheet tr.linha-nova input { width: 100%; border: 0; background: transparent; min-height: 34px; padding: 4px 10px; font-size: 13px; border-radius: 0; outline: none; box-shadow: none; }
table.sheet tr.linha-nova td.m input { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
table.sheet tr.linha-nova input::placeholder { color: var(--accent-ink); opacity: .8; }
table.sheet tr.linha-nova input:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface); }
table.sheet tr.linha-nova td.l input { text-transform: uppercase; }
table.sheet tr.linha-nova td.resp { position: relative; }
table.sheet tr.linha-nova td.resp input.ok { color: var(--pos); font-weight: 650; }
table.sheet tr.linha-nova td.resp input.erro { color: var(--neg); font-weight: 650; }
table.sheet tr.linha-nova td.resp .tag { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }

/* ---------- v16: linha livre com setas, etiquetas de pessoas e sugestões ---------- */
table.sheet tr.linha-nova td.resp { min-width: 190px; }
.quem-in { display: flex; align-items: center; gap: 4px; padding: 0 6px; min-height: 34px; overflow: hidden; }
.quem-in input { flex: 1; min-width: 50px; padding: 4px 4px !important; }
.quem-in .tag { position: static !important; transform: none !important; flex-shrink: 0; }
.chip-mini { display: inline-flex; align-items: center; gap: 2px; background: var(--accent-soft); color: var(--accent-ink); border-radius: 6px;
  padding: 2px 3px 2px 7px; font-size: 11.5px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.chip-mini.rateio { background: color-mix(in srgb, #1baf7a 18%, var(--surface)); color: color-mix(in srgb, #1baf7a 70%, var(--text)); }
.chip-mini button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 3px; opacity: .7; }
.chip-mini button:hover { opacity: 1; }
.sug-quem { position: fixed; z-index: 120; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-2); padding: 4px; }
.sug-quem .sug-op { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 600; }
.sug-quem .sug-op.on { background: var(--accent-soft); color: var(--accent-ink); }
.sug-quem .sug-op .muted { margin-left: auto; }
.sug-quem .sug-dica { font-size: 11px; color: var(--muted); padding: 6px 10px 4px; border-top: 1px solid var(--border); margin-top: 4px; }

/* ---------- v17: conferir planilha ---------- */
.conf-topo { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.conf-topo .campo { min-width: 180px; flex: 1; margin: 0; }
.conf-topo .seg { align-self: center; }
.conf-topo .seg button .ico, .conferir .seg button .ico { margin-right: 5px; }
.conf-tot { text-align: right; margin-left: auto; }
.conf-tot b { font-size: 20px; }
.grid-conf { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid-conf { grid-template-columns: 1fr; } }
.tabela-conf { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tabela-conf th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border-strong); background: var(--surface-2); }
.tabela-conf th.m { text-align: right; }
.tabela-conf td { padding: 8px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
.tabela-conf tr { cursor: pointer; }
.tabela-conf.ia tr { cursor: default; }
.tabela-conf tr:hover td { background: var(--sel); }
.tabela-conf td.c { width: 30px; padding-right: 0; }
.tabela-conf td.m { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.tabela-conf td.p, .tabela-conf .p { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tabela-conf tr.feito td:not(.c) { color: var(--muted); text-decoration: line-through; }
.tabela-conf tr.igual td { background: color-mix(in srgb, var(--accent) 16%, var(--surface)) !important; }
.tabela-conf tr.ign td { opacity: .5; font-style: italic; }
.tabela-conf td.vazio { text-align: center; color: var(--muted); cursor: default; }
.anexo { display: flex; align-items: center; gap: 14px; cursor: pointer; border: 2px dashed var(--border-strong); background: var(--surface-2); }
.anexo:hover { border-color: var(--accent); }
.anexo > .ico { width: 28px; height: 28px; color: var(--accent-ink); }
.anexo.lendo { opacity: .7; }
.conf-dif { justify-content: space-between; font-weight: 600; }
.badge-st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.tabela-conf.ia tr.st-ok .badge-st, .tag.st-ok { color: var(--pos); }
.tabela-conf.ia tr.st-warn .badge-st, .tag.st-warn { color: var(--warn); }
.tabela-conf.ia tr.st-erro .badge-st, .tag.st-erro { color: var(--neg); }
.tabela-conf.ia tr.st-erro td:first-child { box-shadow: inset 3px 0 0 var(--neg); }
.tabela-conf.ia tr.st-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.tabela-conf.ia tr.st-ok td:first-child { box-shadow: inset 3px 0 0 var(--pos); }

/* ---------- v18: conferência com IA em grupos ---------- */
.ci-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ci-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; cursor: pointer; color: var(--text); }
.ci-chip:hover { background: var(--sel); }
.ci-chip.st-ok .ico { color: var(--pos); }
.ci-chip.st-warn .ico { color: var(--warn); }
.ci-chip.st-erro .ico { color: var(--neg); }
.ci-resumo { display: flex; gap: 10px; align-items: flex-start; background: var(--accent-soft); color: var(--accent-ink); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.ci-resumo .ico { flex: none; margin-top: 2px; }
.ci-resumo p { margin: 4px 0 0; line-height: 1.5; }
.ci-grupo { scroll-margin-top: 70px; overflow: hidden; }
.ci-cab { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; background: none; border: 0; text-align: left; cursor: pointer; color: var(--text); font: inherit; }
.ci-cab:hover { background: var(--sel); }
.ci-cab .num { white-space: nowrap; }
.ci-desc { display: block; margin-top: 2px; }
.ci-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.ci-grupo.st-ok .ci-ico { background: var(--ok-soft); color: var(--pos); }
.ci-grupo.st-warn .ci-ico { background: var(--warn-soft); color: var(--warn); }
.ci-grupo.st-erro .ci-ico { background: color-mix(in srgb, var(--neg) 14%, var(--surface)); color: var(--neg); }
.ci-grupo.st-ok { box-shadow: inset 3px 0 0 var(--pos), var(--shadow-1); }
.ci-grupo.st-warn { box-shadow: inset 3px 0 0 var(--warn), var(--shadow-1); }
.ci-grupo.st-erro { box-shadow: inset 3px 0 0 var(--neg), var(--shadow-1); }
.ci-seta { display: inline-flex; color: var(--muted); transition: transform .15s; transform: rotate(90deg); }
.ci-seta.on { transform: rotate(-90deg); }
.ci-item { padding: 10px 14px 12px; border-top: 1px solid var(--border); }
.ci-lados { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.ci-lados.um { grid-template-columns: minmax(0, 1fr); max-width: 50%; }
@media (max-width: 700px) { .ci-lados, .ci-lados.um { grid-template-columns: 1fr; max-width: none; } }
.ci-lado { display: flex; align-items: baseline; gap: 8px; font-size: 13.5px; min-width: 0; }
.ci-lado .grow { min-width: 0; overflow-wrap: anywhere; }
.ci-lado .num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ci-lado .p { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ci-rot { flex: none; width: 54px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ci-exp { margin-top: 6px; font-size: 13px; color: var(--text-2); line-height: 1.45; }
.ci-exp .tag { margin-right: 6px; }
.ci-grupo .vazio { padding: 14px; text-align: center; color: var(--muted); }
