/* FaceCantina Família · portal dos pais, feito primeiro para o celular */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f2f5;
  --line: #e4e6eb;
  --line-strong: #d4d7de;
  --text: #1c1d21;
  --muted: #6b6f7a;
  --faint: #9a9ea8;
  --accent: #e8262d;
  --accent-dark: #c41d23;
  --accent-soft: #fdecec;
  --success: #1f9d5c;
  --success-soft: #e6f5ec;
  --warning: #b87c00;
  --warning-soft: #fdf4e1;
  --danger: #d92d2d;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 22, 28, .04), 0 8px 24px rgba(20, 22, 28, .06);
  --shadow-lg: 0 24px 60px rgba(20, 22, 28, .2);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
p { margin: 0; }
:focus-visible { outline: 3px solid rgba(232, 38, 45, .3); outline-offset: 2px; }
.icon { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 18px; height: 18px; }

/* Marca */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 46px; height: 46px; flex: none; }
.brand-mark.sm { width: 36px; height: 36px; }
.brand b { display: block; font-size: 1.25rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.brand em { font-style: normal; color: var(--accent); }
.brand small { display: block; margin-top: 4px; color: var(--faint); font-size: .66rem; font-weight: 700; letter-spacing: .3em; text-transform: uppercase; }

/* Botões e campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border: 1px solid transparent; border-radius: 14px; font-weight: 700; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-dark); }
.btn.secondary { background: var(--surface); border-color: var(--line-strong); }
.btn.light { background: rgba(255, 255, 255, .18); color: #fff; border-color: rgba(255, 255, 255, .35); }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 14px; border-radius: 11px; font-size: .9rem; }
.link { display: block; margin: 8px auto 0; padding: 8px; border: 0; background: none; color: var(--accent-dark); font-weight: 600; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 12px; background: var(--surface-2); }
label { display: grid; gap: 6px; font-size: .88rem; font-weight: 600; }
input, select { width: 100%; min-height: 48px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); padding: 0 14px; font-size: 1rem; outline: none; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232, 38, 45, .12); }
.error { min-height: 1.3em; margin-top: 10px; color: var(--danger); font-size: .9rem; font-weight: 600; }
.hint { color: var(--muted); font-size: .8rem; }

/* Entrada */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(circle at 50% -10%, #fde3e4 0%, var(--bg) 55%); }
.login-card { width: min(420px, 100%); padding: 28px 22px; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow-lg); }
.login-card h1 { margin-top: 22px; font-size: 1.7rem; font-weight: 800; }
.login-card > .muted { margin: 4px 0 18px; }
.login-card form { display: grid; gap: 14px; }
.form-intro { color: var(--muted); font-size: .9rem; }
#first-code { text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.login-note { display: block; margin-top: 10px; color: var(--faint); font-size: .78rem; text-align: center; }

/* Aplicativo */
.app { min-height: 100vh; padding-bottom: calc(76px + var(--safe-bottom)); }
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: rgba(255, 255, 255, .94); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
.child-switch { display: flex; flex: 1; min-width: 0; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 14px; padding: 6px 10px 6px 6px; background: var(--surface); text-align: left; }
.child-text { flex: 1; min-width: 0; }
.child-text small { display: block; color: var(--faint); font-size: .7rem; font-weight: 600; }
.child-text b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: grid; width: 38px; height: 38px; flex: none; place-items: center; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 800; font-size: .9rem; }
.views { width: min(720px, 100%); margin: 0 auto; padding: 16px; }
.view { display: none; }
.view.active { display: grid; gap: 14px; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view.active { animation: none; } }
.page-title { font-size: 1.4rem; font-weight: 800; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 16px; box-shadow: var(--shadow); }
.card h3 { font-size: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head .link { margin: 0; padding: 4px; }

/* Início */
.balance { position: relative; overflow: hidden; border-radius: 22px; padding: 20px; background: linear-gradient(135deg, #e8262d 0%, #b8171d 100%); color: #fff; box-shadow: 0 16px 36px rgba(196, 29, 35, .28); }
.balance::after { content: ""; position: absolute; right: -60px; top: -60px; width: 190px; height: 190px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.balance small { opacity: .85; font-weight: 600; }
.balance strong { display: block; margin: 4px 0 6px; font-size: 2.4rem; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.balance .credit { font-size: .85rem; opacity: .9; }
.balance .actions { position: relative; z-index: 1; display: flex; gap: 10px; margin-top: 14px; }
.balance .btn { flex: 1; }
.btn.white { background: #fff; color: var(--accent-dark); }
.alerts { display: grid; gap: 10px; }
.alert { display: flex; gap: 12px; align-items: flex-start; border-radius: 14px; padding: 12px 14px; background: var(--warning-soft); color: #6b4a00; }
.alert.danger { background: var(--accent-soft); color: #8e1418; }
.alert.info { background: #e9f0fc; color: #1d4d9e; }
.alert strong { display: block; }
.alert p { font-size: .88rem; }
.alert .btn { margin-top: 8px; }
.today-row { display: flex; justify-content: space-between; align-items: baseline; }
.today-row strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.progress { height: 10px; margin-top: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 999px; background: var(--success); }
.progress i.warn { background: var(--warning); }
.progress i.full { background: var(--danger); }

/* Extrato */
.segmented { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.segmented button { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; }
.segmented button.active { background: var(--text); color: #fff; }
.day { margin: 6px 4px 6px; color: var(--muted); font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.entries { display: grid; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.card .entries { margin: 0 -16px -16px; border: 0; border-radius: 0 0 var(--radius) var(--radius); background: transparent; }
.entry { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: flex-start; padding: 13px 14px; border-top: 1px solid var(--line); }
.entry:first-child { border-top: 0; }
.entry-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 11px; background: var(--surface-2); color: var(--muted); }
.entry-icon.top_up { background: var(--success-soft); color: var(--success); }
.entry-icon.refund { background: #e9f0fc; color: #1d4d9e; }
.entry-icon.purchase { background: var(--accent-soft); color: var(--accent); }
.entry b { display: block; }
.entry small { display: block; color: var(--muted); font-size: .82rem; }
.entry .items { margin-top: 2px; color: var(--text); font-size: .85rem; }
.entry .value { text-align: right; white-space: nowrap; font-weight: 800; font-variant-numeric: tabular-nums; }
.value.plus { color: var(--success); }
.value small { font-weight: 500; }
.empty { padding: 30px 16px; color: var(--muted); text-align: center; }

/* Cardápio */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 600; font-size: .9rem; }
.chips button.active { background: var(--text); border-color: var(--text); color: #fff; }
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; }
.product { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.product.blocked { border-color: #f3b6b8; }
.product .photo { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); }
.product .photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.product .photo .initial { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-size: 1.8rem; font-weight: 800; }
.product .flag { position: absolute; left: 8px; top: 8px; padding: 3px 9px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .7rem; font-weight: 800; }
.product .flag.out { background: rgba(28, 29, 33, .75); }
.product .info { display: grid; gap: 4px; padding: 10px 12px 12px; flex: 1; }
.product .name { font-weight: 700; font-size: .95rem; line-height: 1.25; }
.product .price { font-weight: 800; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-size: .7rem; font-weight: 600; }
.tag.good { background: var(--success-soft); color: var(--success); }
.tag.warn { background: var(--accent-soft); color: var(--accent-dark); }
.product .btn { margin-top: auto; }

/* Regras e conta */
.rule-row, .setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.rule-row:first-of-type, .setting:first-of-type { border-top: 0; }
.setting small { display: block; color: var(--muted); font-size: .8rem; }
.switch { position: relative; flex: none; width: 50px; height: 30px; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; min-height: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background .18s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.switch input:checked + span { background: var(--success); }
.switch input:checked + span::after { transform: translateX(20px); }
.inline { display: flex; gap: 10px; align-items: flex-end; }
.inline label { flex: 1; }
.list-button { display: flex; width: 100%; align-items: center; gap: 12px; min-height: 52px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; font-weight: 600; }
.list-button:first-of-type { border-top: 0; }
.list-button .icon { color: var(--muted); }
.list-button.danger { color: var(--danger); }
.list-button.danger .icon { color: var(--danger); }
.kids { display: grid; gap: 8px; }
.kid { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-align: left; width: 100%; }
.kid.current { border-color: var(--accent); background: var(--accent-soft); }
.kid div { flex: 1; min-width: 0; }
.kid small { display: block; color: var(--muted); font-size: .8rem; }

/* Barra de abas */
.tabs { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 6px calc(6px + var(--safe-bottom)); background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line); backdrop-filter: blur(10px); }
.tabs button { display: grid; justify-items: center; gap: 2px; min-height: 54px; border: 0; border-radius: 12px; background: transparent; color: var(--faint); font-size: .72rem; font-weight: 600; }
.tabs button.active { color: var(--accent); }
.tabs button.active .icon { stroke-width: 2.2; }

/* Folha */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; background: rgba(20, 22, 28, .45); }
.sheet { width: min(560px, 100%); max-height: 92vh; overflow-y: auto; border-radius: 24px 24px 0 0; background: var(--surface); padding-bottom: calc(18px + var(--safe-bottom)); animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; background: var(--surface); }
.sheet-head h2 { font-size: 1.2rem; }
.sheet-body { display: grid; gap: 14px; padding: 4px 18px; }
.amounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.amounts button { min-height: 58px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); font-size: 1.1rem; font-weight: 800; }
.amounts button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.pix { display: grid; justify-items: center; gap: 12px; text-align: center; }
.pix img { width: min(240px, 70vw); aspect-ratio: 1; border-radius: 14px; border: 1px solid var(--line); background: #fff; padding: 8px; image-rendering: pixelated; }
.pix code { display: block; width: 100%; max-height: 4.6em; overflow: hidden; padding: 10px; border-radius: 10px; background: var(--surface-2); font-size: .75rem; word-break: break-all; text-align: left; }
.pix-status { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.done-mark { display: grid; width: 64px; height: 64px; place-items: center; border-radius: 50%; background: var(--success); color: #fff; }
.done-mark .icon { width: 36px; height: 36px; stroke-width: 2.6; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--muted); }

/* Aviso rápido */
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(92px + var(--safe-bottom)); max-width: calc(100% - 32px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; border-radius: 14px; padding: 12px 16px; background: var(--text); color: #fff; font-weight: 600; font-size: .92rem; transition: .22s; box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

@media (min-width: 760px) {
  .tabs { left: 50%; right: auto; width: 560px; transform: translateX(-50%); bottom: 14px; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding-bottom: 6px; }
  .app { padding-bottom: 110px; }
  .sheet { border-radius: 24px; margin-bottom: 5vh; }
  .sheet-backdrop { align-items: center; }
}

/* App FaceCantina Família: escolha da escola */
.school-list { margin-top: 14px; max-height: 52vh; overflow-y: auto; }
.school-list .kid b { display: block; }
.school-chosen { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -6px 0 16px; padding: 8px 12px; border-radius: 12px; background: var(--accent-soft); font-size: .9rem; font-weight: 600; }
.school-chosen .link { margin: 0; padding: 4px 6px; }
