:root {
  --bg: #f5f3ee;
  --card: #ffffff;
  --ink: #102a3c;
  --soft: #5b6b78;
  --line: #e3e0d8;
  --navy: #0b2a43;
  --sea: #0f6b8f;
  --accent: #e4572e;
  --accent-ink: #ffffff;
  --good: #1f7a4d;
  --good-bg: #e5f4ec;
  --warn: #9a5b00;
  --warn-bg: #fdf1dc;
  --bad: #b3261e;
  --bad-bg: #fde8e6;
  --note-bg: #e8f2f7;
  --field: #fbfaf7;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1620;
    --card: #10222f;
    --ink: #e8eef2;
    --soft: #9aabb8;
    --line: #1f3546;
    --navy: #06121b;
    --sea: #5fb6d6;
    --accent: #f26a43;
    --good: #6fd39f;
    --good-bg: #123426;
    --warn: #f0b860;
    --warn-bg: #3a2a10;
    --bad: #ff8a80;
    --bad-bg: #3a1614;
    --note-bg: #12303f;
    --field: #0c1b26;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--sea); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--soft); margin-top: .5rem; }
small { font-size: .82em; }

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

/* Header */
.top { background: var(--navy); color: #fff; }
.top .wrap { padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.brand .mark { width: 30px; height: 30px; color: var(--accent); flex: none; }
.brand span { display: flex; flex-direction: column; min-width: 0; }
.brand b { font-size: 1rem; }
.brand small { color: #b8c7d3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

main { padding-top: 20px; padding-bottom: 40px; }
.foot { color: var(--soft); font-size: .8rem; padding-bottom: 32px; }

/* Hero */
.hero { padding: 8px 0 12px; }
.hero h1 { font-size: clamp(1.6rem, 6vw, 2.3rem); letter-spacing: -.01em; }
.lead { color: var(--soft); font-size: 1.05rem; max-width: 36em; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 8px; }
.page { font-size: 1.5rem; }
.page small { color: var(--soft); font-weight: 400; font-size: .6em; }
.eyebrow { color: var(--soft); font-size: .85rem; margin: 0 0 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 0 0 14px;
}
.card.flush { padding: 0; overflow: hidden; }
.card .pad { padding: 18px 18px 6px; }
.card.ok { border-color: var(--good); }
fieldset.card { min-width: 0; }
legend { font-weight: 700; font-size: 1.05rem; padding: 0 6px; margin-left: -6px; }
legend small { font-weight: 400; color: var(--soft); }
.hint { color: var(--soft); font-size: .88rem; margin: -4px 0 4px; }
.narrow { max-width: 480px; margin: 0 auto; }
.muted { color: var(--soft); }
.small { font-size: .85rem; }
.center { text-align: center; }

.note, .alert {
  border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; font-size: .92rem;
  background: var(--note-bg);
}
.note.demo { background: var(--warn-bg); color: var(--warn); }
.alert { background: var(--bad-bg); color: var(--bad); }
.waiting::before { content: ""; display: inline-block; width: .7em; height: .7em; border-radius: 50%; background: var(--sea); margin-right: 8px; animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .25; } }

.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--line); color: var(--soft); }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--sea); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.block { display: flex; width: 100%; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: .85rem; }
form + .btn, .card > form { margin-top: 10px; }

/* Fee lists */
.tiers, .items, .lines, .people { list-style: none; margin: 0; padding: 0; }
.tiers li, .items li, .lines li {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.tiers li:first-child, .items li:first-child, .lines li:first-child { border-top: 0; }
.tiers li > span:first-child, .items li > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.tiers small, .items small { color: var(--soft); }
.amt { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; display: flex; flex-direction: column; }
.tiers li { position: relative; }
.tiers li.now { background: var(--note-bg); margin: 0 -10px; padding: 10px; border-radius: 10px; border-top-color: transparent; }
.tiers li.now + li { border-top-color: transparent; }
.tiers em { position: absolute; top: -8px; left: 10px; font-style: normal; font-size: .7rem; font-weight: 700; background: var(--sea); color: #fff; border-radius: 6px; padding: 0 6px; }
.lines li { padding: 6px 0; border-top: 0; font-size: .95rem; }
.lines li span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); padding-top: 10px; margin: 8px 0 12px; }
.total b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.people li { display: inline-flex; flex-direction: column; margin: 0 24px 6px 0; font-weight: 600; }
.people small { color: var(--soft); font-weight: 400; }

/* Form */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > span { font-size: .88rem; font-weight: 600; }
.field > span small { font-weight: 400; color: var(--soft); }
input, textarea, select {
  font: inherit; color: var(--ink); background: var(--field);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--sea); outline-offset: 0; border-color: transparent; }
.field.bad input, .field.bad textarea { border-color: var(--bad); }
.field em, .err { color: var(--bad); font-style: normal; font-size: .82rem; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .88rem; color: var(--soft); margin-top: 12px; }
.check input { width: 20px; height: 20px; min-height: 0; flex: none; margin-top: 2px; accent-color: var(--accent); }
.check.bad span { color: var(--bad); }
form.inline { display: flex; gap: 10px; align-items: flex-end; }
form.inline .field { flex: 1; }

/* Extras */
.xgroup + .xgroup { margin-top: 10px; }
.xitem { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.xitem:has(.sizes) { flex-wrap: wrap; }
.xitem:has(.sizes) .xlabel { flex-basis: 100%; }
.xgroup h3 + .xitem { border-top: 0; }
.xitem.out { opacity: .6; }
.xlabel { display: flex; flex-direction: column; min-width: 0; flex: 1 1 0; }
.xlabel small { color: var(--soft); }
.xlabel small.amt { display: block; text-align: left; color: var(--ink); font-weight: 600; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--field); flex: none; }
.stepper button { width: 40px; height: 40px; border: 0; background: transparent; color: var(--ink); font-size: 1.2rem; cursor: pointer; }
.stepper button:active { background: var(--line); }
.stepper input { width: 44px; min-height: 40px; border: 0; border-radius: 0; text-align: center; padding: 0; background: transparent; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.sizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 8px 16px; flex: 1 1 100%; min-width: 0; }
.sizes label { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; font-weight: 600; font-size: .9rem; }
.sizes label > span:first-child { min-width: 2.4em; }

/* Two columns: the form and a sticky total */
.twocol { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.summary { position: sticky; top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.paybar { display: none; }

/* Tables */
.tablewrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
.list th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--soft); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list tr:last-child td { border-bottom: 0; }
.list .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list tr.withdrawn td { opacity: .5; }
.list tr.pending td:first-child { box-shadow: inset 3px 0 var(--warn); }
.acts { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.mini { display: flex; gap: 6px; }
.mini input { min-height: 34px; padding: 4px 8px; width: 110px; font-size: .85rem; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; min-width: 0; }
.tile small { color: var(--soft); }
.tile b { font-size: 1.3rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile b.warn { color: var(--warn); }

details.edit summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
details.edit summary::-webkit-details-marker { display: none; }
details.edit summary::after { content: "Change"; color: var(--sea); font-weight: 600; font-size: .9rem; }
details.edit[open] summary::after { content: "Close"; }
details.edit summary h2 { margin: 0; }
details.edit form { margin-top: 14px; }
details.edit fieldset.card { border: 0; padding: 0; margin: 16px 0; }
details.edit .field.wide { margin-bottom: 14px; }

@media (max-width: 900px) {
  .twocol { grid-template-columns: minmax(0, 1fr); }
  .summary { display: none; }
  .paybar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
    justify-content: space-between; align-items: center; gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(0,0,0,.08);
  }
  .paybar span { display: flex; flex-direction: column; line-height: 1.15; }
  .paybar small { color: var(--soft); }
  .paybar .btn { padding: 0 14px; flex: 0 1 auto; min-width: 0; }
  .paybar b { font-size: 1.15rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
  form.twocol { padding-bottom: 70px; }
  .tiles { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .hide-s { display: none; }
  .card { padding: 16px 14px; }
  form.inline { flex-direction: column; align-items: stretch; }
  .actions .btn { flex: 1 1 auto; }
  .list th, .list td { padding: 9px 8px; }
  .tile b { font-size: 1.1rem; white-space: nowrap; }
  /* The organiser's boats: one block per boat, actions underneath */
  .boats thead { display: none; }
  .boats tr { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) minmax(0, 1.2fr) auto; border-bottom: 1px solid var(--line); padding: 4px 0; }
  .boats td { border: 0; }
  .boats td.acts { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 0; }
  .boats .mini input { width: 100px; }
}
