/* MaisonZi — base visual compartilhada */
:root {
  --rosa: #D3A1AA;
  --rosa-claro: #EED5D9;
  --rosa-bg: #F8ECEE;
  --cacau: #542724;
  --cacau-2: #6E3631;
  --tinta: #231515;
  --papel: #FBF7F4;
  --papel-2: #F3EBE6;
  --linha: #E6D9D3;
  --suave: #8A7470;
  --ok: #3F7A57;
  --ok-bg: #E3F0E7;
  --alerta: #B7791F;
  --alerta-bg: #FBEFD9;
  --erro: #B23A3A;
  --erro-bg: #F8E1E1;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --raio: 14px;
  --sombra: 0 1px 2px rgba(35, 21, 21, .06), 0 4px 16px rgba(35, 21, 21, .06);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--sans); background: var(--papel); color: var(--tinta); font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--linha); border-radius: 10px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--rosa); box-shadow: 0 0 0 3px var(--rosa-claro); }
label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--suave); margin: 0 0 6px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; color: var(--cacau); margin: 0; letter-spacing: .01em; }
.num { font-variant-numeric: tabular-nums; }
.suave { color: var(--suave); }
.oculto { display: none !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 999px; font-weight: 600; background: var(--cacau); color: #fff; transition: transform .08s, background .15s, opacity .15s; white-space: nowrap; min-height: 44px; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.sec { background: #fff; color: var(--cacau); border: 1px solid var(--linha); }
.btn.rosa { background: var(--rosa); color: var(--tinta); }
.btn.ok { background: var(--ok); }
.btn.perigo { background: #fff; color: var(--erro); border: 1px solid #EBC8C8; }
.btn.peq { padding: 6px 12px; min-height: 34px; font-size: 13px; }
.btn.grande { padding: 15px 22px; font-size: 17px; min-height: 54px; }
.btn.bloco { width: 100%; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--papel-2); color: var(--cacau); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.alerta { background: var(--alerta-bg); color: var(--alerta); }
.chip.erro { background: var(--erro-bg); color: var(--erro); }
.chip.rosa { background: var(--rosa-bg); color: var(--cacau); }

.card { background: #fff; border: 1px solid var(--linha); border-radius: var(--raio); box-shadow: var(--sombra); }

/* Topo */
.topo { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: rgba(251, 247, 244, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--linha); }
.topo .marca { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topo .marca img { width: 36px; height: 36px; border-radius: 50%; }
.topo .marca b { font-family: var(--serif); font-size: 19px; color: var(--cacau); font-weight: 600; }
.topo .marca small { display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--suave); }
.topo .esp { flex: 1; }
.conexao { width: 9px; height: 9px; border-radius: 50%; background: var(--alerta); box-shadow: 0 0 0 3px var(--alerta-bg); flex: none; }
.conexao.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.conexao.off { background: var(--erro); box-shadow: 0 0 0 3px var(--erro-bg); }

/* Login por PIN */
#login { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--rosa-bg); overflow: auto; }
#login .caixa-login { width: 100%; max-width: 340px; text-align: center; }
#login .logo { width: 150px; height: 150px; margin: 0 auto 6px; display: block; }
#login h2 { font-size: 20px; margin: 4px 0 18px; }
#login .msg { min-height: 20px; color: var(--erro); font-size: 14px; margin-top: 12px; }
#login .treme { animation: treme .35s; }
@keyframes treme { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* Toast e modais */
#toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--tinta); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 14px; animation: sobe .25s; pointer-events: auto; }
.toast.ok { background: var(--ok); }
.toast.erro { background: var(--erro); }
.toast.rosa { background: var(--rosa); color: var(--tinta); font-weight: 600; }
/* com uma janela aberta, os avisos vão para o topo para não cobrir botões e valores */
body:has(.modal-fundo) #toasts { top: calc(12px + env(safe-area-inset-top)); bottom: auto !important; }
@keyframes sobe { from { transform: translateY(12px); opacity: 0; } }

.modal-fundo { position: fixed; inset: 0; z-index: 150; background: rgba(35, 21, 21, .45); display: flex; align-items: flex-end; justify-content: center; animation: aparece .15s; }
@media (min-width: 700px) { .modal-fundo { align-items: center; padding: 20px; } }
.modal { background: var(--papel); width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 20px; animation: sobe .2s; }
@media (min-width: 700px) { .modal { border-radius: 20px; } .modal.largo { max-width: 760px; } }
.modal h3 { font-size: 21px; margin-bottom: 14px; }
.modal .acoes { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
@keyframes aparece { from { opacity: 0; } }

.campos { display: grid; gap: 14px; }
.campos.dois { grid-template-columns: 1fr 1fr; }
.vazio { text-align: center; padding: 40px 16px; color: var(--suave); }
.vazio img { width: 56px; opacity: .35; margin-bottom: 8px; }

.contador { display: inline-flex; align-items: center; border: 1px solid var(--linha); border-radius: 999px; background: #fff; }
.contador button { width: 38px; height: 38px; font-size: 20px; color: var(--cacau); font-weight: 600; }
.contador span { min-width: 26px; text-align: center; font-weight: 700; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--linha); border-radius: 8px; }
input[type=checkbox] { accent-color: var(--cacau); width: auto; }
