/* School Management System - one stylesheet, no external fonts (works offline). */
:root {
  --ink: #18231f; --ink-2: #4b5a54; --ink-3: #7a8783;
  --bg: #f5f3ee; --card: #ffffff; --line: #e3e0d8; --line-2: #efece6;
  --brand: #0e6b4f; --brand-ink: #ffffff; --brand-soft: #e3f1ea;
  --good: #1d7a46; --good-soft: #e2f3e8; --warn: #9a6200; --warn-soft: #fbf0d9; --bad: #b42318; --bad-soft: #fde8e6;
  --radius: 10px; --shadow: 0 1px 2px rgba(24, 35, 31, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 1.55rem; line-height: 1.2; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--line-2); padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.big { font-size: 2rem; font-weight: 700; margin: .5rem 0; }

/* ---------- Header ---------- */
.top { background: var(--brand); color: var(--brand-ink); }
.top-inner { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; min-width: 0; }
.brand span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { width: 32px; height: 32px; border-radius: 8px; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 800; flex: none; }
.who { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 14px; }
.who small { opacity: .8; margin-left: 4px; }
.who a, .who .link { color: #fff; opacity: .9; }
.menu-btn { display: none; margin-left: auto; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 8px; padding: 6px 12px; font: inherit; }
.nav { background: #0b5a42; }
.nav-inner { max-width: 1180px; margin: 0 auto; padding: 0 8px; display: flex; gap: 2px; overflow-x: auto; }
.nav a { color: #d6ece3; text-decoration: none; padding: 10px 12px; font-size: 14px; white-space: nowrap; border-bottom: 3px solid transparent; }
.nav a:hover { color: #fff; }
.nav a.on { color: #fff; border-bottom-color: #f2c14e; font-weight: 600; }

main { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; }
main.wide { max-width: 1180px; }
.foot { text-align: center; color: var(--ink-3); font-size: 12px; padding: 24px 16px; }

/* ---------- Layout ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
.cols > .card { margin-bottom: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow-x: auto; }
.card.narrow { max-width: 440px; margin: 32px auto; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head.pad { padding: 16px 20px 0; }
.card.restricted { border-left: 4px solid var(--warn); }
.card.danger-zone { border-color: #f1c7c2; }
.card.setup { background: var(--brand-soft); border-color: #c7e2d5; }
.stack > * + * { margin-top: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 16px; align-items: start; }
.grid .actions, .grid .check { grid-column: 1 / -1; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions.sticky { position: sticky; bottom: 0; background: var(--card); padding: 14px 0 4px; border-top: 1px solid var(--line-2); margin-top: 12px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field.grow { flex: 1; min-width: 160px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field em { color: var(--bad); font-style: normal; }
.field small { color: var(--ink-3); font-size: 12px; }
input, select, textarea { font: inherit; color: inherit; background: #fff; border: 1px solid #cfcbc1; border-radius: 8px; padding: 9px 11px; width: 100%; min-height: 40px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filters input, .filters select { width: auto; min-width: 150px; }
.filters input[type=search] { flex: 1; min-width: 200px; }
.inline-label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); }
.inline { display: inline; margin: 0; }
.inline-select select { min-width: 160px; padding: 6px 8px; min-height: 34px; }
details.add { margin-top: 14px; border-top: 1px solid var(--line-2); padding-top: 12px; }
details.add summary { cursor: pointer; font-weight: 600; color: var(--brand); margin-bottom: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 14px; padding: 9px 16px; min-height: 40px;
  border-radius: 8px; border: 1px solid #cfcbc1; background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0b5a42; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; }
.link.danger, .bad-text { color: var(--bad); }
.warn-text { color: var(--warn); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.card:not(.flush) .table th:first-child, .card:not(.flush) .table td:first-child { padding-left: 0; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #faf9f6; }
.table tr.dim td { color: var(--ink-3); }
.table tr.flag td { background: var(--bad-soft); }
.table tr.total td { font-weight: 700; border-top: 1px solid var(--line); }
.table .msg { max-width: 420px; }
.row-actions { white-space: nowrap; }
.row-actions form + form { margin-left: 10px; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); text-transform: capitalize; white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; background: var(--brand-soft); border: 1px solid #c7e2d5; }
.flash.good { background: var(--good-soft); border-color: #bfe3cc; }
.flash.warn { background: var(--warn-soft); border-color: #f0dbab; }
.flash.bad { background: var(--bad-soft); border-color: #f6c6c0; }
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.secret { margin-top: 8px; padding: 10px 12px; background: #fff; border: 1px dashed var(--ink-3); border-radius: 6px; font-size: 14px; }

/* ---------- Stats & tiles ---------- */
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.stat-row.cards { margin-bottom: 16px; }
.stat-row.cards .stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; flex: 1; min-width: 170px; box-shadow: var(--shadow); text-decoration: none; color: inherit; }
.stat { display: flex; flex-direction: column; min-width: 90px; }
.stat b { font-size: 1.35rem; font-variant-numeric: tabular-nums; line-height: 1.2; text-transform: capitalize; }
.stat span { font-size: 13px; color: var(--ink-2); }
.stat.good b { color: var(--good); } .stat.bad b { color: var(--bad); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.tile:hover { border-color: var(--brand); }
.tile b { font-size: 1.1rem; }
.tile span:not(.badge):not(.btn) { color: var(--ink-2); font-size: 13px; }
.kids { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.kid h2 { margin-bottom: 0; }
.empty { text-align: center; padding: 32px 16px; color: var(--ink-2); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 7px 0; border-bottom: 1px solid var(--line-2); }
.plain li:last-child { border-bottom: 0; }
.timeline { margin: 0; padding-left: 18px; }
.timeline li { padding: 3px 0; text-transform: none; }
.steps li { margin-bottom: 8px; }
.checklist { margin: 0; padding-left: 22px; }
.checklist li { padding: 3px 0; }
.checklist li.done a { color: var(--ink-3); text-decoration: line-through; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.pager { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Attendance register ---------- */
.register-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.register-list { list-style: none; margin: 0; padding: 0; counter-reset: n; }
.register-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; counter-increment: n; }
.register-list .name::before { content: counter(n) ". "; color: var(--ink-3); }
.choices { display: flex; gap: 4px; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: inline-block; padding: 7px 11px; border: 1px solid #cfcbc1; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; background: #fff; user-select: none; }
.choice input:focus-visible + span { outline: 2px solid var(--brand); }
.choice.present input:checked + span { background: var(--good); border-color: var(--good); color: #fff; }
.choice.absent input:checked + span { background: var(--bad); border-color: var(--bad); color: #fff; }
.choice.late input:checked + span { background: var(--warn); border-color: var(--warn); color: #fff; }
.choice.excused input:checked + span { background: var(--ink-2); border-color: var(--ink-2); color: #fff; }

/* ---------- Invoice ---------- */
.inv-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 12px; }
.inv-head h2 { margin: 0; }
.inv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 14px; }
.test-checkout { text-align: center; }
.test-checkout .row { justify-content: center; }

@media (max-width: 720px) {
  .menu-btn { display: inline-block; }
  .who { display: none; position: absolute; }
  .top.open .who { display: flex; position: static; flex-direction: column; align-items: flex-start; width: 100%; padding: 0 16px 12px; }
  .top.open .top-inner { flex-wrap: wrap; }
  h1 { font-size: 1.3rem; }
  .card { padding: 16px; }
  .register-list li { flex-direction: column; align-items: stretch; }
  .choices { justify-content: space-between; }
  .choice { flex: 1; } .choice span { width: 100%; text-align: center; }
  .inv-meta { align-items: flex-start; }
}

@media print {
  .top, .foot, .no-print, .flash { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; padding: 0; }
}

/* ---------- Website admin ---------- */
.card.highlight { border-color: #e7b84a; box-shadow: 0 0 0 3px #fbf0d9; }
.levels-pick { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.levels-pick legend { font-size: 14px; font-weight: 600; padding: 0 4px; }
.news-admin { list-style: none; padding: 0; margin: 16px 0 0; }
.news-admin li { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.nowrap { white-space: nowrap; }

/* ---------- Assistant ---------- */
.assist { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
.chat { display: flex; flex-direction: column; gap: 16px; }
.turns { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.turn { max-width: 82%; padding: 10px 14px; border-radius: 12px; font-size: 15px; }
.turn p { margin: 0 0 .5em; } .turn p:last-child { margin-bottom: 0; }
.turn ul { margin: .25em 0 .5em; padding-left: 20px; }
.turn.me { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.turn.bot { align-self: flex-start; background: var(--line-2); border-bottom-left-radius: 4px; }
.turn.err { align-self: flex-start; background: var(--bad-soft); color: var(--bad); }
.turn.note { align-self: center; max-width: 100%; font-size: 13px; color: var(--ink-2); background: none; padding: 0; }
.turn.action { align-self: stretch; max-width: 100%; padding: 0; }
.action-card { border: 1px solid #e7b84a; background: #fffaf0; border-radius: 10px; padding: 14px 16px; }
.turn.action.done .action-card { border-color: #bfe3cc; background: var(--good-soft); }
.turn.action.cancelled .action-card, .turn.action.failed .action-card { border-color: var(--line); background: #faf9f6; }
.action-card p { margin: 8px 0 4px; }
.msg-preview { margin: 0 0 6px; padding: 8px 12px; background: #fff; border-left: 3px solid var(--brand); border-radius: 4px; font-size: 14px; white-space: pre-wrap; }
.ask { display: flex; gap: 10px; align-items: flex-end; border-top: 1px solid var(--line-2); padding-top: 14px; }
.ask textarea { min-height: 52px; }
.try { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.try p { width: 100%; margin: 0; }
.chip { font: inherit; font-size: 14px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; cursor: pointer; color: var(--ink); text-align: left; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.side h2 { font-size: 1rem; }
.side li.on a { font-weight: 700; }
.small-gap { margin-top: 14px; }
.card.narrow-wide { max-width: 680px; margin: 24px auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (max-width: 820px) { .assist { grid-template-columns: 1fr; } .turn { max-width: 92%; } .ask { flex-direction: column; align-items: stretch; } }

/* ---------- Website editor ---------- */
.web-tabs { flex-wrap: wrap; margin-bottom: 16px; }
.card h3 { margin: 8px 0 0; }
.rep { display: flex; flex-direction: column; gap: 12px; }
.rep [data-rep-rows] { display: flex; flex-direction: column; gap: 12px; }
.rep-row { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 12px; margin: 0; display: flex; flex-direction: column; gap: 12px; background: #fcfbf8; }
.rep-row legend { font-size: 13px; font-weight: 700; color: var(--ink-2); padding: 0 6px; }
.rep-remove { align-self: flex-end; color: var(--bad); }
.img-pick-row { display: flex; gap: 12px; align-items: center; }
.img-thumb { width: 88px; height: 64px; border-radius: 8px; background: var(--line-2); display: grid; place-items: center; overflow: hidden; flex: none; }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.colour-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.colour-row input[type=color] { width: 56px; height: 40px; padding: 2px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); padding: 3px; background: #fff; cursor: pointer; }
.swatch span { display: block; width: 100%; height: 100%; border-radius: 50%; }
.swatch-0b4a36 { background: #0B4A36; } .swatch-1f3a6b { background: #1F3A6B; } .swatch-7a1f2b { background: #7A1F2B; } .swatch-5b2a86 { background: #5B2A86; }
.swatch-1d5fbf { background: #1D5FBF; } .swatch-0d6e73 { background: #0D6E73; } .swatch-f2a93b { background: #F2A93B; } .swatch-e9c46a { background: #E9C46A; }
.swatch-f28c6b { background: #F28C6B; } .swatch-7fc8a9 { background: #7FC8A9; } .swatch-ffffff { background: #FFFFFF; border: 1px solid #ccc; } .swatch-d62828 { background: #D62828; }
.photo-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.photo-grid li { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; gap: 8px; padding-bottom: 10px; background: #fff; }
.photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--line-2); }
.photo-grid form { padding: 0 10px; }
.stack-s { display: flex; flex-direction: column; gap: 6px; }
.stack-s input:not([type=checkbox]) { min-height: 34px; padding: 5px 8px; }
