/* Right for Life — one stylesheet for the website, the app and the admin area.
   Mobile-first, 48 px touch targets, light and dark through CSS variables. No inline styles anywhere (CSP). */

:root {
  --primary: #101a4a;
  --primary-ink: #ffffff;
  --accent: #d81b60;
  --accent-ink: #ffffff;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --ink: #15192b;
  --ink-2: #5b6177;
  --line: #d9dde8;
  --good: #1e7e46;
  --good-bg: #e6f4ec;
  --warn: #9a6400;
  --warn-bg: #fff4dc;
  --bad: #b3261e;
  --bad-bg: #fde8e6;
  --info-bg: #e8edff;
  --choice-bg: #fff1d6;   /* the notification-choices card has its own distinct colour */
  --choice-line: #e3a93a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 26, 74, 0.08), 0 4px 16px rgba(16, 26, 74, 0.06);
  --tap: 48px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1220;
    --surface: #181c2e;
    --surface-2: #222742;
    --ink: #eef0f8;
    --ink-2: #a3a9c2;
    --line: #353b57;
    --good-bg: #16331f;
    --warn-bg: #3a2c08;
    --bad-bg: #40191a;
    --info-bg: #1e2550;
    --choice-bg: #3b2d0f;
    --choice-line: #c9952f;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.45; color: var(--ink); background: var(--bg); min-height: 100vh; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); }
small, .muted { color: var(--ink-2); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- Layout ---------------------------------------------------------------- */
.topbar { background: var(--primary); color: var(--primary-ink); position: sticky; top: 0; z-index: 20; }
.topbar .inner { display: flex; align-items: center; gap: .5rem; min-height: 56px; padding: 0 .75rem; max-width: 1100px; margin: 0 auto; }
.topbar .brand { font-weight: 700; font-size: 1.05rem; color: var(--primary-ink); text-decoration: none; display: flex; align-items: center; gap: .5rem; flex: 1; min-width: 0; }
.topbar .brand img { height: 32px; width: auto; }
.topbar .title { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar button, .topbar a.icon { background: transparent; border: 0; color: var(--primary-ink); min-width: var(--tap); min-height: var(--tap); display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem; border-radius: 8px; text-decoration: none; position: relative; }
.topbar button:active { background: rgba(255, 255, 255, 0.15); }
.badge { position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: .72rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.page { max-width: 1100px; margin: 0 auto; padding: 1rem .75rem 5rem; }
.page.narrow { max-width: 520px; }
.layout { display: grid; gap: 1rem; }
@media (min-width: 900px) { .layout.two { grid-template-columns: 1fr 1fr; } .layout.three { grid-template-columns: repeat(3, 1fr); } }

/* ---- Cards ---------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.tight { padding: .75rem; }
.card.accent { border-left: 4px solid var(--accent); }
.card.choice { background: var(--choice-bg); border: 2px solid var(--choice-line); }
.card.info { background: var(--info-bg); }
.row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: .5rem; }
.grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stat { background: var(--surface-2); border-radius: 10px; padding: .75rem; }
.stat .n { font-size: 1.4rem; font-weight: 700; }
.stat .l { color: var(--ink-2); font-size: .85rem; }

/* ---- Buttons and inputs ------------------------------------------------------ */
button, .btn { font: inherit; font-weight: 600; min-height: var(--tap); padding: 0 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-decoration: none; }
button:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; }
.btn.primary, button.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.accent, button.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger, button.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost, button.ghost { background: transparent; }
.btn.block, button.block { width: 100%; }
.btn.small, button.small { min-height: 40px; padding: 0 .75rem; font-size: .9rem; }
.chip { display: inline-flex; align-items: center; min-height: 32px; padding: 0 .6rem; border-radius: 16px; background: var(--surface-2); font-size: .85rem; font-weight: 600; }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--primary); }
label { display: block; font-weight: 600; margin-bottom: .25rem; font-size: .95rem; }
.field { margin-bottom: .9rem; }
.field .help { color: var(--ink-2); font-size: .85rem; margin-top: .25rem; }
input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="search"], select, textarea {
  font: inherit; width: 100%; min-height: var(--tap); padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.check { display: flex; align-items: flex-start; gap: .75rem; min-height: var(--tap); padding: .5rem 0; cursor: pointer; font-weight: 500; }
.check input { width: 24px; height: 24px; margin: 2px 0 0; flex: none; accent-color: var(--primary); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: var(--tap); padding: .4rem 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.switch input { width: 24px; height: 24px; accent-color: var(--primary); flex: none; }
.amounts { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.amounts button { flex: 1; min-width: 80px; }
.amounts button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* ---- Progress, lists, tables ---------------------------------------------------- */
.progress { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 5px; transition: width .3s; }
.progress.done > div { background: var(--good); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .6rem 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: .75rem; align-items: center; min-height: var(--tap); }
.list li:last-child { border-bottom: 0; }
.list li.unread { font-weight: 600; }
.list .main { flex: 1; min-width: 0; }
.list .main .sub { color: var(--ink-2); font-size: .85rem; font-weight: 400; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
th { color: var(--ink-2); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
td.wrap, th.wrap { white-space: normal; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--surface-2); }

/* ---- Tabs, nav, menu ---------------------------------------------------------------- */
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a, .tabs button { flex: none; min-height: var(--tap); padding: 0 .9rem; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--ink-2); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; border-radius: 0; }
.tabs a.active, .tabs button.active { color: var(--primary); border-bottom-color: var(--accent); }
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); display: flex; z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav a { flex: 1; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .72rem; color: var(--ink-2); text-decoration: none; font-weight: 600; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a span.ico { font-size: 1.3rem; }
@media (min-width: 900px) { .bottom-nav { display: none; } .page { padding-bottom: 2rem; } }
.admin-shell { display: grid; min-height: 100vh; }
@media (min-width: 900px) { .admin-shell { grid-template-columns: 250px 1fr; } }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: .75rem; }
.side .section { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); margin: .75rem .5rem .25rem; display: flex; justify-content: space-between; align-items: center; cursor: pointer; min-height: 36px; }
.side a { display: flex; align-items: center; gap: .6rem; min-height: 44px; padding: 0 .6rem; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; }
.side a.active { background: var(--info-bg); color: var(--primary); font-weight: 700; }
.side .ico { width: 24px; text-align: center; }
.side.collapsed .items { display: none; }
@media (max-width: 899px) { .side { display: none; } .side.open { display: block; position: fixed; inset: 56px 0 0 0; z-index: 30; overflow: auto; } }

/* ---- Messages, toasts, dialogs ------------------------------------------------------- */
.note { padding: .75rem .9rem; border-radius: 10px; margin-bottom: .9rem; border: 1px solid transparent; }
.note.good { background: var(--good-bg); color: var(--good); }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.bad { background: var(--bad-bg); color: var(--bad); }
.note.info { background: var(--info-bg); }
.banner { background: var(--warn-bg); color: var(--warn); padding: .5rem .75rem; display: flex; align-items: center; gap: .75rem; }
.banner .grow { flex: 1; }
.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: .75rem 1rem; border-radius: 10px; z-index: 50; box-shadow: var(--shadow); max-width: 90vw; }
.toast.bad { background: var(--bad); color: #fff; }
dialog { border: 0; border-radius: var(--radius); padding: 1rem; max-width: 520px; width: calc(100vw - 2rem); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.gallery { display: flex; gap: .5rem; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: .5rem; }
.gallery > * { flex: none; scroll-snap-align: start; width: 85%; max-width: 420px; aspect-ratio: 4 / 3; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.gallery iframe { border: 0; }
.receipt { background: #fff; color: #111; padding: 1.5rem; border: 1px solid #ccc; border-radius: 8px; max-width: 640px; margin: 0 auto; }
.receipt h1 { font-size: 1.3rem; }
.receipt table td { white-space: normal; border-bottom: 1px solid #e5e5e5; }
.spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hero { background: var(--primary); color: var(--primary-ink); padding: 2.5rem 1rem; text-align: center; }
.hero h1 { font-size: 1.8rem; }
.hero p { opacity: .9; max-width: 560px; margin: .5rem auto 1rem; }
.hero .row { justify-content: center; }
.hero .btn { border-color: transparent; }
.qr { width: 220px; height: 220px; image-rendering: pixelated; display: block; margin: .5rem auto; background: #fff; padding: 8px; border-radius: 8px; }
.code-list { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1rem; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .75rem; }
.app-only { display: none; }
body.app .app-only { display: initial; }
body.app .web-only { display: none !important; }
body.app .topbar .inner { min-height: 52px; }
.pull-hint { text-align: center; color: var(--ink-2); font-size: .85rem; padding: .25rem; }
/* ---- Public pages and the member area (small extras) ----------------------------- */
.hero img.logo { width: 72px; height: 72px; border-radius: 16px; display: block; margin: 0 auto 1rem; }
.site-foot { text-align: center; color: var(--ink-2); font-size: .9rem; padding: 1.5rem 1rem 2rem; }
.site-foot a { margin: 0 .5rem; }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--primary); }
.pre { white-space: pre-line; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.actions > * { flex: 1 1 auto; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.photo { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.notice-pic { width: 100%; max-height: 220px; object-fit: cover; border-radius: 10px; margin-top: .5rem; }
.answer button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
details.past > summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.centre { text-align: center; }
@media print {
  .topbar, .bottom-nav, .no-print, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .page { padding: 0; }
  .receipt { border: 0; }
}
