:root {
  --green: #16a34a;
  --green-dark: #15803d;
  --sky: #0ea5e9;
  --ink: #0f172a;
  --muted: #64748b;
  --line: rgba(148, 163, 184, 0.28);
  --glass: rgba(255, 255, 255, 0.68);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --surface: rgba(248, 250, 252, 0.72);
  --danger: #dc2626;
  --warning: #f59e0b;
  --ok: #16a34a;
  --shadow: 0 22px 70px rgba(15, 23, 42, 0.11);
  --soft-shadow: 0 12px 34px rgba(15, 23, 42, 0.07);
  font-family: "Noto Sans Thai", "Segoe UI", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(22, 163, 74, 0.12), transparent 34%),
    linear-gradient(225deg, rgba(14, 165, 233, 0.16), transparent 36%),
    linear-gradient(180deg, #f8fafc 0%, #eef8f4 48%, #f8fbff 100%);
  font-weight: 500;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.72), transparent 82%);
}

body::after {
  position: fixed;
  inset: auto -10% 0 -10%;
  z-index: -1;
  height: 42vh;
  content: "";
  background:
    radial-gradient(circle at 20% 40%, rgba(22, 163, 74, 0.12), transparent 28%),
    radial-gradient(circle at 76% 56%, rgba(14, 165, 233, 0.12), transparent 26%);
  filter: blur(18px);
  animation: ambientMove 12s ease-in-out infinite alternate;
}

.auth-locked .app-header,
.auth-locked .tabs,
.auth-locked .ops-strip,
.auth-locked main {
  display: none;
}

.app-ready .login-screen {
  display: none;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: clamp(18px, 5vw, 48px);
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.82fr);
  gap: clamp(22px, 4vw, 42px);
  width: min(1120px, 100%);
  padding: clamp(22px, 5vw, 42px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.52)),
    radial-gradient(circle at 18% 18%, rgba(22, 163, 74, 0.12), transparent 32%),
    radial-gradient(circle at 88% 76%, rgba(14, 165, 233, 0.14), transparent 34%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(150%);
}

.login-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-copy h1 {
  margin: 16px 0 12px;
  max-width: 680px;
  font-size: clamp(2rem, 5.4vw, 3.65rem);
  font-weight: 800;
  line-height: 1.12;
}

.login-copy p {
  max-width: 620px;
  margin-bottom: 0;
  color: #475569;
  font-size: 1.05rem;
  line-height: 1.85;
}

.login-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.login-status small {
  color: var(--muted);
  font-weight: 800;
}

.webapp-login-link {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 40px;
  margin-top: 12px;
  padding: 8px 14px;
  border: 1px solid rgba(14, 165, 233, 0.24);
  border-radius: 8px;
  color: #075985;
  background: rgba(224, 242, 254, 0.72);
  font-size: 0.92rem;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(14, 165, 233, 0.12);
}

.webapp-login-link[hidden] {
  display: none;
}

.login-options {
  display: grid;
  gap: 14px;
}

.login-card {
  position: relative;
  overflow: hidden;
  min-height: 190px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 8px;
  text-align: left;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.46));
  box-shadow: var(--soft-shadow);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.login-card::after {
  position: absolute;
  right: -28px;
  bottom: -32px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  content: "";
  background: rgba(22, 163, 74, 0.08);
}

.login-card:hover {
  transform: translateY(-3px);
  border-color: rgba(14, 165, 233, 0.32);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.14);
}

.login-card span {
  display: inline-flex;
  margin-bottom: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  color: white;
  background: linear-gradient(135deg, var(--green), var(--sky));
  font-size: 0.78rem;
  font-weight: 900;
}

.login-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 1.34rem;
  font-weight: 800;
}

.login-card small {
  display: block;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.admin-login span {
  background: linear-gradient(135deg, #0f172a, #0ea5e9);
}

.admin-login::after {
  background: rgba(14, 165, 233, 0.1);
}

.landing-track {
  position: relative;
  width: min(520px, 100%);
  height: 74px;
  margin-top: 28px;
  border: 1px solid rgba(22, 163, 74, 0.14);
  border-radius: 8px;
  background:
    repeating-linear-gradient(90deg, rgba(15, 23, 42, 0.04) 0 1px, transparent 1px 54px),
    rgba(255, 255, 255, 0.34);
  overflow: hidden;
}

.landing-track::before {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 36px;
  height: 4px;
  border-radius: 999px;
  content: "";
  background: linear-gradient(90deg, var(--green), var(--sky));
  opacity: 0.78;
}

.landing-track span {
  position: absolute;
  top: 28px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 0 6px rgba(14, 165, 233, 0.12);
}

.landing-track span:nth-child(1) { left: 14%; background: var(--green); }
.landing-track span:nth-child(2) { left: 48%; background: var(--sky); }
.landing-track span:nth-child(3) { right: 14%; background: #f59e0b; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1200px, calc(100% - 24px));
  margin: 14px auto 0;
  padding: clamp(20px, 4vw, 34px);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.48));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(150%);
}

.eyebrow {
  display: inline-flex;
  margin: 0 0 8px;
  padding: 5px 10px;
  color: var(--green-dark);
  border: 1px solid rgba(22, 163, 74, 0.22);
  border-radius: 999px;
  background: rgba(240, 253, 244, 0.72);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(1.55rem, 4vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: 0;
  font-weight: 800;
}

h2 {
  margin-bottom: 0;
  font-size: 1.02rem;
  letter-spacing: 0;
  font-weight: 800;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.tabs {
  position: sticky;
  top: 10px;
  z-index: 3;
  display: flex;
  gap: 6px;
  width: min(1200px, calc(100% - 24px));
  margin: 12px auto 0;
  overflow-x: auto;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(18px) saturate(150%);
}

.ops-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(1200px, calc(100% - 24px));
  margin: 10px auto 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(16px);
}

.ops-strip > div {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ops-strip small {
  color: var(--muted);
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  color: #334155;
  background: rgba(226, 232, 240, 0.78);
  font-size: 0.78rem;
  font-weight: 900;
}

.status-pill.connected {
  color: #14532d;
  background: rgba(220, 252, 231, 0.82);
}

.status-pill.syncing {
  color: #075985;
  background: rgba(224, 242, 254, 0.86);
}

.status-pill.warning {
  color: #78350f;
  background: rgba(254, 243, 199, 0.86);
}

.runner-control {
  margin-left: auto;
}

.role-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
}

.mode-button {
  margin-left: 0;
}

.role-control select {
  min-height: 34px;
  padding: 6px 30px 6px 10px;
}

.role-control select:disabled {
  color: #0f172a;
  border-color: rgba(22, 163, 74, 0.22);
  background: rgba(240, 253, 244, 0.72);
  opacity: 1;
  cursor: not-allowed;
}

.tab,
.segmented button {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #475569;
  background: transparent;
  white-space: nowrap;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.tab:hover,
.segmented button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
}

.tab.active,
.segmented button.active {
  color: white;
  border-color: rgba(22, 163, 74, 0.38);
  background: linear-gradient(135deg, var(--green), var(--sky));
  box-shadow: 0 10px 24px rgba(22, 163, 74, 0.22);
}

main {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 4vw, 32px) 40px;
}

.race-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(300px, 1.05fr);
  gap: 20px;
  min-height: 320px;
  margin-bottom: 14px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.46)),
    linear-gradient(120deg, rgba(22, 163, 74, 0.11), rgba(14, 165, 233, 0.12));
}

.race-hero::before {
  position: absolute;
  inset: 18px;
  content: "";
  border: 1px solid rgba(22, 163, 74, 0.16);
  border-radius: 8px;
  background:
    repeating-radial-gradient(ellipse at center, transparent 0 28px, rgba(22, 163, 74, 0.08) 29px 31px),
    linear-gradient(90deg, transparent 0 48%, rgba(255, 255, 255, 0.56) 48% 52%, transparent 52%);
  opacity: 0.68;
  pointer-events: none;
}

.hero-copy,
.race-visual {
  position: relative;
  z-index: 1;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.event-pill {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  padding: 5px 10px;
  color: var(--green-dark);
  border: 1px solid rgba(22, 163, 74, 0.22);
  border-radius: 999px;
  background: rgba(240, 253, 244, 0.74);
  font-size: 0.78rem;
  font-weight: 900;
}

.race-hero h2 {
  margin: 14px 0 10px;
  font-size: clamp(1.7rem, 5vw, 3.35rem);
  line-height: 1.05;
}

.race-hero p {
  max-width: 560px;
  margin-bottom: 0;
  color: #475569;
  font-size: 1rem;
  line-height: 1.7;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.hero-stats div,
.risk-metrics div {
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.hero-stats small,
.risk-metrics small {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.hero-stats strong,
.risk-metrics strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 1.28rem;
}

.race-visual {
  display: grid;
  align-content: center;
  gap: 16px;
}

.progress-ring {
  display: grid;
  place-items: center;
  width: 172px;
  height: 172px;
  justify-self: end;
  border-radius: 50%;
  background:
    conic-gradient(var(--green) var(--progress), rgba(226, 232, 240, 0.64) 0),
    rgba(255, 255, 255, 0.6);
  box-shadow: 0 18px 42px rgba(22, 163, 74, 0.17);
}

.progress-ring > div {
  display: grid;
  place-items: center;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.82);
}

.progress-ring strong {
  color: var(--green-dark);
  font-size: 2rem;
  line-height: 1;
}

.progress-ring small {
  color: var(--muted);
  font-weight: 800;
}

.route-map {
  position: relative;
  min-height: 152px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
  overflow: hidden;
}

.route-map svg {
  width: 100%;
  height: 150px;
}

.route-shadow,
.route-line {
  fill: none;
  stroke-linecap: round;
}

.route-shadow {
  stroke: rgba(15, 23, 42, 0.1);
  stroke-width: 16;
}

.route-line {
  stroke: url("#routeGradient");
  stroke-dasharray: 12 12;
  stroke-width: 6;
  animation: routeDash 9s linear infinite;
}

.route-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--sky);
  box-shadow: 0 0 0 8px rgba(14, 165, 233, 0.12);
}

.dot-a { left: 8%; bottom: 26%; }
.dot-b { left: 52%; top: 34%; background: var(--green); }
.dot-c { right: 6%; top: 21%; }

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid,
.dashboard-grid,
.form-grid {
  display: grid;
  gap: 14px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.runner-profile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  overflow: hidden;
}

.runner-identity h2 {
  margin: 10px 0 6px;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
}

.runner-identity p {
  margin-bottom: 0;
  color: var(--muted);
}

.runner-home-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.runner-home-actions span,
.runner-bib-card span {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 900;
}

.runner-home-actions span {
  color: #075985;
  background: rgba(224, 242, 254, 0.76);
}

.runner-bib-card {
  min-width: 220px;
  padding: 18px;
  border-radius: 8px;
  color: white;
  background:
    linear-gradient(135deg, var(--dept-color, var(--green)), rgba(14, 165, 233, 0.92)),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.22) 0 8px, transparent 8px 16px);
  box-shadow: 0 18px 42px color-mix(in srgb, var(--dept-color, var(--green)) 32%, transparent);
}

.runner-bib-card small {
  display: block;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 900;
}

.runner-bib-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(2.4rem, 7vw, 4rem);
  line-height: 0.95;
}

.runner-bib-card span {
  margin-top: 14px;
  color: rgba(255, 255, 255, 0.94);
  background: rgba(255, 255, 255, 0.18);
}

.runner-bib-card.is-pulsing {
  animation: bibPulse 900ms ease;
}

.personal-metrics .metric {
  border-left: 5px solid var(--dept-color, var(--green));
}

.metric,
.panel {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: var(--glass);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(18px) saturate(145%);
}

.metric {
  position: relative;
  overflow: hidden;
  min-height: 126px;
  padding: 18px;
}

.metric-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  min-width: 42px;
  height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  color: white;
  background: rgba(15, 23, 42, 0.72);
  font-size: 0.72rem;
  font-weight: 900;
}

.metric-distance .metric-icon { background: linear-gradient(135deg, #16a34a, #0ea5e9); }
.metric-runners .metric-icon { background: linear-gradient(135deg, #0ea5e9, #22c55e); }
.metric-runs .metric-icon { background: linear-gradient(135deg, #15803d, #84cc16); }
.metric-calories .metric-icon { background: linear-gradient(135deg, #f59e0b, #16a34a); }
.metric-pending .metric-icon { background: linear-gradient(135deg, #f59e0b, #f97316); }

.metric::after {
  position: absolute;
  right: 16px;
  bottom: 12px;
  width: 44px;
  height: 3px;
  border-radius: 999px;
  content: "";
  background: linear-gradient(90deg, var(--green), var(--sky));
  opacity: 0.6;
}

.metric span,
.metric small,
.panel-heading span {
  color: var(--muted);
}

.metric span {
  font-weight: 700;
}

.metric strong {
  display: block;
  margin: 10px 0 4px;
  color: var(--green-dark);
  font-size: clamp(1.8rem, 5vw, 2.55rem);
  line-height: 1;
}

.sparkline {
  position: absolute;
  right: 18px;
  bottom: 22px;
  display: flex;
  align-items: end;
  gap: 4px;
  height: 34px;
}

.sparkline i {
  display: block;
  width: 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(14, 165, 233, 0.82), rgba(22, 163, 74, 0.72));
}

.sparkline i:nth-child(1) { height: 12px; }
.sparkline i:nth-child(2) { height: 22px; }
.sparkline i:nth-child(3) { height: 16px; }
.sparkline i:nth-child(4) { height: 30px; }
.sparkline i:nth-child(5) { height: 25px; }

.dashboard-grid {
  grid-template-columns: 1.4fr 1fr;
}

.panel {
  padding: 18px;
}

.panel.wide {
  grid-column: span 2;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 4px 9px;
  border: 1px solid rgba(14, 165, 233, 0.18);
  border-radius: 999px;
  background: rgba(240, 249, 255, 0.74);
  font-size: 0.78rem;
  font-weight: 800;
}

.form-panel {
  max-width: 960px;
  margin: 0 auto;
}

.register-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 14px;
  align-items: start;
}

.bib-preview {
  position: sticky;
  top: 92px;
}

.bib-card {
  position: relative;
  overflow: hidden;
  min-height: 250px;
  padding: 22px;
  color: white;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(22, 163, 74, 0.95), rgba(14, 165, 233, 0.9)),
    linear-gradient(90deg, rgba(255,255,255,0.22) 0 2px, transparent 2px 18px);
  box-shadow: 0 22px 48px rgba(22, 163, 74, 0.24);
}

.bib-card::before,
.bib-card::after {
  position: absolute;
  left: 0;
  right: 0;
  height: 26px;
  content: "";
  background: repeating-linear-gradient(90deg, rgba(255,255,255,0.85) 0 18px, transparent 18px 34px);
  opacity: 0.35;
}

.bib-card::before { top: 0; }
.bib-card::after { bottom: 0; }

.bib-label {
  display: inline-flex;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.8rem;
  font-weight: 900;
}

.bib-card strong {
  display: block;
  margin: 42px 0 12px;
  font-size: clamp(3.2rem, 9vw, 5rem);
  letter-spacing: 0;
  line-height: 0.9;
}

.bib-card p {
  margin-bottom: 2px;
  font-size: 1.15rem;
  font-weight: 900;
}

.bib-card small {
  color: rgba(255, 255, 255, 0.82);
}

.bib-note {
  margin-top: 14px;
}

.bib-note h3 {
  margin: 0 0 6px;
}

.bib-note p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.podium-card {
  position: relative;
  overflow: hidden;
  min-height: 168px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
  border-top: 4px solid var(--dept-color, rgba(22, 163, 74, 0.6));
}

.podium-card::after {
  position: absolute;
  right: -24px;
  bottom: -34px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  content: "";
  background: color-mix(in srgb, var(--dept-color, #0ea5e9) 20%, transparent);
}

.podium-card.rank-1 {
  min-height: 196px;
  transform: translateY(-8px);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(240, 253, 244, 0.66));
}

.medal {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: white;
  background: linear-gradient(135deg, #f59e0b, #facc15);
  font-weight: 900;
}

.rank-2 .medal { background: linear-gradient(135deg, #94a3b8, #e2e8f0); color: #334155; }
.rank-3 .medal { background: linear-gradient(135deg, #b45309, #fdba74); }

.podium-card h3 {
  margin: 14px 0 4px;
  font-size: 1.05rem;
}

.podium-card p {
  margin-bottom: 8px;
  color: var(--muted);
}

.podium-card strong {
  color: var(--green-dark);
  font-size: 1.45rem;
}

.form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.custom-fields {
  display: contents;
}

.submit-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.flow-step {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  color: #64748b;
  background: rgba(255, 255, 255, 0.45);
}

.flow-step strong {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: white;
  background: #94a3b8;
}

.flow-step span {
  font-weight: 900;
}

.flow-step.active {
  color: #075985;
  border-color: rgba(14, 165, 233, 0.28);
  background: rgba(224, 242, 254, 0.68);
}

.flow-step.active strong,
.flow-step.done strong {
  background: linear-gradient(135deg, var(--green), var(--sky));
}

.flow-step.done {
  color: #166534;
  border-color: rgba(22, 163, 74, 0.2);
}

.run-preview {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid rgba(14, 165, 233, 0.22);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(240, 249, 255, 0.74), rgba(255, 255, 255, 0.54));
}

.run-preview[data-risk="clear"] {
  border-color: rgba(22, 163, 74, 0.22);
  background: linear-gradient(135deg, rgba(240, 253, 244, 0.78), rgba(255, 255, 255, 0.54));
}

.run-preview[data-risk="low"],
.run-preview[data-risk="medium"] {
  border-color: rgba(245, 158, 11, 0.28);
  background: linear-gradient(135deg, rgba(255, 251, 235, 0.78), rgba(255, 255, 255, 0.54));
}

.run-preview[data-risk="high"] {
  border-color: rgba(220, 38, 38, 0.26);
  background: linear-gradient(135deg, rgba(254, 242, 242, 0.82), rgba(255, 255, 255, 0.54));
}

.run-preview span,
.run-preview small,
.preview-metrics small {
  color: var(--muted);
  font-weight: 900;
}

.run-preview strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
}

.preview-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 10px;
  min-width: min(360px, 100%);
}

.preview-metrics div {
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}

label,
.stack {
  display: grid;
  gap: 8px;
}

label {
  color: #475569;
  font-size: 0.9rem;
  font-weight: 700;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.checkbox-row input {
  width: auto;
  min-height: 0;
}

input,
select,
textarea,
.search {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.66);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(14, 165, 233, 0.72);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.14);
}

.primary-button,
.ghost-button {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  align-self: end;
  border: 1px solid rgba(22, 163, 74, 0.38);
  color: white;
  background: linear-gradient(135deg, var(--green), var(--sky));
  box-shadow: 0 13px 28px rgba(22, 163, 74, 0.24);
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.ghost-button {
  border: 1px solid rgba(255, 255, 255, 0.72);
  color: var(--green-dark);
  background: rgba(255, 255, 255, 0.38);
  backdrop-filter: blur(12px);
}

main .ghost-button {
  color: var(--green-dark);
  border-color: rgba(22, 163, 74, 0.18);
  background: rgba(240, 253, 244, 0.62);
}

.result-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(22, 163, 74, 0.22);
  border-radius: 8px;
  color: #14532d;
  background: rgba(240, 253, 244, 0.7);
  backdrop-filter: blur(12px);
}

.result-box.error {
  border-color: rgba(220, 38, 38, 0.22);
  color: #7f1d1d;
  background: rgba(254, 242, 242, 0.72);
}

.toolbar,
.export-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.leaderboard-motivation {
  position: sticky;
  top: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  overflow: hidden;
}

.leaderboard-motivation::after {
  content: "";
  position: absolute;
  right: 28px;
  bottom: -36px;
  width: 150px;
  height: 150px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.12);
}

.leaderboard-motivation h2 {
  margin: 9px 0 5px;
}

.leaderboard-motivation p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.risk-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.risk-summary h2 {
  margin-top: 10px;
  font-size: clamp(1.35rem, 3vw, 2.1rem);
}

.risk-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(95px, 1fr));
  gap: 10px;
  min-width: min(440px, 100%);
}

.segmented {
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(16px);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
}

.dept-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  color: color-mix(in srgb, var(--dept-color) 72%, #0f172a);
  background: color-mix(in srgb, var(--dept-color) 13%, white);
  border: 1px solid color-mix(in srgb, var(--dept-color) 24%, transparent);
  font-size: 0.82rem;
  font-weight: 900;
}

.dept-chip::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  content: "";
  background: var(--dept-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--dept-color) 14%, transparent);
}

.heatmap {
  display: grid;
  grid-template-columns: 82px repeat(7, minmax(34px, 1fr));
  gap: 7px;
  align-items: stretch;
}

.heatmap-label,
.heatmap-day,
.heat-cell {
  min-height: 34px;
  border-radius: 8px;
}

.heatmap-label,
.heatmap-day {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.heat-cell {
  display: grid;
  place-items: center;
  color: #0f172a;
  background: rgba(22, 163, 74, calc(0.08 + (var(--intensity) * 0.58)));
  border: 1px solid rgba(255, 255, 255, 0.62);
  font-size: 0.78rem;
  font-weight: 900;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  text-align: left;
  vertical-align: top;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.54);
}

th {
  color: var(--muted);
  background: rgba(248, 250, 252, 0.62);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.badge.ok {
  color: #14532d;
  background: rgba(220, 252, 231, 0.8);
}

.badge.warn {
  color: #78350f;
  background: rgba(254, 243, 199, 0.82);
}

.badge.info {
  color: #075985;
  background: rgba(224, 242, 254, 0.82);
}

.badge.danger {
  color: #7f1d1d;
  background: rgba(254, 226, 226, 0.82);
}

.notice,
.flag-item {
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.flag-item {
  border-color: rgba(245, 158, 11, 0.24);
  background: linear-gradient(135deg, rgba(255, 251, 235, 0.72), rgba(255, 255, 255, 0.52));
}

.risk-card[data-risk="high"] {
  border-color: rgba(220, 38, 38, 0.28);
  background: linear-gradient(135deg, rgba(254, 242, 242, 0.8), rgba(255, 255, 255, 0.54));
}

.risk-card[data-risk="medium"] {
  border-color: rgba(245, 158, 11, 0.28);
}

.risk-card[data-risk="low"] {
  border-color: rgba(14, 165, 233, 0.22);
  background: linear-gradient(135deg, rgba(240, 249, 255, 0.78), rgba(255, 255, 255, 0.54));
}

.risk-card-head,
.risk-card-grid {
  display: grid;
  gap: 10px;
}

.risk-card-head {
  grid-template-columns: auto 1fr;
  align-items: center;
  margin-bottom: 10px;
}

.risk-card-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.risk-card-grid div {
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
}

.risk-card-grid small {
  display: block;
  color: var(--muted);
  font-weight: 900;
}

.risk-card-grid a {
  color: #075985;
}

.risk-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.risk-reasons span {
  padding: 5px 9px;
  border-radius: 999px;
  color: #78350f;
  background: rgba(254, 243, 199, 0.82);
  font-size: 0.82rem;
  font-weight: 900;
}

.ocr-review-block {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #f8fbff;
}

.ocr-review-block.empty {
  display: grid;
  gap: 3px;
  color: var(--muted);
  border-color: #e2e8f0;
  background: #f8fafc;
}

.ocr-review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.ocr-compare-grid {
  display: grid;
  gap: 6px;
}

.ocr-compare-grid > div {
  display: grid;
  grid-template-columns: minmax(90px, .7fr) repeat(2, minmax(110px, 1fr));
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
}

.ocr-compare-grid small {
  color: var(--muted);
  font-weight: 800;
}

.ocr-compare-grid strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .86rem;
}

.ocr-compare-label {
  background: #eff6ff !important;
}

.ocr-review-raw {
  margin-top: 9px;
}

.ocr-review-raw summary {
  cursor: pointer;
  color: #0369a1;
  font-size: .8rem;
  font-weight: 900;
}

.ocr-review-raw pre {
  max-height: 150px;
  margin: 8px 0 0;
  overflow: auto;
  padding: 10px;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  font: .74rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.proof-preview {
  display: block;
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
}

.proof-preview img {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
}

.risk-level {
  display: inline-flex;
  margin-bottom: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  color: #7f1d1d;
  background: rgba(254, 226, 226, 0.82);
  font-size: 0.75rem;
  font-weight: 900;
}

.risk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.mini-button {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
  font-weight: 800;
}

.mini-button.approve {
  color: #14532d;
  border-color: rgba(22, 163, 74, 0.2);
  background: rgba(220, 252, 231, 0.76);
}

.mini-button.reject {
  color: #7f1d1d;
  border-color: rgba(220, 38, 38, 0.2);
  background: rgba(254, 226, 226, 0.76);
}

.mini-button.ask {
  color: #075985;
  border-color: rgba(14, 165, 233, 0.22);
  background: rgba(224, 242, 254, 0.76);
}

.ocr-workspace {
  grid-column: 1 / -1;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #f8fafc;
}

.ocr-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.ocr-heading > div {
  display: grid;
  gap: 3px;
}

.ocr-kicker {
  color: #0ea5e9;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ocr-heading strong {
  font-size: 1rem;
}

.ocr-heading small {
  color: var(--muted);
  line-height: 1.55;
}

.ocr-progress {
  height: 7px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.ocr-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0ea5e9, #16a34a);
  transition: width 180ms ease;
}

.ocr-result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.ocr-result-grid[hidden],
.ocr-actions[hidden],
.ocr-raw[hidden],
.ocr-progress[hidden] {
  display: none;
}

.ocr-result-grid > div {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
}

.ocr-result-grid small,
.ocr-result-grid strong {
  display: block;
}

.ocr-result-grid small {
  color: var(--muted);
  font-size: 0.76rem;
}

.ocr-result-grid strong {
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ocr-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.ocr-raw {
  margin-top: 12px;
  color: var(--muted);
}

.ocr-raw summary {
  cursor: pointer;
  font-weight: 800;
}

.ocr-raw pre {
  max-height: 180px;
  margin: 10px 0 0;
  overflow: auto;
  padding: 12px;
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  font: 0.76rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.proof-file-preview {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(140px, 0.38fr) 1fr;
  gap: 14px;
  align-items: center;
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(14, 165, 233, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
}

.proof-file-preview[hidden] {
  display: none;
}

.proof-file-preview img {
  width: 100%;
  max-height: 170px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.proof-file-preview figcaption {
  color: #475569;
  font-weight: 900;
  line-height: 1.55;
}

.proof-file-preview small {
  color: var(--muted);
}

.proof-warning {
  grid-column: 1 / -1;
  color: #7f1d1d;
}

.health-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.health-actions p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.health-grid:empty {
  display: none;
}

.health-overview,
.health-card {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
}

.health-overview {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.health-card {
  padding: 12px;
}

.health-overview.ok,
.health-card.ok {
  border-color: rgba(22, 163, 74, 0.18);
  background: rgba(240, 253, 244, 0.62);
}

.health-overview.warn,
.health-card.warn {
  border-color: rgba(245, 158, 11, 0.2);
  background: rgba(255, 251, 235, 0.68);
}

.health-card div {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
}

.health-card span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  color: #14532d;
  background: rgba(220, 252, 231, 0.82);
  font-size: 0.76rem;
  font-weight: 900;
}

.health-card.warn span {
  color: #78350f;
  background: rgba(254, 243, 199, 0.9);
}

.health-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.settings-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.setting-chip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
}

.setting-chip span {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--dept-color, var(--green));
}

.setting-chip small {
  color: var(--muted);
  font-weight: 900;
}

@keyframes bibPulse {
  0% { transform: scale(1); box-shadow: 0 18px 42px color-mix(in srgb, var(--dept-color, var(--green)) 32%, transparent); }
  45% { transform: scale(1.025); box-shadow: 0 26px 58px color-mix(in srgb, var(--dept-color, var(--green)) 54%, transparent); }
  100% { transform: scale(1); box-shadow: 0 18px 42px color-mix(in srgb, var(--dept-color, var(--green)) 32%, transparent); }
}

.log-list {
  display: grid;
  gap: 10px;
}

.log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
}

.log-item strong {
  text-transform: capitalize;
}

.log-item p,
.log-item small {
  display: block;
  margin: 3px 0 0;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid rgba(22, 163, 74, 0.22);
  border-radius: 8px;
  color: #14532d;
  background: rgba(240, 253, 244, 0.86);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
  backdrop-filter: blur(16px);
  font-weight: 800;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  color: #7f1d1d;
  border-color: rgba(220, 38, 38, 0.22);
  background: rgba(254, 242, 242, 0.9);
}

button.is-loading {
  cursor: wait;
  opacity: 0.72;
}

.notice h3,
.flag-item h3 {
  margin: 0 0 5px;
  font-size: 0.98rem;
}

.notice p,
.flag-item p {
  margin: 0;
  color: var(--muted);
}

canvas {
  width: 100%;
  max-width: 100%;
}

@media (max-width: 900px) {
  .metric-grid,
  .dashboard-grid,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel.wide {
    grid-column: span 2;
  }

  .race-hero,
  .register-layout {
    grid-template-columns: 1fr;
  }

  .progress-ring {
    justify-self: start;
  }

  .bib-preview {
    position: static;
  }

  .login-panel {
    grid-template-columns: 1fr;
  }

  .submit-flow,
  .preview-metrics {
    grid-template-columns: 1fr;
  }

  .run-preview,
  .leaderboard-motivation {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .ops-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .ops-strip > div,
  .role-control,
  .runner-profile {
    align-items: stretch;
    flex-direction: column;
  }

  .runner-bib-card {
    min-width: 0;
    width: 100%;
  }

  .login-status {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid,
  .dashboard-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .panel.wide {
    grid-column: auto;
  }

  .panel-heading,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented {
    overflow-x: auto;
  }

  .race-hero {
    min-height: auto;
  }

  .hero-stats,
  .podium,
  .risk-summary,
  .risk-metrics,
  .risk-card-grid,
  .health-grid,
  .ocr-result-grid,
  .proof-file-preview {
    grid-template-columns: 1fr;
  }

  .ocr-compare-grid > div {
    grid-template-columns: 1fr;
  }

  .ocr-review-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .risk-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .podium-card.rank-1 {
    transform: none;
  }

  .heatmap {
    grid-template-columns: 70px repeat(7, minmax(30px, 1fr));
    gap: 5px;
    overflow-x: auto;
  }
}

@keyframes routeDash {
  to { stroke-dashoffset: -144; }
}

@keyframes ambientMove {
  from { transform: translate3d(-2%, 0, 0); }
  to { transform: translate3d(2%, -3%, 0); }
}


/* MaterialPro-inspired dashboard shell */
body:not(.auth-locked){color:#263238;background:#f4f7fb}body:not(.auth-locked)::before,body:not(.auth-locked)::after{display:none}.app-header{width:100%;min-height:86px;margin:0;padding:16px max(24px,calc((100vw - 1240px)/2));border:0;border-bottom:1px solid #e8edf2;border-radius:0;background:#fff;box-shadow:0 1px 4px rgba(15,23,42,.04);backdrop-filter:none}.brand-block,.header-actions{display:flex;align-items:center}.brand-block{gap:14px;min-width:0}.brand-mark{display:grid;flex:0 0 46px;width:46px;height:46px;place-items:center;border-radius:12px;color:#fff;background:linear-gradient(135deg,#1e88e5,#5c6bc0);box-shadow:0 6px 16px rgba(30,136,229,.22);font-size:.82rem;font-weight:900;letter-spacing:.06em}.app-header .eyebrow{margin:0 0 2px;color:#1e88e5;font-size:.7rem;font-weight:800;letter-spacing:.09em}.app-header h1{margin:0;color:#263238;font-size:clamp(1rem,2vw,1.28rem)}.page-context{margin:3px 0 0;color:#78909c;font-size:.76rem}.header-actions{gap:10px}.header-chip{display:inline-flex;min-height:32px;align-items:center;padding:5px 11px;border:1px solid #dce8f5;border-radius:999px;color:#1565c0;background:#f3f8fd;font-size:.74rem;font-weight:700;white-space:nowrap}.tabs{position:sticky;top:0;z-index:8;width:100%;margin:0;padding:0 max(24px,calc((100vw - 1240px)/2));gap:2px;border:0;border-bottom:1px solid #dfe7ee;border-radius:0;background:#fff;box-shadow:0 2px 7px rgba(15,23,42,.04);backdrop-filter:none;scrollbar-width:none}.tabs::-webkit-scrollbar{display:none}.tab{min-height:50px;padding:0 15px;border:0;border-bottom:3px solid transparent;border-radius:0;color:#607d8b;background:transparent;font-size:.82rem;font-weight:700;white-space:nowrap}.tab:hover{color:#1e88e5;background:#f8fbff}.tab.active{color:#1e88e5;border-bottom-color:#1e88e5;background:transparent;box-shadow:none}.ops-strip{width:min(1240px,calc(100% - 32px));margin:18px auto 0;padding:10px 14px;border:1px solid #e8edf2;border-radius:10px;background:#fff;box-shadow:0 2px 12px rgba(31,45,61,.07);backdrop-filter:none}.ops-strip small,.role-control{color:#78909c}.role-control select,select,input,textarea{border-color:#dfe7ee;border-radius:7px;background-color:#fff}main{width:min(1240px,100%);padding:18px 16px 48px}.metric,.panel{border:1px solid #e8edf2;border-radius:10px;background:#fff;box-shadow:0 2px 12px rgba(31,45,61,.07);backdrop-filter:none;transition:box-shadow .16s ease,transform .16s ease}.metric:hover,.panel:hover{box-shadow:0 8px 24px rgba(31,45,61,.11)}.race-hero{min-height:240px;grid-template-columns:minmax(0,1.2fr) minmax(280px,.8fr);gap:24px;margin-bottom:18px;padding:24px;overflow:hidden;color:#263238;border-color:#dbe8f5;background:linear-gradient(110deg,#fff 0%,#fff 55%,rgba(232,243,252,.9) 100%)}.race-hero::before{inset:auto -60px -100px auto;width:300px;height:300px;border:0;border-radius:50%;background:rgba(30,136,229,.06)}.race-hero h2{margin:10px 0 8px;color:#263238;font-size:clamp(1.55rem,3.2vw,2.35rem)}.race-hero p{color:#607d8b}.race-hero .event-pill{color:#1565c0;border-color:#d6e7f7;background:#f0f7fd}.hero-stats>div{border-color:#e6edf3;background:rgba(255,255,255,.84)}.metric-grid{gap:18px;margin-bottom:18px}.metric{min-height:118px;padding:18px 18px 16px}.metric::after{display:none}.metric-icon{top:16px;right:16px;min-width:40px;height:40px;border-radius:10px;box-shadow:none;font-size:.68rem}.metric-runners .metric-icon{background:#e8f2fd;color:#1e88e5}.metric-distance .metric-icon{background:#e8f8f8;color:#00a5b5}.metric-runs .metric-icon{background:#eef3ff;color:#5c6bc0}.metric-calories .metric-icon{background:#fff4e5;color:#ef8c00}.metric span{color:#78909c;font-size:.78rem;font-weight:600}.metric strong{margin:14px 0 3px;color:#263238;font-size:clamp(1.65rem,3.2vw,2.15rem);font-weight:700}.dashboard-grid{grid-template-columns:minmax(0,1.55fr) minmax(310px,.85fr);gap:18px}.panel{padding:20px}.panel-heading{margin-bottom:18px;padding-bottom:12px;border-bottom:1px solid #eef2f5}.panel-heading h2{color:#37474f;font-size:1rem;font-weight:700}.panel-heading span{min-height:24px;border-color:#e4ebf1;color:#90a4ae;background:#f8fafc;font-size:.7rem}.primary-button,button[type=submit]{border-radius:7px;background:#1e88e5;box-shadow:0 3px 8px rgba(30,136,229,.2)}.primary-button:hover,button[type=submit]:hover{background:#1565c0}@media(max-width:900px){.app-header{padding-inline:18px}.tabs{padding-inline:10px}.race-hero{grid-template-columns:1fr}.dashboard-grid{grid-template-columns:1fr}.dashboard-grid .panel.wide{grid-column:auto}}@media(max-width:620px){.app-header{gap:12px;padding:13px 14px}.brand-block{align-items:flex-start}.brand-mark{flex-basis:40px;width:40px;height:40px;border-radius:10px}.page-context{display:none}.header-actions{width:100%;justify-content:space-between}.tabs{justify-content:flex-start;padding:0 8px}.tab{min-height:46px;padding-inline:12px}.ops-strip{width:calc(100% - 20px);margin-top:10px}main{padding:12px 10px 36px}.race-hero,.panel{padding:16px}.metric-grid{gap:10px}.metric{min-height:108px}}

/* Secure auth UI */
.auth-login-panel { display: flex; align-items: stretch; }
.login-form { width: 100%; display: grid; gap: 14px; padding: clamp(18px, 3vw, 30px); border: 1px solid rgba(148,163,184,.22); border-radius: 16px; background: rgba(255,255,255,.92); box-shadow: 0 20px 48px rgba(15,23,42,.08); }
.login-form-heading { display: grid; gap: 5px; margin-bottom: 4px; }
.login-form-heading > span { color: var(--green-dark); font-size: .76rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.login-form-heading > strong { font-size: 1.35rem; }
.login-form-heading > small, .login-security-note { color: var(--muted); line-height: 1.55; }
.login-form label { display: grid; gap: 7px; color: #334155; font-weight: 800; }
.login-form input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid rgba(148,163,184,.35); border-radius: 10px; background: #fff; font: inherit; }
.login-form input:focus { outline: 3px solid rgba(14,165,233,.12); border-color: rgba(14,165,233,.6); }
.proof-open-button { padding: 0; border: 0; color: #0369a1; background: transparent; cursor: pointer; font: inherit; font-weight: 800; text-decoration: underline; }
.protected-proof-preview { width: 100%; min-height: 88px; margin-top: 12px; border: 1px dashed rgba(14,165,233,.35); border-radius: 10px; color: #075985; background: rgba(240,249,255,.72); cursor: pointer; font: inherit; font-weight: 800; }

/* Account security */
.change-password-panel { width:min(1200px,calc(100% - 24px)); margin:10px auto 0; }
.change-password-panel[hidden] { display:none; }
.change-password-form { display:grid; grid-template-columns:1.2fr repeat(3,minmax(0,1fr)) auto; gap:12px; align-items:end; padding:16px; border:1px solid rgba(148,163,184,.24); border-radius:12px; background:#fff; box-shadow:0 10px 30px rgba(15,23,42,.06); }
.change-password-form > div:first-child { display:grid; gap:4px; }
.change-password-form small { color:var(--muted); }
.change-password-form label { display:grid; gap:6px; font-weight:800; }
.change-password-form input { min-height:42px; padding:9px 11px; border:1px solid rgba(148,163,184,.35); border-radius:9px; font:inherit; }
.change-password-actions { display:flex; gap:8px; }
@media (max-width:900px) { .change-password-form { grid-template-columns:1fr 1fr; } }
@media (max-width:620px) { .change-password-form { grid-template-columns:1fr; } .change-password-actions { flex-direction:column; } }
