/* LapFund – base styles. No external resources (CSP: 'self' only).
   Club color comes from /theme.css as --accent, --accent-dark, --on-accent. */

@font-face { font-family: "Barlow"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/barlow-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }

:root {
  --accent: #0B5FA8;
  --accent-dark: #08467C;
  --on-accent: #FFFFFF;
  --ink: #14212E;
  --ink-2: #3B4A58;
  --muted: #586776;
  --line: #DCE3EA;
  --line-strong: #B9C5D1;
  --bg: #F3F6F9;
  --surface: #FFFFFF;
  --nav: #14212E;
  --ok-bg: #E1F4E7; --ok-ink: #1B6B3A;
  --warn-bg: #FFF1C7; --warn-ink: #6B4A00;
  --err-bg: #FDE8E6; --err-ink: #9E2418;
  --info-bg: #E6F0FA; --info-ink: #0B4A82;
  --radius: 12px;
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Barlow Condensed", "Barlow", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--bg); }
img { max-width: 100%; height: auto; }
a { color: var(--accent-dark); text-underline-offset: 2px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
code, .input--mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }

.h1 { font-family: var(--font-display); font-weight: 700; font-size: 34px; line-height: 1.1; margin: 0 0 8px; }
.h2 { font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1.2; margin: 0; }
.lead { font-size: 17px; color: var(--ink-2); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 16px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -9999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip-link:focus { left: 8px; }

/* Cards and layout helpers */
.card { background: var(--surface); border-radius: var(--radius); padding: 24px; box-shadow: 0 1px 2px rgba(20, 33, 46, 0.08); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.cols { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.cols__main { flex: 999 1 480px; min-width: 0; }
.cols__side { flex: 1 1 300px; }
.cols__side .facts div { flex-direction: column; gap: 0; }
.cols__side .facts dd { text-align: left; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.back { display: inline-block; font-size: 14px; margin-bottom: 4px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .label, .fieldset legend { font-weight: 600; font-size: 15px; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="search"], input[type="date"], input[type="datetime-local"], select, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  min-height: 48px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 10px; width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[readonly] { background: var(--bg); }
input[type="file"] { font: inherit; }
input[type="color"] { width: 64px; height: 48px; padding: 4px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
.input--code { font-size: 26px; letter-spacing: 0.25em; text-align: center; font-variant-numeric: tabular-nums; }
.field__help { margin: 0; font-size: 14px; color: var(--muted); }
.field__error { margin: 0; font-size: 14px; color: var(--err-ink); font-weight: 600; }
.field--error input { border-color: var(--err-ink); }
.fieldset { border: 0; margin: 0; padding: 0; }
.fieldset legend { padding: 0; margin-bottom: 10px; }
.fieldset legend.h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.fieldset + .fieldset, .stack > .fieldset:first-of-type { margin-top: 28px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.choice input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.choice:has(input:checked) { border: 2px solid var(--accent); background: #F4F8FC; padding: 11px 13px; }
.copy-row { display: flex; gap: 8px; flex-wrap: wrap; }
.copy-row input { flex: 1 1 280px; font-size: 14px; }
.color-row { display: flex; align-items: center; gap: 12px; }
.swatch-sample { display: inline-flex; align-items: center; min-height: 48px; padding: 0 18px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-weight: 600; }
.logo-preview { display: inline-flex; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); width: max-content; }
.logo-preview img { max-height: 96px; width: auto; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer; }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-dark); color: #FFFFFF; }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn--secondary:hover { border-color: var(--ink); color: var(--ink); }
.btn--danger { background: var(--surface); color: var(--err-ink); border-color: var(--err-ink); }
.btn--danger:hover { background: var(--err-bg); }
.btn--link { background: none; border: 0; color: var(--accent-dark); text-decoration: underline; padding: 0; min-height: 44px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.cols__side form + form { margin-top: 8px; }
.inline-form { margin-top: 8px; }

/* Notices and badges */
.notice { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: 15px; }
.notice--success { background: var(--ok-bg); color: var(--ok-ink); }
.notice--warning { background: var(--warn-bg); color: var(--warn-ink); }
.notice--error { background: var(--err-bg); color: var(--err-ink); }
.notice--info { background: var(--info-bg); color: var(--info-ink); }
.badge { display: inline-block; font-size: 13px; font-weight: 600; border-radius: 999px; padding: 3px 10px; white-space: nowrap; background: #E8ECF0; color: var(--ink-2); }
.badge--active { background: var(--ok-bg); color: var(--ok-ink); }
.badge--invited, .badge--totp_pending { background: var(--info-bg); color: var(--info-ink); }
.badge--locked { background: var(--warn-bg); color: var(--warn-ink); }
.badge--inactive { background: #E8ECF0; color: var(--muted); }

/* Lists */
.facts { margin: 0; display: grid; gap: 8px; }
.facts div { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; }
.checks, .checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.checks__item, .checklist__item { display: flex; gap: 10px; align-items: baseline; }
.checks__icon, .checklist__icon { font-weight: 700; width: 18px; flex-shrink: 0; }
.checks__item.is-ok .checks__icon, .checklist__item.is-done .checklist__icon { color: var(--ok-ink); }
.checks__item.is-fail { color: var(--err-ink); font-weight: 600; }
.checklist__item.is-done { color: var(--muted); }
.steps { padding-left: 22px; }
.steps li + li { margin-top: 6px; }
.codes { list-style: none; padding: 16px; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; background: var(--bg); border-radius: 10px; font-size: 17px; }
.qr { margin: 16px 0; text-align: center; }
.qr img { border: 1px solid var(--line); border-radius: 10px; image-rendering: pixelated; }
.secret { display: inline-block; margin-top: 6px; font-size: 15px; letter-spacing: 0.05em; word-break: break-all; }
.debug { white-space: pre-wrap; font-size: 13px; background: var(--bg); padding: 12px; border-radius: 8px; overflow-x: auto; }

/* Tables */
.table-wrap { background: var(--surface); border-radius: var(--radius); overflow-x: auto; box-shadow: 0 1px 2px rgba(20, 33, 46, 0.08); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 640px; }
.table th { text-align: left; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 16px; border-bottom: 1px solid #EEF2F5; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table a { color: var(--ink); }

/* Auth pages */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 32px 16px; gap: 20px; border-top: 6px solid var(--accent); }
.auth__brand { display: flex; align-items: center; gap: 12px; }
.auth__logo { width: 56px; height: 56px; object-fit: contain; }
.auth__club { font-family: var(--font-display); font-weight: 700; font-size: 24px; }
.auth__card { width: 100%; max-width: 440px; }
.page-auth--wide .auth__card { max-width: 680px; }
.auth__footer { font-size: 13px; color: var(--muted); }

/* Admin shell */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.nav { flex: 1 1 240px; max-width: 100%; background: var(--nav); color: #FFFFFF; padding: 20px 16px; display: flex; flex-direction: column; gap: 20px; }
.nav__brand { display: flex; align-items: center; gap: 10px; }
.nav__logo { width: 40px; height: 40px; object-fit: contain; background: #FFFFFF; border-radius: 8px; padding: 2px; }
.nav__club { font-family: var(--font-display); font-weight: 700; font-size: 20px; line-height: 1.1; }
.nav__group { display: flex; flex-direction: column; gap: 2px; }
.nav__heading { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: #9FB0C1; padding: 0 10px 6px; }
.nav__link { color: #DDE5EC; text-decoration: none; padding: 10px; border-radius: 8px; min-height: 44px; display: flex; align-items: center; }
.nav__link:hover { color: #FFFFFF; background: rgba(255, 255, 255, 0.08); }
.nav__link.is-active { color: #FFFFFF; background: rgba(255, 255, 255, 0.14); font-weight: 600; }
.nav__link:focus-visible, .nav__logout:focus-visible { outline-color: #FFFFFF; }
.nav__account { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.15); padding-top: 16px; display: flex; flex-direction: column; gap: 2px; }
.nav__user { font-weight: 600; }
.nav__role { font-size: 13px; color: #9FB0C1; margin-bottom: 8px; }
.nav__logout { background: none; border: 1px solid rgba(255, 255, 255, 0.3); color: #FFFFFF; font: inherit; font-size: 14px; border-radius: 8px; min-height: 40px; padding: 0 12px; cursor: pointer; width: 100%; text-align: left; }
.nav__logout:hover { background: rgba(255, 255, 255, 0.08); }
.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px 48px; }
.main > .card + .card, .main > section + section { margin-top: 16px; }

/* Events */
.main > * + * { margin-top: 16px; }
.main > .page-head + * { margin-top: 0; }
.page-head__badges { display: flex; gap: 8px; flex-wrap: wrap; }
.event-meta { margin: 0; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line-strong); margin-bottom: 20px; }
.tabs__link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; color: var(--ink-2); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs__link:hover { color: var(--ink); }
.tabs__link.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.event-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.event-card { display: flex; flex-direction: column; gap: 6px; color: var(--ink); text-decoration: none; border-top: 4px solid var(--accent); }
.event-card:hover { color: var(--ink); box-shadow: 0 2px 8px rgba(20, 33, 46, 0.16); }
.event-card.is-archived { opacity: 0.75; border-top-color: var(--line-strong); }
.event-card__top { display: flex; gap: 6px; flex-wrap: wrap; }
.event-card__name { font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1.2; }
.event-card__stats { display: flex; gap: 16px; color: var(--ink-2); margin-top: auto; }
.event-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.event-list__item .badge { margin-left: 6px; }
.badge--status-preparation { background: #E8ECF0; color: var(--ink-2); }
.badge--status-collecting { background: var(--info-bg); color: var(--info-ink); }
.badge--status-run_done { background: var(--warn-bg); color: var(--warn-ink); }
.badge--status-billing { background: #F1E6FA; color: #5B2A86; }
.badge--status-closed { background: var(--ok-bg); color: var(--ok-ink); }
.badge--assigned { background: var(--accent); color: var(--on-accent); }
.empty { text-align: center; padding: 40px 24px; }
.empty .h2 { margin-bottom: 8px; }
.form-narrow { max-width: 720px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cards--wide { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.inline-check { display: flex; gap: 10px; align-items: center; font-weight: 400; cursor: pointer; min-height: 32px; }
.inline-check input { width: 20px; height: 20px; accent-color: var(--accent); }
.checks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.choice--compact { margin-bottom: 0; padding: 10px 12px; }
.choice--compact:has(input:checked) { padding: 9px 11px; }
.logo-preview--qr img { max-height: 180px; }
textarea { min-height: 0; resize: vertical; line-height: 1.5; }
select { appearance: auto; }
.field--error textarea, .field--error select { border-color: var(--err-ink); }

/* Status stepper */
.stepper { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; counter-reset: step; }
.stepper__step { flex: 1 1 120px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-top: 10px; border-top: 4px solid var(--line); color: var(--muted); font-size: 14px; }
.stepper__dot { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--line); color: var(--ink-2); font-weight: 700; font-size: 14px; }
.stepper__step.is-done { border-top-color: var(--ok-ink); color: var(--ink-2); }
.stepper__step.is-done .stepper__dot { background: var(--ok-bg); color: var(--ok-ink); }
.stepper__step.is-current { border-top-color: var(--accent); color: var(--ink); font-weight: 600; }
.stepper__step.is-current .stepper__dot { background: var(--accent); color: var(--on-accent); }

/* Teams and participant tables */
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions form { display: inline-flex; vertical-align: middle; margin-left: 8px; }
.table .check-col { width: 48px; }
.table .check-col input { width: 20px; height: 20px; accent-color: var(--accent); }
.table tr.is-muted td { color: var(--muted); }
.break { word-break: break-word; }
.rename-row { display: flex; gap: 8px; align-items: center; }
.rename-row input { min-height: 40px; max-width: 280px; }
.icon-actions { display: flex; gap: 4px; }
.btn--small { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn--icon { min-width: 40px; min-height: 40px; padding: 0; background: var(--surface); border-color: var(--line-strong); color: var(--ink); font-size: 18px; }
.btn--icon:hover:not([disabled]) { border-color: var(--ink); }
.btn--danger-link { color: var(--err-ink); }
.inline-add .field { margin-bottom: 0; }
.inline-add .copy-row input { font-size: 16px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: flex-end; }
.filter-bar .field { flex: 0 1 220px; }
.filter-bar__grow { flex: 1 1 260px !important; }
.filter-bar__actions { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.copy-row--labelled { align-items: flex-end; }
.copy-row--labelled .field { margin-bottom: 0; }
.pool-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; }
.pool-list__item { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.pool-list__form { display: flex; gap: 8px; align-items: center; }
.pool-list__form select { min-height: 40px; width: auto; padding: 6px 10px; }

/* CSV import */
.code-sample { background: var(--bg); border-radius: 10px; padding: 12px 14px; font-size: 13px; overflow-x: auto; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.summary-chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 12px; border-radius: 999px; background: #E8ECF0; font-weight: 600; font-size: 14px; }
.chip--new { background: var(--ok-bg); color: var(--ok-ink); }
.chip--existing { background: var(--info-bg); color: var(--info-ink); }
.chip--error { background: var(--err-bg); color: var(--err-ink); }
.badge--import-new { background: var(--ok-bg); color: var(--ok-ink); }
.badge--import-existing { background: var(--info-bg); color: var(--info-ink); }
.badge--import-invalid { background: var(--err-bg); color: var(--err-ink); }
.import-row--in_event td, .import-row--duplicate td { color: var(--muted); }
.import-row--invalid td { background: #FFF8F7; }

@media (max-width: 820px) {
  .nav { gap: 12px; }
  .nav__group { flex-direction: row; flex-wrap: wrap; }
  .nav__heading { width: 100%; padding-top: 4px; }
  .nav__account { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  .nav__role { margin: 0; }
  .nav__account form { margin-left: auto; }
  .nav__logout { width: auto; }
  .main { padding: 20px 16px 40px; }
  .card { padding: 20px 16px; }
  .codes { grid-template-columns: 1fr; }
}

@media print {
  .nav, .auth__footer, form, .btn { display: none !important; }
  body, .auth { background: #FFFFFF; border: 0; }
  .card { box-shadow: none; }
}
