/* Layout: one calm column for parents on a phone; a two-zone desk (calendar + list) for the teacher. */
:root {
  --paper: #f3f6f5;
  --surface: #ffffff;
  --sunken: #e9efed;
  --ink: #13232a;
  --muted: #586a70;
  --line: #d7e0de;
  --accent: #1d6b59;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe9;
  --promise: #b87414;
  --promise-soft: #fbedd5;
  --late: #b4441a;
  --late-soft: #fbe3d8;
  --ok: #2c7a4b;
  --ok-soft: #dff1e5;
  --wa: #157a52;
  --focus: #2b7fd9;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 14px;
  --radius-sm: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1618; --surface: #162125; --sunken: #1d2a2f; --ink: #e5eeec; --muted: #94a6a8; --line: #27363b;
    --accent: #4fb399; --accent-ink: #0b1a16; --accent-soft: #173a32; --promise: #f0b552; --promise-soft: #3b2e17;
    --late: #f08a5d; --late-soft: #3d2219; --ok: #63c08a; --ok-soft: #173326; --wa: #5fd19f; --focus: #6aa9ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e1618; --surface: #162125; --sunken: #1d2a2f; --ink: #e5eeec; --muted: #94a6a8; --line: #27363b;
  --accent: #4fb399; --accent-ink: #0b1a16; --accent-soft: #173a32; --promise: #f0b552; --promise-soft: #3b2e17;
  --late: #f08a5d; --late-soft: #3d2219; --ok: #63c08a; --ok-soft: #173326; --wa: #5fd19f; --focus: #6aa9ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font-body); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.num { font-variant-numeric: tabular-nums; }
.label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* Controls */
.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 0.55rem 0.95rem; border-radius: 999px; cursor: pointer; display: inline-flex; gap: 0.4rem; align-items: center; justify-content: center; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); padding-inline: 0.5rem; }
.btn.danger { color: var(--late); }
.btn.small { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.block { width: 100%; padding-block: 0.8rem; font-size: 1rem; }
.field { display: grid; gap: 0.3rem; }
.field > span { font-size: 0.85rem; font-weight: 600; }
input[type="text"], input[type="tel"], input[type="number"], input[type="date"], input[type="password"], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 4rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.error { color: var(--late); font-weight: 600; font-size: 0.9rem; }
.check { display: grid; grid-template-columns: auto 1fr; gap: 0.6rem; align-items: start; font-size: 0.9rem; }
.check input { width: 1.15rem; height: 1.15rem; margin-top: 0.15rem; accent-color: var(--accent); }

/* Choice pills (text / WhatsApp / none) */
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.choices label { position: relative; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.55rem 0.4rem; text-align: center; cursor: pointer; font-weight: 600; font-size: 0.88rem; background: var(--surface); }
.choices input { position: absolute; opacity: 0; pointer-events: none; }
.choices label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent); }
.choices label:has(input:focus-visible) { outline: 3px solid var(--focus); }

/* Status pills */
.pill { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; font-weight: 650; padding: 0.15rem 0.6rem; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; }
.pill.paid { background: var(--ok-soft); color: var(--ok); }
.pill.scheduled { background: var(--promise-soft); color: var(--promise); }
.pill.today { background: var(--accent-soft); color: var(--accent); }
.pill.late, .pill.no_date_late { background: var(--late-soft); color: var(--late); }
.pill.waiting { background: var(--sunken); color: var(--muted); }
.tag { font-size: 0.72rem; font-weight: 700; padding: 0.05rem 0.45rem; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); }
.tag.wa { color: var(--wa); border-color: currentColor; }

/* Month calendar */
.cal { display: grid; gap: 0.5rem; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.cal-head h3 { text-transform: capitalize; }
.cal-nav { display: flex; gap: 0.25rem; }
.cal-nav button { font: inherit; width: 2.2rem; height: 2.2rem; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.cal-nav button[disabled] { opacity: 0.35; cursor: default; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-dow { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); text-align: center; padding-block: 0.2rem; font-weight: 600; }
.cal-day { position: relative; border: 0; background: var(--surface); color: var(--ink); font: inherit; border-radius: var(--radius-sm);
  aspect-ratio: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; font-variant-numeric: tabular-nums; min-width: 0; }
.cal-day.out { visibility: hidden; }
.cal-day[disabled] { color: var(--muted); opacity: 0.4; cursor: default; background: transparent; }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--ink); }
.cal-day.due::after { content: ""; position: absolute; bottom: 14%; width: 1.1rem; height: 3px; border-radius: 2px; background: var(--late); }
.cal-day.sel { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.cal-day.sel::after { background: var(--accent-ink); }
.cal-day:not([disabled]):not(.sel):hover { background: var(--accent-soft); }
.cal-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); }
.cal-legend i { display: inline-block; width: 0.9rem; height: 3px; background: var(--late); vertical-align: middle; margin-right: 0.35rem; border-radius: 2px; }

/* Teacher calendar (bigger cells with names) */
.desk-cal .cal-grid { gap: 2px; }
.desk-cal .cal-day { aspect-ratio: auto; min-height: 4.6rem; align-items: stretch; justify-content: flex-start; padding: 0.3rem; cursor: default; border-radius: 6px; gap: 2px; }
.desk-cal .cal-day .d { font-size: 0.78rem; color: var(--muted); text-align: right; }
.desk-cal .cal-day.today .d { color: var(--ink); font-weight: 700; }
.desk-cal .chip { font-size: 0.7rem; line-height: 1.2; padding: 2px 4px; border-radius: 4px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; border: 0; cursor: pointer; font-family: inherit; }
.chip.scheduled { background: var(--promise-soft); color: var(--promise); }
.chip.today { background: var(--accent); color: var(--accent-ink); }
.chip.late { background: var(--late-soft); color: var(--late); }
.chip.paid { background: var(--ok-soft); color: var(--ok); text-decoration: line-through; }
.chip.due { background: transparent; color: var(--muted); border: 1px dashed var(--line); }

/* Parent page */
.pay { max-width: 30rem; margin: 0 auto; padding-block: 1.25rem 2.5rem; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 1rem; }
.brand { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.brand-name { display: flex; align-items: center; gap: 0.6rem; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; min-width: 0; }
.mono { width: 2.2rem; height: 2.2rem; flex: none; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 0.95rem; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; flex: none; }
.lang button { font: inherit; font-size: 0.8rem; font-weight: 700; border: 0; background: transparent; color: var(--muted); padding: 0.3rem 0.7rem; cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; display: grid; gap: 0.85rem; }
.bill-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.amount { font-family: var(--font-display); font-size: 2.1rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; font-size: 0.9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.step { display: grid; gap: 0.7rem; }
.step-n { display: flex; gap: 0.55rem; align-items: center; }
.step-n b { width: 1.5rem; height: 1.5rem; flex: none; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; font-size: 0.8rem; }
.picked { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; font-weight: 650; }
.promise { background: var(--accent); color: var(--accent-ink); border-radius: var(--radius); padding: 1.2rem; display: grid; gap: 0.4rem; }
.promise .big { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; line-height: 1.15; }
.promise .big::first-letter { text-transform: uppercase; }
.howto { background: var(--sunken); border-radius: var(--radius-sm); padding: 0.8rem; font-size: 0.9rem; white-space: pre-line; }
.foot { text-align: center; font-size: 0.78rem; color: var(--muted); }

/* Teacher desk */
.desk { max-width: 76rem; margin: 0 auto; padding-block: 1.25rem 3rem; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 1.1rem; }
.desk-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.desk-top .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.6rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 0.95rem; display: grid; gap: 0.15rem; }
.stat .v { font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat.warn .v { color: var(--late); }
.stat.prom .v { color: var(--promise); }
.desk-main { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: grid; gap: 0.8rem; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.bills { display: grid; gap: 0; }
.bill { border-top: 1px solid var(--line); padding-block: 0.7rem; display: grid; gap: 0.45rem; }
.bill:first-child { border-top: 0; }
.bill.focus { background: linear-gradient(var(--accent-soft), var(--accent-soft)) no-repeat; background-size: 100% 100%; margin-inline: -0.6rem; padding-inline: 0.6rem; border-radius: var(--radius-sm); }
.bill-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.75rem; align-items: start; }
.bill-who { min-width: 0; }
.bill-who b { font-weight: 650; }
.bill-meta { display: flex; gap: 0.4rem 0.75rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); align-items: center; }
.bill-amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; display: grid; gap: 0.25rem; justify-items: end; }
.bill-actions { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.log { background: var(--sunken); border-radius: var(--radius-sm); padding: 0.6rem 0.75rem; font-size: 0.82rem; display: grid; gap: 0.4rem; }
.log-item { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 0.6rem; }
.log-item .when { color: var(--muted); font-variant-numeric: tabular-nums; }
.sheet { background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); padding: 1rem; display: grid; gap: 0.8rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; }
.form-grid .wide { grid-column: 1 / -1; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.toast { position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 0.6rem 1rem; border-radius: 999px; font-weight: 600; font-size: 0.9rem; z-index: 50; box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); }
.login { max-width: 22rem; margin: 12vh auto; padding-inline: 16px; display: grid; gap: 0.8rem; }

@media (max-width: 900px) {
  .desk-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .desk-cal .cal-day { min-height: 3.4rem; padding: 2px; }
  .desk-cal .chip { font-size: 0.62rem; padding: 1px 2px; }
  .amount { font-size: 1.8rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .cal-day, .btn, .choices label { transition: background-color 0.15s, border-color 0.15s, color 0.15s; }
}
