/* Turnout design system: tokens + shared components for member app, kiosk, TV and admin.
   Neutral defaults here; each gym's brand arrives at runtime from org_settings.brand.theme
   (web/shared/app.js → applyBrand). Staff screens wear the Turnout staff theme on top
   (web/admin/staff-theme.css, body.staff-theme). Roles: --accent = links, selection, focus;
   --primary = the one main action; --energy = big moments; --energy-text = energy as words
   (text-safe). Derived tokens (var()) resolve where they are declared, so a theme scoped below
   :root must set them itself. Motion: entrances ease-out, moves ease-in-out, exits ease-in
   and 20% shorter; spring only for celebrations; everyday UI never bounces (decision 15). */
:root {
  --bg: #EEF3F4; --surface: #FFFFFF; --surface-2: #F3F7F8; --ink: #0D1C27; --muted: #566875; --line: #D3DDE2;
  --accent: #097574; --accent-ink: #FFFFFF; --accent-soft: #D7EEEC;
  --primary: var(--accent); --primary-ink: var(--accent-ink);
  --energy: #F2642B; --energy-soft: #FDE6DA; --energy-ink: #0D1C27; --brand-hi: var(--accent);
  --energy-text: #AC4923;
  --good: #137738; --good-soft: #DDF2E4; --warn: #945F0E; --warn-soft: #FBEFD6; --bad: #B32322; --bad-soft: #F9E0DD;
  --device: #0E161D; --tv-accent: #3FD0C9; --tv-energy: #FF7F45; --tv-brand-hi: var(--tv-accent);
  --shadow: 0 1px 2px rgba(13,28,39,.06), 0 12px 32px -12px rgba(13,28,39,.22);
  --ease-out: cubic-bezier(.23, 1, .32, 1); --ease-in-out: cubic-bezier(.77, 0, .175, 1); --ease-in: cubic-bezier(.55, .06, .68, .19); --spring: cubic-bezier(.34, 1.56, .64, 1);
  --t-press: 140ms; --t-pop: 200ms; --t-pop-out: 160ms; --t-enter: 280ms; --t-exit: 224ms; --t-move: 320ms; --stagger: 30ms;
  --font-display: 'Barlow Semi Condensed', 'Archivo', 'Arial Narrow', system-ui, sans-serif;
  --font-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --r: 14px;
  color-scheme: only light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #091219; --surface: #111D26; --surface-2: #16242E; --ink: #E6EEF2; --muted: #8FA2AE; --line: #22323D;
  --accent: #27B3AE; --accent-ink: #04201F; --accent-soft: #123A3B; --energy: #FF7F45; --energy-soft: #3A2016; --energy-text: #FEA47C;
  --good: #46C07A; --good-soft: #12301F; --warn: #E7A33C; --warn-soft: #33260F; --bad: #F06A5E; --bad-soft: #3A1715;
  --device: #02070B; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px -12px rgba(0,0,0,.7); color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #091219; --surface: #111D26; --surface-2: #16242E; --ink: #E6EEF2; --muted: #8FA2AE; --line: #22323D;
  --accent: #27B3AE; --accent-ink: #04201F; --accent-soft: #123A3B; --energy: #FF7F45; --energy-soft: #3A2016; --energy-text: #FEA47C;
  --good: #46C07A; --good-soft: #12301F; --warn: #E7A33C; --warn-soft: #33260F; --bad: #F06A5E; --bad-soft: #3A1715;
  --device: #02070B; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px -12px rgba(0,0,0,.7); color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.01em; line-height: 1.1; margin: 0; }
h1 { font-weight: 800; font-size: clamp(26px, 3.4vw, 36px); }
h2 { font-weight: 800; font-size: 22px; }
h3 { font-weight: 700; font-size: 17px; }

/* layout */
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; align-content: start; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 12px; }
.grow { flex: 1; min-width: 0; }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 10px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; transition: transform var(--t-press) var(--ease-out), border-color var(--t-pop) var(--ease-out), background var(--t-pop) var(--ease-out); }
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.97); transition-duration: 0s; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; font-weight: 700; }
.btn.energy { background: var(--energy); color: var(--energy-ink); border-color: transparent; }
.btn.danger { background: var(--bad); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled, .btn[aria-busy="true"] { opacity: .5; cursor: not-allowed; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 700; }

/* cards, chips, avatars */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card.flat { box-shadow: none; }
.card.pad-lg { padding: 20px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.energy { background: var(--energy-soft); color: var(--energy-text); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.stat b { display: block; font-family: var(--font-display); font-weight: 800; font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; }
.wm-hi { color: var(--brand-hi); }
.wm-logo { height: 1.6em; width: auto; vertical-align: -.45em; margin-right: .3em; }
/* A class's name (EXCEL, LIFT…) in the gym's class lettering: condensed caps, slanted when the brand
   sets --class-style: italic (i'move's printed schedule). Use on every surface that names a class. */
.cls { font-family: var(--font-display); font-style: var(--class-style, normal); font-weight: 800; text-transform: uppercase; letter-spacing: .01em; }
.sect-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; }

/* lists + tables */
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .sub { font-size: 12px; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); position: sticky; top: 0; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--surface-2); }

/* forms */
.field { display: grid; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.field input, .field select, .field textarea { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; font-size: 15px; font-weight: 500; color: var(--ink); min-height: 44px; }
.field textarea { min-height: 96px; resize: vertical; }
.field .hint { font-weight: 500; }
.check { display: grid; grid-template-columns: 22px 1fr; gap: 10px; font-size: 14px; align-items: start; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.err { color: var(--bad); font-size: 14px; font-weight: 600; margin: 0; }
.switch { width: 44px; height: 26px; border-radius: 13px; background: var(--line); border: 0; position: relative; flex: none; transition: background var(--t-move) var(--ease-in-out); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 10px; background: #fff; transition: transform var(--t-move) var(--ease-in-out); box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.seg { display: inline-grid; grid-auto-flow: column; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.seg button { border: 0; background: transparent; padding: 7px 12px; font-weight: 700; font-size: 13px; color: var(--muted); border-radius: 999px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

/* states */
.empty { text-align: center; color: var(--muted); padding: 28px 12px; display: grid; gap: 8px; justify-items: center; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: 10px; min-height: 18px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* toasts + modals */
.toasts { position: fixed; z-index: 90; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--surface); padding: 12px 16px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); animation: rise var(--t-enter) var(--ease-out); }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { animation: fadeout var(--t-exit) var(--ease-in) forwards; }
.modal-bg { position: fixed; inset: 0; z-index: 75; background: rgba(2, 12, 16, .5); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; animation: fadein var(--t-enter) var(--ease-out); }
.modal-bg.out { animation: fadeout var(--t-exit) var(--ease-in) forwards; }
.modal { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 20px; display: grid; gap: 14px; animation: pop-in var(--t-enter) var(--ease-out); }
.modal.wide { width: min(1000px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.modal-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
@keyframes fadein { from { opacity: 0; } }
@keyframes fadeout { to { opacity: 0; } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
@keyframes pop-in { from { transform: scale(.96); opacity: 0; } }
@keyframes row-in { from { transform: translateY(6px); opacity: 0; } }
.enter { animation: row-in var(--t-enter) var(--ease-out) both; animation-delay: calc(var(--i, 0) * var(--stagger)); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; } }
