/* Maple Tree Montessori Academy — toddler daily reports.
   Built for a classroom tablet held in one hand: big targets, high contrast,
   nothing that needs a precise tap. */

:root {
  --bg: #f7f3ec;
  --surface: #fffdf9;
  --surface-2: #f2ede4;
  --ink: #2b2926;
  --muted: #756f66;
  --line: #e4ded2;
  --accent: #3f6b4f;
  --accent-ink: #ffffff;
  --accent-soft: #e6efe7;
  --warn: #9a5b1f;
  --warn-soft: #fbf0e2;
  --error: #a33a2c;
  --error-soft: #fbeae7;
  --radius: 12px;
  --tap: 46px;
  --shadow: 0 1px 2px rgba(43, 41, 38, .06), 0 4px 14px rgba(43, 41, 38, .05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

h1 { font-size: 1.5rem; margin: 0 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.warn { color: var(--warn); }

/* Off-screen rather than display:none, so it is still a real form control. */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- chrome ---------- */

.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: .8rem; letter-spacing: .02em;
}
.brand-text { font-weight: 650; }

.topnav { display: flex; gap: .15rem; flex: 1; flex-wrap: wrap; }
.topnav a {
  padding: .5rem .75rem; border-radius: 8px;
  text-decoration: none; color: var(--muted); font-weight: 550;
  min-height: 40px; display: flex; align-items: center;
}
.topnav a:hover { background: var(--surface-2); color: var(--ink); }
.topnav a.on { background: var(--accent-soft); color: var(--accent); }

.topbar-user { display: flex; align-items: center; gap: .6rem; font-size: .85rem; color: var(--muted); }
.topbar-user a { color: inherit; text-decoration: none; }
.topbar-user a:hover { color: var(--ink); text-decoration: underline; }

.linkbtn {
  background: none; border: 0; padding: .3rem; cursor: pointer;
  color: var(--accent); font: inherit; font-size: .85rem; text-decoration: underline;
}

.page { max-width: 1000px; margin: 0 auto; padding: 1.25rem 1rem 8rem; }
.page-bare { display: grid; place-items: center; min-height: 100vh; padding-bottom: 1rem; }

/* ---------- shared bits ---------- */

.flash {
  padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem;
  background: var(--accent-soft); color: #24452f; border: 1px solid #cfe0d2;
}
.flash-error { background: var(--error-soft); color: #7a2b20; border-color: #f0cec8; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
/* A card holding a form of stacked fields, which look broken full-width. */
.card-form { max-width: 26rem; }

.pagehead {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.pagehead p { margin: 0; }
.pagehead-actions { display: flex; gap: .5rem; align-items: center; }
.pagehead-child { display: flex; align-items: center; gap: .8rem; }
.pagehead-child h1, .pagehead-child h2 { margin: 0; }

.empty {
  text-align: center; padding: 3rem 1rem; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty p { margin: 0 0 1rem; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--tap); padding: .6rem 1.1rem;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #365d44; }
.btn-quiet { background: transparent; }
.btn-lg { font-size: 1.05rem; padding: .8rem 1.6rem; }
.btn-sm { min-height: 36px; padding: .35rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; }

.stickybar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  display: flex; justify-content: center; gap: .75rem;
  padding: .8rem 1rem calc(.8rem + env(safe-area-inset-bottom));
  background: rgba(255, 253, 249, .96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.stickybar-split { justify-content: space-between; max-width: 1000px; margin: 0 auto; }

/* ---------- day bar ---------- */

.daybar {
  display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .4rem .6rem;
}
.daybar-label { flex: 1; text-align: center; display: flex; gap: .5rem; justify-content: center; align-items: center; }
.daybtn {
  width: 42px; height: 42px; border-radius: 9px;
  display: grid; place-items: center; text-decoration: none;
  color: var(--accent); background: var(--surface-2); font-size: 1.1rem;
}
.daybtn.is-disabled { opacity: .25; }

.pill {
  display: inline-block; padding: .15rem .5rem; border-radius: 99px;
  font-size: .72rem; font-weight: 700; letter-spacing: .03em;
  background: var(--surface-2); color: var(--muted);
}
.pill-sent { background: var(--accent-soft); color: var(--accent); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-error { background: var(--error-soft); color: var(--error); }

/* ---------- forms ---------- */

.field { display: block; margin-bottom: .9rem; }
.field > span { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .25rem; }
.field-narrow { max-width: 180px; }

input[type=text], input[type=email], input[type=password], input[type=search],
input[type=time], input[type=file], select, textarea {
  width: 100%; min-height: var(--tap);
  padding: .55rem .7rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font: inherit;
}
textarea { min-height: 64px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: 3px solid rgba(63, 107, 79, .35); outline-offset: 1px;
}

.search { max-width: 260px; }
.inline { display: inline; }
.inline-form { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.inline-form .field { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.checkline { display: flex; align-items: center; gap: .45rem; min-height: var(--tap); }
.checkline input { width: 22px; height: 22px; }
.formrow { padding: .7rem 0; border-top: 1px solid var(--line); }
.formrow:first-of-type { border-top: 0; }
.control-label {
  display: block; font-size: .78rem; color: var(--muted);
  margin-bottom: .3rem; font-weight: 600;
}

.auth { width: min(420px, 100%); padding: 1rem; }
.auth-title { text-align: center; font-size: 1.35rem; }
.auth-sub { text-align: center; color: var(--muted); margin: 0 0 1.5rem; }

/* ---------- roster / attendance ---------- */

.toolbar { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.toolbar-count { margin-left: auto; color: var(--muted); font-size: .88rem; }

.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem; }
.roster-item {
  background: var(--surface); border: 2px solid var(--line);
  border-radius: var(--radius); overflow: hidden; transition: border-color .12s, background .12s;
}
.roster-item.is-on { border-color: var(--accent); background: var(--accent-soft); }
.roster-item[hidden] { display: none; }

.roster-tap {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem; cursor: pointer; min-height: 62px;
}
.roster-tap input { position: absolute; opacity: 0; width: 0; height: 0; }
.roster-name { flex: 1; min-width: 0; line-height: 1.25; }
.roster-name strong { display: block; }
.roster-name span { font-size: .8rem; color: var(--muted); }

.roster-check {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--surface); flex: none;
}
.roster-tap input:checked ~ .roster-check,
.reviewrow-pick input:checked ~ .roster-check {
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/15px no-repeat;
  border-color: var(--accent);
}
.reviewrow-pick input { position: absolute; opacity: 0; width: 0; height: 0; }

.roster-room { border: 0; border-top: 1px solid var(--line); border-radius: 0; min-height: 40px; font-size: .85rem; background: transparent; }
.roster-compact { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.avatar {
  flex: none; border-radius: 50%; object-fit: cover;
  display: grid; place-items: center;
  background: hsl(var(--hue, 90) 32% 88%); color: hsl(var(--hue, 90) 45% 26%);
  font-weight: 700; letter-spacing: .01em;
}
.avatar-md { width: 44px; height: 44px; font-size: .9rem; }
.avatar-sm { width: 36px; height: 36px; font-size: .78rem; }

/* ---------- step nav ---------- */

.steps {
  display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: .75rem;
  -webkit-overflow-scrolling: touch;
}
.step {
  flex: none; padding: .55rem .9rem; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem;
  white-space: nowrap;
}
.step.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.roomfilter { display: flex; align-items: center; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; font-size: .88rem; color: var(--muted); }

.chip {
  display: inline-flex; align-items: center; min-height: 38px; padding: .3rem .75rem;
  border-radius: 99px; border: 1px solid var(--line); background: var(--surface);
  text-decoration: none; color: var(--ink); font-size: .88rem; cursor: pointer; font-family: inherit;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-action:hover { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- logging rows ---------- */

.setall {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  padding: .7rem .9rem; margin-bottom: .75rem;
  background: var(--surface-2); border-radius: var(--radius);
}
.setall-label { font-size: .85rem; color: var(--muted); font-weight: 600; }

.loglist { display: flex; flex-direction: column; gap: .6rem; }
.logrow {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .8rem;
  display: grid; grid-template-columns: 200px 1fr; gap: 1rem; align-items: center;
}
.logrow.is-sent { border-left: 3px solid var(--accent); }
.logrow-child { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.logrow-name { min-width: 0; line-height: 1.25; }
.logrow-name strong { display: block; }
.logrow-name span { font-size: .78rem; color: var(--muted); }
.logrow-controls { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

.segmented { display: inline-flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.segmented .control-label { width: 100%; margin: 0; }
.seg { position: relative; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg span {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; min-width: 58px; padding: .4rem .8rem;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); cursor: pointer; font-weight: 600; font-size: .9rem;
}
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 3px solid rgba(63, 107, 79, .35); }

/* The usual answer, marked so it is quick to find — but still unchosen until
   somebody taps it. Only a hint of the accent, so a highlighted button is never
   mistaken for a selected one. */
.seg-typical span { border-color: var(--accent); border-style: dashed; }
.seg-typical input:checked + span { border-style: solid; }

.chips { display: inline-flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.chips .control-label { width: 100%; margin: 0; }
.chipbox { position: relative; }
.chipbox input { position: absolute; opacity: 0; width: 0; height: 0; }
.chipbox span {
  display: inline-flex; align-items: center; min-height: 42px; padding: .4rem .8rem;
  border: 1px solid var(--line); border-radius: 99px;
  background: var(--surface); cursor: pointer; font-size: .88rem;
}
.chipbox input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chipbox input:focus-visible + span { outline: 3px solid rgba(63, 107, 79, .35); }

.othernote { max-width: 260px; }
.timefield { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.timefield input[type=time] { width: auto; min-width: 130px; }
.timefield .control-label { width: 100%; margin: 0; }
.textfield { display: block; flex: 1 1 100%; }

/* Closed is the normal state; one holding a comment renders open. The summary
   carries the label, so it has to read as a label and not as a button. */
.commentbox > summary {
  cursor: pointer; font-size: .78rem; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); padding: .2rem 0;
}
.commentbox[open] > summary { margin-bottom: .25rem; }
.commentbox > summary:hover { color: var(--ink); }

/* ---------- toileting ---------- */

.round {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem; margin-bottom: 1rem;
}
.round summary { cursor: pointer; padding: .3rem 0; }
.round-form { margin-top: .9rem; display: flex; flex-direction: column; gap: .9rem; }
.round-controls { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: flex-start; }

.events { display: flex; flex-wrap: wrap; gap: .35rem; flex: 1 1 100%; }
.event {
  display: inline-flex; align-items: center; gap: .3rem;
  background: var(--surface-2); border-radius: 99px;
  padding: .25rem .3rem .25rem .7rem; font-size: .85rem;
}
.events-readonly .event { padding-right: .7rem; }

/* A chip opens to reveal the note box for that one entry. Closed it is still
   just a chip, so a row of them reads as a list of times as it always did.
   Open, it takes the whole row: a note box squeezed between two other chips
   is not worth typing into. */
.event-note { min-width: 0; }
.event-note > summary { cursor: pointer; list-style-position: inside; }
.event-note > summary::marker { color: var(--muted); font-size: .7em; }
.event-note[open] { flex: 1 1 auto; }
.event-note[open] > summary { margin-bottom: .4rem; font-weight: 600; }
.event-note input { width: 100%; font-size: .85rem; padding: .3rem .5rem; }

.event:has(.event-note[open]) {
  flex: 1 1 100%; align-items: flex-start;
  border-radius: var(--radius); padding: .5rem .5rem .55rem .7rem;
}
.event-x {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font-size: 1.1rem; line-height: 1; width: 26px; height: 26px; border-radius: 50%;
}
.event-x:hover { background: var(--error-soft); color: var(--error); }
.addevent { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* ---------- review ---------- */

.reviewlist { display: flex; flex-direction: column; gap: .6rem; }
.reviewrow {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .85rem;
  display: grid; grid-template-columns: auto 1fr auto; gap: .9rem; align-items: start;
}
.reviewrow.is-sent { border-left: 3px solid var(--accent); }
.reviewrow.is-blocked { background: var(--warn-soft); border-color: #ecd9bf; }
/* Sendable, but with sections nobody filled in: not selected for you. */
.reviewrow.is-incomplete { border-left: 3px solid var(--warn); }
/* A send that failed or half-failed. Pre-ticked, because retrying is safe. */
.reviewrow.is-unfinished { border-left: 3px solid var(--error); background: var(--error-soft); }
.reviewrow-pick { display: flex; align-items: center; min-height: 40px; cursor: pointer; }
.reviewrow-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .5rem; }
.reviewrow-summary { display: flex; flex-wrap: wrap; gap: .35rem; }
.reviewrow-note { margin: .5rem 0 0; color: var(--muted); font-size: .9rem; font-style: italic; }
.reviewrow-missing { margin: .4rem 0 0; font-size: .82rem; color: var(--warn); }
.reviewrow-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.tag {
  display: inline-flex; gap: .3rem; align-items: baseline;
  background: var(--surface-2); border-radius: 7px;
  padding: .2rem .5rem; font-size: .82rem;
}
.tag em { color: var(--muted); font-style: normal; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; }

.preview { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- send results ---------- */

.sendlist { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.sendrow {
  display: flex; gap: .7rem; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .7rem .9rem;
}
.sendrow-mark {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: .9rem;
}
.sendrow.is-ok .sendrow-mark { background: var(--accent-soft); color: var(--accent); }
.sendrow.is-problem .sendrow-mark { background: var(--error-soft); color: var(--error); }
.sendrow.is-problem { border-color: #f0cec8; }
.sendrow.is-note .sendrow-mark { background: var(--surface-2); color: var(--muted); }
.tips { margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: .9rem; }
.tips li { margin-bottom: .35rem; }

/* ---------- history & admin ---------- */

.historylist, .adminlist { display: flex; flex-direction: column; gap: .4rem; }
.historyrow {
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .7rem .9rem;
  text-decoration: none; color: var(--ink);
}
.historyrow:hover { background: var(--surface-2); }
.historyrow-day { font-weight: 600; min-width: 210px; }
.historyrow-body { flex: 1; display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }

.adminrow {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .6rem .9rem;
}
.adminrow.is-inactive { opacity: .6; }
.adminrow-main { flex: 1; min-width: 180px; line-height: 1.3; }
.adminrow-main strong { display: block; }

.guardianrow {
  display: grid; grid-template-columns: 1fr 1fr 180px auto; gap: .75rem;
  align-items: end; padding: .7rem 0; border-top: 1px solid var(--line);
}
.guardian-remove { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.reset summary { list-style: none; display: inline-flex; }
.reset summary::-webkit-details-marker { display: none; }
.reset[open] summary { margin-bottom: .5rem; }

.config { display: grid; grid-template-columns: 140px 1fr; gap: .4rem .9rem; margin: 0; }
.config dt { color: var(--muted); font-size: .85rem; }
.config dd { margin: 0; }

/* ---------- CSV import ---------- */

.importsummary { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.importsub { font-size: .95rem; margin: 1.2rem 0 .5rem; }
.importtable td { vertical-align: top; }
.importtable tr.import-create td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.importtable tr.import-update td:first-child { box-shadow: inset 3px 0 0 #b08a3e; }
.importtable tr.import-skip td:first-child { box-shadow: inset 3px 0 0 var(--error); }
.importtable tr.import-unchanged { opacity: .65; }
.importtable code {
  background: var(--surface-2); border-radius: 5px;
  padding: .05rem .3rem; font-size: .85em;
}

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .4rem .5rem; }
.table td { padding: .5rem; border-top: 1px solid var(--line); vertical-align: top; }
.table td.nowrap { white-space: nowrap; }
/* Starts a new action in the activity log: one click, however many changes. */
.table tr.is-newgroup td { border-top: 2px solid var(--line); }

/* ---------- narrow screens ---------- */

@media (max-width: 760px) {
  .logrow { grid-template-columns: 1fr; gap: .6rem; }
  .reviewrow { grid-template-columns: auto 1fr; }
  .reviewrow-actions { grid-column: 2; }
  .guardianrow { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .config { grid-template-columns: 1fr; gap: .1rem .9rem; }
  .config dd { margin-bottom: .5rem; }
  .historyrow-day { min-width: 0; width: 100%; }
  .topnav { order: 3; width: 100%; }
  .page { padding-bottom: 7rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
