:root {
  --brand: #2f7d4a;
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #1f2421;
  --muted: #6b7069;
  --line: #e7e2d8;
  --wa: #1fa855;
  --danger: #b3412f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); -webkit-tap-highlight-color: transparent; }
body.noscroll { overflow: hidden; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.wrap { max-width: 760px; margin: 0 auto; padding: 12px 16px 110px; }
.loading { text-align: center; padding: 48px 0; color: var(--muted); font-size: 28px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.h2 { font-size: 18px; margin: 24px 0 10px; }
.h3 { font-size: 16px; margin: 22px 0 10px; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
.top-title { flex: 1; font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { font-size: 22px; padding: 0 4px; }
.icon-btn { background: none; border: 0; color: inherit; font-size: 28px; line-height: 1; padding: 0 8px; text-decoration: none; cursor: pointer; }
.pill { background: rgba(255, 255, 255, .18); border: 0; color: #fff; border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; cursor: pointer; }

/* home */
.hero { padding: 28px 4px 4px; }
.hero h1 { margin: 0 0 6px; font-size: 34px; color: var(--brand); letter-spacing: -.5px; }
.hero p { margin: 0; font-size: 17px; line-height: 1.4; color: var(--muted); }
.school-list { display: grid; gap: 10px; margin-bottom: 18px; }
.school-card {
  display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow); text-decoration: none; color: var(--ink);
}
.school-card .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); flex: none; }
.school-card span:nth-child(2) { flex: 1; display: grid; }
.school-card small { color: var(--muted); }
.chev { font-size: 26px; color: var(--muted); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--brand); color: #fff; border: 0; border-radius: 12px;
  padding: 13px 18px; font-weight: 700; font-size: 16px; text-decoration: none; cursor: pointer;
}
.btn:disabled { opacity: .6; }
.btn.ghost { background: transparent; color: var(--brand); box-shadow: inset 0 0 0 1.5px var(--brand); }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn.tiny { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.btn.wa { background: var(--wa); width: 100%; margin-top: 8px; }
.btn.small.wa { width: auto; margin: 0; }
.btn.danger { background: var(--danger); }
.btn.danger.ghost { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1.5px var(--danger); }
.link { background: none; border: 0; padding: 12px 0; color: var(--brand); text-decoration: underline; cursor: pointer; display: block; margin: 6px auto 0; }
.link.danger { color: var(--danger); font-size: 14px; }

/* school page */
.wa-group, .admin-link, .sponsor {
  display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-radius: 12px; margin-bottom: 8px;
  text-decoration: none; font-weight: 600; font-size: 15px;
}
.wa-group { background: #e5f6ec; color: #136b36; }
.admin-link { background: #eef1f6; color: #33415c; }
.sponsor { background: #fff8e6; color: #6b5413; font-weight: 400; }
.sponsor small { text-transform: uppercase; font-size: 11px; letter-spacing: .5px; opacity: .8; }

.tabs { display: flex; background: #ece7dd; border-radius: 12px; padding: 4px; margin: 6px 0 12px; }
.tabs.small { margin-top: 2px; }
.tab { flex: 1; border: 0; background: none; padding: 10px 6px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.grade-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.grade-pick { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; flex: 1 1 160px; }
.grade-pick select, .search-row select, .search-row input {
  padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); font-size: 15px; color: var(--ink);
}
.seg { display: flex; border-radius: 10px; overflow: hidden; border: 1.5px solid var(--brand); flex: 1 1 260px; }
.seg button { flex: 1; border: 0; background: var(--card); padding: 9px 4px; font-size: 13px; font-weight: 600; color: var(--brand); cursor: pointer; }
.seg button.on { background: var(--brand); color: #fff; }
.seg button:disabled { color: #b9bcb6; cursor: default; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 2px; min-height: 1px; line-height: 1.35; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1.5px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 7px 12px; font-size: 14px; white-space: nowrap; cursor: pointer;
}
.chip.on { border-color: var(--brand); background: var(--brand); color: #fff; }
.search-row { display: flex; gap: 8px; margin: 4px 0 14px; }
.search-row input { flex: 1; min-width: 0; }
.search-row select { flex: none; max-width: 42%; }

/* grid */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 620px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.card {
  border: 0; padding: 0; text-align: left; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; cursor: pointer; display: flex; flex-direction: column;
}
.ph { position: relative; aspect-ratio: 1; background: #f0ece4; display: grid; place-items: center; }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.ph-emoji { font-size: 46px; }
.ribbon { position: absolute; top: 8px; left: 8px; background: #f2b84b; color: #3b2a04; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.cbody { padding: 9px 10px 11px; display: grid; gap: 3px; }
.ctitle { font-weight: 650; font-size: 14.5px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cmeta { font-size: 12.5px; color: var(--muted); }

.badge { display: inline-block; width: fit-content; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eef2ea; color: #3c5a40; }
.badge.k-troca { background: #e8eefb; color: #2e4a86; }
.badge.k-venda { background: #fdf0e3; color: #8a4a12; }
.badge.reserved, .badge.s-reservado { background: #fdf1d6; color: #7a5507; }
.badge.s-entregue, .badge.s-atendido { background: #e2f3e7; color: #1d6a37; }
.badge.s-expirado { background: #eee; color: #666; }
.badge.s-oculto { background: #fbe4e0; color: #8f2e1f; }

.empty { text-align: center; color: var(--muted); padding: 40px 12px; display: grid; gap: 12px; justify-items: center; }

/* rows */
.rows { display: grid; gap: 10px; }
.row { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.row.mine { align-items: flex-start; }
.row-emoji { font-size: 28px; width: 52px; height: 52px; display: grid; place-items: center; background: #f0ece4; border-radius: 10px; flex: none; }
.row-img { width: 52px; height: 52px; object-fit: cover; border-radius: 10px; flex: none; }
.row-body { flex: 1; display: grid; gap: 3px; min-width: 0; }
.row-body small { color: var(--muted); font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border-radius: 12px; padding: 12px 8px; text-align: center; box-shadow: var(--shadow); display: grid; gap: 2px; }
.stat b { font-size: 22px; color: var(--brand); }
.stat small { font-size: 11.5px; color: var(--muted); line-height: 1.2; }

/* fab */
.fab {
  position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--brand); color: #fff; border: 0; border-radius: 999px; padding: 15px 22px;
  font-size: 16px; font-weight: 800; box-shadow: 0 6px 20px rgba(0, 0, 0, .22); cursor: pointer;
}

/* modal sheet */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(20, 24, 22, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  position: relative; background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 18px 18px calc(24px + env(safe-area-inset-bottom));
  animation: up .18s ease-out;
}
@media (min-width: 620px) { .modal { align-items: center; } .sheet { border-radius: 20px; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet h3 { margin: 6px 40px 10px 0; font-size: 20px; }
.close { position: absolute; top: 10px; right: 8px; color: var(--muted); font-size: 22px; z-index: 2; }
.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 28px -18px 12px; padding: 0 18px; }
.gallery img { scroll-snap-align: center; height: 300px; width: auto; max-width: 88%; object-fit: cover; border-radius: 12px; flex: none; }
.gallery.empty-ph { font-size: 80px; justify-content: center; background: #f0ece4; border-radius: 12px; margin: 28px 0 12px; padding: 30px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.desc { white-space: pre-wrap; line-height: 1.45; }

/* forms */
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 5px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.form input, .form select, .form textarea {
  padding: 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); font-size: 16px; color: var(--ink); font-weight: 400; width: 100%;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--brand); border-color: transparent; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; color: var(--ink); line-height: 1.35; }
.form .check input { width: auto; margin-top: 3px; }
.form .file-btn {
  display: flex; justify-content: center; align-items: center; padding: 14px; border-radius: 12px;
  border: 2px dashed var(--brand); color: var(--brand); font-size: 15px; font-weight: 700; cursor: pointer; background: var(--card);
}
.form .file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.previews { display: flex; gap: 8px; }
.previews img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }

/* misc */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); z-index: 60;
  background: #222; color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14.5px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; white-space: pre-line; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 10px 0 100px; }
.foot a { color: var(--muted); }
.prose { line-height: 1.55; }
.prose h1 { color: var(--brand); }
.prose h3 { margin-top: 22px; }
