/* Heritage School · Familias. Mobile first. Brand from heritageschool.cl: navy crest, warm orange quote, cream sky. */

:root {
  --navy: #213B76;
  --navy-d: #172B58;
  --orange: #E2763A;
  --orange-bg: rgba(226, 118, 58, 0.12);
  --cream: #F4EFE6;
  --paper: #FFFDF9;
  --ink: #1B2440;
  --muted: #6B7086;
  --line: rgba(33, 59, 118, 0.12);
  --ok: #2F8F5B;
  --ok-bg: rgba(47, 143, 91, 0.12);
  --warn: #B7791F;
  --warn-bg: rgba(214, 158, 46, 0.16);
  --bad: #C2413A;
  --bad-bg: rgba(194, 65, 58, 0.1);
  --info-bg: rgba(33, 59, 118, 0.08);
  --wa: #25D366;
  --radius: 14px;
  --tabbar-h: 66px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --app-w: 500px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; background: #E9E2D6; }
body {
  font-family: 'Montserrat', system-ui, sans-serif;
  font-size: 15px;
  background: #E9E2D6;
  color: var(--ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ type */

.serif, .h-l, .h-m, .h-s { font-family: 'Source Serif 4', Georgia, serif; font-weight: 700; letter-spacing: -0.01em; }
.h-l { font-size: 34px; line-height: 1.08; color: var(--navy); }
.h-m { font-size: 24px; line-height: 1.15; color: var(--navy); }
.h-s { font-size: 18px; line-height: 1.2; color: var(--navy); }
.orange { color: var(--orange); }
.kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--orange); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
p + p { margin-top: 8px; }

/* ------------------------------------------------------------ shell */

.app {
  position: relative;
  max-width: var(--app-w);
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--cream);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.03), 0 30px 90px rgba(33,59,118,0.18);
}
body.wide .app { max-width: 1100px; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: rgba(255, 253, 249, 0.92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand img { width: 34px; height: 34px; border-radius: 50%; }
.brand span { font-family: 'Source Serif 4', serif; font-weight: 700; color: var(--navy); font-size: 15px; line-height: 1.02; }
.demo-pill { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; padding: 3px 7px; border-radius: 99px; background: var(--orange-bg); color: var(--orange); }
.avatar-btn { margin-left: auto; min-width: 38px; height: 38px; padding: 0 10px; border-radius: 99px; background: var(--navy); color: #fff; font-weight: 700; font-size: 13px; }
.avatar-btn.colegio { background: var(--orange); font-size: 11px; letter-spacing: 0.08em; }

.view { padding: 18px 16px calc(var(--tabbar-h) + 28px + var(--safe-b)); outline: none; }
body.no-tabbar .view { padding-bottom: calc(28px + var(--safe-b)); }

.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 30;
  width: 100%; max-width: var(--app-w);
  display: flex; height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(255, 253, 249, 0.96); border-top: 1px solid var(--line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
body.wide .tabbar { max-width: 1100px; }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--muted); }
.tabbar a svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--navy); }
.tabbar a.on svg { stroke: var(--orange); }

/* ------------------------------------------------------------ blocks */

.stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.navy { background: var(--navy); color: #fff; border-color: var(--navy); }
.card.navy .h-m, .card.navy .h-s, .card.navy .h-l { color: #fff; }
.card.navy .muted { color: rgba(255,255,255,0.7); }
.card.tight { padding: 0; overflow: hidden; }
.section-t { display: flex; align-items: baseline; gap: 8px; margin: 26px 0 10px; }
.section-t h3 { font-family: 'Source Serif 4', serif; font-size: 19px; color: var(--navy); }
.section-t a, .section-t button { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--orange); }

.hero { position: relative; border-radius: 18px; overflow: hidden; background: linear-gradient(180deg, #EFE6D6 0%, #F2D9C2 62%, #C9CFD8 63%, #AEB8C6 100%); padding: 26px 20px 22px; }
.hero .quote { font-family: 'Source Serif 4', serif; font-weight: 700; font-size: 25px; line-height: 1.22; color: var(--orange); }
.hero .who { margin-top: 10px; color: var(--navy); font-size: 13px; }
.hero .volcan { position: absolute; right: -10px; bottom: 37%; width: 62%; opacity: 0.55; }

.list > * { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--line); }
.list > *:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .t { font-weight: 600; }
.list .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.amt { text-align: right; font-variant-numeric: tabular-nums; flex: none; }
.amt b { display: block; }
.amt span { display: block; font-size: 12px; color: var(--muted); }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--navy); }
.chip.orange { background: var(--orange-bg); color: var(--orange); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 20px; border-radius: 12px; background: var(--navy); color: #fff; font-weight: 700; font-size: 15px; width: 100%; }
.btn.orange { background: var(--orange); }
.btn.ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--line); }
.btn.wa { background: var(--wa); color: #fff; }
.btn.sm { height: 38px; padding: 0 14px; font-size: 13px; width: auto; border-radius: 10px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn svg { width: 19px; height: 19px; fill: currentColor; }
.btns { display: flex; gap: 10px; }
.btns > * { flex: 1; }

.field { display: block; }
.field > span { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 6px; }
.input { width: 100%; height: 50px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-size: 16px; outline: none; }
.input:focus { border-color: var(--navy); }
textarea.input { height: auto; min-height: 120px; padding: 12px 14px; resize: vertical; }
.input.code { letter-spacing: 0.5em; text-align: center; font-size: 22px; font-weight: 700; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { padding: 9px 13px; border-radius: 99px; border: 1.5px solid var(--line); background: #fff; font-size: 13.5px; font-weight: 600; }
.seg button.on { background: var(--navy); border-color: var(--navy); color: #fff; }

.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-family: 'Source Serif 4', serif; font-size: 28px; color: var(--navy); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--muted); }
.bar { height: 7px; border-radius: 9px; background: var(--info-bg); overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--orange); border-radius: 9px; }

.todo { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.todo:first-of-type { border-top: 0; }
.todo .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; }
.todo.done .dot { background: var(--ok); border-color: var(--ok); }
.todo .dot svg { width: 14px; height: 14px; stroke: #fff; fill: none; stroke-width: 3; }
.todo.done .t { color: var(--muted); text-decoration: line-through; }
.todo .grow { flex: 1; }
.todo a { font-size: 13px; font-weight: 700; color: var(--orange); }

.aviso { border-left: 3px solid var(--orange); padding: 2px 0 2px 12px; }
.aviso + .aviso { margin-top: 16px; }
.aviso .t { font-weight: 700; }
.aviso .x { white-space: pre-wrap; margin-top: 4px; font-size: 14px; }
.aviso .s { font-size: 12px; color: var(--muted); margin-top: 4px; }

.code-box { font-family: 'Source Serif 4', serif; font-size: 30px; letter-spacing: 0.22em; color: var(--navy); font-weight: 700; }
.empty { text-align: center; padding: 26px 10px; color: var(--muted); }
.empty .h-s { margin-bottom: 6px; }

.kid { display: flex; align-items: center; gap: 12px; }
.kid .av { width: 42px; height: 42px; border-radius: 50%; background: var(--orange-bg); color: var(--orange); display: grid; place-items: center; font-weight: 700; flex: none; }

/* ------------------------------------------------------------ table (school, wide) */

.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: rgba(33,59,118,0.03); }
.scroll-x { overflow-x: auto; }
.grid-2 { display: grid; gap: 14px; }
@media (min-width: 860px) {
  body.wide .grid-2 { grid-template-columns: 1.4fr 1fr; align-items: start; }
  body.wide .stat-row { grid-template-columns: repeat(4, 1fr); }
}

/* ------------------------------------------------------------ sheet, toast, fake WhatsApp */

.sheet-root { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.sheet-root.open { pointer-events: auto; }
.sheet-bg { position: absolute; inset: 0; background: rgba(23, 43, 88, 0.4); opacity: 0; transition: opacity .2s; }
.sheet-root.open .sheet-bg { opacity: 1; }
.sheet {
  position: absolute; left: 50%; bottom: 0; width: 100%; max-width: var(--app-w); max-height: 92dvh; overflow-y: auto;
  transform: translate(-50%, 100%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
  background: var(--paper); border-radius: 20px 20px 0 0; padding: 10px 18px calc(24px + var(--safe-b));
}
.sheet-root.open .sheet { transform: translate(-50%, 0); }
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 14px; }

.toast { pointer-events: none; position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 18px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 80; opacity: 0; transition: all .22s; background: var(--navy-d); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.wa-note { position: fixed; top: calc(10px + var(--safe-t)); left: 50%; transform: translate(-50%, -140%); z-index: 90; width: min(94vw, 420px); transition: transform .35s cubic-bezier(.2,.8,.2,1); background: rgba(250,250,250,0.97); border-radius: 18px; padding: 12px 14px; box-shadow: 0 12px 40px rgba(0,0,0,0.22); display: flex; gap: 11px; align-items: flex-start; color: #111; }
.wa-note { visibility: hidden; }
.wa-note.show { visibility: visible; transform: translate(-50%, 0); }
.wa-note .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--wa); display: grid; place-items: center; flex: none; }
.wa-note .ic svg { width: 22px; height: 22px; fill: #fff; }
.wa-note b { font-size: 14px; }
.wa-note p { font-size: 14px; margin-top: 2px; }
