/* Minhas Despesas — layout pensado primeiro para celular */
:root {
    --primaria: #0f766e;
    --primaria-escura: #115e59;
    --fundo: #f1f5f4;
    --cartao: #ffffff;
    --texto: #1e293b;
    --suave: #64748b;
    --borda: #e2e8f0;
    --perigo: #dc2626;
    --ok-fundo: #ecfdf5;
    --ok-texto: #065f46;
    --raio: 14px;
    --menu-altura: 64px;
    color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    color: var(--texto);
    background: var(--fundo);
    min-height: 100vh;
    min-height: 100dvh;
}

body.com-menu { padding-bottom: calc(var(--menu-altura) + env(safe-area-inset-bottom) + 16px); }

a { color: var(--primaria); }

/* Topo */
.topo {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: var(--primaria);
    color: #fff;
}
.topo h1 { margin: 0; font-size: 1.15rem; font-weight: 600; }
.topo-acoes { display: flex; align-items: center; gap: 4px; }
.topo-acoes form { margin: 0; }
.topo-link {
    background: none; border: 0; color: #fff; font: inherit; font-size: .9rem;
    padding: 6px 8px; text-decoration: none; opacity: .9; cursor: pointer;
}

/* Conteúdo */
.conteudo { max-width: 560px; margin: 0 auto; padding: 14px 14px 0; }

.cartao {
    background: var(--cartao);
    border-radius: var(--raio);
    padding: 16px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
    margin-bottom: 14px;
}
.cartao h2 { font-size: 1.05rem; margin: 6px 0 12px; }
.cartao-login { margin-top: 8vh; }
.marca { font-size: 1.4rem; font-weight: 700; text-align: center; margin: 4px 0 16px; color: var(--primaria-escura); }
.dica { color: var(--suave); margin: 0 0 12px; font-size: .95rem; }

/* Formulários */
label { display: block; font-size: .9rem; font-weight: 600; color: var(--suave); margin-bottom: 12px; }
input[type=text], input[type=password], input[type=date], input:not([type]), select {
    display: block; width: 100%;
    margin-top: 4px; padding: 12px;
    font: inherit; font-size: 16px; /* 16px evita o zoom automático no iPhone */
    color: var(--texto);
    background: #fff;
    border: 1px solid var(--borda); border-radius: 10px;
    -webkit-appearance: none; appearance: none;
    min-height: 48px;
}
input:focus, select:focus { outline: 2px solid var(--primaria); outline-offset: 0; border-color: transparent; }
.campo-valor { font-size: 1.6rem !important; font-weight: 700; text-align: center; }

fieldset { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
legend { font-size: .9rem; font-weight: 600; color: var(--suave); margin-bottom: 6px; padding: 0; }

/* Categorias como "chips" para tocar */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { width: 100%; }
.chip { margin: 0; position: relative; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
    display: inline-block; padding: 9px 14px; border-radius: 999px;
    border: 2px solid var(--cor); color: var(--texto); background: #fff;
    font-weight: 600; font-size: .95rem; cursor: pointer;
}
.chip input:checked + span { background: var(--cor); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--texto); outline-offset: 2px; }

/* Seletor de cor */
.cores { display: flex; flex-wrap: wrap; gap: 10px; }
.cores legend { width: 100%; }
.cor { margin: 0; position: relative; }
.cor input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cor span { display: block; width: 36px; height: 36px; border-radius: 50%; background: var(--cor); cursor: pointer; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--borda); }
.cor input:checked + span { box-shadow: 0 0 0 3px var(--texto); }

/* Botões */
.botao {
    display: block; width: 100%; text-align: center; text-decoration: none;
    padding: 14px; margin-top: 8px;
    font: inherit; font-weight: 700; font-size: 1rem;
    color: #fff; background: var(--primaria);
    border: 0; border-radius: 12px; cursor: pointer;
    min-height: 50px;
}
.botao:active { background: var(--primaria-escura); }
.botao.secundario { background: #fff; color: var(--primaria); border: 2px solid var(--primaria); }
.botao.perigo { background: #fff; color: var(--perigo); border: 2px solid #fecaca; margin-top: 16px; }
.voltar { display: block; text-align: center; margin-top: 14px; padding: 8px; text-decoration: none; }

/* Mensagens */
.aviso { background: var(--ok-fundo); color: var(--ok-texto); padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 600; }
.erro { background: #fef2f2; color: #991b1b; padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 600; }
.vazio { text-align: center; color: var(--suave); padding: 28px 12px; }

/* Mês e total */
.seletor-mes { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.seletor-mes strong { font-size: 1.05rem; }
.seta {
    display: grid; place-items: center; width: 44px; height: 44px;
    font-size: 1.8rem; line-height: 1; text-decoration: none;
    background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
}
.total-destaque {
    display: flex; flex-direction: column; align-items: center;
    background: linear-gradient(135deg, var(--primaria), #14b8a6);
    color: #fff; border-radius: var(--raio); padding: 16px; margin-bottom: 14px;
}
.total-destaque span { font-size: .9rem; opacity: .9; }
.total-destaque strong { font-size: 2rem; letter-spacing: -.5px; }
.total-destaque small { opacity: .85; }

/* Listas */
.lista { list-style: none; margin: 0; padding: 0; background: var(--cartao); border-radius: var(--raio); overflow: hidden; box-shadow: 0 1px 3px rgba(15, 23, 42, .08); }
.lista li + li { border-top: 1px solid var(--borda); }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; color: inherit; min-height: 60px; }
.item:active { background: #f8fafc; }
.bolinha { flex: 0 0 12px; width: 12px; height: 12px; border-radius: 50%; background: var(--cor, #94a3b8); display: inline-block; }
.item-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-texto strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-texto small { color: var(--suave); }
.item-valor { font-weight: 700; white-space: nowrap; }
.item-seta { color: var(--suave); font-size: 1.4rem; }

/* Botão flutuante "+" */
.fab {
    position: fixed; right: max(18px, calc(50% - 262px));
    bottom: calc(var(--menu-altura) + env(safe-area-inset-bottom) + 16px);
    width: 60px; height: 60px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--primaria); color: #fff; text-decoration: none;
    font-size: 2.2rem; line-height: 1;
    box-shadow: 0 6px 16px rgba(15, 118, 110, .4);
    z-index: 9;
}

/* Abrir/fechar "Nova categoria" */
details.novo summary { cursor: pointer; font-weight: 700; color: var(--primaria); list-style: none; }
details.novo summary::-webkit-details-marker { display: none; }
details.novo[open] summary { margin-bottom: 12px; }

/* Abas */
.abas { display: flex; background: #e2e8f0; border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.abas a { flex: 1; text-align: center; padding: 10px; border-radius: 9px; text-decoration: none; color: var(--suave); font-weight: 600; }
.abas a.ativo { background: #fff; color: var(--texto); box-shadow: 0 1px 2px rgba(15, 23, 42, .1); }

/* Relatório */
.relatorio { background: var(--cartao); border-radius: var(--raio); box-shadow: 0 1px 3px rgba(15, 23, 42, .08); overflow: hidden; }
.grupo + .grupo { border-top: 1px solid var(--borda); }
.grupo summary { list-style: none; padding: 12px 14px; cursor: pointer; display: block; }
.grupo summary::-webkit-details-marker { display: none; }
.grupo-linha { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grupo-nome { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.grupo-valor { font-weight: 700; white-space: nowrap; }
.barra { display: block; height: 8px; background: #f1f5f9; border-radius: 999px; margin: 8px 0 4px; overflow: hidden; }
.barra span { display: block; height: 100%; background: var(--cor); border-radius: 999px; }
.grupo small { color: var(--suave); }
.sub-lista { list-style: none; margin: 0; padding: 0 14px 10px 34px; }
.sub-lista a { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; text-decoration: none; color: var(--texto); border-top: 1px dashed var(--borda); font-size: .95rem; }
.sub-lista a span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linha-total { display: flex; justify-content: space-between; padding: 14px; background: #f8fafc; border-top: 2px solid var(--borda); font-size: 1.05rem; }

/* Menu inferior */
.menu {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: flex; justify-content: center;
    background: #fff; border-top: 1px solid var(--borda);
    padding-bottom: env(safe-area-inset-bottom);
}
.menu a {
    flex: 1; max-width: 187px; height: var(--menu-altura);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    text-decoration: none; color: var(--suave); font-size: .78rem; font-weight: 600;
}
.menu a span { font-size: 1.35rem; line-height: 1; filter: grayscale(1); opacity: .7; }
.menu a.ativo { color: var(--primaria); }
.menu a.ativo span { filter: none; opacity: 1; }
