:root{
    --bg:#f5f7fb;
    --card:#fff;
    --text:#111827;
    --muted:#6b7280;
    --line:#e5e7eb;
    --accent:#111827;
    --soft:#eef2f7;
    --danger:#b42318
}

*{
    box-sizing:border-box
}

html,body{
    margin:0;
    background:var(--bg);
    color:var(--text);
    font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif
}

body{
    min-height:100vh
}

.app{
    max-width:720px;
    margin:auto;
    min-height:100vh;
    padding-bottom:96px
}

.topbar{
    padding:22px 18px 10px;
    display:flex;
    align-items:center;
    justify-content:space-between
}

.topbar small,
.muted{
    color:var(--muted)
}

h1,h2,p{
    margin:0
}

.topbar h1{
    font-size:25px;
    margin-top:2px
}

.icon-btn{
    width:42px;
    height:42px;
    border:0;
    border-radius:14px;
    background:#fff;
    display:grid;
    place-items:center;
    text-decoration:none;
    color:var(--text);
    font-size:22px;
    box-shadow:0 2px 12px #0000000b
}

.content{
    padding:10px 14px 24px
}


/* =========================================================
   SELETOR DE PERÍODO
   ========================================================= */

.period-picker{
    display:grid;
    grid-template-columns:46px minmax(0,1fr) 92px 46px;
    gap:8px;
    align-items:center;
    margin-bottom:14px
}

.period-picker select,
.period-picker button{
    height:46px;
    margin:0;
    border:1px solid var(--line);
    background-color:#fff;
    border-radius:13px;
    font-size:15px;
    color:var(--text);
    box-sizing:border-box
}

.period-picker select{
    width:100%;
    padding:0 42px 0 14px;

    -webkit-appearance:none;
    -moz-appearance:none;
    appearance:none;

    background-color:#fff;

    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M6 8l4 4 4-4' fill='none' stroke='%23111827' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

    background-repeat:no-repeat;
    background-size:16px 16px;
    background-position:right 14px center;
}

.period-picker button{
    width:46px;
    min-width:46px;
    padding:0;
    display:flex;
    align-items:center;
    justify-content:center;
    line-height:1;
    cursor:pointer
}


/* =========================================================
   CARDS DO DASHBOARD
   ========================================================= */

.stats{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:10px;
    margin-bottom:12px
}

.stats article{
    background:var(--card);
    padding:17px;
    border-radius:18px;
    box-shadow:0 5px 20px #11182708
}

.stats article.wide{
    grid-column:1/-1;
    background:var(--accent);
    color:#fff
}

.stats small{
    display:block;
    opacity:.65;
    margin-bottom:8px
}

.stats strong{
    font-size:22px
}

.stats .wide strong{
    font-size:30px
}


/* =========================================================
   PAINÉIS
   ========================================================= */

.panel{
    background:#fff;
    border-radius:19px;
    padding:16px;
    margin:12px 0;
    box-shadow:0 5px 20px #11182708
}

.section-title{
    display:flex;
    align-items:center;
    justify-content:space-between;
    margin-bottom:12px
}

.section-title h2{
    font-size:17px
}

.section-title a,
.section-title span,
.text-btn{
    font-size:13px;
    color:var(--muted);
    text-decoration:none
}

.text-btn{
    border:0;
    background:none;
    font-weight:700
}


/* =========================================================
   CATEGORIAS
   ========================================================= */

.category-row{
    display:grid;
    grid-template-columns:1fr auto;
    gap:3px 12px;
    padding:11px 0
}

.category-row small,
.expense-row small{
    display:block;
    color:var(--muted);
    margin-top:3px;
    font-size:12px
}

.bar{
    grid-column:1/-1;
    height:5px;
    background:var(--soft);
    border-radius:9px;
    overflow:hidden
}

.bar i{
    display:block;
    height:100%;
    background:var(--accent);
    border-radius:9px
}


/* =========================================================
   GASTOS
   ========================================================= */

.expense-row{
    display:flex;
    align-items:center;
    gap:11px;
    padding:12px 0;
    border-bottom:1px solid var(--line);
    color:var(--text);
    text-decoration:none
}

.expense-row:last-child{
    border:0
}

.expense-icon{
    width:40px;
    height:40px;
    border-radius:13px;
    background:var(--soft);
    display:grid;
    place-items:center;
    font-weight:800
}

.grow{
    flex:1;
    min-width:0
}

.expense-row b{
    display:block;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis
}

.empty{
    text-align:center;
    padding:24px 8px;
    color:var(--muted)
}


/* =========================================================
   MENU INFERIOR
   ========================================================= */

.bottom-nav{
    position:fixed;
    bottom:0;
    left:50%;
    transform:translateX(-50%);
    width:min(720px,100%);
    height:76px;
    padding:8px max(12px,env(safe-area-inset-left));
    background:#fff;
    border-top:1px solid var(--line);
    display:grid;
    grid-template-columns:1fr 1fr 70px 1fr 1fr;
    align-items:center;
    z-index:20
}

.bottom-nav a{
    font-size:10px;
    text-align:center;
    text-decoration:none;
    color:#8a919e
}

.bottom-nav a span{
    display:block;
    font-size:20px;
    margin-bottom:3px
}

.bottom-nav a.active{
    color:var(--text);
    font-weight:700
}

.fab{
    width:58px;
    height:58px;
    border-radius:19px;
    border:0;
    background:var(--accent);
    color:#fff;
    font-size:32px;
    transform:translateY(-16px);
    box-shadow:0 10px 24px #11182740
}


/* =========================================================
   MODAL / SHEET
   ========================================================= */

.sheet-wrap{
    position:fixed;
    inset:0;
    background:#0007;
    z-index:50;
    display:none;
    align-items:flex-end
}

.sheet-wrap.open{
    display:flex
}

.sheet{
    background:#fff;
    width:min(720px,100%);
    margin:auto;
    border-radius:24px 24px 0 0;
    padding:10px 16px calc(20px + env(safe-area-inset-bottom))
}

.sheet-handle{
    width:42px;
    height:5px;
    border-radius:10px;
    background:#d1d5db;
    margin:0 auto 14px
}

.sheet-head{
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:12px
}

.sheet-head h2{
    font-size:20px
}

.sheet-head p{
    font-size:13px;
    color:var(--muted);
    margin-top:3px
}

.action-card{
    display:block;
    width:100%;
    border:1px solid var(--line);
    background:#fff;
    border-radius:16px;
    padding:15px;
    margin:8px 0;
    text-align:left;
    text-decoration:none;
    color:var(--text)
}

.action-card b,
.action-card small{
    display:block
}

.action-card small{
    color:var(--muted);
    margin-top:4px
}


/* =========================================================
   CARREGAMENTO
   ========================================================= */

.loading{
    display:none;
    position:fixed;
    inset:0;
    background:#fffef9;
    z-index:80;
    align-items:center;
    justify-content:center;
    flex-direction:column;
    gap:10px
}

.loading.show{
    display:flex
}

.loading small{
    color:var(--muted)
}

.spinner{
    width:42px;
    height:42px;
    border:4px solid #e5e7eb;
    border-top-color:#111827;
    border-radius:50%;
    animation:spin .8s linear infinite
}

@keyframes spin{
    to{
        transform:rotate(360deg)
    }
}


/* =========================================================
   EDITOR DE GASTO
   ========================================================= */

.editor{
    max-width:720px;
    margin:auto;
    padding-bottom:30px
}

.editor-head{
    height:68px;
    padding:10px 16px;
    display:grid;
    grid-template-columns:40px 1fr 40px;
    align-items:center
}

.editor-head a{
    text-decoration:none;
    color:var(--text);
    font-size:34px
}

.editor-head h1{
    text-align:center;
    font-size:18px
}

.editor-form{
    padding:0 14px
}

.form-grid{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:12px
}

.form-grid .full{
    grid-column:1/-1
}

label{
    font-size:12px;
    color:var(--muted);
    font-weight:600
}

input,
select,
textarea{
    width:100%;
    margin-top:6px;
    border:1px solid var(--line);
    border-radius:13px;
    background:#fff;
    padding:12px;
    font:inherit;
    color:var(--text);
    outline:none
}

input:focus,
select:focus,
textarea:focus{
    border-color:#9ca3af
}


/* =========================================================
   ITENS
   ========================================================= */

.item-card{
    border:1px solid var(--line);
    border-radius:16px;
    padding:12px;
    margin:10px 0
}

.item-card>input{
    margin:0 0 10px
}

.item-values{
    display:grid;
    grid-template-columns:.7fr 1fr 1fr;
    gap:7px
}

.remove{
    border:0;
    background:none;
    color:var(--danger);
    font-size:12px;
    padding:10px 0 0
}


/* =========================================================
   TOTAIS
   ========================================================= */

.totals{
    display:flex;
    align-items:end;
    justify-content:space-between;
    gap:18px
}

.totals label{
    max-width:150px
}

.totals strong{
    font-size:25px;
    display:block;
    margin-top:4px
}

.note-label{
    display:block;
    margin:14px 2px
}


/* =========================================================
   BOTÕES
   ========================================================= */

.btn{
    border:0;
    border-radius:14px;
    padding:14px 18px;
    font-weight:750;
    font-size:15px;
    text-decoration:none;
    text-align:center;
    display:inline-block
}

.primary{
    background:var(--accent);
    color:#fff
}

.danger{
    background:#fff;
    color:var(--danger);
    border:1px solid #f2c7c2;
    margin-top:10px
}

.full{
    width:100%
}

.sticky-save{
    min-height:50px
}


/* =========================================================
   FILTROS
   ========================================================= */

.filter-card{
    margin-bottom:10px
}

.filter-card input{
    height:46px;
    border:1px solid var(--line);
    background:#fff;
    border-radius:13px;
    padding:0 10px;
    font-size:15px;
    color:var(--text)
}

.list-panel{
    padding-top:4px
}


/* =========================================================
   CATEGORIAS - EDIÇÃO
   ========================================================= */

.inline-add{
    display:grid;
    grid-template-columns:1fr auto;
    gap:8px;
    margin-bottom:12px
}

.inline-add input{
    margin:0
}

.category-edit{
    display:grid;
    grid-template-columns:1fr auto;
    gap:5px 10px;
    padding:10px 0;
    border-bottom:1px solid var(--line);
    align-items:center
}

.category-edit input{
    margin:0
}

.category-edit small{
    color:var(--muted)
}

.category-edit button{
    grid-row:1/3;
    grid-column:2;
    border:0;
    background:var(--soft);
    border-radius:10px;
    padding:10px
}


/* =========================================================
   LOGIN
   ========================================================= */

.login-body{
    display:grid;
    place-items:center;
    padding:20px
}

.login-card{
    width:min(420px,100%);
    background:#fff;
    padding:28px;
    border-radius:24px;
    box-shadow:0 10px 40px #11182710
}

.login-card h1{
    margin-top:12px
}

.login-card .muted{
    margin:6px 0 20px
}

.brand-mark{
    width:52px;
    height:52px;
    border-radius:17px;
    background:var(--accent);
    color:#fff;
    display:grid;
    place-items:center;
    font-weight:900
}

.stack{
    display:grid;
    gap:13px
}

.alert{
    background:#fff1f0;
    color:#9f1c12;
    padding:12px;
    border-radius:12px;
    margin-bottom:12px
}


/* =========================================================
   DESKTOP
   ========================================================= */

@media(min-width:700px){

    .content{
        padding-left:20px;
        padding-right:20px
    }

    .stats{
        grid-template-columns:1fr 1fr 1.4fr
    }

    .stats article.wide{
        grid-column:auto
    }
}

/* =========================================================
   ÍCONES MODERNOS
   ========================================================= */

svg{
    display:block
}

.modern-icon-btn svg{
    width:19px;
    height:19px;
    fill:none;
    stroke:currentColor;
    stroke-width:1.8;
    stroke-linecap:round;
    stroke-linejoin:round
}


/* MENU INFERIOR */

.bottom-nav .nav-icon{
    height:24px;
    margin:0 auto 3px;
    display:flex;
    align-items:center;
    justify-content:center
}

.bottom-nav .nav-icon svg{
    width:20px;
    height:20px;
    fill:none;
    stroke:currentColor;
    stroke-width:1.8;
    stroke-linecap:round;
    stroke-linejoin:round
}


/* AÇÕES DO NOVO GASTO */

.action-modern{
    display:grid;
    grid-template-columns:46px 1fr 24px;
    gap:12px;
    align-items:center;
    padding:13px 14px
}

.action-icon{
    width:46px;
    height:46px;
    border-radius:14px;
    background:var(--soft);
    display:flex;
    align-items:center;
    justify-content:center;
    color:var(--text)
}

.action-icon svg{
    width:22px;
    height:22px;
    fill:none;
    stroke:currentColor;
    stroke-width:1.8;
    stroke-linecap:round;
    stroke-linejoin:round
}

.action-content{
    min-width:0
}

.action-content b{
    font-size:15px;
    color:var(--text);
    margin:0
}

.action-content small{
    font-size:12px;
    color:var(--muted);
    margin-top:4px
}

.action-arrow{
    color:#9ca3af;
    font-size:25px;
    line-height:1;
    text-align:center
}
/* =========================================================
   USUÁRIOS
   ========================================================= */

.success-alert{
    background:#ecfdf3;
    color:#027a48;
    padding:12px 14px;
    border-radius:12px;
    margin-bottom:12px;
    font-size:14px
}

.user-row{
    display:flex;
    align-items:center;
    gap:12px;
    padding:13px 0;
    border-bottom:1px solid var(--line)
}

.user-row:last-child{
    border-bottom:0
}

.user-avatar{
    width:42px;
    height:42px;
    min-width:42px;
    border-radius:14px;
    background:var(--soft);
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:800;
    font-size:15px;
    color:var(--text)
}

.user-row b{
    display:block;
    font-size:14px
}

.user-row small{
    display:block;
    color:var(--muted);
    margin-top:3px;
    font-size:12px
}

.user-status{
    padding:5px 8px;
    border-radius:20px;
    background:var(--soft);
    color:var(--muted);
    font-size:11px;
    font-weight:700
}

.user-status.active{
    background:#ecfdf3;
    color:#027a48
}

/* =========================================================
   AÇÕES DO TOPO
   ========================================================= */

.topbar-actions{
    display:flex;
    align-items:center;
    gap:8px
}

.topbar-actions .icon-btn{
    flex:0 0 42px
}