/* Creator Academi page styles (v3). The app frame lives in shell.css. See DESIGN.md. */

:root {
  --bg: #F3F5F8; --surface: #FFFFFF; --surface-2: #EEF1F6; --line: #DCE1EA; --line-strong: #BCC4D3;
  --ink: #16213A; --muted: #566079;
  --primary: #1B2A4A; --primary-hover: #24365C; --on-primary: #FFFFFF; --primary-soft: #E6EBF4;
  --signal: #C8102E;
  --danger: #B42318; --danger-soft: #FCEBEA; --warning: #8A5300; --warning-soft: #FDF2DC; --success: #1D7048; --success-soft: #E3F2EA;
  --focus: 0 0 0 3px rgba(36, 54, 92, .32);
  --overlay: 0 16px 40px rgba(16, 24, 40, .16), 0 2px 6px rgba(16, 24, 40, .08);
  --scrim: rgba(14, 19, 29, .45);
  --t-xs: 13px; --t-sm: 14px; --t-md: 16px; --t-lg: 19px; --t-xl: 23px; --t-2xl: 28px;
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px;
  --ease: cubic-bezier(.16, 1, .3, 1);          /* entrances: quick out, soft landing */
  --ease-standard: cubic-bezier(.4, 0, .2, 1);  /* state changes: fills, colours */
  --dur-fast: .15s; --dur-med: .4s;
  --track-tight: -.02em;
  --row-hover: color-mix(in srgb, var(--surface-2) 60%, var(--surface));
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0E131D; --surface: #151B27; --surface-2: #1C2433; --line: #283247; --line-strong: #3A465E;
  --ink: #E7EBF3; --muted: #9AA4BA;
  --primary: #A9C1EE; --primary-hover: #C0D2F3; --on-primary: #0E131D; --primary-soft: #1D2840;
  --signal: #FF5A6E;
  --danger: #FF8A80; --danger-soft: #3A1F1C; --warning: #F2B45A; --warning-soft: #372A14; --success: #6FD19A; --success-soft: #183326;
  --focus: 0 0 0 3px rgba(169, 193, 238, .45);
  --overlay: 0 16px 40px rgba(0, 0, 0, .55);
  --scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------- Base and browser surfaces ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; scrollbar-color: var(--line-strong) transparent; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--t-md)/1.5 "Atkinson Hyperlegible Next", system-ui, sans-serif; }
::selection { background: var(--primary-soft); color: var(--ink); }
input, textarea { caret-color: var(--primary); }
h1, h2 { margin: 0; text-wrap: balance; letter-spacing: var(--track-tight); }
h3 { margin: 0; text-wrap: balance; letter-spacing: -.01em; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--primary); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
a, button, label, select, summary { touch-action: manipulation; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn svg.i { width: 18px; height: 18px; }

/* ---------- Page layout ---------- */
.content { width: 100%; max-width: 1180px; padding: 32px 32px 64px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head > div:first-child { flex: 1 1 320px; min-width: 0; }
.page-head h1 { font-size: var(--t-2xl); line-height: 1.2; font-weight: 700; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.banner { padding: 12px 16px; border-radius: var(--r-md); background: var(--danger-soft); color: var(--danger); font-weight: 600; margin-bottom: 16px; }
@media (max-width: 1023px) and (min-width: 768px) { .content { padding: 28px 24px 56px; } }
@media (max-width: 767px) {
  .content { padding: 20px 16px 40px; }
  .page-head { margin-bottom: 16px; }
  .page-head h1 { display: none; }
  /* The phone top bar already carries the page's main action */
  body[data-action] .page-actions .btn.primary { display: none; }
}

/* ---------- Sign in ---------- */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 360px; display: grid; gap: 20px; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-self: center; color: var(--ink); font-weight: 700; font-size: 19px; }
.auth-brand .ca-mark { width: 32px; height: 32px; }
.auth-card form { display: grid; gap: 16px; padding: 24px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.auth-card .btn.primary { width: 100%; }
.auth-card p.err { min-height: 20px; }

/* ---------- Buttons and controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: var(--t-sm); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard), transform .1s var(--ease-standard); }
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px) scale(.985); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger-text { border-color: transparent; background: none; color: var(--danger); }
.btn.danger-text:hover { background: var(--danger-soft); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: var(--t-xs); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--r-md); background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
@media (pointer: coarse) { .btn { min-height: 44px; } .btn.sm { min-height: 40px; } .icon-btn { width: 44px; height: 44px; } }
input[type=text], input[type=search], input[type=number], input[type=date], input[type=email], input[type=tel], input[type=password], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background-color: var(--surface); color: var(--ink); font-size: var(--t-md); transition: border-color .15s; }
@media (pointer: coarse) { input[type=text], input[type=search], input[type=number], input[type=date], input[type=email], input[type=tel], input[type=password], select { min-height: 44px; } }
select { cursor: pointer; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--primary); }
textarea { min-height: 96px; resize: vertical; }
.field { display: grid; gap: 6px; align-content: start; }
.field > span { font-size: var(--t-sm); font-weight: 600; }
.field .hint { font-size: var(--t-xs); color: var(--muted); font-weight: 400; }
.err { color: var(--danger); font-weight: 600; font-size: var(--t-sm); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; cursor: pointer; }
.switch + .switch { border-top: 1px solid var(--line); }
.switch input { appearance: none; width: 40px; height: 24px; border-radius: 12px; background: var(--line-strong); position: relative; cursor: pointer; flex: 0 0 auto; margin: 0; transition: background-color .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); }
.switch input:checked { background: var(--success); }
.switch input:checked::after { transform: translateX(16px); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: var(--t-sm); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }

/* Status: dot plus words */
.status { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 9999px; font-weight: 700; font-size: var(--t-xs); line-height: 1.5; white-space: nowrap; background: var(--surface-2); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.status.overdue { color: var(--danger); background: var(--danger-soft); } .status.soon { color: var(--warning); background: var(--warning-soft); }
.status.ok { color: var(--success); background: var(--success-soft); } .status.done, .status.none { color: var(--muted); }
.callout .status { padding: 0; background: none; font-size: var(--t-md); }
.pd { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-xs); white-space: nowrap; color: var(--muted); }
.pd::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex: 0 0 auto; }
.pd.owed { color: var(--warning); font-weight: 600; }
.pd.owed::before { background: var(--warning); }

/* ---------- Surfaces: one border, no shadow ---------- */
.surface { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.section + .section { margin-top: 32px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-head h2 { font-size: var(--t-lg); font-weight: 700; }
.section-head .muted { font-size: var(--t-sm); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* Worklist rows */
.work { list-style: none; margin: 0; padding: 0; }
.work li { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 20px; transition: background-color var(--dur-fast) var(--ease-standard); }
.work li:not(.all-clear):hover { background: var(--row-hover); }
.work li:first-child { border-radius: var(--r-lg) var(--r-lg) 0 0; } .work li:last-child { border-radius: 0 0 var(--r-lg) var(--r-lg); } .work li:only-child { border-radius: var(--r-lg); }
.work li + li { border-top: 1px solid var(--line); }
.work .when { font-size: var(--t-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.work .what { font-weight: 600; }
.work .sub { font-size: var(--t-sm); color: var(--muted); margin-top: 2px; line-height: 1.55; }
.work .status + .what { margin-top: 6px; }
.work .meter { display: flex; align-items: center; gap: 12px; font-size: var(--t-sm); color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.work .meter strong { color: var(--ink); margin-right: 4px; }
.work .acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.work li.all-clear { display: block; color: var(--muted); }
.bar { flex: 0 0 120px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--success); border-radius: inherit; transition: width var(--dur-med) var(--ease-standard); }
@media (max-width: 640px) {
  .work li { grid-template-columns: 1fr; gap: 6px; padding: 14px 16px; }
  .work .acts { justify-content: flex-start; margin-top: 6px; }
}

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.seg-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.seg-tabs::-webkit-scrollbar { display: none; }
.seg-tabs button { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border: 1px solid transparent; border-radius: 999px;
  background: none; color: var(--muted); font-weight: 600; font-size: var(--t-sm); cursor: pointer; white-space: nowrap; }
.seg-tabs button:hover { color: var(--ink); background: var(--surface-2); }
.seg-tabs button[aria-pressed="true"] { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.seg-tabs .n { font-variant-numeric: tabular-nums; color: var(--muted); }
.seg-tabs .n.danger { color: var(--danger); } .seg-tabs .n.warning { color: var(--warning); }
.find { display: flex; gap: 8px; flex: 1 1 500px; max-width: 640px; }
.find input { flex: 1; padding-left: 38px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238791a8' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center / 16px; }
.find select { flex: 0 0 150px; width: auto; }

/* ---------- Data table ---------- */
.table-wrap { overflow: hidden; }
table.data { width: 100%; border-collapse: collapse; }
.data th { text-align: left; font-size: var(--t-xs); font-weight: 600; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.data td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: var(--t-sm); }
.data tbody tr { position: relative; transition: background-color .12s; }
.data tbody tr:hover { background: var(--surface-2); }
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr.selected { background: var(--primary-soft); }
.data .who a { color: var(--ink); font-weight: 700; font-size: var(--t-md); text-decoration: none; white-space: nowrap; }
.data .who a::after { content: ""; position: absolute; inset: 0; }
.data .who a:focus-visible { box-shadow: none; }
.data tr:has(.who a:focus-visible) { box-shadow: inset 0 0 0 3px rgba(36, 54, 92, .32); }
.data .ref { font-size: var(--t-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.data .sub { color: var(--muted); font-size: var(--t-xs); margin-top: 2px; }
.data .menu-cell { width: 52px; text-align: right; padding-right: 8px; }
.data .menu-cell .icon-btn { position: relative; z-index: 1; }
.data th:nth-child(1) { width: 15%; } .data th:nth-child(2) { width: 19%; } .data th:nth-child(3) { width: 17%; } .data th:nth-child(5) { width: 17%; }
.pays { display: grid; gap: 3px; }
.track { display: flex; gap: 3px; margin-bottom: 6px; }
.track i { width: 18px; height: 5px; border-radius: 3px; background: var(--line); }
.track i.on { background: var(--primary); }
.table-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); font-size: var(--t-sm); color: var(--muted); }
.table-foot strong { color: var(--ink); }
@media (min-width: 768px) and (max-width: 1180px) {
  .data th:nth-child(3), .data td.stage, .data .award .sub { display: none; }
  .data th:nth-child(1) { width: 20%; } .data th:nth-child(2) { width: 22%; } .data th:nth-child(5) { width: 22%; }
}
@media (max-width: 767px) {
  .data thead { display: none; }
  .data, .data tbody, .data tr, .data td { display: block; }
  .data tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 12px 8px 12px 16px; border-bottom: 1px solid var(--line); }
  .data tbody tr:last-child { border-bottom: 0; }
  .data td { padding: 0; border: 0; }
  .data td.who { grid-column: 1; grid-row: 1; }
  .data td.who .ref { display: none; }
  .data td.deadline { grid-column: 1; grid-row: 2; margin-top: 4px; }
  .data td.deadline .sub, .data td.award .sub, .data td.stage, .data td.pay { display: none; }
  .data td.award { grid-column: 1; grid-row: 3; margin-top: 2px; color: var(--muted); font-size: var(--t-xs); }
  .data td.menu-cell { grid-column: 2; grid-row: 1 / span 3; align-self: center; width: auto; }
  .data td.empty-cell { grid-column: 1 / -1; }
  .find { flex: 1 1 100%; max-width: none; flex-wrap: wrap; }
  .find input { flex: 1 1 100%; }
  .find select { flex: 1 1 0; min-width: 0; }
}

/* ---------- Menu ---------- */
.menu { position: fixed; z-index: 60; min-width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--overlay); animation: pop .14s var(--ease); }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink); font-size: var(--t-sm); font-weight: 500; text-align: left; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); box-shadow: none; }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- Side panel; a full-screen sheet on phones ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); animation: fade .2s var(--ease); }
.panel { position: fixed; z-index: 50; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--overlay); display: flex; flex-direction: column; animation: slide .26s var(--ease); overscroll-behavior: contain; }
.panel > form { display: contents; }
.panel-head { display: flex; align-items: flex-start; gap: 8px; padding: 18px 16px 14px 24px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: var(--t-xl); font-weight: 700; }
.panel-head p { color: var(--muted); font-size: var(--t-sm); margin-top: 2px; }
.panel-head .spacer { flex: 1; }
.panel-body { flex: 1; overflow-y: auto; padding: 20px 24px 32px; display: grid; gap: 24px; align-content: start; }
.panel-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 24px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.panel h3 { font-size: var(--t-sm); font-weight: 700; margin-bottom: 8px; }
.callout { padding: 14px 16px; border-radius: var(--r-md); background: var(--surface-2); display: grid; gap: 10px; }
.callout.overdue { background: var(--danger-soft); } .callout.soon { background: var(--warning-soft); }
.callout .status { font-size: var(--t-md); }
.callout p { font-size: var(--t-sm); }
.callout .btn { justify-self: start; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { position: relative; display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 8px 0; }
.steps li::before { counter-increment: s; content: counter(s); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; background: var(--surface); border: 1.5px solid var(--line-strong); color: var(--muted); }
.steps li.done::before { content: ""; border-color: var(--success);
  background: var(--success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") no-repeat center / 13px; }
.steps li.current::before { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.steps li + li::after { content: ""; position: absolute; left: 11.5px; top: -9px; height: 18px; border-left: 1.5px solid var(--line-strong); }
.steps .name { font-weight: 600; font-size: var(--t-sm); }
.steps li:not(.done):not(.current) .name { color: var(--muted); font-weight: 500; }
.steps .date { font-size: var(--t-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
dl.facts { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0; font-size: var(--t-sm); }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
details.more { border-top: 1px solid var(--line); padding-top: 12px; }
details.more summary { cursor: pointer; font-weight: 600; font-size: var(--t-sm); color: var(--primary); list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+ "; }
details.more[open] summary::before { content: "− "; }
details.more .form-grid { margin-top: 14px; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 767px) {
  .panel { width: 100vw; border-left: 0; animation: rise .26s var(--ease); }
  .panel-head { padding-left: 16px; }
  .panel-body { padding: 16px 16px 24px; }
  .panel-foot { padding-left: 16px; padding-right: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  dl.facts { grid-template-columns: 120px 1fr; }
  @keyframes rise { from { transform: translateY(32px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* ---------- Registers ---------- */
.club-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.club-tabs::-webkit-scrollbar { display: none; }
.club-tabs button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px;
  background: none; color: var(--muted); font-weight: 600; font-size: var(--t-sm); white-space: nowrap; cursor: pointer; }
.club-tabs button:hover { color: var(--ink); }
.club-tabs button[aria-current="page"] { color: var(--ink); border-bottom-color: var(--signal); }
.club-tabs .settings-link { margin-left: auto; }
.weeks { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; margin-bottom: 20px; }
.weeks button { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; }
.weeks button:hover { border-color: var(--line-strong); }
.weeks button[aria-current="page"] { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.weeks .w { font-weight: 700; font-size: var(--t-sm); }
.weeks .d { font-size: var(--t-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.weeks .s { font-size: var(--t-xs); font-weight: 600; }
.weeks .s.taken { color: var(--success); } .weeks .s.today { color: var(--primary); } .weeks .s.missed { color: var(--warning); } .weeks .s.later { color: var(--muted); font-weight: 400; }
@media (max-width: 767px) { .weeks { display: flex; overflow-x: auto; scrollbar-width: none; } .weeks button { flex: 0 0 96px; } }
.reg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 12px 14px 20px; border-bottom: 1px solid var(--line); }
.reg-head h2 { font-size: var(--t-lg); font-weight: 700; }
.reg-head .muted { font-size: var(--t-sm); }
.reg-head .spacer { flex: 1; }
.attendance { list-style: none; margin: 0; padding: 0; }
.attendance li { display: flex; align-items: center; gap: 12px; padding: 10px 16px 10px 20px; }
.attendance li + li { border-top: 1px solid var(--line); }
.attendance .nm { flex: 1; min-width: 0; font-weight: 600; }
.attendance .nm small { display: block; font-weight: 400; color: var(--muted); font-size: var(--t-xs); }
.attendance h3 { font-size: var(--t-xs); font-weight: 600; color: var(--muted); padding: 10px 20px; background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-md); overflow: hidden; flex: 0 0 auto; }
.toggle button { min-height: 40px; min-width: 92px; border: 0; background: var(--surface); color: var(--ink); font-weight: 600; font-size: var(--t-sm); cursor: pointer; }
.toggle button + button { border-left: 1px solid var(--line-strong); }
.toggle button:hover { background: var(--surface-2); }
.toggle button[aria-pressed="true"].p { background: var(--success); color: #fff; }
.toggle button[aria-pressed="true"].a { background: var(--danger); color: #fff; }
:root[data-theme="dark"] .toggle button[aria-pressed="true"] { color: #0E131D; }
@media (pointer: coarse) { .toggle button { min-height: 44px; } }
.reg-foot { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 12px 16px 12px 20px; border-top: 1px solid var(--line); font-size: var(--t-sm); }
.reg-foot .spacer { flex: 1; }
.walkin { display: flex; gap: 8px; flex: 1 1 100%; }
.walkin input { flex: 1; }
.kids { list-style: none; margin: 0; padding: 0; }
.kids li { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 20px; }
.kids li + li { border-top: 1px solid var(--line); }
.kids .nm { flex: 1; min-width: 0; }
.kids .nm b { display: block; }
.kids .nm span { color: var(--muted); font-size: var(--t-xs); }
@media (max-width: 767px) {
  .attendance li { padding: 10px 12px 10px 16px; }
  .toggle button { min-width: 76px; }
  .reg-foot { position: sticky; bottom: calc(57px + env(safe-area-inset-bottom)); background: var(--surface); border-radius: 0 0 var(--r-lg) var(--r-lg); }
}

/* Import dialog (registers) */
.wide-dialog { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  background: var(--surface); color: var(--ink); box-shadow: var(--overlay); }
.wide-dialog[open] { animation: pop .18s var(--ease); }
.wide-dialog::backdrop { background: var(--scrim); }
.wide-dialog form { padding: 24px; display: grid; gap: 12px; }
.wide-dialog h2 { font-size: var(--t-lg); font-weight: 700; }
.wide-dialog .small { font-size: var(--t-sm); color: var(--muted); }
.wide-dialog label.f { display: grid; gap: 6px; font-size: var(--t-sm); font-weight: 600; }
.wide-dialog label.opt { display: flex; gap: 10px; align-items: flex-start; font-size: var(--t-sm); cursor: pointer; }
.wide-dialog label.opt input[type=radio], .wide-dialog label.opt input[type=checkbox] { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--primary); flex: 0 0 auto; }
.wide-dialog h3 { font-size: var(--t-sm); font-weight: 700; margin-top: 6px; }
.preview { padding: 12px 14px; background: var(--surface-2); border-radius: var(--r-md); font-size: var(--t-sm); }
.preview ul { margin: 6px 0 0; padding-left: 18px; columns: 2; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
@media (max-width: 600px) { .preview ul { columns: 1; } }

/* ---------- Settings ---------- */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: start; }
.settings nav { display: grid; gap: 2px; position: sticky; top: 24px; }
.settings nav a { display: block; padding: 8px 12px; border-radius: var(--r-md); color: var(--muted); text-decoration: none; font-weight: 600; font-size: var(--t-sm); }
.settings nav a:hover { color: var(--ink); background: var(--surface-2); }
.settings nav a[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.set-card { padding: 24px; }
.set-card + .set-card { margin-top: 16px; }
.set-card h2 { font-size: var(--t-lg); font-weight: 700; }
.set-card > p { color: var(--muted); font-size: var(--t-sm); margin: 4px 0 20px; }
.set-card .row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.fees { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.fees th { text-align: left; color: var(--muted); font-weight: 600; font-size: var(--t-xs); padding: 0 8px 8px 0; }
.fees td { padding: 6px 8px 6px 0; border-top: 1px solid var(--line); }
.fees td:first-child { font-weight: 600; width: 55%; }
.money { position: relative; display: inline-block; }
.money::before { content: "£"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: var(--t-sm); }
.money input { padding-left: 24px; max-width: 130px; text-align: right; font-variant-numeric: tabular-nums; }
.theme-choice { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.theme-choice label { position: relative; display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; font-weight: 600; font-size: var(--t-sm); }
.theme-choice label:has(input:checked) { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.theme-choice input { position: absolute; opacity: 0; pointer-events: none; }
.theme-choice label:has(input:focus-visible) { box-shadow: var(--focus); }
.swatch { height: 64px; border-radius: 6px; border: 1px solid var(--line); display: grid; grid-template-columns: 26% 1fr; overflow: hidden; }
.swatch .s1 { background: #1B2A4A; } .swatch .s2 { background: #F3F5F8; }
.swatch.dark .s1 { background: #121A2B; } .swatch.dark .s2 { background: #151B27; }
.swatch.auto .s2 { background: linear-gradient(90deg, #F3F5F8 50%, #151B27 50%); }
@media (max-width: 860px) {
  .settings { grid-template-columns: 1fr; gap: 16px; }
  .settings nav { position: static; display: flex; overflow-x: auto; scrollbar-width: none; gap: 4px; }
  .settings nav a { white-space: nowrap; }
  .theme-choice { gap: 8px; }
  .set-card { padding: 18px; }
}

/* ---------- Motion: exits as smooth as entrances ---------- */
.scrim.closing { animation: fade-out .18s ease-in forwards; }
.panel.closing { animation: slide-out .18s ease-in forwards; }
.menu.closing { animation: pop-out .12s ease-in forwards; pointer-events: none; }
@keyframes fade-out { to { opacity: 0; } }
@keyframes slide-out { to { transform: translateX(24px); opacity: 0; } }
@keyframes pop-out { to { opacity: 0; transform: translateY(-4px); } }
@media (max-width: 767px) { .panel.closing { animation: sink-out .18s ease-in forwards; } @keyframes sink-out { to { transform: translateY(32px); opacity: 0; } } }
.wide-dialog[open] { animation: none; }
.wide-dialog { transition: opacity .16s ease, transform .16s var(--ease), overlay .16s allow-discrete, display .16s allow-discrete; }
.wide-dialog:not([open]) { opacity: 0; transform: translateY(-4px) scale(.98); }
@starting-style { .wide-dialog[open] { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* Register progress and the "complete" moment */
.reg-progress { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.reg-progress .bar { flex: 0 0 96px; }
.done-badge { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-sm); font-weight: 700; color: var(--success); }
.done-badge svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.done-badge.fresh { animation: done-in .45s var(--ease); }
@keyframes done-in { 0% { opacity: 0; transform: scale(.6); } 60% { opacity: 1; transform: scale(1.08); } 100% { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Print: a register sheet to sign and keep ---------- */
.print-sheet { display: none; }
@media print {
  @page { margin: 16mm; }
  .page-actions, .filters, .menu-cell, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  body.printing-register .content > *:not(#view), body.printing-register #view > *:not(.print-sheet) { display: none !important; }
  body.printing-register .print-sheet { display: block; font-size: 12pt; color: #000; }
  .print-sheet h1 { font-size: 20pt; margin: 0 0 2pt; }
  .print-sheet .meta { margin: 0 0 12pt; color: #333; }
  .print-sheet table { width: 100%; border-collapse: collapse; }
  .print-sheet th, .print-sheet td { border: 1px solid #555; padding: 6pt 8pt; text-align: left; }
  .print-sheet th { background: #eee; font-size: 10pt; }
  .print-sheet td.tick { width: 18%; text-align: center; }
  .print-sheet .box { display: inline-block; width: 12pt; height: 12pt; border: 1.5px solid #000; vertical-align: middle; }
  .print-sheet .box.on { background: #000 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") no-repeat center / 10pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-sheet .totals { margin: 12pt 0 24pt; }
  .print-sheet .sign { display: grid; grid-template-columns: 1fr 1fr; gap: 24pt; margin-top: 24pt; }
  .print-sheet .sign div { border-top: 1px solid #000; padding-top: 4pt; font-size: 10pt; }
  .print-sheet .foot { margin-top: 24pt; font-size: 9pt; color: #555; }
}

/* ---------- Contacts (CRM) ---------- */
.status.new { color: var(--primary); background: var(--primary-soft); }
.data.contacts th:nth-child(1) { width: 30%; } .data.contacts th:nth-child(2) { width: 16%; } .data.contacts th:nth-child(3) { width: auto; } .data.contacts th:nth-child(4) { width: 22%; } .data.contacts th:nth-child(5) { width: 52px; }
.data.contacts .who .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 36ch; }
.data.contacts td.progs { color: var(--muted); }
@media (min-width: 768px) and (max-width: 1180px) {
  .data.contacts th:nth-child(3), .data.contacts td.progs { display: none; }
  .data.contacts th:nth-child(1) { width: 40%; } .data.contacts th:nth-child(4) { width: 30%; }
}
@media (max-width: 767px) {
  .data.contacts td.stat { grid-column: 1; grid-row: 2; margin-top: 6px; }
  .data.contacts td.next { grid-column: 1; grid-row: 3; margin-top: 6px; }
  .data.contacts td.progs { display: none; }
  .data.contacts .who .sub { max-width: none; }
}
.row-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row-btns input, .row-btns select { flex: 1 1 160px; min-width: 0; }
.chip-set { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-toggle { position: relative; display: inline-flex; cursor: pointer; }
.chip-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-toggle span { display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: var(--t-sm); font-weight: 600; color: var(--muted); transition: background-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard); }
.chip-toggle:hover span { color: var(--ink); background: var(--surface-2); }
.chip-toggle input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip-toggle input:focus-visible + span { box-shadow: var(--focus); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink); font-size: var(--t-xs); font-weight: 600; text-decoration: none; }
.chip:hover { background: var(--primary-soft); color: var(--primary); }
.kids.compact li { padding: 10px 0; }
.kids.compact .nm span.chips { color: inherit; }
.hist-add { display: grid; gap: 8px; margin-bottom: 12px; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); font-size: var(--t-sm); }
.history li.muted { display: block; }
.history .h-when { color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.history .h-what p { margin: 2px 0 0; color: var(--muted); overflow-wrap: anywhere; white-space: pre-line; }
.history .icon-btn { margin-top: -6px; }
@media (max-width: 767px) { .history li { grid-template-columns: minmax(0, 1fr) auto; } .history .h-when { grid-column: 1 / -1; } }
.panel-body { grid-template-columns: minmax(0, 1fr); }
.panel-head > div:first-child { min-width: 0; }
.panel-head h2[tabindex="-1"]:focus { box-shadow: none; }
.status-pick { flex-wrap: wrap; overflow: visible; }
.status-pick button { border-color: var(--line); }
/* Families / Organisations switch: a segmented control above the filters */
.side-switch { display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.side-switch button { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--r-sm); background: none;
  color: var(--muted); font-weight: 700; font-size: var(--t-sm); cursor: pointer; transition: background-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard); }
.side-switch button:hover { color: var(--ink); }
.side-switch button[aria-pressed="true"] { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.side-switch .n { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.side-switch .due { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--warning-soft); color: var(--warning); font-size: var(--t-xs); line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
@media (max-width: 767px) { .side-switch { display: flex; } .side-switch button { flex: 1; justify-content: center; padding: 0 8px; } }
.links { list-style: none; margin: 0; padding: 0; }
.links li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--t-sm); }
.links li > div { flex: 1; min-width: 0; display: grid; }
.links a { font-weight: 700; text-decoration: none; color: var(--ink); }
.links a:hover { color: var(--primary); text-decoration: underline; }
.links .muted { font-size: var(--t-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data.contacts td.progs .sub { margin-top: 2px; }
