:root {
  --ground: #ffffff;
  --surface: #f5f6f4;
  --raised: #ffffff;
  --border: #e6e7e4;
  --rule: #eff0ed;
  --control: #d3d5d0;
  --text: #1f201d;
  --muted: #5c5d5a;
  --accent: #1b6e66;
  --accent-ink: #ffffff;
  --accent-tint: #e3f0ee;
  --negative: #b42318;
  --pill-positive-bg: #dcfae5; --pill-positive-ink: #04250e;
  --pill-negative-bg: #fdecea; --pill-negative-ink: #7a1d14;
  --pill-warning-bg: #fffbeb; --pill-warning-ink: #92400e;
  --pill-neutral-bg: #eceeea; --pill-neutral-ink: #3d3d3a;
  --radius-card: 22px;
  --radius-row: 14px;
  --radius-control: 999px;
  --gap: 16px;
  --pad: 20px;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Instrument Sans", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--text); font: 400 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.top { max-width: 1132px; margin: 0 auto; padding: 18px 16px; display: flex; align-items: center; justify-content: space-between; gap: var(--gap); }
.brand { font: 400 26px/1 var(--serif); color: var(--text); text-decoration: none; }
.who { color: var(--muted); }
form.inline { display: flex; align-items: center; gap: 12px; margin: 0; }

main { max-width: 1132px; margin: 0 auto; padding: 24px 16px 96px; }
.narrow .top, .narrow main { max-width: 792px; }

h1 { font: 400 48px/1.05 var(--serif); letter-spacing: -0.01em; margin: 8px 0 12px; }
h2 { font-size: 18px; font-weight: 600; line-height: 1.3; margin: 40px 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 24px 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.crumbs { margin: 0 0 4px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a::before { content: "← "; }
.crumbs a:hover { color: var(--text); }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.motion { font: 400 30px/1.2 var(--serif); margin: 4px 0 12px; }
.narrow h1 { font-size: 40px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.stack { display: flex; flex-direction: column; gap: 14px; margin: 16px 0; }
.stack label, label.block { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
input, select, textarea { font: 400 16px/1.4 var(--sans); padding: 10px 14px; border: 1px solid var(--control); border-radius: 12px; background: var(--raised); color: var(--text); width: 100%; }
input:hover, select:hover, textarea:hover { border-color: #b9bbb5; }
select { width: auto; }
textarea { min-height: 120px; resize: vertical; }

button, .button { font: 500 15px/1 var(--sans); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: var(--radius-control); border: 0; background: var(--text); color: #fff; cursor: pointer; text-decoration: none; transition: background-color .15s, transform .1s; }
button:hover, .button:hover { background: #3a3b37; }
button:active, .button:active { transform: scale(.98); }
button.secondary, .button.secondary { background: var(--pill-neutral-bg); color: var(--text); }
button.secondary:hover, .button.secondary:hover { background: #e0e2dd; }
button.danger { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
button.danger:hover { background: #f9d9d5; }
button.link { background: none; color: var(--text); padding: 0 4px; min-height: 0; text-decoration: underline; text-underline-offset: 3px; }
button.link:hover { background: none; color: var(--accent); }

.alert { background: var(--pill-negative-bg); color: var(--pill-negative-ink); padding: 12px 16px; border-radius: var(--radius-row); margin: 16px 0; }
.alert ul { margin: 0; padding-left: 18px; }
.notice { background: var(--accent-tint); color: #0d3b36; padding: 14px 18px; border-radius: var(--radius-row); margin: 16px 0; }

.badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 500; line-height: 1; padding: 5px 10px; border-radius: var(--radius-control); background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); white-space: nowrap; }

.cards, .rows { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-direction: column; gap: 8px; }
.cards li, .rows li, .panel, .bubble { background: var(--surface); border-radius: var(--radius-row); padding: 14px 18px; }
.cards li { display: flex; flex-direction: column; gap: 2px; }
.cards li a { font-weight: 600; }
.rows li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; min-height: 63px; }
.bubble { margin: 8px 0; max-width: 85%; }
.bubble.counselor { background: var(--accent-tint); margin-left: auto; }

.code, .receipt { font-family: var(--sans); font-variant-numeric: tabular-nums; font-weight: 600; }
.code { background: var(--surface); padding: 4px 10px; border-radius: 8px; letter-spacing: .04em; }
.receipt { font-size: 28px; letter-spacing: .06em; text-align: center; padding: 24px; background: var(--accent-tint); color: #0d3b36; border-radius: var(--radius-card); overflow-wrap: anywhere; }

.tally { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tally th, .tally td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--rule); }
.tally th { font-weight: 500; color: var(--muted); }
.tally td:not(:first-child), .tally th:not(:first-child) { text-align: right; }

.greeting { margin: 24px 0 40px; }
.greeting h1 { margin: 0 0 8px; }
.greeting p { color: var(--muted); font-size: 16px; max-width: 640px; }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-9 { grid-column: span 9; }

.tile { display: flex; flex-direction: column; justify-content: space-between; min-height: 140px; padding: 18px 20px; background: var(--surface); border-radius: var(--radius-card); color: var(--text); text-decoration: none; transition: background-color .15s, transform .1s; }
.tile:hover { background: #ebece9; }
.tile:active { transform: scale(.99); }
.tile-label { font-weight: 600; }
.tile-value { font-size: 32px; line-height: 1.1; font-variant-numeric: tabular-nums; margin: 10px 0 4px; }
.tile-caption { color: var(--muted); font-size: 14px; }

.box { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius-card); padding: var(--pad); }
.box .box-foot { margin-top: auto; padding-top: 14px; }
.box-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.box-head h2 { margin: 0; font-size: 15px; }
.box .rows { margin: 0; }
.box .rows li { background: var(--raised); }
.box .stack { margin: 0; }
.box .stack textarea { min-height: 96px; }
.list-link { display: block; color: var(--text); text-decoration: none; font-weight: 500; }
.list-link:hover { color: var(--accent); }
.empty { color: var(--muted); margin: 0; }

.roles { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); margin: 0 0 24px; padding: 0; list-style: none; }
.roles li { grid-column: span 4; }
.roles li:last-child { grid-column: span 12; }
.roles form { margin: 0; height: 100%; }
.role { width: 100%; height: 100%; min-height: 128px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 18px 20px; border-radius: var(--radius-card); background: var(--surface); color: var(--text); text-align: left; line-height: 1.4; }
.role:hover { background: #ebece9; }
.role-name { font-size: 20px; font-weight: 600; }
.role-does { color: var(--muted); font-weight: 400; }
.role-as { font-size: 14px; font-weight: 500; color: var(--accent); }
.role.operator { background: var(--accent-tint); }
.role.operator:hover { background: #d3e8e4; }

@media (max-width: 860px) {
  .span-3 { grid-column: span 6; }
  .span-4, .span-6, .span-8, .span-9 { grid-column: span 12; }
  .roles li { grid-column: span 6; }
  .roles li:last-child { grid-column: span 12; }
}
@media (max-width: 560px) {
  h1, .narrow h1 { font-size: 32px; }
  .motion { font-size: 22px; }
  .greeting { margin: 8px 0 28px; }
  .tile { min-height: 120px; padding: 16px; }
  .tile-value { font-size: 26px; }
  .roles li { grid-column: span 12; }
  .role { min-height: 0; }
  .top { padding: 14px 16px; }
  .who { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
