/* 100+ Club. Big, clear and calm (brief §2): 18px minimum text, 48px buttons,
   strong contrast, a visible focus ring. Colours come from the organisation's
   settings via the custom properties set in base.html. */
@font-face { font-family: "Atkinson Hyperlegible"; src: url("../fonts/AtkinsonHyperlegible-Regular.43b63ccfb94f.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("../fonts/AtkinsonHyperlegible-Bold.4de508efffb2.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --primary: #29498D; --secondary: #79ABDB; --accent: #D8137C;
  --text: #14213d; --muted: #3f4a5e; --bg: #f5f7fb; --surface: #fff; --border: #b8c3d6;
  --paid: #1d6b34; --paid-bg: #dff3e4;
  --due: #7a4b00; --due-bg: #fff0c2;
  --grace: #8a3c00; --grace-bg: #ffe0c7;
  --release: #9b1c1c; --release-bg: #fde0e0;
  --free: #34495e; --free-bg: #eef1f5;
  --radius: 10px;
  --focus: #ffbf47;
}
* { box-sizing: border-box; }
html { font-size: 112.5%; } /* 18px */
body { margin: 0; font-family: "Atkinson Hyperlegible", Arial, sans-serif; line-height: 1.5; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 7px var(--text); border-radius: 4px; }
h1, h2, h3 { color: var(--primary); line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; max-width: 46em; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--focus); color: #000; padding: 12px 16px; z-index: 10; }
.skip-link:focus { left: 8px; }

/* Header and the five big navigation buttons */
.site-header { background: var(--primary); color: #fff; }
.site-header .inner { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.brand img { height: 44px; background: #fff; border-radius: 6px; padding: 3px 6px; }
.account { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .95rem; }
.account a, .account button { color: #fff; }
.link-button { background: none; border: none; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; min-height: 0; }
.main-nav { background: #fff; border-bottom: 3px solid var(--secondary); }
.main-nav ul { list-style: none; margin: 0 auto; padding: 8px 16px; max-width: 1100px; display: flex; gap: 8px; flex-wrap: wrap; }
.main-nav a { display: inline-flex; align-items: center; min-height: 52px; padding: 0 20px; border-radius: var(--radius); font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--primary); border: 2px solid transparent; }
.main-nav a:hover { background: var(--free-bg); }
.main-nav a[aria-current="page"] { background: var(--primary); color: #fff; }
.main-nav .settings-link { margin-left: auto; font-size: 1rem; font-weight: 400; }
.demo-banner { background: #9b1c1c; color: #fff; text-align: center; padding: 8px 16px; font-weight: 700; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.narrow { max-width: 760px; }

/* Buttons: at least 48px tall, always with words */
.button, button, input[type=submit] {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 10px 24px; border-radius: var(--radius);
  font: inherit; font-weight: 700; font-size: 1.05rem; line-height: 1.2; text-align: center;
  background: var(--primary); color: #fff; border: 2px solid var(--primary); cursor: pointer; text-decoration: none;
}
.button:hover, button:hover { filter: brightness(1.12); }
.button.secondary, button.secondary { background: #fff; color: var(--primary); }
.button.danger, button.danger { background: var(--release); border-color: var(--release); }
.button.big, button.big { min-height: 72px; font-size: 1.25rem; padding: 14px 30px; }
.button.small, button.small { min-height: 48px; padding: 6px 16px; font-size: 1rem; }
.button-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 20px 0; align-items: center; }
.button-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 16px 0 24px; }
.button-grid .button { justify-content: flex-start; text-align: left; }

/* Today */
.todo-list { list-style: none; padding: 0; margin: 0 0 32px; display: grid; gap: 12px; }
.todo-list a, .todo-list .todo { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 18px 22px; min-height: 72px; background: var(--surface); border: 2px solid var(--border); border-left: 10px solid var(--secondary); border-radius: var(--radius); font-size: 1.15rem; font-weight: 700; text-decoration: none; color: var(--text); }
.todo-list a:hover { border-color: var(--primary); }
.todo-list .todo-go { margin-left: auto; color: var(--primary); white-space: nowrap; }
.todo-list .urgent { border-left-color: var(--accent); }
.todo-list .calm { border-left-color: var(--paid); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 18px; text-align: center; }
.stat strong { display: block; font-size: 2.8rem; color: var(--primary); line-height: 1.1; }

/* Cards and tables */
.card { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; }
.card h2 { margin-bottom: .4em; }
.card.highlight { border-color: var(--primary); }
.card.warning { border-color: var(--due); background: var(--due-bg); }
.card.danger { border-color: var(--release); background: var(--release-bg); }
dl.details { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 6px 16px; margin: 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; font-weight: 700; }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); }
table.list th, table.list td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.list th { color: var(--muted); font-weight: 700; font-size: .95rem; }
table.list tr.ended td { color: var(--muted); }
.table-wrap { overflow-x: auto; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

/* Status badges: colour plus a word, never colour alone */
.badge { display: inline-block; padding: 3px 12px; border-radius: 999px; font-weight: 700; font-size: .92rem; border: 2px solid currentColor; white-space: nowrap; }
.badge-paid { color: var(--paid); background: var(--paid-bg); }
.badge-due_soon { color: var(--due); background: var(--due-bg); }
.badge-in_grace { color: var(--grace); background: var(--grace-bg); }
.badge-to_be_released { color: var(--release); background: var(--release-bg); }
.badge-ended, .badge-free { color: var(--free); background: var(--free-bg); }
.badge-paid::before { content: "✓ "; }
.badge-to_be_released::before { content: "! "; }

/* Forms */
.field { margin-bottom: 22px; }
.field > label, .field legend { display: block; font-weight: 700; margin-bottom: 6px; font-size: 1.05rem; }
.field .help { color: var(--muted); margin: -2px 0 8px; font-size: .95rem; }
fieldset { border: none; padding: 0; margin: 0; }
input[type=text], input[type=email], input[type=number], input[type=password], input[type=date], input[type=search], input[type=tel], select, textarea {
  width: 100%; max-width: 32em; font: inherit; padding: 12px 14px; min-height: 52px; border: 2px solid var(--muted); border-radius: 8px; background: #fff; color: var(--text);
}
textarea { min-height: 100px; }
input[type=color] { width: 80px; height: 52px; border: 2px solid var(--muted); border-radius: 8px; padding: 2px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--release); border-width: 3px; }
.error-text { color: var(--release); font-weight: 700; margin: 0 0 8px; }
.error-text::before { content: "⚠ "; }
.radio-list, .check { display: grid; gap: 10px; }
.radio-list label, .check label { display: flex; gap: 12px; align-items: center; padding: 12px 16px; min-height: 52px; border: 2px solid var(--border); border-radius: 8px; background: #fff; font-weight: 400; cursor: pointer; max-width: 32em; }
.radio-list input, .check input { width: 26px; height: 26px; flex: none; accent-color: var(--primary); }
.radio-list label:has(input:checked), .check label:has(input:checked) { border-color: var(--primary); background: #eef3fb; font-weight: 700; }
.error-summary { border: 4px solid var(--release); background: #fff; padding: 16px 20px; border-radius: var(--radius); margin-bottom: 24px; }
.error-summary h2 { color: var(--release); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 20px; }
.messages li { padding: 14px 18px; border-radius: var(--radius); margin-bottom: 8px; font-weight: 700; border: 2px solid; }
.messages .success { background: var(--paid-bg); border-color: var(--paid); color: #0f3d1d; }
.messages .error { background: var(--release-bg); border-color: var(--release); color: #5c0f0f; }
.messages .info, .messages .warning { background: #eef3fb; border-color: var(--primary); }

/* Wizard progress */
.progress { font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.progress-bar { height: 10px; background: var(--free-bg); border-radius: 999px; margin-bottom: 20px; overflow: hidden; border: 1px solid var(--border); }
.progress-bar span { display: block; height: 100%; background: var(--primary); }
.choice-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.choice-buttons button { min-height: 120px; font-size: 1.35rem; flex-direction: column; background: #fff; color: var(--primary); }
.choice-buttons button span { font-weight: 400; font-size: 1rem; color: var(--muted); }
.live-total { font-size: 1.3rem; font-weight: 700; background: #eef3fb; border: 2px solid var(--primary); padding: 14px 18px; border-radius: var(--radius); max-width: 32em; }
.confirm-box { background: #fff; border: 4px solid var(--primary); border-radius: var(--radius); padding: 24px; font-size: 1.35rem; font-weight: 700; margin: 20px 0; }

/* Numbers grid */
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; list-style: none; padding: 0; }
.number-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; list-style: none; padding: 0; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 76px; border-radius: 8px; text-decoration: none; border: 2px solid currentColor; font-weight: 700; }
.tile .n { font-size: 1.35rem; line-height: 1.1; }
.tile .w { font-size: .82rem; }
.tile.paid { color: var(--paid); background: var(--paid-bg); }
.tile.due_soon { color: var(--due); background: var(--due-bg); }
.tile.in_grace { color: var(--grace); background: var(--grace-bg); }
.tile.to_be_released { color: var(--release); background: var(--release-bg); }
.tile.free { color: var(--free); background: #fff; border-style: dashed; }
label.tile { cursor: pointer; position: relative; }
label.tile input { position: absolute; opacity: 0; }
label.tile:has(input:checked) { background: var(--primary); color: #fff; border-style: solid; }
label.tile .w-on { display: none; }
label.tile:has(input:checked) .w-on { display: inline; }
label.tile:has(input:checked) .w-off { display: none; }
label.tile:has(input:focus-visible) { outline: 4px solid var(--focus); outline-offset: 2px; }

.search-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: flex-end; }
.search-form input { flex: 1 1 260px; }
.letters { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; padding: 0; list-style: none; }
.letters a { display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; border: 2px solid var(--border); border-radius: 6px; text-decoration: none; font-weight: 700; background: #fff; }
.letters a[aria-current="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }

.timeout-warning { position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 640px; margin: 0 auto; background: #fff; border: 4px solid var(--accent); border-radius: var(--radius); padding: 18px 20px; box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 20; font-weight: 700; font-size: 1.1rem; }
.site-footer { text-align: center; color: var(--muted); padding: 24px 16px; font-size: .95rem; }

@media (max-width: 640px) {
  h1 { font-size: 1.6rem; }
  .main-nav a { padding: 0 14px; font-size: 1rem; min-height: 48px; }
  .main-nav .settings-link { margin-left: 0; }
  dl.details { grid-template-columns: 1fr; }
  dl.details dd { margin-bottom: 8px; }
  .button-row .button, .button-row button { flex: 1 1 100%; }
  table.list.stack thead { display: none; }
  table.list.stack tr { display: block; border-bottom: 2px solid var(--border); padding: 8px 0; }
  table.list.stack td { display: block; border: none; padding: 4px 10px; }
}
@media print {
  .site-header, .main-nav, .button-row, .no-print, .site-footer, .timeout-warning { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { border: 1px solid #999; break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); }

fieldset.card > legend { float: left; width: 100%; font-weight: 700; font-size: 1.1rem; color: var(--primary); margin-bottom: 10px; }
fieldset.card > legend + * { clear: both; }
