/* ==========================================================================
   Minhas Finanças — estilos (mobile first, sem dependências externas)
   ========================================================================== */
:root {
    --brand: #0f5c4d;
    --brand-600: #0c4d40;
    --brand-50: #e6f2ef;
    --bg: #f3f5f2;
    --surface: #ffffff;
    --ink: #16211d;
    --ink-2: #3b4743;
    --muted: #66726d;
    --line: #e2e7e3;
    --line-2: #eef1ee;
    --in: #15803d;
    --in-bg: #e8f6ec;
    --out: #c0392b;
    --out-bg: #fcebe8;
    --late: #b42318;
    --late-bg: #fdecea;
    --today: #a15c07;
    --today-bg: #fdf3dc;
    --soon: #1e57c8;
    --soon-bg: #e6eefc;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(22, 33, 29, .05), 0 4px 14px rgba(22, 33, 29, .05);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --num: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
    --sidebar: 252px;
    --bottom: 66px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.08rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
a { color: var(--brand); }
a:hover { color: var(--brand-600); }
img, svg { max-width: 100%; }
code { font-family: var(--num); font-size: .88em; background: var(--line-2); padding: .1em .35em; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--line); margin: .5rem 0; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.pos { color: var(--in); }
.neg { color: var(--out); }
.print-only { display: none; }
.skip { position: absolute; left: -999px; top: 0; background: var(--brand); color: #fff; padding: .6rem 1rem; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }

.ic { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
.ic-xs { width: 13px; height: 13px; vertical-align: -1px; }
.ic-sm { width: 16px; height: 16px; vertical-align: -3px; }
.ic-lg { width: 32px; height: 32px; }
.ic-xl { width: 44px; height: 44px; }
.dot { flex: none; vertical-align: middle; }

:focus-visible { outline: 3px solid rgba(15, 92, 77, .45); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   Estrutura
   -------------------------------------------------------------------------- */
.sidebar { display: none; }
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top, 0px));
    background: rgba(243, 245, 242, .92);
    backdrop-filter: saturate(160%) blur(10px);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--line);
}
.brand-mini img { display: block; border-radius: 8px; }
.topbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar-title .hello { font-size: .76rem; color: var(--muted); }
.topbar-title strong { font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 12px; color: var(--ink-2);
    text-decoration: none; font-size: 1.4rem; line-height: 1; background: transparent;
}
.icon-btn:hover, .icon-btn.is-active { background: var(--surface); color: var(--brand); }
.badge {
    position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--late); color: #fff; font-size: .7rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--bg);
}

.main {
    padding: 1rem 1rem calc(var(--bottom) + var(--safe-b) + 1.5rem);
    max-width: 1180px; margin: 0 auto;
}

.offline-bar {
    display: flex; align-items: center; gap: .5rem; justify-content: center;
    background: #3b2f05; color: #fff7d6; font-size: .86rem; padding: .5rem 1rem;
}

/* Navegação inferior (celular) */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex; justify-content: space-around; align-items: stretch;
    height: calc(var(--bottom) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -4px 18px rgba(22, 33, 29, .06);
}
.bn-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: .7rem; color: var(--muted); text-decoration: none; cursor: pointer; list-style: none;
    -webkit-tap-highlight-color: transparent;
}
.bn-item::-webkit-details-marker { display: none; }
.bn-item .ic { width: 23px; height: 23px; }
.bn-item.is-active { color: var(--brand); font-weight: 600; }
.bn-add {
    flex: 0 0 auto; align-self: center; width: 52px; height: 52px; margin: 0 .25rem; border-radius: 16px;
    background: var(--brand); color: #fff !important; box-shadow: 0 6px 16px rgba(15, 92, 77, .35);
    transform: translateY(-10px);
}
.bn-add .ic { width: 26px; height: 26px; }
.bn-more { flex: 1; display: flex; }
.bn-more > summary { width: 100%; }
.bn-more[open] > summary { color: var(--brand); }
.sheet {
    position: fixed; left: 8px; right: 8px; bottom: calc(var(--bottom) + var(--safe-b) + 8px);
    background: var(--surface); border-radius: 18px; padding: .5rem;
    box-shadow: 0 12px 40px rgba(22, 33, 29, .22); border: 1px solid var(--line);
    max-height: 70vh; overflow-y: auto;
}
.sheet-link {
    display: flex; align-items: center; gap: .75rem; width: 100%; padding: .75rem .8rem;
    color: var(--ink); text-decoration: none; border-radius: 12px; font-size: .98rem;
    background: none; border: 0; font: inherit; text-align: left; cursor: pointer;
}
.sheet-link:hover, .sheet-link.is-active { background: var(--brand-50); color: var(--brand); }

/* Computador */
@media (min-width: 960px) {
    .sidebar {
        display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
        background: var(--surface); border-right: 1px solid var(--line); padding: 1.1rem .8rem; overflow-y: auto;
    }
    .topbar, .bottom-nav { display: none; }
    .main, .offline-bar { margin-left: var(--sidebar); }
    .main { padding: 1.6rem 2rem 3rem; max-width: calc(1180px + var(--sidebar)); }
    .is-admin .main, .is-user .main { margin-left: var(--sidebar); }
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.05rem; padding: .2rem .5rem 1rem; }
.brand img { border-radius: 9px; }
.role-tag { align-self: flex-start; margin: -0.6rem 0 .8rem .5rem; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); background: var(--brand-50); padding: .15rem .5rem; border-radius: 6px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
    display: flex; align-items: center; gap: .7rem; padding: .62rem .75rem; border-radius: 10px;
    color: var(--ink-2); text-decoration: none; font-size: .95rem; width: 100%;
    background: none; border: 0; font-family: inherit; cursor: pointer; text-align: left;
}
.side-link:hover { background: var(--line-2); color: var(--ink); }
.side-link.is-active { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.side-link.small { font-size: .88rem; padding: .48rem .75rem; }
.side-link .count { margin-left: auto; background: var(--late); color: #fff; font-size: .72rem; font-weight: 700; border-radius: 9px; padding: 0 .45rem; min-width: 20px; text-align: center; }
.side-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--line); }
.side-user { display: flex; align-items: center; gap: .6rem; padding: .3rem .75rem .6rem; margin: 0; font-weight: 600; font-size: .9rem; }
.side-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
form.inline { margin: 0; }

/* --------------------------------------------------------------------------
   Componentes
   -------------------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-title { margin: 0; font-size: 1.4rem; }
@media (max-width: 959px) { .page-title { font-size: 1.25rem; } }

.card {
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
    border: 1px solid var(--line); padding: 1rem; margin-bottom: 1rem;
}
@media (min-width: 640px) { .card { padding: 1.25rem; } }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; }
.card-head h2 { margin: 0; }
.link { font-size: .9rem; font-weight: 600; text-decoration: none; }

.grid-2 { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.grid-2.align-start { align-items: start; }

/* Botões */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    min-height: 44px; padding: .55rem 1rem; border-radius: 12px; border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer;
    background: var(--line-2); color: var(--ink); transition: background .15s, transform .05s;
    -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-sm { min-height: 36px; padding: .35rem .7rem; font-size: .86rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); color: #fff; }
.btn-success { background: var(--in); color: #fff; }
.btn-success:hover { background: #126c33; color: #fff; }
.btn-danger { background: var(--out); color: #fff; }
.btn-danger:hover { background: #a3301f; color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-2); color: var(--ink); }
.btn-ghost.danger { color: var(--out); }
.btn-success-soft { background: var(--in-bg); color: var(--in); }
.btn-success-soft:hover { background: #d4efdc; color: var(--in); }
.btn-danger-soft { background: var(--out-bg); color: var(--out); }
.btn-danger-soft:hover { background: #f8d9d3; color: var(--out); }
.btn[disabled], .btn.is-busy { opacity: .6; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.btn-row.center { justify-content: center; }
.as-link { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
button.link { color: var(--brand); font-size: inherit; }
.push-right { margin-left: auto; }

/* Mensagens */
.flash {
    display: flex; align-items: flex-start; gap: .6rem; padding: .75rem .9rem; border-radius: 12px;
    margin-bottom: 1rem; font-size: .94rem; border: 1px solid transparent;
}
.flash > span { flex: 1; }
.flash-success { background: var(--in-bg); color: #0f5a2b; border-color: #c6e9d1; }
.flash-error { background: var(--late-bg); color: #8f1c12; border-color: #f6cbc5; }
.flash-info { background: var(--soon-bg); color: #163f91; border-color: #cddcf8; }
.flash-close { background: none; border: 0; color: inherit; cursor: pointer; padding: 0; opacity: .6; }
.flash-close .ic { width: 18px; height: 18px; }
.hint { font-size: .84rem; color: var(--muted); margin: -.4rem 0 1rem; }

/* Formulários */
.form { display: flex; flex-direction: column; gap: .9rem; }
.field { display: flex; flex-direction: column; gap: .3rem; margin: 0; min-width: 0; border: 0; padding: 0; }
.field > span:first-child, .field > legend { font-size: .86rem; font-weight: 600; color: var(--ink-2); }
fieldset.field > legend { margin-bottom: .35rem; padding: 0; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=tel],
input[type=number], input[type=date], select, textarea {
    width: 100%; min-height: 46px; padding: .6rem .75rem; border: 1px solid #cfd7d2; border-radius: 11px;
    background: #fff; color: var(--ink); font: inherit; font-size: 16px; /* evita zoom no iOS */
    appearance: none; -webkit-appearance: none;
}
select {
    padding-right: 2.2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366726d' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .7rem center; background-size: 16px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 92, 77, .15); }
input[disabled] { background: var(--line-2); color: var(--muted); }
[aria-invalid=true] { border-color: var(--late) !important; background: #fffafa; }
.field-error { color: var(--late); font-size: .84rem; font-weight: 600; }
.field-help { color: var(--muted); font-size: .8rem; }
.input-money { font-family: var(--num); font-size: 1.15rem !important; font-weight: 600; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 380px) { .row-2 { grid-template-columns: 1fr; } }
.check { display: flex; gap: .6rem; align-items: flex-start; font-size: .94rem; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--brand); flex: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding-top: .3rem; }
.input-icon { position: relative; display: block; }
.input-icon .ic { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 2.3rem; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; border: 0; padding: .3rem; margin: 0; background: var(--line-2); border-radius: 13px; }
.seg { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: flex; align-items: center; justify-content: center; gap: .4rem; min-height: 42px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.seg-out input:checked + span { background: #fff; color: var(--out); box-shadow: var(--shadow); }
.seg-in input:checked + span { background: #fff; color: var(--in); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 3px solid rgba(15, 92, 77, .45); }

.repeat-box { background: var(--brand-50); border-radius: 12px; padding: .8rem; display: flex; flex-direction: column; gap: .6rem; }
.inline-field { max-width: 260px; }

.swatches { display: flex; flex-wrap: wrap; gap: .45rem; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; }
.swatch > span:first-of-type { display: inline-flex; padding: 3px; border-radius: 50%; border: 2px solid transparent; }
.swatch input:checked + span { border-color: var(--ink); }
.swatch input:focus-visible + span { outline: 3px solid rgba(15, 92, 77, .45); }

/* Filtros */
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; padding: .8rem; }
.filters .field { flex: 1 1 140px; }
.filters .field.grow { flex: 2 1 220px; }
.filters input, .filters select { min-height: 42px; }
.filter-actions { display: flex; gap: .4rem; }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: .4rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: none; padding: .45rem .85rem; border-radius: 999px; font-size: .86rem; font-weight: 600;
    text-decoration: none; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line);
}
.chip.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip-late:not(.is-active) { color: var(--late); }
.chip-today:not(.is-active) { color: var(--today); }
.tabs { display: flex; gap: .3rem; background: var(--line-2); padding: .3rem; border-radius: 13px; margin-bottom: .8rem; max-width: 420px; }
.tab { flex: 1; text-align: center; padding: .55rem; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .92rem; }
.tab.is-active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

.month-picker { display: flex; align-items: center; gap: .3rem; }
.month-picker select { min-height: 40px; width: auto; padding-top: .4rem; padding-bottom: .4rem; font-weight: 600; }
.month-picker .icon-btn { background: var(--surface); border: 1px solid var(--line); }

/* Indicadores */
.kpis { display: grid; grid-template-columns: 1fr; gap: .7rem; margin-bottom: 1rem; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(3, 1fr); } .kpis-4 { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 639px) { .kpis-4 { grid-template-columns: 1fr 1fr; } }
.kpi {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: .9rem 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .15rem;
    border-left: 4px solid var(--line);
}
.kpi-label { font-size: .82rem; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: .35rem; }
.kpi-value { font-size: 1.5rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .8rem; color: var(--muted); }
.kpi-in { border-left-color: var(--in); }
.kpi-in .kpi-value { color: var(--in); }
.kpi-out { border-left-color: var(--out); }
.kpi-out .kpi-value { color: var(--out); }
.kpi-balance { border-left-color: var(--brand); background: linear-gradient(135deg, #0f5c4d, #137560); color: #fff; border-color: transparent; }
.kpi-balance .kpi-label, .kpi-balance .kpi-sub { color: rgba(255, 255, 255, .8); }
.kpi-balance.is-neg { background: linear-gradient(135deg, #8f2a1f, #b23a2a); }

.alerts-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: 1rem; }
.alert-tile {
    display: flex; flex-direction: column; gap: .1rem; padding: .8rem; border-radius: var(--radius);
    text-decoration: none; border: 1px solid transparent; min-width: 0;
}
.alert-tile .tile-n { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.alert-tile .tile-l { font-size: .8rem; font-weight: 700; }
.alert-tile .tile-v { font-size: .72rem; opacity: .9; line-height: 1.25; overflow-wrap: anywhere; }
.tile-late { background: var(--late-bg); color: var(--late); border-color: #f6cbc5; }
.tile-today { background: var(--today-bg); color: var(--today); border-color: #f2dfae; }
.tile-soon { background: var(--soon-bg); color: var(--soon); border-color: #cddcf8; }
.alert-tile:hover { filter: brightness(.98); }

.summary-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; margin-bottom: .8rem; }
.summary-strip span { display: block; font-size: .76rem; color: var(--muted); font-weight: 600; }
.summary-strip strong { font-size: .98rem; font-variant-numeric: tabular-nums; }
.list-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .5rem; }

/* Lista de lançamentos */
.tx-list { list-style: none; margin: 0; padding: 0; }
.card .tx-list:not(.flush) { margin: 0 -1rem -1rem; }
@media (min-width: 640px) { .card .tx-list:not(.flush) { margin: 0 -1.25rem -1.25rem; } }
.tx { border-top: 1px solid var(--line-2); display: flex; flex-direction: column; position: relative; }
.tx:first-child { border-top: 0; }
.tx::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.tx-atrasada::before { background: var(--late); }
.tx-hoje::before { background: var(--today); }
.tx-proxima::before { background: var(--soon); }
.tx-atrasada { background: #fffbfa; }
.tx-main { display: flex; gap: .75rem; padding: .8rem 1rem .3rem; color: inherit; text-decoration: none; align-items: flex-start; }
.tx-main:hover .tx-desc { color: var(--brand); }
.tx-icon { width: 36px; height: 36px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tx-icon .ic { width: 18px; height: 18px; }
.tx-icon.in { background: var(--in-bg); color: var(--in); }
.tx-icon.out { background: var(--out-bg); color: var(--out); }
.tx-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.tx-desc { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-repeat { color: var(--muted); }
.tx-meta { font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.tx-side { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; flex: none; text-align: right; }
.tx-amount { font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .98rem; }
.tx-actions { display: flex; gap: .35rem; padding: .2rem 1rem .7rem 3.75rem; flex-wrap: nowrap; }
@media (max-width: 759px) { .tx-actions .act-delete { display: none; } }
.tx-actions form { margin: 0; }
.tx-cancelled .tx-desc, .tx-cancelled .tx-amount { text-decoration: line-through; color: var(--muted); }
@media (min-width: 760px) {
    .tx { flex-direction: row; align-items: center; }
    .tx-main { flex: 1; padding: .75rem 1rem; align-items: center; min-width: 0; }
    .tx-actions { padding: 0 1rem 0 0; flex-wrap: nowrap; }
}
@media (max-width: 459px) { .hide-sm { display: none; } }
@media (max-width: 380px) { .hide-xs { display: none; } }

.pill { display: inline-flex; align-self: flex-start; align-items: center; font-size: .72rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; white-space: nowrap; }
.pill-atrasada { background: var(--late-bg); color: var(--late); }
.pill-hoje { background: var(--today-bg); color: var(--today); }
.pill-proxima { background: var(--soon-bg); color: var(--soon); }
.status { display: inline-block; font-size: .74rem; font-weight: 600; padding: .1rem .5rem; border-radius: 6px; white-space: nowrap; }
.status-pendente { background: #f1f2ef; color: #57605c; }
.status-pago, .status-recebido { background: var(--in-bg); color: var(--in); }
.status-cancelado { background: #f4e9e8; color: #8b4a43; }

/* Gráficos */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .baseline { stroke: #b9c2bd; stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
@media (max-width: 600px) { .chart-bars .axis { font-size: 19px; } }
.chart .bar-receita { fill: var(--in); }
.chart .bar-despesa { fill: var(--out); }
.chart .bar:hover { opacity: .8; }
.chart-donut { max-width: 190px; margin: 0 auto; }
.chart-donut .donut-bg { stroke: var(--line-2); }
.chart-donut circle[stroke-dasharray]:hover { opacity: .85; }
.chart .donut-total-label { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .donut-total { fill: var(--ink); font-size: 16px; font-weight: 700; font-family: var(--font); }
.legend { display: flex; gap: 1rem; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; }
.sw-in { background: var(--in); }
.sw-out { background: var(--out); }
.donut-wrap { display: grid; gap: 1rem; align-items: center; }
@media (min-width: 520px) { .donut-wrap { grid-template-columns: 190px 1fr; } }
.cat-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; font-size: .88rem; }
.cat-legend li { display: grid; grid-template-columns: auto 1fr auto 3em; gap: .5rem; align-items: center; }
.cl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.cl-pct { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.data-table { margin-top: .6rem; }
.data-table summary { font-size: .84rem; color: var(--brand); cursor: pointer; font-weight: 600; }
.empty-mini { padding: 1.2rem; }

/* Tabelas */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: #fafbfa; }
.table.compact th, .table.compact td { padding: .45rem .5rem; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.actions { text-align: right; }
.row-cancelled td { color: var(--muted); text-decoration: line-through; }
@media (max-width: 759px) {
    .table.responsive thead { display: none; }
    .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
    .table.responsive tr { padding: .6rem .9rem; border-bottom: 1px solid var(--line); }
    .table.responsive td { border: 0; padding: .15rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
    .table.responsive td::before { content: attr(data-label); font-size: .78rem; color: var(--muted); font-weight: 600; text-align: left; }
    .table.responsive td.actions { justify-content: flex-end; padding-top: .4rem; }
    .table.responsive td.actions::before { content: none; }
    .table.responsive td.num { text-align: right; }
}

/* Detalhes / confirmação */
.details { margin: 0 0 1rem; display: grid; gap: .1rem; }
.details > div { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--line-2); font-size: .92rem; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 600; text-align: right; }
.confirm-card { text-align: center; }
.confirm-card .details, .confirm-card .form, .confirm-card form { text-align: left; }
.confirm-card .form-actions { justify-content: center; }
.confirm-icon { width: 64px; height: 64px; border-radius: 20px; background: var(--out-bg); color: var(--out); display: inline-flex; align-items: center; justify-content: center; margin-bottom: .6rem; }

/* Estado vazio */
.empty-state { text-align: center; padding: 2rem 1.2rem; }
.empty-illus { width: 84px; height: 84px; border-radius: 26px; background: var(--brand-50); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; margin-bottom: .9rem; }
.steps { text-align: left; max-width: 520px; margin: 0 auto 1.2rem; padding-left: 1.3rem; display: flex; flex-direction: column; gap: .45rem; }
.quick-add { justify-content: center; margin: .5rem 0 1rem; }

/* Categorias */
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-top: 1px solid var(--line-2); }
.cat-list li:first-child { border-top: 0; }
.cat-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Notificações */
.notif-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.notif { display: grid; grid-template-columns: auto 1fr; gap: .3rem .7rem; padding: .85rem 1rem; border-top: 1px solid var(--line-2); align-items: center; }
.notif:first-child { border-top: 0; }
.notif.is-unread { background: #fbfdfb; }
.notif.is-unread .notif-text { font-weight: 650; }
.notif-text { color: var(--ink); text-decoration: none; }
.notif-text:hover { color: var(--brand); }
.notif-date { grid-column: 2; }
.notif form { grid-column: 2; margin: 0; }
@media (min-width: 760px) {
    .notif { grid-template-columns: auto 1fr auto auto; }
    .notif-date, .notif form { grid-column: auto; }
}

/* Visitante / login */
.guest { min-height: 100vh; background: radial-gradient(1200px 500px at 50% -10%, #d6ebe5 0%, var(--bg) 60%); }
.guest-main { max-width: 480px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.guest-brand { display: flex; flex-direction: column; align-items: center; gap: .5rem; margin-bottom: 1.2rem; text-decoration: none; color: var(--ink); font-weight: 750; font-size: 1.25rem; }
.guest-brand img { border-radius: 16px; box-shadow: 0 8px 22px rgba(15, 92, 77, .25); }
.auth-card { padding: 1.5rem; }
.guest .card.narrow { max-width: 100%; }
.checklist { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: .3rem; font-size: .92rem; }
.checklist .ok { color: var(--in); }
.checklist .fail { color: var(--late); font-weight: 600; }
.error-page { padding: 2.5rem 1.5rem; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--brand); margin: 0; opacity: .3; }

/* Instalação */
.install-hero { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.install-hero img { border-radius: 18px; flex: none; }
.install-hero h1 { margin-bottom: .2rem; }
.install-page h2 { margin-top: 1.4rem; display: flex; align-items: center; gap: .4rem; }
.install-now { margin: 1rem 0; }
.note { background: var(--brand-50); border-radius: 12px; padding: 1rem; margin-top: 1.4rem; font-size: .92rem; }
.note ul { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .35rem; }
.pager { display: flex; justify-content: center; align-items: center; gap: .8rem; margin: 1rem 0; }

/* Tela de abertura do app instalado */
.splash {
    position: fixed; inset: 0; z-index: 200; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
    background: var(--brand); color: #fff; font-size: 1.2rem;
}
.splash img { border-radius: 24px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
html.show-splash .splash { display: flex; }
html.show-splash.splash-out .splash { opacity: 0; transition: opacity .35s ease; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* --------------------------------------------------------------------------
   Impressão
   -------------------------------------------------------------------------- */
@media print {
    @page { margin: 14mm 12mm; }
    body { background: #fff; font-size: 11pt; color: #000; }
    .sidebar, .topbar, .bottom-nav, .offline-bar, .no-print, .filters, .chips, .btn, .flash, .splash, .skip, details.data-table, .hint { display: none !important; }
    .print-only { display: block !important; }
    .main { margin: 0 !important; padding: 0 !important; max-width: none; }
    .card, .kpi { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
    .kpi-balance, .kpi-balance.is-neg { background: #fff !important; color: #000; border-left: 4px solid #000; }
    .kpi-balance .kpi-label, .kpi-balance .kpi-sub { color: #444; }
    .kpis { grid-template-columns: repeat(3, 1fr) !important; }
    .grid-2 { grid-template-columns: 1fr 1fr !important; }
    .avoid-break { break-inside: avoid; }
    .table.responsive thead { display: table-header-group !important; }
    .table.responsive, .table.responsive tbody { display: table !important; width: 100%; }
    .table.responsive tbody { display: table-row-group !important; }
    .table.responsive tr { display: table-row !important; }
    .table.responsive td { display: table-cell !important; text-align: left; }
    .table.responsive td.num { text-align: right; }
    .table.responsive td::before { content: none !important; }
    .table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .chart .bar-receita, .chart .bar-despesa, .chart circle, .dot circle { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .print-head h1 { font-size: 16pt; margin-bottom: 4pt; }
    .print-head { margin-bottom: 10pt; border-bottom: 2px solid #000; padding-bottom: 6pt; }
    a { color: #000; text-decoration: none; }
}
.cat-cell { display: inline-flex; align-items: center; gap: .4rem; }
.row-2:has(> .hidden) { grid-template-columns: 1fr; }
/* No celular o título já aparece na barra superior */
@media (max-width: 959px) {
    .page-head .page-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
    .page-head:not(:has(> :not(.page-title))) { margin: 0; }
}
.tx-cat { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
