:root {
  color-scheme: light;
  --ink: #14221f;
  --muted: #5c6b66;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #e2d9c8;
  --teal: #0e6e67;
  --teal-dark: #0a524d;
  --amber: #8a5a12;
  --bad: #8d2b2b;
  --good: #1d6b3a;
  --shadow: 0 10px 30px rgba(20, 34, 31, 0.06);
  font-family: "DM Sans", "Segoe UI", sans-serif;
  font-weight: 400;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  font-weight: 400;
  letter-spacing: 0.005em;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: var(--ink);
  color: white;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand strong { display: block; font-size: 1.05rem; font-weight: 600; letter-spacing: 0.01em; }
.brand small { color: #c9d5d1; font-weight: 400; }
.mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--teal); font-weight: 600;
}
.menu-btn, button, .button {
  appearance: none;
  border: 0;
  background: var(--teal);
  color: white;
  min-height: 48px;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 10px;
  cursor: pointer;
}
.menu-btn {
  width: auto;
  min-width: 5.5rem;
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,.3);
  margin: 0;
}
.menu-btn[aria-expanded="true"] {
  background: rgba(255,255,255,.12);
}
button.secondary, .button.secondary { background: transparent; color: var(--teal-dark); border: 1px solid var(--line); }

/* Staff menu: closed by default; open as a left drawer so it never stacks the page. */
nav#nav[hidden],
nav#nav[hidden=""] {
  display: none !important;
}
nav#nav {
  display: none;
  position: fixed;
  top: 68px;
  left: 0;
  bottom: 0;
  z-index: 40;
  width: min(18rem, 86vw);
  margin: 0;
  padding: 8px 0 24px;
  overflow-y: auto;
  background: #20312e;
  box-shadow: 12px 0 32px rgba(20, 34, 31, 0.18);
}
nav#nav.is-open {
  display: grid;
  align-content: start;
}
nav#nav a {
  color: white;
  text-decoration: none;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-weight: 400;
}
nav#nav a:hover,
nav#nav a:focus-visible {
  background: rgba(255,255,255,.08);
}
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 68px 0 0;
  z-index: 30;
  background: rgba(20, 34, 31, 0.35);
  border: 0;
  padding: 0;
  margin: 0;
  width: auto;
  min-height: 0;
  border-radius: 0;
}
.nav-backdrop.is-open {
  display: block;
}
main { width: min(40rem, calc(100% - 28px)); margin: 22px auto 48px; }
h1 { font-size: 1.7rem; line-height: 1.15; margin: 0 0 8px; font-weight: 600; }
h2 { font-size: 1.15rem; margin: 28px 0 8px; font-weight: 600; }
p { line-height: 1.45; }
.lede { color: var(--muted); margin-top: 0; }
form.stack, form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-weight: 500; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
label.picker { margin-bottom: 8px; }
.field-hint { color: var(--muted); font-size: .88rem; font-weight: 400; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 400;
  background: white;
}
textarea { min-height: 96px; }
.flash { padding: 12px 14px; border-radius: 12px; background: #e7f5ee; }
.flash.bad { background: #fde8e8; color: var(--bad); }
.flash.ok { background: #e7f5ee; }
.errors { background: #fde8e8; color: var(--bad); border-radius: 12px; padding: 10px 16px; }
.waitlist { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; }
.waitlist li { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.row {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  background: var(--card); border-radius: 16px; padding: 14px;
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
}
.row span { display: grid; }
.row small { color: var(--muted); }
.edit { color: var(--teal-dark); font-weight: 600; }
.pill { border-radius: 999px; padding: 6px 10px; background: #f3e2c4; color: var(--amber); font-size: .85rem; white-space: nowrap; }
.pill.paid { background: #e5f6ea; color: var(--good); }
.pill.square-processing { background: #e4f1f8; color: #185a78; }
.redacted { display: grid; gap: 10px; background: var(--card); border-radius: 16px; padding: 14px; }
.redacted div { display: flex; justify-content: space-between; gap: 12px; }
.local-code { background: #fff4d6; border-radius: 12px; padding: 10px 12px; }
.audit { color: var(--muted); font-size: .92rem; }
.choices { padding-left: 18px; }
.history { padding-left: 18px; }
.actions { display: grid; gap: 8px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; }

/* Qualifier tree on institution page */
.qual-tree { margin-top: 36px; }
.tree-list, .tree-options {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.tree-qual, .tree-option {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
.tree-option { background: #faf7f0; }
.tree-options { margin: 10px 0 0 18px; gap: 8px; }
.tree-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
}
.drag-handle {
  cursor: grab;
  user-select: none;
  color: var(--muted);
  padding: 4px 2px;
  letter-spacing: -0.08em;
  font-size: 1rem;
  line-height: 1.2;
}
.tree-qual.dragging, .tree-option.dragging {
  opacity: 0.55;
}
.tree-list.drag-over, .tree-options.drag-over {
  outline: 2px dashed var(--teal);
  outline-offset: 4px;
  border-radius: 12px;
}
.tree-copy { display: grid; gap: 2px; }
.tree-copy strong { font-weight: 600; }
.tree-copy small { color: var(--muted); }
.tree-edit, .tree-add {
  margin-top: 8px;
}
.tree-edit summary, .tree-add summary {
  cursor: pointer;
  color: var(--teal-dark);
  font-weight: 500;
  margin-bottom: 8px;
}
.tree-edit form, .tree-add form {
  margin-top: 8px;
}

.pay-panel { margin-top: 28px; }
.pay-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pay-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  display: grid;
  gap: 4px;
}
.pay-item small { color: var(--muted); display: block; }
.pay-item a { color: var(--teal-dark); font-weight: 500; }

@media (min-width: 800px) {
  button, .button { width: auto; min-width: 180px; }
  .actions { grid-auto-flow: column; justify-content: start; }
}
