/* =====================================================================
   PREVI — app

   Mesma língua da página de apresentação: traço sólido é fato, hachura e
   pontilhado é previsão. Valores em fonte monoespaçada, como extrato de
   banco. Títulos na Bricolage Grotesque, texto na Inter.
   ===================================================================== */

/* ===== Design tokens ===== */
:root {
    --page: #f7f7fb;
    --bg: #f1f1f8;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text: #12122a;
    --text-secondary: #4c4c66;
    --text-muted: #8a8aa4;
    --border: #e5e5ef;
    --border-strong: #d0d0e0;

    --primary: #4f46e5;
    --primary-hover: #6d68f0;
    --primary-soft: #eef0ff;
    --primary-line: #c7c4f7;
    --primary-text-on: #ffffff;

    --positive: #12925a;
    --positive-soft: #e7f7ee;
    --negative: #d92d20;
    --negative-soft: #fdeceb;

    --font-display: 'Bricolage Grotesque', 'Inter', sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;

    /* profundidade em camadas, como na landing */
    --shadow-sm: 0 1px 2px rgba(18, 18, 42, .05);
    --shadow-md: 0 1px 2px rgba(18, 18, 42, .04), 0 8px 20px rgba(18, 18, 42, .07);
    --shadow-lg: 0 2px 4px rgba(18, 18, 42, .04), 0 14px 30px rgba(18, 18, 42, .09), 0 36px 70px rgba(18, 18, 42, .09);
    --shadow-brand: 0 8px 24px rgba(79, 70, 229, .30);

    --grid-line: rgba(18, 18, 42, .05);

    --focus-ring: 0 0 0 3px rgba(79, 70, 229, .35);
}

@media (prefers-color-scheme: dark) {
    :root {
        --page: #0a0a12;
        --bg: #1b1b29;
        --sidebar-bg: #14141f;
        --card-bg: #14141f;
        --text: #f3f3f8;
        --text-secondary: #aeaec6;
        --text-muted: #6e6e8a;
        --border: #262636;
        --border-strong: #35354c;

        --primary: #6d68f0;
        --primary-hover: #8f8bff;
        --primary-soft: #1b1938;
        --primary-line: #3a3670;
        --primary-text-on: #ffffff;

        --positive: #3bc687;
        --positive-soft: #102b21;
        --negative: #f37066;
        --negative-soft: #351816;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-md: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 20px rgba(0, 0, 0, .45);
        --shadow-lg: 0 2px 6px rgba(0, 0, 0, .4), 0 16px 34px rgba(0, 0, 0, .5), 0 40px 80px rgba(0, 0, 0, .45);
        --shadow-brand: 0 10px 30px rgba(109, 104, 240, .35);

        --grid-line: rgba(255, 255, 255, .045);

        --focus-ring: 0 0 0 3px rgba(143, 139, 255, .4);
    }
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--page);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    font-variation-settings: 'opsz' 36;
}

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 6px; }

/* ===== App shell / sidebar ===== */
.sidebar-toggle-input { display: none; }

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 248px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px 18px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.95rem;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px;
    flex: 1;
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px;
    border-top: 1px solid var(--border);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}
.nav-item svg { flex-shrink: 0; color: var(--text-muted); transition: color 0.15s ease; }
.nav-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-item:hover svg { color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item.active svg { color: var(--primary); }
.nav-item-danger { color: #b42318; }
.nav-item-danger svg { color: #b42318; }
.nav-item-danger:hover { background: var(--negative-soft); color: #b42318; }
.nav-item-danger:hover svg { color: #b42318; }

.sidebar-backdrop { display: none; }

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.mobile-topbar { display: none; }

.container {
    max-width: 1080px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 32px 64px;
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: var(--shadow-lg);
    }
    .sidebar-toggle-input:checked ~ .sidebar { transform: translateX(0); }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(16, 24, 40, 0.45);
        z-index: 50;
    }
    .sidebar-toggle-input:checked ~ .sidebar-backdrop { display: block; }

    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 14px 16px;
        background: var(--card-bg);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 40;
    }
    .hamburger-btn {
        display: flex;
        color: var(--text);
        cursor: pointer;
        padding: 4px;
    }
    .mobile-brand { font-weight: 700; }
    .container { padding: 20px 16px 48px; }
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 20px;
}
.card h1 { margin-top: 0; font-size: 1.5rem; }
.card h2 { margin-top: 0; font-size: 1.05rem; font-weight: 700; }

.highlight-card {
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
    background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 5%, var(--card-bg)), var(--card-bg));
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.card-header h1 { margin: 0; font-size: 1.6rem; }
.card-header-actions { display: flex; align-items: center; gap: 10px; }
.page-hint { margin: -12px 0 20px; font-size: 0.88rem; max-width: 680px; }
.form-card .page-hint { margin: -8px 0 20px; }
.card-header-actions form { margin: 0; }

.grid {
    display: grid;
    gap: 16px;
    margin-bottom: 20px;
}
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 720px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ===== Stat tiles ===== */
.stat {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 0;
}
.stat-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.stat-value.positive, .positive { color: var(--positive); }
.stat-value.negative, .negative { color: var(--negative); }

/* ===== Tables ===== */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.9rem; }
.table th { color: var(--text-muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.table tbody tr:hover { background: var(--bg); }
.table tr:last-child td { border-bottom: none; }
.align-right { text-align: right; font-variant-numeric: tabular-nums; }

.row-actions { display: flex; gap: 14px; justify-content: flex-end; align-items: center; }
.row-actions form { margin: 0; display: inline-flex; }

.muted { color: var(--text-muted); }
.small { font-size: 0.8rem; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.05s ease;
}
.btn:hover { text-decoration: none; border-color: var(--text-muted); background: var(--bg); }
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-text-on);
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-small { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

.link-btn {
    background: none;
    border: none;
    color: var(--negative);
    cursor: pointer;
    padding: 0;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }

/* ===== Forms ===== */
form label {
    display: block;
    margin-bottom: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="number"],
form input[type="date"],
form input[type="month"],
form select,
form textarea {
    display: block;
    width: 100%;
    margin-top: 7px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
form input:focus, form select:focus, form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
    background: var(--card-bg);
}
form textarea { resize: vertical; font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.85rem; }

form input[type="color"] {
    margin-top: 7px;
    width: 56px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    padding: 2px;
    background: var(--bg);
}

.radio-group { display: flex; gap: 20px; margin-bottom: 16px; }
.radio-group label { display: flex; align-items: center; gap: 6px; margin-bottom: 0; font-weight: 500; }
.radio-group input { width: auto; accent-color: var(--primary); }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.form-card { max-width: 480px; }

.inline-form { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.inline-form label { margin-bottom: 0; min-width: 140px; flex: 1; }
.inline-form button { height: 42px; }

/* ===== Flash / badges ===== */
.flash {
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}
.flash.success { background: var(--positive-soft); color: var(--positive); }
.flash.error { background: var(--negative-soft); color: var(--negative); }
.flash ul { margin: 0; padding-left: 20px; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    background: var(--bg);
    color: var(--text-muted);
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-success { background: var(--positive-soft); color: var(--positive); }
.badge-pending { background: var(--negative-soft); color: var(--negative); }

.chart-legend { display: flex; gap: 20px; margin-top: 16px; font-size: 0.85rem; color: var(--text-secondary); }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }

.color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

/* ===== Tabs ===== */
.tabs {
    display: inline-flex;
    gap: 4px;
    background: var(--bg);
    border-radius: 11px;
    padding: 4px;
    margin-bottom: 16px;
}
.tab { padding: 8px 16px; border-radius: 8px; font-size: 0.87rem; font-weight: 600; color: var(--text-muted); }
.tab:hover { text-decoration: none; color: var(--text); }
.tab.active { background: var(--card-bg); color: var(--text); box-shadow: var(--shadow-sm); }

.month-nav { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; }

/* ===== Month accordion ===== */
.month-accordion {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.month-accordion > summary {
    list-style: none;
    cursor: pointer;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    font-weight: 600;
}
.month-accordion > summary::-webkit-details-marker { display: none; }
.month-accordion > summary::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(-45deg);
    margin-right: 12px;
    transition: transform 0.15s ease;
}
.month-accordion[open] > summary::before { transform: rotate(45deg); }
.month-accordion[open] > summary { border-bottom: 1px solid var(--border); }
.month-name { display: flex; align-items: center; }
.month-summary-stats { display: flex; gap: 18px; font-size: 0.88rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.month-accordion .table, .month-accordion .tx-list, .month-accordion > p { margin: 0 20px 16px; width: calc(100% - 40px); }
.month-accordion .table, .month-accordion .tx-list { margin-top: 8px; }

/* ===== Trend chart (análise) ===== */
.trend-body { display: flex; gap: 12px; }
.trend-axis {
    width: 70px;
    flex-shrink: 0;
    height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: right;
    padding-bottom: 1px;
    font-variant-numeric: tabular-nums;
}
.trend-plot { flex: 1; position: relative; height: 200px; }
.trend-gridline { position: absolute; left: 0; right: 0; height: 1px; background: var(--border); }
.trend-gridline.baseline { background: var(--border-strong); }
.trend-months { display: flex; height: 100%; align-items: flex-end; justify-content: space-around; }
.trend-bars { display: flex; align-items: flex-end; gap: 3px; height: 100%; }
.trend-bar { width: 16px; border-radius: 4px 4px 0 0; min-height: 2px; }
.trend-bar.receita { background: var(--positive); }
.trend-bar.despesa { background: var(--negative); }
.trend-labels-row { display: flex; gap: 12px; margin-top: 10px; }
.trend-labels { flex: 1; display: flex; justify-content: space-around; }
.trend-label { font-size: 0.72rem; color: var(--text-muted); font-weight: 500; }

/* ===== Category bars (análise) ===== */
.cat-bars { display: flex; flex-direction: column; gap: 14px; }
.cat-bar-row { display: grid; grid-template-columns: 140px 1fr 100px 44px; gap: 12px; align-items: center; }
.cat-bar-label { font-size: 0.88rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-bar-track { background: var(--bg); border-radius: 5px; height: 10px; overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 0 5px 5px 0; }
.cat-bar-value { font-size: 0.88rem; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.cat-bar-pct { font-size: 0.78rem; text-align: right; color: var(--text-muted); }

@media (max-width: 720px) {
    .cat-bar-row { grid-template-columns: 90px 1fr 80px; }
    .cat-bar-pct { display: none; }
}

/* ===== Item grid (fatura de cartão) ===== */
.item-grid {
    display: grid;
    grid-template-columns: 130px 1fr 160px 110px 130px;
    gap: 10px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.item-grid-head {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 2px solid var(--border);
}
.item-grid input, .item-grid select { margin-top: 0; padding: 7px 9px; font-size: 0.88rem; }
.checkbox-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; }
.checkbox-inline input { margin: 0; }
@media (max-width: 800px) {
    .item-grid { grid-template-columns: 1fr 1fr; }
    .item-grid-head { display: none; }
}

.review-table input, .review-table select { padding: 7px 9px; margin-top: 0; font-size: 0.88rem; }
.row-warning { background: var(--negative-soft); }

.review-summary {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 14px 4px 4px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    margin-top: 8px;
}
.review-summary strong { font-size: 1.15rem; color: var(--text); font-variant-numeric: tabular-nums; }
.review-summary-split { gap: 32px; }
.review-summary-split > div { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.review-summary-split .muted { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; }
.review-summary-split strong.positive { color: var(--positive); }
.review-summary-split strong.negative { color: var(--negative); }

/* ===== Transaction rows (app-style feed) ===== */
.tx-list { display: flex; flex-direction: column; }
.tx-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
}
.tx-row:last-child { border-bottom: none; }
.tx-row:hover { background: var(--bg); border-radius: var(--radius-sm); }

.tx-icon {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tx-icon.positive { background: var(--positive-soft); color: var(--positive); }
.tx-icon.negative { background: var(--negative-soft); color: var(--negative); }

.tx-main { flex: 1; min-width: 0; }
.tx-desc { font-weight: 600; font-size: 0.92rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-desc a { color: inherit; }
.tx-desc a:hover { color: var(--primary); }
.tx-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-meta .dot { margin: 0 5px; }

.tx-cat-trigger {
    cursor: pointer;
    border-bottom: 1px dashed var(--text-muted);
    padding-bottom: 1px;
}
.tx-cat-trigger:hover, .tx-cat-trigger:focus { color: var(--primary); border-color: var(--primary); outline: none; }
.tx-cat-select {
    font-size: 0.78rem;
    padding: 2px 4px;
    margin-top: 0;
    border-radius: 5px;
    border: 1px solid var(--border-strong);
    background: var(--card-bg);
    color: var(--text);
    max-width: 160px;
}

.tx-right { text-align: right; flex-shrink: 0; }
.tx-amount { font-weight: 700; font-size: 0.95rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-date { font-size: 0.76rem; color: var(--text-muted); margin-top: 3px; }

.tx-actions { display: flex; gap: 4px; flex-shrink: 0; margin-left: 2px; }
.tx-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
}
.tx-action-btn:hover { background: var(--border); color: var(--text); }
.tx-action-btn.danger:hover { background: var(--negative-soft); color: var(--negative); }

@media (max-width: 620px) {
    .tx-date { display: none; }
    .tx-icon { width: 36px; height: 36px; }
}

/* ===== Auth page ===== */
.auth-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    padding: 36px 32px;
}
.auth-card h1 {
    text-align: center;
    font-size: 1.4rem;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.auth-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

/* ===== Multiusuário: cadastro, convite e gestão da casa ===== */

/* Campo isca contra robôs de cadastro — invisível para gente. */
.honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.field-hint {
    display: block;
    margin-top: 5px;
    font-size: 12.5px;
    font-weight: 400;
    color: var(--text-muted);
}

.auth-alt {
    margin: 18px 0 0;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-terms {
    margin: 14px 0 0;
    text-align: center;
    line-height: 1.5;
}

.small { font-size: 13px; }

.invite-link-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.invite-link-input {
    flex: 1 1 320px;
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
}

.sidebar-user {
    padding: 10px 12px 12px;
    border-top: 1px solid var(--border);
    margin-bottom: 4px;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* A marca agora é um desenho, não uma letra: o SVG ocupa o quadrado roxo. */
.brand-mark svg,
.auth-logo svg {
    display: block;
}


/* =====================================================================
   Acabamento no padrão da página de apresentação
   ===================================================================== */

/* ---- títulos ---- */
.card h1 { font-size: 1.5rem; }
.card-header h1 { font-size: 1.8rem; font-variation-settings: 'opsz' 40; }
.card h2 { font-size: 1.08rem; font-weight: 800; }
.auth-card h1 { font-size: 1.45rem; }

/* ---- rótulos: maiúsculas espaçadas, como cabeçalho de planilha ---- */
.stat-label,
.table th,
.item-grid-head,
.review-summary-split .muted,
.badge {
    font-family: var(--font-mono);
    font-weight: 500;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}
.stat-label { font-size: 0.66rem; color: var(--text-muted); }
.table th { font-size: 0.64rem; }
.item-grid-head { font-size: 0.64rem; font-weight: 500; }

/* ---- dinheiro em monoespaçada, como extrato de banco ---- */
.stat-value,
.tx-amount,
.cat-bar-value,
.month-summary-stats,
.review-summary strong,
.trend-axis,
.align-right,
.fc-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
}
.stat-value { font-size: 1.7rem; font-weight: 600; }
.tx-amount { font-weight: 600; }
.tx-date { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.01em; }

/* ---- profundidade e movimento ---- */
.card {
    box-shadow: var(--shadow-sm);
    transition: box-shadow .25s ease, border-color .25s ease;
}

.btn {
    border-radius: var(--radius-sm);
    transition: transform .18s cubic-bezier(.2, .8, .3, 1), box-shadow .18s ease,
                background .18s ease, border-color .18s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn-primary { box-shadow: var(--shadow-brand); }
.btn-primary:hover { box-shadow: 0 12px 32px rgba(79, 70, 229, .40); }

.nav-item { transition: background .18s ease, color .18s ease; }
.tx-row { transition: background .18s ease; }
.tx-action-btn { transition: background .18s ease, color .18s ease; }

/* ---- previsão x fato: o que ainda não aconteceu vem pontilhado ---- */
.badge-pending {
    background: transparent;
    border: 1px dashed var(--negative);
    color: var(--negative);
}
.badge-success {
    background: var(--positive-soft);
    border: 1px solid transparent;
}

/* linha de conta ainda não paga: hachura leve, igual às barras de previsão */
.table tbody tr:has(.badge-pending) {
    background-image: repeating-linear-gradient(
        -45deg,
        color-mix(in srgb, var(--negative) 6%, transparent) 0 6px,
        transparent 6px 12px
    );
}
.table tbody tr:has(.badge-pending):hover { background-color: var(--bg); }

/* o cartão de contas previstas do mês é, ele mesmo, uma previsão */
.highlight-card {
    border-style: dashed;
    border-color: var(--primary-line);
    background: linear-gradient(180deg, var(--primary-soft), var(--card-bg) 70%);
}

/* ---- barra lateral ---- */
.sidebar { border-right: 1px solid var(--border); }
.brand-text,
.mobile-brand {
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: -0.02em;
}
.brand-mark { box-shadow: var(--shadow-brand); border-radius: 10px; }
.nav-item.active { box-shadow: inset 0 0 0 1px var(--primary-line); }
.sidebar-user-name { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.05em; }

/* ---- abas e acordeão ---- */
.tabs { border: 1px solid var(--border); }
.tab.active { box-shadow: var(--shadow-sm); }
.month-accordion { transition: border-color .2s ease, box-shadow .2s ease; }
.month-accordion[open] { border-color: var(--primary-line); box-shadow: var(--shadow-md); }

/* ---- gráficos ---- */
.trend-bar { border-radius: 5px 5px 2px 2px; }
.trend-gridline { background: var(--grid-line); }
.trend-label { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.06em; }
.cat-bar-track { border-radius: 6px; height: 12px; }
.cat-bar-fill { border-radius: 6px; }
.cat-bar-pct { font-family: var(--font-mono); font-size: 0.7rem; }

/* ---- formulários ---- */
form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="number"],
form input[type="date"],
form input[type="month"],
form select,
form textarea {
    border-radius: var(--radius-sm);
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
form input[type="number"],
form input[type="date"],
form input[type="month"] {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}
form label { font-size: 0.82rem; }

/* ---- avisos ---- */
.flash {
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
}
.flash.success { border-color: color-mix(in srgb, var(--positive) 30%, transparent); }
.flash.error { border-color: color-mix(in srgb, var(--negative) 30%, transparent); }

/* ---- entrada e cadastro ---- */
.auth-card { box-shadow: var(--shadow-lg); border-radius: var(--radius-lg); }
.auth-logo { box-shadow: var(--shadow-brand); }
.invite-link-input { font-family: var(--font-mono); }

/* ---- quem prefere menos movimento não vê nenhum ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: .001ms !important;
        animation-duration: .001ms !important;
    }
}

/* ---------------------------------------------------------------------
   Correções de componentes que estavam sem acabamento
   --------------------------------------------------------------------- */

/* O gráfico de categorias do painel usa .bar-* e essas classes nunca
   existiram na folha de estilo: as barras simplesmente não apareciam.
   Mesmo desenho das barras da tela de Análise. */
.bars {
    display: flex;
    flex-direction: column;
    gap: 13px;
}
.bar-row {
    display: grid;
    grid-template-columns: minmax(0, 108px) minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}
.bar-label {
    font-size: 0.86rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bar-track {
    background: var(--bg);
    border-radius: 6px;
    height: 12px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    border-radius: 6px;
    min-width: 3px;
}
.bar-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
    font-size: 0.84rem;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}
@media (max-width: 720px) {
    .bar-row { grid-template-columns: minmax(0, 86px) minmax(0, 1fr) auto; }
}

/* A linha de rótulos do gráfico de tendência repete o .trend-axis apenas
   como espaçador — sem isto ele herda os 200px do eixo e abre um buraco. */
.trend-labels-row .trend-axis {
    height: auto;
    display: block;
}

/* No cabeçalho do mês a seta conta como item do flex e empurrava o nome
   para o centro. O nome fica junto da seta; os totais, à direita. */
.month-accordion > summary .month-name { flex: 1; }

/* Numa tabela, a célula de ações precisa continuar sendo célula: com
   display:flex ela sai do layout da tabela, não acompanha a altura da
   linha e a borda inferior fica alguns pixels acima das outras — o traço
   horizontal aparece quebrado na última coluna. */
td.row-actions {
    display: table-cell;
    vertical-align: middle;
    text-align: right;
    white-space: nowrap;
}
td.row-actions > *,
td.row-actions form {
    display: inline-flex;
    vertical-align: middle;
    margin: 0;
}
td.row-actions > * + * {
    margin-left: 14px;
}

/* =====================================================================
   Contas e cartões — blocos no lugar da tabela
   ===================================================================== */

/* valores em dinheiro fora dos componentes já cobertos */
.num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
}

.section-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin: 28px 0 14px;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.section-total { color: var(--text-muted); }
.section-total strong { color: var(--text); font-weight: 600; }

.acct-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.acct {
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    transition: box-shadow .25s ease, border-color .25s ease;
}
.acct:hover { box-shadow: var(--shadow-md); }
.acct.is-archived { opacity: .62; }

/* fatura em aberto ainda não aconteceu: mesma língua das contas previstas */
.acct-card.has-open {
    border-style: dashed;
    border-color: var(--primary-line);
}

.acct-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.acct-name { margin: 0; font-size: 1rem; font-weight: 800; letter-spacing: -0.02em; }
.acct-type {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.acct-label {
    margin: 0 0 2px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.acct-balance {
    margin: 0;
    font-size: 1.55rem;
    font-weight: 600;
    line-height: 1.2;
}
.acct-checked {
    margin: 4px 0 16px;
    font-size: 0.76rem;
    color: var(--text-muted);
}
.acct-empty {
    margin: 4px 0 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.acct-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.acct-actions .btn { flex: 1; justify-content: center; }

/* menu de três pontos, sem javascript */
.acct-menu { position: relative; flex: 0 0 auto; }
.acct-menu > summary {
    list-style: none;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--text-muted);
    transition: background .18s ease, color .18s ease;
}
.acct-menu > summary::-webkit-details-marker { display: none; }
.acct-menu > summary:hover { background: var(--bg); color: var(--text); }
.acct-menu-items {
    position: absolute;
    right: 0;
    top: 32px;
    z-index: 20;
    min-width: 160px;
    background: var(--card-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    display: flex;
    flex-direction: column;
}
.acct-menu-items a,
.acct-menu-items button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border: none;
    background: none;
    border-radius: 7px;
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
}
.acct-menu-items a:hover,
.acct-menu-items button:hover { background: var(--bg); text-decoration: none; }
.acct-menu-items button.is-danger { color: var(--negative); }
.acct-menu-items form { margin: 0; }

.archived-link { margin: 4px 0 24px; }

/* ---- conferir saldo ---- */
.check-card { max-width: 460px; }
.check-current {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 18px 20px;
    margin-bottom: 22px;
    border-radius: var(--radius-md);
    background: var(--bg);
    border: 1px dashed var(--border-strong);
}
.check-current-label {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.check-current-value { font-size: 1.7rem; font-weight: 600; }
.check-current-hint { font-size: 0.76rem; color: var(--text-muted); }
.check-field input { font-size: 1.15rem; font-family: var(--font-mono); }

/* ---- quanto devo, no painel ---- */
.owe-card {
    border-style: dashed;
    border-color: color-mix(in srgb, var(--negative) 35%, var(--border));
    background: linear-gradient(180deg, var(--negative-soft), var(--card-bg) 70%);
}

/* Os dois botões do cartão dividem a largura sem quebrar o texto no meio. */
.acct-actions .btn {
    white-space: nowrap;
    padding-left: 10px;
    padding-right: 10px;
}
