/* Fee register: paper, ink, and red only where money is owed. */
:root {
  --bg: #f6f3ec;
  --surface: #fffdf8;
  --raised: #efe9df;
  --border: rgba(31, 27, 22, .10);
  --text: #1f1b16;
  --secondary: #5e554a;
  --muted: #7b7266;

  --accent: #27457f;          /* ink: fills, with --accent-text on top */
  --accent-text: #ffffff;
  --accent-ink: #27457f;      /* ink as text on the page */
  --red: #a2231d;             /* arrears only, never decoration */
  --red-edge: rgba(162, 35, 29, .38);

  --r-cell: 6px;
  --r-control: 10px;
  --r-card: 14px;
  --shadow: 0 1px 2px rgba(31, 27, 22, .05);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, 0, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #1c1a18;
    --raised: #262421;
    --border: rgba(239, 233, 222, .10);
    --text: #efe9de;
    --secondary: #aaa398;
    --muted: #8a847a;

    --accent: #3a5ca8;
    --accent-ink: #9db6ec;
    --red: #ef8d84;
    --red-edge: rgba(239, 141, 132, .42);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent-ink); }

/* Figures are the content of a register, so they are set like one. */
.fig { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* ---------------------------------------------------------- chrome */

header.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

header.bar h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
header.bar .spacer { flex: 1; }
header.bar a { font-size: 13px; text-decoration: none; color: var(--secondary); }
header.bar a:hover, header.bar a[aria-current="page"] { color: var(--text); }

nav.tabs {
  display: flex;
  gap: 4px;
  padding: 0 12px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

nav.tabs a {
  flex: 1 1 0;
  min-width: 0;
  padding: 7px 4px;
  border-radius: var(--r-cell);
  font-size: 13px;
  text-align: center;
  text-decoration: none;
  color: var(--secondary);
  white-space: nowrap;
  transition: background-color .12s var(--ease), color .12s var(--ease);
}

nav.tabs a:hover { background: var(--raised); }
nav.tabs a[aria-current="page"] { background: var(--raised); color: var(--text); font-weight: 500; }

main { max-width: 760px; margin: 0 auto; padding: 16px; }

/* ---------------------------------------------------------- surfaces */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.card h2 { margin: 0 0 12px; font-size: 14px; font-weight: 500; color: var(--secondary); }

/* ---------------------------------------------------------- controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--r-control);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .12s var(--ease), border-color .12s var(--ease);
}

.btn:active { transform: scale(.995); }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font-size: 17px; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--raised); }
.btn.quiet, .btn.danger {
  min-height: 32px;
  padding: 0 12px;
  background: transparent;
  border-color: var(--border);
  font-size: 13px;
  font-weight: 400;
}
.btn.quiet { color: var(--secondary); }
.btn.danger { color: var(--red); }
.btn.quiet:hover, .btn.danger:hover { background: var(--raised); }

label { display: block; font-size: 13px; font-weight: 500; color: var(--secondary); margin-bottom: 4px; }

input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  background: var(--raised);
  color: var(--text);
  font: inherit;
}

input:focus-visible, select:focus-visible, textarea:focus-visible,
.btn:focus-visible, nav.tabs a:focus-visible, .list a:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
}

.field { margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }

/* The CSP forbids inline style attributes, so spacing one-offs live here. */
.gap-b { margin-bottom: 16px; }
.gap-t { margin-top: 16px; }
.filter { margin-bottom: 12px; }
input.fee { max-width: 120px; text-align: right; }

/* ---------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 400; }
td.num, th.num { text-align: right; }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 14px; }
tr:last-child td { border-bottom: 0; }
td .owed { color: var(--red); }

@media (max-width: 430px) {
  th, td { padding: 10px 4px; font-size: 14px; }
  .hide-narrow { display: none; }
}

/* ---------------------------------------------------------- lists */

.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }

.list a, .list .item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  text-decoration: none;
  color: inherit;
  border-radius: var(--r-cell);
  transition: background-color .12s var(--ease);
}

.list a:hover { background: var(--raised); }
.list .who { flex: 1; min-width: 0; }
.list .who strong { display: block; font-weight: 500; }
.list .who span { font-size: 13px; color: var(--muted); }

/* A balance is a figure, not a badge. Red is the only signal. */
.owed, .settled {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}

.owed { color: var(--red); }
.settled { color: var(--muted); }

/* A receipt is a block, so every action stays on a phone's screen. */
.receipt { padding: 12px 4px; }
.receipt .top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.receipt .amt { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 16px; font-weight: 500; }
.receipt .when { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.receipt .meta { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.receipt .acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.receipt .acts form { margin: 0; }

/* A job still to do, in ink. Red stays reserved for money owed. */
.todo { flex: 0 0 auto; font-size: 13px; color: var(--accent-ink); }

/* ------------------------------------------- the ledger strip (signature) */

.ledger { display: flex; flex-wrap: wrap; gap: 4px; }

.ledger .cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 60px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--r-cell);
  background: var(--raised);
  font-size: 12px;
  color: var(--muted);
}

.ledger .cell b { font-weight: 500; color: var(--secondary); }
.ledger .cell .amt { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 11px; }

/* Owed months are ruled in red ink and nothing else on the screen is. */
.ledger .cell.owing { background: transparent; border-color: var(--red-edge); color: var(--red); }
.ledger .cell.owing b { color: var(--red); }

.muted { color: var(--muted); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 32px 8px; font-size: 14px; }

.flash {
  padding: 12px;
  border-radius: var(--r-control);
  margin-bottom: 16px;
  font-size: 14px;
  background: var(--raised);
  color: var(--secondary);
  border: 1px solid var(--border);
}

.flash.error { color: var(--red); border-color: var(--red-edge); background: transparent; }

/* ---------------------------------------------------------- attendance */

.check {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  margin: 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.check:last-of-type { border-bottom: 0; }
.check input[type="checkbox"] { width: 24px; height: 24px; min-height: 0; flex: 0 0 auto; accent-color: var(--accent); }
.check .avatar { width: 32px; height: 32px; font-size: 12px; }
.check .nm { font-size: 16px; flex: 1; min-width: 0; }
.check:has(input:not(:checked)) .nm { color: var(--muted); text-decoration: line-through; }

/* Live "N of 15 present" with no JavaScript: count the checked boxes. */
form.roster { counter-reset: present; }
.roster .check input:checked { counter-increment: present; }
.roster .count::after { content: counter(present); }

.sticky-save {
  position: sticky;
  bottom: 0;
  padding: 12px 0;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}

.center-box { max-width: 360px; margin: 96px auto; padding: 0 16px; }

/* ---------------------------------------------------------- avatars */

.avatar {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--raised);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.person { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.person h2 { margin: 0; font-size: 18px; font-weight: 500; color: var(--text); }
.person p { margin: 2px 0 0; }

/* ------------------------------------------- dashboard: the two figures */

.balances {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
}

/* Inside a card the figures are already on a surface: no second box. */
.card .balances { padding: 0; margin: 0 0 16px; background: none; border: 0; box-shadow: none; }

.balances .label { display: block; font-size: 13px; color: var(--secondary); }
.balances .big {
  display: block;
  margin-top: 4px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.balances .big.owing { color: var(--red); }
.balances .sub { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }

.collected {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  padding: 0 4px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--muted);
}

.collected strong { color: var(--text); font-weight: 400; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ------------------------------------------- collect: the figure being written */

.amount-hero { text-align: center; padding: 4px 0 20px; }
.amount-hero label { display: block; margin-bottom: 8px; }
.amount-hero .sub { margin: 8px 0 0; font-size: 14px; color: var(--muted); }

.amount-input { display: flex; align-items: baseline; justify-content: center; gap: 4px; }
.amount-input span { font-size: 24px; color: var(--muted); }

.amount-input input {
  width: 8ch;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -.02em;
  text-align: left;
}

.amount-input input:focus { outline: 0; }
.amount-input:focus-within { box-shadow: inset 0 -1px 0 var(--accent-ink); }

/* ---------------------------------------------------------- method */

.methods { border: 0; padding: 0; margin: 0 0 16px; }
.methods legend { padding: 0; margin-bottom: 4px; font-size: 13px; font-weight: 500; color: var(--secondary); }
.method-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.method { position: relative; margin: 0; }
.method input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; }

.method span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  background: var(--surface);
  cursor: pointer;
  transition: background-color .12s var(--ease), border-color .12s var(--ease);
}

/* Chosen is a surface step and an ink hairline, so the one filled button stays the primary action. */
.method input:checked + span { border-color: var(--accent-ink); background: var(--raised); font-weight: 500; }
.method input:focus-visible + span { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
