:root {
  --navy: #123a73;
  --blue: #1f6fd1;
  --sky: #5aa6ea;
  --mist: #dceeff;
  --card: #f3f9ff;
  --ink: #102a4a;
  --muted: #3d6a96;
  --line: #b7d4f0;
  --needed: #2a7fd4;
  --progress: #0f5fb8;
  --done: #1a4f9a;
  --shadow: 0 12px 32px rgba(18, 58, 115, 0.14);
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "DM Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 8% -10%, #8ec4f4, transparent 58%),
    radial-gradient(800px 380px at 100% 0%, #4e90d6, transparent 52%),
    #6eaae6;
  line-height: 1.5;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3.5rem;
}

.lede {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.4rem;
  align-items: end;
}
.lede h2 {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0 0 0.45rem;
  line-height: 1.15;
  color: var(--navy);
}
.lede p { margin: 0; color: var(--muted); max-width: 42rem; }
.page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}
.login-panel {
  max-width: 28rem;
  margin: 2.5rem auto 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.4rem 1.5rem 1.5rem;
  box-shadow: var(--shadow);
}
.login-panel h2 {
  font-family: var(--serif);
  color: var(--navy);
  margin: 0 0 0.4rem;
}
.login-panel > p {
  margin: 0 0 1rem;
  color: var(--muted);
}
a.btn { text-decoration: none; display: inline-flex; align-items: center; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  box-shadow: var(--shadow);
}
.stat b {
  display: block;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1;
  color: var(--navy);
}
.stat span {
  font-size: 0.78rem;
  color: var(--muted);
}
.stat.needed b { color: var(--needed); }
.stat.progress b { color: var(--progress); }
.stat.done b { color: var(--done); }

.toolbar, .composer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
  align-items: center;
}
.search {
  flex: 1 1 220px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.7rem 0.9rem;
  outline: none;
}
.search:focus, select:focus, input:focus, textarea:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(126, 179, 217, 0.35);
  outline: none;
}
.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.4rem 0.85rem;
  color: var(--muted);
}
.chip:hover { background: #e7f3ff; }
.chip[aria-pressed="true"] {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.composer {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}
.composer form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  flex: 1;
}
.composer label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-right: 0.2rem;
}
.composer input, .composer select {
  background: #f7fbff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.55rem 0.7rem;
  min-width: 0;
}
.composer input[type="text"],
.composer input[type="email"] { flex: 1 1 180px; }
.composer select { flex: 0 1 180px; }
.student-form {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem 0.85rem;
  align-items: center;
  width: 100%;
}
.student-form button { grid-column: 2; justify-self: start; }
.creds {
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}
.roster-side {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem 0.65rem;
}
.roster-side .btn { white-space: normal; text-align: right; }
.student.is-disabled { opacity: 0.7; }

.btn {
  background: var(--navy);
  color: #fff;
  border: 0;
  border-radius: 4px;
  padding: 0.58rem 0.95rem;
  font-weight: 600;
  white-space: nowrap;
}
.btn:hover { background: #0d2d5c; }
.btn.secondary {
  background: #e7f3ff;
  color: var(--navy);
  border: 1px solid var(--line);
}
.btn.secondary:hover { background: #d4ebff; }
.btn.brick { background: var(--blue); }
.btn.brick:hover { background: #185bb3; }
.btn.sage { background: var(--done); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.board { display: grid; gap: 1rem; }
.student {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.student-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 1rem 1.15rem 0.7rem;
  background: linear-gradient(180deg, #d7ebff, #f3f9ff);
}
.student-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--navy);
}
.student-head small { color: var(--muted); }

.needs { display: grid; }
.need {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem 1rem;
  padding: 0.95rem 1.15rem;
  border-top: 1px solid var(--line);
}
.need:first-child { border-top: 0; }
.need h4 {
  margin: 0 0 0.25rem;
  font-size: 1.02rem;
  font-weight: 600;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.7rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 4px;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.pill.needed { background: #cfe6ff; color: #0f4f96; }
.pill.in_progress { background: #9ecdf5; color: #0a3d7a; }
.pill.fulfilled { background: #1f6fd1; color: #f3f9ff; }
.actions { display: flex; gap: 0.4rem; align-items: start; flex-wrap: wrap; }
.status-select {
  background: #f3f9ff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.5rem 0.65rem;
  min-width: 9.5rem;
}

.notes {
  grid-column: 1 / -1;
  background: var(--mist);
  border-radius: 6px;
  padding: 0.7rem 0.8rem;
}
.notes h5 {
  margin: 0 0 0.45rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.note {
  padding: 0.45rem 0;
  border-top: 1px solid var(--line);
}
.note:first-of-type { border-top: 0; padding-top: 0; }
.note .who { font-weight: 600; font-size: 0.88rem; }
.note p { margin: 0.2rem 0 0; }

.empty {
  text-align: center;
  padding: 2.4rem 1rem;
  color: var(--muted);
}
.empty strong {
  display: block;
  color: var(--navy);
  font-family: var(--serif);
  font-size: 1.3rem;
  margin-bottom: 0.3rem;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 58, 115, 0.4);
  display: none;
  z-index: 20;
}
.drawer-backdrop.show { display: block; }
.drawer {
  position: fixed;
  right: 0;
  top: 0;
  height: 100%;
  width: min(420px, 100%);
  background: var(--card);
  z-index: 21;
  transform: translateX(110%);
  transition: transform 0.22s ease;
  box-shadow: -16px 0 40px rgba(30, 74, 120, 0.16);
  display: flex;
  flex-direction: column;
}
.drawer.show { transform: translateX(0); }
.drawer header {
  padding: 1.2rem 1.2rem 0.8rem;
  border-bottom: 1px solid var(--line);
  background: #cfe6ff;
}
.drawer header h3 {
  font-family: var(--serif);
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
  color: var(--navy);
}
.drawer header p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.drawer form {
  padding: 1.1rem 1.2rem;
  display: grid;
  gap: 0.7rem;
  overflow: auto;
}
.drawer label { font-weight: 600; font-size: 0.88rem; color: var(--navy); }
.drawer input, .drawer textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.65rem 0.75rem;
  background: #f3f9ff;
}
.drawer textarea { min-height: 140px; resize: vertical; }
.drawer .row { display: flex; gap: 0.5rem; }

.toast {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy);
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 30;
  max-width: calc(100% - 2rem);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: #a33b4a; }

.field-error { color: #a33b4a; font-size: 0.82rem; min-height: 1.1em; }

@media (max-width: 800px) {
  .lede, .need { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .composer { flex-direction: column; align-items: stretch; }
  .actions { justify-content: flex-start; }
}
