/* Sahwah Connect design system.
   Brand: Sahwah navy + rust, set in Matter, app-shell UI.
   Rules: no decorative lines (separation comes from surface, space, and
   shadow), no em-dashes in copy, sentence case, mobile first. */

@font-face {
  font-family: 'Matter';
  src: url('/fonts/MatterRegular.otf') format('opentype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Matter';
  src: url('/fonts/MatterMedium.otf') format('opentype');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Matter';
  src: url('/fonts/MatterSemiBold.otf') format('opentype');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Matter';
  src: url('/fonts/MatterBold.otf') format('opentype');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-latin.woff2') format('woff2');
  font-weight: 400 700; font-style: normal; font-display: swap;
}

:root {
  --navy: #050A40;
  --navy-soft: #1c2155;
  --rust: #8D2316;
  --rust-dark: #71190f;
  --ink: #20243d;
  --muted: #666b80;
  --bg: #f4f5f9;
  --panel: #ffffff;
  --field: #eef0f6;

  --present: #156e3e;   --present-bg: #e5f2ea;
  --late: #8a5c00;      --late-bg: #f7eeda;
  --absent: #8d2316;    --absent-bg: #f6e7e4;
  --excused: #565e72;   --excused-bg: #e9ebf1;
  --unmarked-bg: #dfe2ec;

  --paid: #156e3e;
  --due: #8a5c00;

  --font: 'Matter', 'Segoe UI', system-ui, sans-serif;
  --mono: 'JetBrains Mono', Consolas, monospace;

  --r-card: 12px;
  --r-ctl: 9px;
  --shadow: 0 1px 2px rgba(5, 10, 64, 0.05), 0 4px 16px rgba(5, 10, 64, 0.05);
  --pad: 20px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}

h1, h2, h3 { color: var(--navy); line-height: 1.2; margin: 0 0 0.4em; }
h1 { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.015em; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.02rem; font-weight: 600; }
p { margin: 0 0 0.9em; }
a { color: var(--navy); }

:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; border-radius: 4px; }

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

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

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar img { width: 30px; height: 30px; border-radius: 7px; background: #fff; }
.topbar .wordmark { font-weight: 600; font-size: 1.02rem; color: #fff; letter-spacing: 0.01em; }
.topbar .wordmark span { font-weight: 400; opacity: 0.75; }
.topbar .spacer { flex: 1; }
.topbar a { color: #fff; }

.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 56px; }
.wrap-wide { max-width: 1180px; }

.eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}

.section { margin: 26px 0 0; }

/* ---------- cards, rows ---------- */

.card {
  background: var(--panel);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: var(--pad);
}

.rows { display: flex; flex-direction: column; gap: 8px; }
.row {
  background: var(--panel);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; color: var(--navy); }
.row .sub { font-size: 0.84rem; color: var(--muted); }

/* ---------- figures ---------- */

.figure {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.9rem;
  color: var(--navy);
  letter-spacing: -0.02em;
}
.figure small { font-family: var(--font); font-weight: 500; font-size: 0.88rem; color: var(--muted); letter-spacing: 0; }
.mono { font-family: var(--mono); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: 600 0.95rem var(--font);
  color: #fff;
  background: var(--navy);
  border: 0;
  border-radius: var(--r-ctl);
  padding: 11px 18px;
  min-height: 44px;
  cursor: pointer;
  text-decoration: none;
  transition: background 150ms ease;
}
.btn:hover { background: var(--navy-soft); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-rust { background: var(--rust); }
.btn-rust:hover { background: var(--rust-dark); }
.btn-quiet { background: var(--field); color: var(--navy); }
.btn-quiet:hover { background: var(--unmarked-bg); }
.btn-wa { background: #12784a; }
.btn-wa:hover { background: #0e5f3b; }
.btn-sm { min-height: 36px; padding: 7px 13px; font-size: 0.86rem; border-radius: 8px; }
.btn-block { display: flex; width: 100%; }

/* ---------- status chips + attendance ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  font: 600 0.8rem var(--font);
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.st-present { background: var(--present-bg); color: var(--present); }
.st-late { background: var(--late-bg); color: var(--late); }
.st-absent { background: var(--absent-bg); color: var(--absent); }
.st-excused { background: var(--excused-bg); color: var(--excused); }
.st-unmarked { background: var(--unmarked-bg); color: var(--muted); }
.st-draft { background: var(--excused-bg); color: var(--excused); }
.st-published { background: var(--present-bg); color: var(--present); }
.st-paid { background: var(--present-bg); color: var(--paid); }
.st-unpaid { background: var(--late-bg); color: var(--due); }
.st-waived { background: var(--excused-bg); color: var(--excused); }

/* big tap target for marking: cycles present > absent > late */
.mark {
  min-width: 96px;
  min-height: 44px;
  border: 0;
  border-radius: var(--r-ctl);
  font: 600 0.9rem var(--font);
  cursor: pointer;
  transition: transform 80ms ease;
}
.mark:active { transform: scale(0.96); }
.mark.st-unmarked { background: var(--field); }

/* the split-day ribbon: one column per school day, AM square over PM square */
.ribbon { display: flex; gap: 3px; flex-wrap: wrap; padding: 2px 0; }
.ribbon .day { display: flex; flex-direction: column; gap: 3px; }
.ribbon .cell { width: 13px; height: 13px; border-radius: 3.5px; background: var(--unmarked-bg); }
.ribbon .c-present { background: var(--present); }
.ribbon .c-late { background: #c98f1a; }
.ribbon .c-absent { background: var(--absent); }
.ribbon .c-excused { background: #a8aebe; }
.ribbon-key { font-size: 0.74rem; color: var(--muted); margin-top: 6px; }

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

label.lbl { display: block; font: 600 0.84rem var(--font); color: var(--navy); margin: 14px 0 5px; }
input[type="text"], input[type="email"], input[type="date"], input[type="month"],
input[type="number"], input[type="url"], select, textarea {
  width: 100%;
  font: 400 1rem var(--font);
  color: var(--ink);
  background: var(--field);
  border: 0;
  border-radius: var(--r-ctl);
  padding: 11px 13px;
  min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
select { appearance: auto; }

.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; min-width: 0; }

/* segmented control (lesson kind) */
.seg { display: flex; background: var(--field); border-radius: var(--r-ctl); padding: 3px; gap: 3px; }
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  font: 600 0.86rem var(--font);
  color: var(--muted);
  padding: 9px 6px;
  border-radius: 7px;
  cursor: pointer;
  min-height: 40px;
}
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; }

/* PIN gate */
.gate { min-height: 88vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.gate .card { width: 100%; max-width: 400px; text-align: center; padding: 34px 26px; }
.gate img { width: 52px; height: 52px; border-radius: 12px; margin-bottom: 12px; }
.pin-input {
  font: 700 1.9rem var(--mono);
  text-align: center;
  letter-spacing: 0.45em;
  text-indent: 0.45em;
  margin: 14px 0;
}
.gate .err { color: var(--rust); font-weight: 600; font-size: 0.9rem; min-height: 1.4em; margin: 4px 0; }

/* ---------- admin ---------- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--panel); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi .n { font: 700 1.7rem var(--mono); color: var(--navy); }
.kpi .l { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.kpi.warn .n { color: var(--rust); }

.tbl { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.tbl th {
  text-align: left;
  font: 600 0.74rem var(--font);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 12px;
}
.tbl td { padding: 11px 12px; background: var(--panel); vertical-align: middle; }
.tbl tr td:first-child { border-radius: var(--r-card) 0 0 var(--r-card); }
.tbl tr td:last-child { border-radius: 0 var(--r-card) var(--r-card) 0; }
.tbl { border-spacing: 0 6px; border-collapse: separate; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0; }
.tabs button, .tabs a {
  border: 0;
  background: var(--panel);
  color: var(--muted);
  font: 600 0.88rem var(--font);
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow);
  text-decoration: none;
  min-height: 38px;
}
.tabs [aria-current="true"], .tabs [aria-pressed="true"] { background: var(--navy); color: #fff; }

/* ---------- utility ---------- */

.muted { color: var(--muted); }
.small { font-size: 0.84rem; }
.right { text-align: right; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.split { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.hidden { display: none !important; }
.copy-ok { color: var(--present); font-weight: 600; font-size: 0.84rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  font: 600 0.9rem var(--font);
  padding: 11px 20px;
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(5, 10, 64, 0.28);
  z-index: 50;
}
.toast.rust { background: var(--rust); }

.empty {
  color: var(--muted);
  background: var(--panel);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 22px;
  text-align: center;
  font-size: 0.94rem;
}

@media (min-width: 700px) {
  h1 { font-size: 2rem; }
  .wrap { padding: 28px 20px 72px; }
}
