:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1c2638;
  --muted: #66708a;
  --line: #e2e5ea;
  --brand: #203049;
  --brand-ink: #ffffff;
  --brand-soft: #e8ecf3;
  --accent: #ffc132;
  --accent-ink: #3a2a00;
  --ok: #1f7a3e;
  --danger: #b4432f;
  --danger-soft: #f8e5e1;
  --warn-soft: #fdf1d3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Lato", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* layout */
.topbar {
  background: var(--brand); color: var(--brand-ink);
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 5;
}
.topbar .brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 10px; }
.topbar .brand .logo { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-weight: 800; color: #3a2a08; }
.topbar button { color: var(--brand-ink); border-color: rgba(255,255,255,.4); }
.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 640px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 12px; }
/* campos lado a lado sempre alinhados: o campo fica na base, mesmo se um rotulo quebrar de linha */
.grid > .field { display: flex; flex-direction: column; justify-content: flex-end; }
.grid > .field > label { margin-top: auto; }
.help { font-size: .82rem; color: var(--muted); margin: -4px 0 12px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 16px 0; background: var(--brand); position: sticky; top: 58px; z-index: 4; }
.tabs button { background: transparent; border: 0; color: rgba(255,255,255,.75); padding: 10px 12px; border-radius: 10px 10px 0 0; font-weight: 600; white-space: nowrap; }
.tabs button.active { background: var(--bg); color: var(--ink); }
.tabs a.tablink { color: var(--accent); padding: 10px 12px; font-weight: 800; white-space: nowrap; text-decoration: none; }

/* form */
label { display: block; font-size: .85rem; color: var(--muted); margin: 0 0 4px; font-weight: 600; }
input, select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.field { margin-bottom: 12px; }
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px; padding: 9px 14px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); min-height: 40px;
}
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.danger { color: var(--danger); border-color: #e7c3bb; }
button.ghost { background: transparent; border-color: transparent; color: var(--brand); padding: 6px 8px; min-height: 0; }
button:disabled { opacity: .5; cursor: not-allowed; }
.full { width: 100%; }

/* saldo */
.balance { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--brand); color: #fff; border: 0; border-bottom: 4px solid var(--accent); }
.balance .value { font-size: 1.8rem; font-weight: 800; }
.balance.low { border-bottom-color: var(--danger); }
.balance.low .value { color: #ffd2c8; }
.balance button { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.35); }

/* semana */
.weeknav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.weeknav strong { text-align: center; flex: 1; }
.day { padding: 0; overflow: hidden; }
.day header { padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.day header h3 { margin: 0; text-transform: capitalize; }
.day .body { padding: 12px 16px; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.badge.closed { background: #eceae4; color: var(--muted); }
.badge.warn { background: var(--warn-soft); color: #8a5a10; }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.student { margin-bottom: 12px; }
.student:last-child { margin-bottom: 0; }
.student .who { font-weight: 700; margin-bottom: 6px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.choices { display: grid; gap: 8px; }
.choice {
  text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-weight: 500;
}
.choice .t { display: block; font-weight: 600; }
.choice .d { display: block; font-size: .8rem; color: var(--muted); font-weight: 400; }
.choice .p { font-weight: 700; white-space: nowrap; }
.choice.selected { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.choice:disabled { opacity: 1; cursor: default; }
.choice.dim { opacity: .45; }
.empty { color: var(--muted); font-style: italic; }

/* tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; }
td.r, th.r { text-align: right; }
tr.cancel td { color: var(--muted); text-decoration: line-through; }
.pos { color: var(--ok); font-weight: 600; }
.neg { color: var(--danger); font-weight: 600; }

/* kpis */
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kpi .l { font-size: .8rem; color: var(--muted); font-weight: 600; }
.kpi .v { font-size: 1.45rem; font-weight: 800; margin-top: 2px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 24px; }
.login .logo-big { width: 56px; height: 56px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1.4rem; margin-bottom: 12px; }

/* toast e modal */
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; z-index: 50; max-width: calc(100% - 32px); box-shadow: var(--shadow); }
#toast.err { background: var(--danger); }
.modal-bg { position: fixed; inset: 0; background: rgba(20,25,22,.45); display: grid; place-items: center; padding: 16px; z-index: 40; }
.modal { background: #fff; border-radius: var(--radius); padding: 20px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.modal h2 { margin-bottom: 12px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

/* carrinho */
.cartbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--brand); color: #fff; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 12px; box-shadow: 0 -4px 16px rgba(0,0,0,.15); border-top: 3px solid var(--accent); }
.cartbar strong { font-weight: 900; }
body.has-cart main { padding-bottom: 96px; }
button.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 800; }
.choice.cart { border-style: dashed; border-color: var(--brand); background: #fff; }
.choice.wait { border-color: #d9a21b; background: var(--warn-soft); }
.notice { border-left: 4px solid var(--accent); background: var(--warn-soft); padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; }
.sum { width: 100%; margin: 10px 0; }
.sum td { padding: 6px 0; border: 0; }
.sum tr.total td { border-top: 1px solid var(--line); font-weight: 900; }
.sum tr.due td { color: var(--danger); font-weight: 900; font-size: 1.05rem; }

/* cadastro */
.login .card.wide { max-width: 560px; }
.login h2 { font-size: 1rem; margin: 6px 0 10px; }
.first-access { text-align: center; margin-top: 12px; font-size: .9rem; color: var(--muted); }
.kid { border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px 2px; margin-bottom: 10px; background: #fafbfc; }
.kid .kid-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 800; }
label.check.consent { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0; font-size: .88rem; color: var(--muted); }
label.check.consent input { margin-top: 3px; }
.kid-row { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.kid-row:last-child { border-bottom: 0; }

/* PIX */
.pix { text-align: center; }
.pix .qr { width: 230px; max-width: 70vw; margin: 6px auto 10px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.pix .qr svg { display: block; width: 100%; height: auto; }
.pix .amount { font-size: 1.6rem; font-weight: 900; color: var(--brand); }
.pix textarea { font-family: ui-monospace, Menlo, monospace; font-size: .75rem; word-break: break-all; resize: none; background: #f7f8fa; }
.pix .copy { margin-top: 8px; }

/* grade do cardapio */
.grid-menu th.c, .grid-menu td.c { text-align: center; width: 92px; }
.grid-menu tr.grp td { background: #f2f4f7; font-size: .75rem; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); padding: 6px 8px; }
.daybox { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 2px solid var(--line); cursor: pointer; margin: 0; background: #fff; }
.daybox input { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; margin: 0; }
.daybox.on { border-color: var(--brand); background: var(--brand-soft); }
.daybox.off { opacity: .5; cursor: not-allowed; }
.daybox.off input { cursor: not-allowed; }

/* perfis: esconde o que o perfil nao pode fazer (o servidor tambem bloqueia) */
/* Fin: so le (esconde botoes de alterar fora do financeiro). Adm e Dev veem tudo. */
body.perm-fin .only-adm, body.perm-fin .only-dev { display: none !important; }

.kind-toggle { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.kind-toggle label.check { font-weight: 700; }

@media print {
  .topbar, .tabs, .noprint, #toast { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; padding: 0; }
}

@media (max-width: 420px) {
  .tabs { gap: 2px; padding: 4px 8px 0; }
  .tabs button { padding: 10px 9px; font-size: .9rem; }
}

/* marcas do prato */
.tag { display: inline-block; font-size: .68rem; font-weight: 800; letter-spacing: .3px; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.tag-veggie { background: #e2f3e7; color: #1f7a3e; }
.tag-vegano { background: #fff; color: #1f7a3e; box-shadow: inset 0 0 0 1.5px #1f7a3e; }
.tag-novo { background: var(--accent); color: #3a2a08; }
label.check { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; color: var(--ink); font-weight: 500; font-size: .95rem; }
label.check input { width: auto; }
.group-title { font-size: .75rem; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
.group-title:first-child { margin-top: 0; }
.pick { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.pick .t { font-weight: 600; }
.choice input[type=radio] { width: auto; margin: 0 4px 0 0; accent-color: var(--brand); }
.choice.radio { cursor: pointer; }
.choice.radio:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }

/* identidade Lumiar */
.topbar .brand .logo-img { height: 30px; width: auto; display: block; }
.topbar .brand .sub { font-weight: 600; font-size: .95rem; opacity: .9; padding-left: 10px; border-left: 2px solid var(--accent); }
.login .card { padding: 0; overflow: hidden; }
.login .banner { background: var(--brand); padding: 28px 24px 22px; text-align: center; border-bottom: 4px solid var(--accent); }
.login .banner img { height: 56px; width: auto; }
.login .banner .sub { color: #fff; opacity: .85; margin-top: 8px; font-weight: 600; letter-spacing: .3px; }
.login .inner { padding: 22px 24px 24px; }
.badge.brand { background: var(--accent); color: var(--accent-ink); }
.day header { border-bottom: 2px solid var(--line); }

/* tipografia do site da escola: Lato 900 em maiusculas nos titulos */
h1, h2 { font-weight: 900; text-transform: uppercase; letter-spacing: .3px; color: var(--brand); }
.modal h2 { font-size: 1.05rem; }
.kpi .v, .balance .value { font-weight: 900; }
.login .site { display: block; text-align: center; margin-top: 14px; font-size: .85rem; color: var(--muted); text-decoration: none; }

body.has-cart #toast { bottom: 96px; }
body:has(.modal-bg) #toast { bottom: auto; top: 16px; }

/* mesma altura para todo campo de uma linha (hora, data, numero, texto, lista) */
input:not([type=checkbox]):not([type=radio]), select { height: 44px; }
