:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e2e0da;
  --accent: #2f5d50;
  --accent-dark: #234a3f;
  --danger: #b3261e;
  --ok: #2f5d50;
  --warn: #a15c00;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--accent);
  color: #fff;
}

header.site a { color: #fff; text-decoration: none; font-weight: 600; }

.brand { display: flex; align-items: center; gap: 11px; }
.brand:hover { text-decoration: none; }
.brand .logo { flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 0.72rem; font-weight: 500; opacity: 0.72; letter-spacing: 0.04em; text-transform: uppercase; }

.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand .logo { color: var(--accent); }
.login-brand h1 { margin: 10px 0 2px; font-size: 1.35rem; }
.login-brand p { margin: 0; }
header.site nav a { margin-left: 16px; font-weight: 500; opacity: 0.9; }
header.site nav a:hover { opacity: 1; text-decoration: underline; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}
/* Pages with wide tables get the room to show every column without clipping. */
main.wide { max-width: 1240px; }

h1 { font-size: 1.5rem; margin-bottom: 4px; }
h2 { font-size: 1.15rem; margin-top: 32px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

a.button, button, input[type="submit"] {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
}
a.button:hover, button:hover { background: var(--accent-dark); }
a.button.secondary, button.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
button.danger { background: var(--danger); }

form.inline { display: inline; }

.grid-form { display: grid; gap: 12px; max-width: 480px; }
.grid-form label { font-size: 0.85rem; color: var(--muted); display: block; margin-bottom: 4px; }
.grid-form input, .grid-form select, .grid-form textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem;
}

.balance-pos { color: var(--danger); font-weight: 600; }
.balance-zero { color: var(--ok); font-weight: 600; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.tag.registered { background: #e2f0ea; color: var(--ok); }
.tag.waitlisted { background: #fdf1dc; color: var(--warn); }
.tag.cancelled { background: #f4e2e1; color: var(--danger); }
.tag.needs-info { background: #fdf1dc; color: var(--warn); margin-left: 6px; }

.notice { background: #e2f0ea; border: 1px solid #b9dcc9; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.error { background: #f4e2e1; border: 1px solid #e3b3b0; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; color: var(--danger); }
.muted { color: var(--muted); font-size: 0.85rem; }

.summary-row { display: flex; gap: 24px; margin-bottom: 8px; }
.summary-row div { flex: 1; }
.summary-row .label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.summary-row .value { font-size: 1.3rem; font-weight: 600; }

/* The families table has sixteen columns, so keep it tight: numbers and the
   month grid never wrap, names and emails may, and nothing is clipped — only a
   genuinely narrow viewport gets a horizontal scroll. */
.table-card { overflow-x: auto; padding: 12px 14px; }
table.families th, table.families td { padding: 8px 6px; font-size: 0.88rem; white-space: nowrap; }
table.families th:last-child, table.families td:last-child { padding-right: 4px; }
table.families td:nth-child(2), table.families td:nth-child(3) { white-space: normal; }
table.families td:nth-child(2) { min-width: 150px; }
table.families td:nth-child(2) .muted { overflow-wrap: break-word; }
table.families .muted { font-size: 0.8rem; }
table.families .month-cell { width: 20px; min-width: 20px; padding: 8px 2px; }
table.families td:last-child a.button { padding: 5px 9px; font-size: 0.82rem; }

.month-cell { text-align: center; font-weight: 600; color: var(--muted); padding: 8px 4px; width: 22px; }
.month-cell.paid { background: #e2f0ea; color: var(--ok); }
.month-cell.part { background: #fdf1dc; color: var(--warn); }

table.accounts td { vertical-align: middle; }
table.accounts form.inline { white-space: nowrap; }

/* Row numbers, so the office can talk about "family 12" the way the sheet does. */
th.num, td.num { color: var(--muted); text-align: right; width: 1%; padding-left: 4px; padding-right: 4px; font-variant-numeric: tabular-nums; }
table.families td:first-child, table.families th:first-child { padding-left: 0; }

form.add-child { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 16px; }
form.add-child label { display: block; margin-bottom: 4px; }
form.add-child input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem; height: 38px; }
form.add-child button { height: 38px; }

.register { max-width: 640px; margin: 24px auto; }
.cell-input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem; }
.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .two-up { grid-template-columns: 1fr; } }
.register .grid-form { max-width: none; }
/* The office's Add Family page is laid out like the public form, left-aligned under the admin nav. */
.add-family { max-width: 640px; }
.add-family .grid-form { max-width: none; }

/* School year cards: one form for details, registration window and rates. */
.year-card { padding: 24px; }
.year-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.year-head h2 { margin: 0; font-size: 1.25rem; }
.year-head p { margin: 4px 0 0; }
.status-line { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 14px 0 4px; padding: 10px 12px; background: var(--bg); border-radius: 8px; font-size: 0.9rem; }
.status-line form { margin-left: auto; }
button.small, a.button.small { padding: 5px 10px; font-size: 0.82rem; }

.year-form section { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--border); }
.year-form h3 { margin: 0 0 12px; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.year-form .fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; }
@media (max-width: 700px) { .year-form .fields { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 460px) { .year-form .fields { grid-template-columns: 1fr; } }
.year-form .field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 5px; }
.year-form .field input, .year-form .field select, .year-form .money-input { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem; background: #fff; }
.year-form .field select { padding-right: 28px; }
.year-form .money-input { display: flex; align-items: center; padding: 0 0 0 10px; }
.year-form .money-input span { color: var(--muted); margin-right: 4px; }
.year-form .money-input input { border: none; height: 36px; padding: 0 10px 0 0; width: 100%; font-size: 0.95rem; background: transparent; }
.year-form .money-input:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.year-form .money-input input:focus { outline: none; }
.year-form label.check { display: flex; align-items: center; gap: 8px; height: 38px; font-size: 0.92rem; color: var(--text); margin: 0; }
.year-form label.check input { width: auto; height: auto; margin: 0; }
.year-form .hint { margin: 10px 0 0; font-size: 0.83rem; color: var(--muted); }
.year-form .tiers { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 12px 10px; }
.year-form .tier label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 5px; }
.year-form .tier .year-total { font-size: 0.78rem; margin-top: 5px; white-space: nowrap; }
.year-form .actions { margin-top: 20px; }

/* Classes admin: inline editable rows and the roster assignment table. */
table.classes input[type="text"], table.assign select, table.classes select {
  height: 34px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.92rem; background: #fff; width: 100%;
}
table.classes td, table.assign td { vertical-align: middle; }
table.classes td:nth-child(3) { min-width: 160px; }
table.classes td:nth-child(4), table.classes td:nth-child(5) { min-width: 170px; }
/* Reordering classes: a grab handle for the mouse, arrows for everything else. */
table.classes td.drag-cell { white-space: nowrap; width: 1%; padding-right: 0; color: var(--muted); }
.drag-handle { cursor: grab; font-size: 1.1rem; padding: 4px 6px; user-select: none; }
.drag-handle:active { cursor: grabbing; }
.drag-buttons button { background: none; border: none; color: var(--muted); padding: 0 3px; font-size: 0.7rem; cursor: pointer; }
.drag-buttons button:hover { color: var(--text); background: none; }
table.classes tr.dragging td { opacity: 0.4; }
table.assign td:last-child { min-width: 180px; }
table.assign tr.unassigned td { background: #fdf7ea; }
table.assign tr.group-row th { background: var(--bg); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); padding-top: 12px; }
table.assign tr.group-empty td { font-style: italic; }

/* Attendance: built for a phone in a classroom — big targets, few steps. */
.att-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.att-head h1 { margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 12px; }
.tabs .tab { padding: 8px 14px; margin-bottom: -1px; border: 1px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0; text-decoration: none; color: inherit; font-weight: 600; }
.tabs .tab:hover { background: var(--bg); }
.tabs .tab.active { background: var(--card); border-color: var(--border); }
.tab-panel[hidden] { display: none; }

.att-date { display: flex; align-items: center; gap: 6px; }
.att-date input { height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem; background: #fff; }
.att-step { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: 1.4rem; line-height: 1; text-decoration: none; color: inherit; }
.att-step:hover { background: var(--bg, #f5f5f5); }
.att-offday .att-row { opacity: 0.6; }
.att-offday .att-row:hover { opacity: 1; }
.att-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.att-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; color: var(--text); text-decoration: none; }
.att-row:hover { border-color: var(--accent); text-decoration: none; }
.att-row.done { background: #f3f8f5; }
.att-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.att-name strong { font-size: 1.02rem; }
.att-state { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; font-size: 0.85rem; }
.att-go { color: var(--accent); font-weight: 600; white-space: nowrap; }
@media (max-width: 600px) { .att-row { flex-wrap: wrap; } .att-state { width: 100%; justify-content: flex-start; } }

.att-help { margin: 0 0 12px; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.att-student { position: relative; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid #b9dcc9; background: #e2f0ea; border-radius: 10px; cursor: pointer; user-select: none; font-size: 1.02rem; -webkit-tap-highlight-color: transparent; }
.att-student input { position: absolute; opacity: 0; width: 0; height: 0; }
.att-mark { width: 22px; height: 22px; border-radius: 50%; flex: none; background: var(--ok); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; }
.att-mark::after { content: '✓'; }
.att-label { flex: 1; font-weight: 600; color: var(--ok); }
.att-status { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ok); }
.att-status::after { content: 'present'; }
.att-student:has(input:not(:checked)) { background: #f4e2e1; border-color: #e3b3b0; }
.att-student:has(input:not(:checked)) .att-mark { background: var(--danger); }
.att-student:has(input:not(:checked)) .att-mark::after { content: '✕'; }
.att-student:has(input:not(:checked)) .att-label { color: var(--danger); text-decoration: line-through; }
.att-student:has(input:not(:checked)) .att-status { color: var(--danger); }
.att-student:has(input:not(:checked)) .att-status::after { content: 'absent'; }
.att-student:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.att-save { position: sticky; bottom: 0; display: flex; align-items: center; gap: 14px; margin-top: 16px; padding: 12px 0; background: var(--bg); }
.att-save button { padding: 12px 22px; font-size: 1rem; }
.staff-select { height: 30px; padding: 0 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem; background: #fff; }

/* The header on a phone: brand on one line, links wrapping beneath it. */
@media (max-width: 640px) {
  header.site { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 16px; }
  .brand-name { white-space: nowrap; }
  header.site nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
  header.site nav a { margin-left: 0; }
  header.site nav button { margin-left: 0 !important; }
  main { padding: 16px; }
}
.notice.birthday { background: #fdf1dc; border-color: #e8cd9a; }

/* Background saving: the fallback buttons only show without JavaScript. */
html.js .js-hide { display: none !important; }
.autosave-toast { position: fixed; right: 20px; bottom: 20px; padding: 10px 16px; background: var(--accent-dark); color: #fff; border-radius: 8px; font-size: 0.9rem; box-shadow: 0 4px 14px rgba(0,0,0,0.18); opacity: 0; transform: translateY(8px); transition: opacity 0.15s, transform 0.15s; pointer-events: none; z-index: 50; }
.autosave-toast.show { opacity: 1; transform: none; }
.autosave-toast.bad { background: var(--danger); }
.assign-row { display: flex; gap: 6px; align-items: center; }

/* A class page: teacher and helper on the left, the class name in the middle,
   buttons on the right (gone in print, so the name stays centred). */
.class-head { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: start; }
.class-staff { display: flex; flex-direction: column; gap: 8px; }
.class-staff .label { display: block; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.class-title { text-align: center; }
.class-title h1 { margin: 0; }
.class-title p { margin: 4px 0 0; }
.class-actions { display: flex; gap: 8px; justify-content: flex-end; }
@media (max-width: 720px) { .class-head { grid-template-columns: 1fr; } .class-title { text-align: left; } .class-actions { justify-content: flex-start; } }

/* Printing a class page: what View shows, without the nav and buttons. */
.print-only { display: none; }
@media print {
  header.site, nav, .no-print, .autosave-toast { display: none !important; }
  .print-only { display: block; }
  .class-head { grid-template-columns: 1fr auto 1fr; }
  .class-title { text-align: center; }
  .summary-row { display: flex; }
  body { background: #fff; color: #000; }
  main, main.wide { max-width: none; margin: 0; padding: 0; }
  .card { border: none; box-shadow: none; padding: 0; margin: 0 0 16px; }
  table { font-size: 11pt; }
  th, td { border-bottom: 1px solid #999; }
  a { color: inherit; text-decoration: none; }
}
