/* Layout: soft blue sky wash with white rounded cards. One light look, as in the supplied design.
   The same pages everywhere: a sidebar on a laptop, a tab bar at the bottom of a phone. */
:root {
  color-scheme: light;
  --wash-a: #e7efff; --wash-b: #f3f0ff; --wash-c: #e3f3ff;
  --card: #ffffff; --ink: #131a3c; --muted: #5f6a8a; --line: #e4e9f6; --soft: #f2f6fe;
  --blue: #2f6bff; --blue-dark: #1f52d6; --blue-soft: #e3ecff;
  --green: #0f8f47; --green-bar: #2bbf7a; --green-soft: #d9f5e6;
  --orange: #d9720f; --peach: #ffe9d6; --orange-bar: #f5a623;
  --purple: #7c5cff; --lavender: #ece6ff;
  --mint: #d6f4ea;
  --gold: #f6c343; --gold-ink: #6b4e00; --silver: #cfd7e6; --silver-ink: #3e4a66; --bronze: #eeb086; --bronze-ink: #6e3a12;
  --danger: #c02b2b; --danger-soft: #fde4e4; --warn-ink: #7d5200; --warn-soft: #fff1d2;
  --shadow: 0 10px 30px rgba(52, 84, 160, .08);
  --radius: 16px;
  --tab-h: 0px;
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--wash-a); }
body {
  margin: 0; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  color: var(--ink); font: 400 14px/1.5 var(--font);
  background: linear-gradient(135deg, var(--wash-a), var(--wash-b) 55%, var(--wash-c)) fixed;
  background-color: var(--wash-a);
}
h1, h2, h3, p, ul, dl, dd { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { text-wrap: balance; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* App frame */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100dvh; }
.content { display: flex; flex-direction: column; min-width: 0; min-height: 100dvh; overflow-x: clip; }
.main {
  position: relative; isolation: isolate; flex: 1; width: 100%; max-width: 1120px; margin-inline: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-content: start;
  padding-block: calc(22px + env(safe-area-inset-top, 0px)) 40px;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.leaf { position: absolute; z-index: -1; pointer-events: none; color: #bcd5ff; }
.leaf-top { top: 56px; right: -18px; width: 120px; transform: scaleX(-1) rotate(-14deg); }
.tabbar { display: none; }

/* Login */
.login {
  min-height: 100dvh; display: grid; place-items: center;
  padding-block: calc(20px + env(safe-area-inset-top, 0px)) calc(20px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.login-card { width: min(400px, 100%); gap: 16px; padding: 26px 24px; }
.login-mark { width: 88px; height: 60px; }
.login-btn { width: 100%; min-height: 46px; font-size: 15px; }

.card { background: var(--card); border: 1px solid rgba(255, 255, 255, .9); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-pad { padding: 18px 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; }
.card-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 14px; font-weight: 700; }
.section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.art { display: inline-flex; line-height: 0; }
.art svg { width: 100%; height: 100%; display: block; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Top bar */
.top { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.brand { display: flex; gap: 14px; align-items: center; min-width: 0; }
.brand-mark { width: 74px; height: 50px; flex: none; }
h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; overflow-wrap: anywhere; }
.tagline { color: var(--muted); font-weight: 500; }
.anchor { position: relative; }
.icon-btn {
  appearance: none; background: var(--card); border: 0; box-shadow: var(--shadow); cursor: pointer; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; position: relative; flex: none; width: 44px; height: 44px;
}
.dot { position: absolute; top: 9px; right: 11px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--card); }
.popover {
  position: absolute; z-index: 20; top: calc(100% + 8px); right: 0; width: min(320px, calc(100vw - 32px)); background: var(--card);
  border-radius: 14px; box-shadow: 0 16px 40px rgba(30, 50, 110, .18); padding: 12px; display: grid; gap: 8px;
}
.pick-list { display: grid; gap: 2px; max-height: 300px; overflow-y: auto; }
.pick { appearance: none; background: none; border: 0; border-radius: 10px; padding: 7px 8px; display: flex; gap: 10px; align-items: center; cursor: pointer; text-align: left; font-weight: 600; }
.pick:hover { background: var(--soft); }

/* Avatars and rank medals */
.avatar { width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex: none; letter-spacing: .02em; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.medal { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.medal-1 { background: var(--gold); color: var(--gold-ink); }
.medal-2 { background: var(--silver); color: var(--silver-ink); }
.medal-3 { background: var(--bronze); color: var(--bronze-ink); }

/* Figure cards */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { padding: 14px 16px; display: flex; gap: 14px; align-items: center; }
.kpi-icon { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.kpi-icon .art { width: 30px; height: 30px; }
.tone-blue { background: var(--blue-soft); }
.tone-peach { background: var(--peach); }
.tone-mint { background: var(--mint); }
.tone-lavender { background: var(--lavender); }
.kpi-body { min-width: 0; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 23px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }

/* Leaderboard, event and running cards */
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.side { display: grid; gap: 14px; grid-template-rows: minmax(190px, 1fr) auto; min-width: 0; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--soft); border-radius: 10px; padding: 3px; }
.seg-wide { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.seg-btn { appearance: none; border: 0; background: none; padding: 5px 11px; border-radius: 8px; color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.seg-btn[aria-pressed="true"] { background: var(--blue-soft); color: var(--blue-dark); }
.rows { display: grid; }
.row { display: flex; gap: 12px; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--line); min-width: 0; }
.rows .row:last-child { border-bottom: 0; }
.row.is-me { background: var(--blue-soft); border-radius: 10px; padding-inline: 8px; }
.row-rank { width: 28px; display: grid; place-items: center; font-weight: 700; color: var(--muted); flex: none; }
.row-who { min-width: 0; flex: 1; }
.row-name { font-weight: 700; overflow-wrap: anywhere; line-height: 1.25; }
.row-sub { font-size: 12.5px; color: var(--muted); line-height: 1.3; overflow-wrap: anywhere; }
.row-value { text-align: right; font-size: 17px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-unit { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.link-btn { appearance: none; background: none; border: 0; color: var(--blue-dark); font-weight: 700; cursor: pointer; padding: 4px 0; display: inline-flex; gap: 4px; align-items: center; font-size: 13px; }

.hero { position: relative; overflow: hidden; border-radius: var(--radius); background: #33257f; color: #fff; display: flex; box-shadow: var(--shadow); min-height: 190px; }
.hero-art { position: absolute; inset: 0; }
.hero-text { position: relative; padding: 22px 24px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; max-width: 66%; min-width: 0; }
.hero-title { font-size: 20px; font-weight: 700; color: #fff; overflow-wrap: anywhere; }
.hero-points { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 16px; }
.hero-points .ic { color: #d6a8ff; }
.hero-chip { margin-top: auto; display: inline-flex; gap: 10px; align-items: center; padding: 8px 14px; border-radius: 14px; background: rgba(255, 255, 255, .16); min-width: 0; }
.hero-chip .art { width: 20px; height: 20px; flex: none; }
.hero-chip small { display: block; font-size: 12px; opacity: .85; }
.hero-chip strong { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.running { position: relative; overflow: hidden; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 104px 16px 20px; background: linear-gradient(100deg, #fff4e3, #ffe2bf); display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; min-width: 0; }
.running-head { display: flex; gap: 12px; align-items: center; min-width: 0; }
.running-icon { width: 34px; height: 34px; flex: none; color: var(--orange); }
.running-title { font-weight: 700; font-size: 15px; }
.running-sub { font-size: 13px; color: #6e5130; overflow-wrap: anywhere; }
.bar { height: 8px; border-radius: 999px; background: rgba(120, 90, 40, .14); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; }
.running-trophy { position: absolute; right: 12px; bottom: 6px; width: 80px; height: 96px; }

/* Your stats */
.stats { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px; align-items: center; }
.stat-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat-tile { background: var(--soft); border-radius: 12px; padding: 10px; display: flex; gap: 8px; align-items: center; min-width: 0; }
.stat-tile .art { width: 28px; height: 28px; flex: none; }
.stat-value { font-size: 17px; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--muted); line-height: 1.25; }
.chart { position: relative; min-width: 0; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart-axis { font-size: 11.5px; fill: var(--muted); font-family: var(--font); }
.tip { position: absolute; z-index: 5; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -100%); }

/* Winners and rules */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { border: 1px solid rgba(255, 255, 255, .9); background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; display: grid; gap: 2px; align-content: start; min-width: 0; }
.tile:hover { outline: 2px solid var(--blue-soft); }
.tile-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; font-weight: 700; }
.tile-note { font-size: 12.5px; color: var(--muted); }
.tile-name { font-size: 16px; font-weight: 800; margin-top: 4px; overflow-wrap: anywhere; line-height: 1.25; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 700; line-height: 1; padding: 4px 8px; border-radius: 99px; white-space: nowrap; }
.pill-good { background: var(--green-soft); color: #0b6a35; }
.pill-live { background: var(--peach); color: #93480a; }
.pill-bad { background: var(--danger-soft); color: var(--danger); }
.rules { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.rule { background: var(--soft); border-radius: 12px; padding: 14px; display: grid; gap: 2px; align-content: start; }
.rule strong { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.footnote { font-size: 12.5px; color: var(--muted); }
.empty { background: var(--soft); border-radius: 12px; padding: 20px; display: grid; gap: 4px; }

/* Navigation */
.sidebar { padding: calc(22px + env(safe-area-inset-top, 0px)) 14px 16px; display: flex; flex-direction: column; gap: 6px; background: rgba(255, 255, 255, .55); border-right: 1px solid var(--line); min-width: 0; position: sticky; top: 0; align-self: start; height: 100dvh; }
.sidebar-brand { display: flex; gap: 10px; align-items: center; font-weight: 800; font-size: 15px; padding: 2px 8px 16px; }
.sidebar-brand .art { width: 44px; height: 30px; flex: none; }
.side-nav { display: grid; gap: 4px; }
.side-link { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; font-weight: 600; color: #3b4566; white-space: nowrap; }
.side-link:hover { background: var(--soft); }
.side-link[aria-current="page"] { background: var(--blue-soft); color: var(--blue-dark); }
.side-foot { margin-top: auto; padding: 12px 12px 0; border-top: 1px solid var(--line); display: grid; gap: 2px; justify-items: start; }
.side-name { font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }

/* Admin screens */
.console-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.console-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }

.field { display: grid; gap: 4px; min-width: 0; }
.field label, .label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="date"], select {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; width: 100%; max-width: 100%; min-height: 40px;
}
.btn { appearance: none; font-weight: 700; font-size: 13.5px; padding: 9px 16px; border-radius: 10px; cursor: pointer; background: var(--card); color: var(--ink); border: 1px solid var(--line); white-space: nowrap; }
.btn:hover { border-color: var(--blue); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-danger { color: var(--danger); }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.grow { flex: 1 1 220px; }
.narrow { flex: 0 1 110px; }
.dropzone { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; justify-items: start; padding: 14px 16px; border: 2px dashed #c9d7f5; border-radius: 12px; background: var(--soft); }
input[type="file"] { width: 100%; max-width: 100%; font-size: 13px; color: var(--muted); }
input[type="file"]::file-selector-button { appearance: none; font: inherit; font-weight: 700; padding: 8px 14px; margin-right: 10px; border-radius: 10px; border: 1px solid var(--blue); background: var(--card); color: var(--blue-dark); cursor: pointer; }
.dropzone.is-over { border-color: var(--blue); background: var(--blue-soft); }
.feed { display: grid; gap: 10px; }
.feed li { display: flex; gap: 10px; align-items: baseline; font-size: 13px; font-weight: 500; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-bar); flex: none; transform: translateY(-1px); }
.feed-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.feed-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.table-wrap input[type="text"], .table-wrap select { min-width: 140px; }
.num { text-align: right; }
.total { font-weight: 700; }
.steps-table th:nth-child(2), .steps-table td:nth-child(2) { position: sticky; left: 0; background: var(--card); white-space: nowrap; }
.table-note { padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); }
.row-card { border-top: 1px solid var(--line); padding-top: 14px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.notice { border-radius: 12px; padding: 10px 14px; font-size: 13.5px; }
.notice ul { display: grid; gap: 2px; margin-top: 4px; }
.notice-good { background: var(--green-soft); color: #0b6a35; }
.notice-warn { background: var(--warn-soft); color: var(--warn-ink); }
.notice-bad { background: var(--danger-soft); color: var(--danger); }
.notice-info { background: var(--blue-soft); color: #1b3f9e; }
.publishbar { position: sticky; bottom: 0; z-index: 15; background: var(--card); border-top: 2px solid var(--blue); padding-bottom: env(safe-area-inset-bottom, 0px); box-shadow: 0 -6px 20px rgba(52, 84, 160, .1); }
.publishbar-inner { max-width: 1120px; margin-inline: auto; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.publishbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 860px) {
  :root { --tab-h: calc(58px + env(safe-area-inset-bottom, 0px)); }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .leaf { display: none; }
  .content { padding-bottom: var(--tab-h); }
  .main { padding-block: calc(16px + env(safe-area-inset-top, 0px)) 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); gap: 14px; }
  .tabbar {
    position: fixed; z-index: 30; inset: auto 0 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(52, 84, 160, .08);
    padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  }
  .tab { display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 58px; min-width: 0; padding: 6px 2px; color: var(--muted); font-size: 11.5px; font-weight: 600; }
  .tab .ic { width: 22px; height: 22px; }
  .tab[aria-current="page"] { color: var(--blue-dark); box-shadow: inset 0 2px 0 var(--blue); }
  .publishbar { bottom: var(--tab-h); padding-bottom: 0; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .grid-main, .stats, .rules { grid-template-columns: minmax(0, 1fr); }
  input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="date"], select { font-size: 16px; min-height: 44px; }
  .btn { min-height: 44px; }
  .seg-btn { min-height: 38px; padding: 7px 14px; font-size: 13.5px; }
  .link-btn { min-height: 44px; }
  .pick { min-height: 44px; }
}
@media (max-width: 480px) {
  .card-pad { padding: 16px; }
  .kpi { padding: 12px; gap: 10px; }
  .kpi-icon { width: 40px; height: 40px; }
  .kpi-icon .art { width: 24px; height: 24px; }
  .kpi-value { font-size: 19px; }
  .stat-tile { flex-direction: column; align-items: flex-start; }
  .hero-text { max-width: 78%; padding: 18px; }
  .brand-mark { width: 58px; height: 40px; }
  h1 { font-size: 20px; }
  .publishbar-actions { width: 100%; }
  .publishbar-actions .btn { flex: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .tile, .seg-btn, .side-link, .tab { transition: background-color .12s ease, border-color .12s ease; }
}
