/* ===== Layout para celular (até 820px): navegação inferior, cabeçalho compacto, cartões no lugar de tabelas ===== */
@media(max-width:820px){
  html,body{overflow-x:hidden}
  /* cabeçalhos */
  .topbar,.topbar.mod-top{height:auto!important;min-height:0;padding:12px 16px!important;flex-wrap:wrap;gap:10px 12px;position:static}
  .topbar .page-title small,.mod-top .page-title small{display:none}
  .topbar .page-title strong,.mod-top .page-title strong{font-size:18px}
  .topbar .month-control{order:3;width:100%;justify-content:space-between;height:34px!important}
  .topbar .month-control label{flex:1;justify-content:center;gap:6px}.topbar .month-control label span{font-size:9px!important;letter-spacing:.1em}.topbar .month-control input{font-size:12px!important}
  .topbar .month-control .icon-btn{width:26px;height:26px}
  #addTop{height:38px!important;padding:0 14px 0 10px}
  .app-main,main{padding:14px 12px 24px!important}
  .app-content .app-main{padding:14px 12px 24px}
  /* cartões e painéis */
  .summary-grid{grid-template-columns:1fr 1fr!important;gap:10px}
  .summary-grid .metric.dark{grid-column:1/-1}
  .metric{padding:14px}.metric strong{font-size:20px!important}
  .overview-grid,.grid-two,.lower,.summary-grid{grid-template-columns:minmax(0,1fr)!important}
  .summary-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .app-main>*,main>*,.panel,.ui,.grid>*,.overview-grid>*,.lower>*{min-width:0;max-width:100%}
  .panel,.ui{overflow:hidden}
  .panel{padding:16px;border-radius:16px}
  .panel-head{flex-wrap:wrap;gap:10px}
  .annual-head{align-items:stretch}
  .annual-controls{display:grid!important;grid-template-columns:1fr 1fr;gap:8px;width:100%}
  .annual-controls>*{min-width:0}
  .annual-controls .segmented{grid-column:1/-1;display:flex;width:100%}
  .annual-controls .segmented button{flex:1;padding:7px 4px;font-size:12px}
  .annual-controls .year-filter{padding-left:10px}.annual-controls .year-filter select{max-width:100%}
  .annual-legend{justify-content:flex-start}
  #annualChart{overflow-x:auto;-webkit-overflow-scrolling:touch}
  #annualChart .tr-plot{min-width:620px}
  .trend-chart{overflow:hidden}.trend-chart svg{width:100%!important;height:auto}
  .donut-wrap{flex-direction:column;align-items:center;gap:14px}
  .legend{width:100%}
  /* Destino do saldo: nome e barra em cima; Previsto / Guardado / Diferença em 3 colunas rotuladas */
  .allocation-head{display:none}
  .allocation-list{gap:14px}
  .allocation-row{grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:8px 10px;padding-bottom:14px;border-bottom:1px solid var(--line,#e8e6e1)}
  .allocation-row:last-child{border-bottom:0}
  .allocation-main{grid-column:1/-1}
  .alloc-cell>*{grid-column:auto!important}
  .alloc-cell{display:grid;gap:4px;min-width:0;align-content:start}
  .alloc-cell::before{display:block;content:attr(data-l);font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted,#6b7280)}
  .alloc-cell strong,.alloc-cell .difference{font-size:13px;line-height:36px;white-space:nowrap}
  .alloc-cell .actual-input{width:100%;min-width:0;height:36px;padding:0 8px;font-size:13px;text-align:left}
  .allocation-total{font-size:15px}
  .investment-chart-row{grid-template-columns:minmax(0,1fr)!important;gap:5px!important;padding:6px 0}
  .investment-chart-row>span{font-weight:600;font-size:13px}.investment-chart-row .dual-track{width:100%}
  .investment-chart-row strong{grid-column:auto!important;text-align:left!important;white-space:normal!important;font-size:12px!important;font-weight:500;color:var(--muted-foreground,#6b7280)}
  .investment-chart-wrap{margin-top:18px}
  /* Movimentações: lançamentos em cartões */
  .table-panel .flex.flex-wrap{gap:12px}
  .table-panel .filters{display:grid!important;grid-template-columns:repeat(4,1fr);gap:8px;width:100%}
  .table-panel .filters input{grid-column:1/-1;min-width:0;width:100%}
  .table-panel .filters select{grid-column:span 2;min-width:0;width:100%}
  .table-panel .filters #openImport{grid-column:span 2}
  .table-panel .filters .icon-export{width:100%;justify-self:stretch}
  .table-panel table,.table-panel tbody{display:block;width:100%}
  .table-panel thead{display:none}
  .table-panel tr.entry{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px;padding:14px 44px 14px 14px;position:relative}
  .table-panel tr.entry::after,.table-panel tr.entry::before{content:"";flex-basis:100%;height:0}
  .table-panel tr.entry::after{order:2}.table-panel tr.entry::before{order:4}
  .table-panel tr.entry-section{display:flex;justify-content:space-between;align-items:center;padding:0}
  .table-panel tr.entry-section td{padding:8px 14px!important}.table-panel tr.entry-section td[colspan]{flex:1}
  .table-panel td{display:block;padding:0!important;border:0;font-size:13px}
  .table-panel td[data-col=select],.table-panel td[data-empty]{display:none}
  .table-panel td[data-col=desc]{order:1;flex:1 1 0;min-width:45%;white-space:normal;font-size:15px;font-weight:600}
  .table-panel td[data-col=value]{order:1;flex:0 0 auto;text-align:right;font-size:16px}
  .table-panel td[data-col=bank],.table-panel td[data-col=date],.table-panel td[data-col=due]{order:3;color:var(--muted-foreground,#6b7280);font-size:12.5px}
  .table-panel td[data-col=cat]{order:5}.table-panel td[data-col=status]{order:5}
  .table-panel td[data-col=menu]{position:absolute;top:10px;right:4px}
  .table-panel td[data-col=due]::before{content:"Venc. ";display:inline;margin:0;font-size:inherit;letter-spacing:0;text-transform:none}
  .table-panel td[data-label]::before{display:none}
  .table-panel td[data-col=due]::before{display:inline}
  .batch-bar{margin:0 12px 12px}
  /* tabelas dos demais módulos em cartões */
  table.gg-cards,table.gg-cards tbody{display:block;width:100%}
  table.gg-cards thead{display:none}
  table.gg-cards tr{display:block;position:relative;padding:12px 14px!important;border-bottom:1px solid var(--border,#e8e6e1)}
  table.gg-cards td{display:flex;justify-content:space-between;align-items:baseline;gap:14px;padding:3px 0!important;border:0;white-space:normal!important;text-align:right}
  table.gg-cards td::before{content:attr(data-label);flex:none;font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted-foreground,#6b7280);text-align:left}
  table.gg-cards td:first-child{display:block;text-align:left;font-size:15px;padding-right:34px!important}
  table.gg-cards td:first-child::before{display:none}
  table.gg-cards td[data-label=""]{position:absolute;top:8px;right:6px;display:block;padding:0!important}
  table.gg-cards td[data-label=""]::before{display:none}
  table.gg-cards td:has(.gg-switch){justify-content:space-between}
  /* formulários e janelas */
  .form-grid,.inline-fields{grid-template-columns:minmax(0,1fr)!important}
  .field,.field input,.field select,.password-field{min-width:0;max-width:100%}
  .wide{grid-column:auto}
  .modal{place-items:end center!important;padding:0!important}
  .modal-card{width:100%!important;max-height:92vh;border-radius:22px 22px 0 0!important;padding:20px 16px calc(20px + env(safe-area-inset-bottom))!important}
  dialog{width:100%!important;max-width:100%!important;margin:auto 0 0 0!important;border-radius:22px 22px 0 0!important;max-height:92vh}
  dialog form{padding:18px 16px calc(18px + env(safe-area-inset-bottom))!important}
  .dialog-actions,.modal-actions{flex-wrap:wrap}
  .dialog-actions button,.modal-actions .btn,.modal-actions button{flex:1}
  .permission-grid{grid-template-columns:1.3fr repeat(4,.6fr)!important;font-size:11px}
  .permission-presets{gap:6px}.permission-presets label{padding:7px 9px;font-size:12.5px}
  .detail-grid{grid-template-columns:1fr 1fr}
  .admin-split{grid-template-columns:minmax(0,1fr)!important}.admin-split>*{min-width:0}
  .admin-create{padding:16px}
  .toast{bottom:84px!important}
  /* Compromissos: nome e valor na mesma linha; detalhes abaixo, sem cortar nada */
  .debt-item{display:grid!important;grid-template-columns:minmax(0,1fr) auto;gap:4px 12px;align-items:start;padding:14px 0}
  .debt-item .debt-main{display:contents!important}
  .debt-main>span{grid-column:1;grid-row:1;font-weight:600;font-size:15px;line-height:1.3}
  .debt-actions{grid-column:2;grid-row:1;justify-self:end;display:flex;align-items:center;gap:2px}
  .debt-actions strong{font-size:16px;white-space:nowrap}
  .debt-main>small,.debt-main>.debt-progress{grid-column:1/-1}
  .debt-main>small{font-size:12.5px;line-height:1.4}
  .debt-total{font-size:15px}
  #addCommitment,#editPlan{padding:6px 0}
  /* Senhas */
  .vault-donut-center strong{font-size:22px}
  table.gg-cards code{overflow-wrap:anywhere;word-break:break-all;white-space:normal}
  .gg-dlg-card{width:100%}
  /* PIX / Contas / Senhas: cartões de resumo */
  .dashboard-grid,.quick-grid{grid-template-columns:1fr 1fr!important}
  .tabs{max-width:100%}
  .search-input{width:100%}
  /* Cadastrados */
  #categories-app .grid{grid-template-columns:1fr!important}
}
@media(max-width:380px){.summary-grid{grid-template-columns:1fr!important}.mobile-nav a,.mobile-nav form{flex-basis:56px}}
/* login */
@media(max-width:520px){.auth-main{padding:14px!important;align-items:start}.auth-card{padding:22px 18px!important;border-radius:20px!important;margin-top:24px}}
@media(max-width:1023px){
  .mod-top .top-actions,.topbar .top-actions{display:none!important}
  .mob-action{display:flex;justify-content:flex-end;margin:0 0 12px}
  .mob-action .btn-plus{width:44px;height:44px;border-radius:14px}
  .mob-action .primary{display:inline-flex;align-items:center;gap:9px;height:40px;border-radius:999px;padding:0 18px 0 10px;background:var(--ink,#1a1f2e);color:#fff;border:0;font:600 13.5px Inter,system-ui,sans-serif}
  .mob-action .primary span{display:grid;place-items:center;width:20px;height:20px;border-radius:50%;background:#bfc9bb;color:#1a1f2e;font-size:15px;line-height:1}
  .topbar .month-control{height:30px!important}.topbar .month-control .icon-btn{width:24px;height:24px}
  .overview-grid .donut{width:176px;height:176px}.overview-grid .donut:before{inset:30px}
}
@media(max-width:820px){
  /* Movimentações: descrição + valor, etiquetas, e só então os detalhes */
  .table-panel tr.entry{gap:8px 10px;padding:12px 40px 12px 14px}
  .table-panel tr.entry::after{order:2}.table-panel tr.entry::before{order:4}
  .table-panel td[data-col=cat],.table-panel td[data-col=status]{order:3}
  .table-panel td[data-col=bank],.table-panel td[data-col=date],.table-panel td[data-col=due]{order:5;font-size:12px;position:relative}
  .table-panel td[data-col=desc]{font-size:15px}
  .table-panel td[data-col=desc] .text-xs{font-weight:400;color:var(--muted-foreground,#6b7280)}
}
@media(max-width:1023px){
  .topbar .month-control{order:3;width:auto!important;height:28px!important;justify-content:flex-start!important;align-self:flex-start}
  .topbar .month-control label{flex:none!important}
  .topbar .month-control .icon-btn{width:22px!important;height:22px!important}
}
