/* ═══════════════════════════════════════════════════════════════════
   SPORTBO — one stylesheet for all three surfaces
   Copper & Iron on the Baltic. Mobile-first (base = 375px); wider
   screens add, never override the phone layout. Rules: SPORTBO-IA §3.
   • tap targets ≥ 44px • inputs ≥ 16px • no sideways scroll
   • min-width:0 on flex/grid children • 100dvh • safe-area insets
═══════════════════════════════════════════════════════════════════ */

:root {
  --iron: #1C2226;
  --iron-2: #2A3237;
  --iron-3: #3B444B;
  --muted: #5B656D;
  --faint: #8A939A;
  --copper: #A5582F;
  --copper-dark: #7E4122;
  --copper-glow: #C8773F;
  --copper-light: #E3A57A;
  --copper-soft: #F6E7DC;
  --baltic: #1F4E6B;
  --baltic-soft: #E1EBF1;
  --page: #F4F1EC;
  --page-2: #EFEBE4;
  --surface: #FFFFFF;
  --border: #E3DDD3;
  --border-2: #F0EBE3;
  --good: #1E7650;  --good-soft: #E3F2EA;
  --warn: #875A00;  --warn-soft: #FBF0D9;
  --bad: #A8352A;   --bad-soft: #F8E4E1;
  --neutral-soft: #EFECE7;

  --r-sm: 10px; --r: 16px; --r-lg: 20px;
  --topbar-h: 56px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --text: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100dvh; }
body {
  font-family: var(--text); font-size: 16px; line-height: 1.45; color: var(--iron);
  background: var(--page); -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: var(--copper); }
a:hover { color: var(--copper-dark); }
button { font: inherit; color: inherit; }
img, svg { display: block; }
:focus-visible { outline: 3px solid var(--copper-glow); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.d { font-family: var(--display); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.u-text { overflow-wrap: break-word; min-width: 0; }

/* ── Icons ─────────────────────────────────────────────────────── */
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.ico-sm { width: 18px; height: 18px; }
.globe { width: 36px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2.6; flex-shrink: 0; }
.globe .eq { stroke: var(--copper-glow); }

/* ── App shell (attendee + director on phones) ─────────────────── */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) 8px 0 8px; display: flex; align-items: center; gap: 4px;
  background: rgba(244, 241, 236, .86); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 8px;
  text-decoration: none; color: var(--iron); border-radius: var(--r-sm); }
.topbar .brand-name { font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: .08em; }
.topbar .title { font-weight: 800; font-size: 17px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--iron); padding: 0; flex-shrink: 0; }
.icon-btn:hover { background: var(--page-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: #fff; background: var(--iron); flex-shrink: 0; }
.avatar.copper { background: var(--copper); } .avatar.baltic { background: var(--baltic); } .avatar.lg { width: 52px; height: 52px; font-size: 20px; }

.main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto;
  padding: 20px 16px calc(var(--nav-h) + var(--safe-b) + 28px); display: flex; flex-direction: column; gap: 18px; }
.main.no-nav { padding-bottom: calc(var(--safe-b) + 28px); }

.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex;
  height: calc(var(--nav-h) + var(--safe-b)); padding: 0 6px var(--safe-b);
  background: rgba(255, 255, 255, .92); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border); }
.bottomnav a { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: 11.5px; font-weight: 700; }
.bottomnav a[aria-current="page"] { color: var(--copper); }
.bottomnav.dark { background: rgba(21, 26, 29, .94); border-top-color: var(--iron-3); }
.bottomnav.dark a { color: #C9CED2; } .bottomnav.dark a[aria-current="page"] { color: var(--copper-light); }

/* ── Type ──────────────────────────────────────────────────────── */
h1, h2, h3 { margin: 0; }
.h1 { font-family: var(--display); font-size: 38px; font-weight: 700; line-height: 1; }
.h2 { font-family: var(--display); font-size: 26px; font-weight: 700; line-height: 1.1; }
.lbl { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.big { font-family: var(--display); font-weight: 700; line-height: .9; }

/* ── Cards, lists, rows ────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.card.pad { padding: 16px; }
.hero { border-radius: var(--r-lg); padding: 18px; display: block; text-decoration: none; }
.hero.iron { background: var(--iron); color: var(--page); }
.hero.baltic { background: var(--baltic); color: #fff; }
.hero.copper { background: var(--copper); color: #fff; }
.hero .lbl { color: var(--copper-light); }
.hero.baltic .lbl { color: #BFD6E4; }
.hero .sub { font-size: 14px; color: #C9CED2; margin-top: 6px; }
.hero.baltic .sub { color: #D5E3EC; }
.hero .more { display: flex; align-items: center; gap: 6px; margin-top: 14px; font-weight: 800; font-size: 14px; color: var(--copper-light); }
.hero.baltic .more { color: #fff; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.tile { background: var(--iron-2); border-radius: 12px; padding: 10px 12px; color: var(--copper-light); min-width: 0; }
.tile .v { font-family: var(--display); font-size: 24px; font-weight: 700; color: var(--page); margin-top: 4px; }
.tile .k { font-size: 12px; color: #C9CED2; }

.section { display: flex; flex-direction: column; gap: 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head .aside { font-size: 13px; color: var(--muted); font-weight: 700; }

.list { display: flex; flex-direction: column; gap: 1px; background: var(--border); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px; background: var(--surface);
  text-decoration: none; color: var(--iron); border: 0; width: 100%; text-align: left; }
button.row, a.row { cursor: pointer; }
button.row:hover, a.row:hover { background: #FBFAF8; color: var(--iron); }
.row.selected { background: var(--copper-soft); }
.row-body { flex: 1; min-width: 0; }
.row-title { display: block; font-weight: 700; font-size: 15px; overflow-wrap: break-word; }
.row-sub { display: block; font-size: 13px; color: var(--muted); margin-top: 1px; overflow-wrap: break-word; }
.row .chev { color: var(--faint); }

.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0;
  border-top: 1px solid var(--border-2); font-size: 14px; min-height: 44px; }
.kv > :first-child { color: var(--muted); }
.kv > :last-child { font-weight: 700; text-align: right; overflow-wrap: break-word; min-width: 0; }

/* ── Chips ─────────────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap; background: var(--neutral-soft); color: var(--iron-3); }
.chip.iron { background: var(--iron); color: #fff; } .chip.copper { background: var(--copper); color: #fff; }
.chip.baltic { background: var(--baltic); color: #fff; }
.chip.copper-soft { background: var(--copper-soft); color: var(--copper-dark); }
.chip.baltic-soft { background: var(--baltic-soft); color: var(--baltic); }
.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); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.fchip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-weight: 700; font-size: 14px; cursor: pointer; color: var(--iron-3); white-space: nowrap; }
.fchip[aria-pressed="true"] { background: var(--iron); color: #fff; border-color: var(--iron); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn { min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent; font-weight: 800; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.primary { background: var(--copper); color: #fff; }
.btn.primary:hover { background: var(--copper-dark); color: #fff; }
.btn.secondary { background: var(--surface); color: var(--iron); border-color: var(--border); }
.btn.secondary:hover { border-color: var(--iron-3); color: var(--iron); }
.btn.ghost { background: transparent; color: var(--copper); }
.btn.block { width: 100%; min-height: 50px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ── Forms ─────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 700; }
.input { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); font: inherit; font-size: 16px; color: var(--iron); }
.input:focus { outline: none; border-color: var(--copper); box-shadow: 0 0 0 3px var(--copper-soft); }
.input.code { font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: .2em; text-align: center; text-transform: uppercase; }
.help { font-size: 13px; color: var(--muted); }
.help.bad { color: var(--bad); font-weight: 700; }
.segmented { display: flex; gap: 4px; padding: 4px; background: #E9E4DC; border-radius: 14px; }
.segmented button { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  font-weight: 800; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--iron); box-shadow: 0 1px 3px rgba(28, 34, 38, .15); }

/* ── Sign-in screens ───────────────────────────────────────────── */
.signin { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 20px calc(32px + var(--safe-b)); gap: 22px; }
.signin-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; }
.signin .globe { width: 64px; height: 40px; color: var(--iron); }

/* ── States (Rule 6) ───────────────────────────────────────────── */
.state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 36px 20px; }
.state .ico { width: 34px; height: 34px; color: var(--copper); }
.state-title { font-weight: 800; font-size: 17px; }
.state-body { font-size: 14px; color: var(--muted); max-width: 34ch; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--copper); border-radius: 50%;
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.later-tag { margin-left: auto; font-size: 11px; font-weight: 800; letter-spacing: .06em; color: var(--faint); }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ── Sheet (Rule 7: edits on phones happen here) ───────────────── */
.scrim { position: fixed; inset: 0; background: rgba(28, 34, 38, .45); z-index: 40; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 88dvh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + var(--safe-b));
  box-shadow: 0 -6px 28px rgba(16, 24, 40, .18); }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.sheet-title { flex: 1; font-weight: 800; font-size: 18px; }

/* ── Trip strip ────────────────────────────────────────────────── */
.strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.strip .bar { height: 4px; border-radius: 2px; background: var(--baltic); }
.strip .bar.copper { background: var(--copper); } .strip .bar.iron { background: var(--iron); }
.strip .when { font-weight: 800; font-size: 13px; margin-top: 8px; }
.strip .what { font-size: 12px; color: var(--muted); line-height: 1.3; }

/* ── Public race page ──────────────────────────────────────────── */
.pub-hero { background: var(--iron); color: var(--page); padding: calc(22px + var(--safe-t)) 20px 28px; }
.pub-hero .lbl { color: var(--copper-light); }
.pub-main { max-width: 640px; margin: 0 auto; padding: 18px 16px calc(28px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
.pub-foot { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.5; padding: 4px 12px; }

/* ── Director console ──────────────────────────────────────────── */
.dir { min-height: 100dvh; }
.dir .sidebar { display: none; }
.dir-main { padding: 20px 16px calc(var(--nav-h) + var(--safe-b) + 28px); display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.stat .v { font-family: var(--display); font-size: 34px; font-weight: 700; line-height: 1.05; margin-top: 4px; }
.stat .s { font-size: 13px; color: var(--muted); }
.stat.iron { background: var(--iron); color: var(--page); } .stat.iron .lbl { color: var(--copper-light); }
.stat.copper { background: var(--copper); color: #fff; } .stat.copper .lbl { color: #FBE3D2; }
.stat.plain { background: var(--surface); border: 1px solid var(--border); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--copper); }
.people-table-head { display: none; }
.panel-head { display: flex; align-items: center; gap: 14px; }

@media (min-width: 900px) {
  .dir { display: flex; }
  .dir .sidebar { display: flex; flex-direction: column; gap: 6px; width: 248px; flex-shrink: 0; padding: 18px 14px;
    border-right: 1px solid var(--border); background: var(--page-2); position: sticky; top: 0; height: 100dvh; overflow-y: auto; }
  .dir .dir-topbar, .dir .dir-topbar-sub, .dir .bottomnav { display: none; }
  .dir-body { flex: 1; min-width: 0; display: flex; }
  .dir-main { flex: 1; padding: 28px 36px 40px; max-width: 1100px; }
  .side-link { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px;
    text-decoration: none; color: var(--iron-3); font-weight: 700; font-size: 15px; }
  .side-link:hover { background: rgba(255, 255, 255, .6); color: var(--iron); }
  .side-link[aria-current="page"] { background: var(--surface); color: var(--iron); box-shadow: 0 1px 2px rgba(28, 34, 38, .08); }
  .side-link[aria-current="page"] .ico { color: var(--copper); }
  .side-link.disabled { opacity: .6; cursor: default; }
  .side-link.disabled:hover { background: transparent; }
  .side-badge { margin-left: auto; background: var(--copper); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 800; }
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
  .two-col { display: grid; grid-template-columns: 1.35fr 1fr; gap: 22px; align-items: start; }
  .with-panel { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 0; align-items: start; }
  .with-panel .panel { position: sticky; top: 0; height: 100dvh; overflow-y: auto; background: var(--surface);
    border-left: 1px solid var(--border); padding: 24px 22px; }
  .people-table-head { display: grid; }
  .prow { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, .8fr); gap: 12px; align-items: center; }
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 480px; border-radius: 22px; }
}
.two-col, .with-panel { display: flex; flex-direction: column; gap: 18px; }
@media (min-width: 900px) { .two-col { display: grid; } .with-panel { display: grid; } }
.with-panel .panel-mobile-hidden { display: none; }
@media (min-width: 900px) { .with-panel .panel-mobile-hidden { display: block; } }

/* Attendee app on wide screens: phone-width column, nav stays at the bottom. */
@media (min-width: 700px) {
  .bottomnav.app { left: 50%; right: auto; transform: translateX(-50%); width: 640px; border-left: 1px solid var(--border);
    border-right: 1px solid var(--border); border-radius: 16px 16px 0 0; }
}
