:root {
  /* Team Tycoons palette, taken from the logo */
  --ink: #0a0f5c;          /* deep navy (logo shadow blue) */
  --royal: #1022b0;        /* logo royal blue */
  --royal-2: #2438c8;
  --gold: #f5b50a;         /* logo gold ring */
  --gold-deep: #7a5200;
  --gold-soft: #fff5d6;
  --flame: #fd3a01;        /* logo flames */
  --crimson: #d4003a;      /* logo tagline red */
  --sky: #eef1ff;
  --paper: #f4f6fb;
  --surface: #ffffff;
  --line: #d7dcea;
  --text: #161a36;
  --muted: #565d7a;
  --ok: #1f7a4d;
  --ok-soft: #e4f3ea;
  --bad: #c0102f;
  --bad-soft: #fde9ed;
  --info-soft: #e8ecff;
  --radius: 10px;
  --font-head: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body: "Hind", "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  background: var(--paper);
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; margin: 0 0 .5em; color: var(--ink); }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; font-weight: 600; }
p { margin: 0 0 1em; }
a { color: var(--royal); }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--royal-2); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Forms ---------- */
fieldset { border: 0; margin: 0 0 1.5rem; padding: 0; }
legend {
  font-family: var(--font-head); font-weight: 600; font-size: 1rem; color: var(--ink);
  padding: 0 0 .6rem; margin-bottom: .6rem; width: 100%; border-bottom: 1px solid var(--line);
}
.field { margin-bottom: 1rem; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
label { display: block; font-weight: 500; margin-bottom: .3rem; font-size: .95rem; }
.req { color: var(--crimson); }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=date],
input:not([type]), select {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: .65rem .75rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  min-height: 46px;
}
input:focus, select:focus { border-color: var(--royal); outline: none; box-shadow: 0 0 0 3px rgba(16, 34, 176, .18); }
input[aria-invalid=true], select[aria-invalid=true] { border-color: var(--bad); }
.field-error { color: var(--bad); font-size: .9rem; margin: .3rem 0 0; }
.check { display: flex; gap: .7rem; align-items: flex-start; font-weight: 400; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: .2rem; flex-shrink: 0; accent-color: var(--royal); }
.consent { background: var(--paper); border-radius: 8px; padding: .9rem 1rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; font-size: .98rem;
  padding: .6rem 1.1rem; min-height: 44px;
  border-radius: 8px; border: 1.5px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s;
}
.btn-primary { background: var(--royal); color: #fff; }
.btn-primary:hover { background: var(--ink); color: #fff; }
.btn-accent { background: var(--gold); color: var(--ink); }
.btn-accent:hover { background: #e3a400; color: var(--ink); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--royal); color: var(--ink); }
.btn-small { min-height: 34px; padding: .3rem .7rem; font-size: .88rem; background: var(--paper); border-color: var(--line); color: var(--ink); }
.btn-block { width: 100%; font-size: 1.05rem; min-height: 52px; margin-top: .5rem; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--royal); text-decoration: underline; cursor: pointer; }
.link-btn.danger { color: var(--bad); }
form.inline { display: inline; }

.alert { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; border-left: 4px solid; }
.alert-error { background: var(--bad-soft); border-color: var(--bad); color: #7a1a12; }
.alert-success { background: var(--ok-soft); border-color: var(--ok); color: #14532f; }
.alert-info { background: var(--info-soft); border-color: var(--royal); color: var(--ink); }

/* ---------- Public joining page ---------- */
body.public { background: var(--surface); }
body.public::before {
  content: ""; display: block; height: 6px;
  background: linear-gradient(90deg, var(--gold), var(--flame) 55%, var(--crimson));
}
.join-layout {
  display: grid;
  grid-template-columns: minmax(300px, 5fr) 7fr;
  min-height: calc(100vh - 54px);
}
.join-intro {
  background: var(--sky);
  padding: clamp(2rem, 4vw, 3.5rem);
  display: flex; flex-direction: column; gap: 1.2rem;
  border-right: 1px solid var(--line);
}
.brand-logo { width: min(280px, 80%); height: auto; display: block; margin-bottom: .5rem; }
.join-intro h1 { color: var(--royal); margin: 0; }
.join-intro .lead { font-size: 1.1rem; max-width: 36ch; margin: 0; color: var(--text); }
.sponsor-card {
  margin-top: .3rem;
  background: var(--surface);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 1.1rem 1.3rem;
  display: grid; gap: .1rem;
  max-width: 360px;
  position: relative;
}
.sponsor-card::after {
  content: ""; position: absolute; top: 12px; right: 14px;
  width: 26px; height: 26px; background: var(--gold);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.sponsor-label { font-size: .9rem; color: var(--muted); }
.sponsor-name { font-family: var(--font-head); font-size: 1.45rem; color: var(--ink); line-height: 1.25; padding-right: 2.2rem; }
.sponsor-code { font-size: .9rem; color: var(--gold-deep); }
.join-steps { margin: auto 0 0; padding-left: 1.3rem; color: var(--muted); }
.join-steps li { margin-bottom: .3rem; padding-left: .2rem; }
.join-steps li::marker { color: var(--crimson); font-family: var(--font-head); font-weight: 600; }

.join-form-wrap {
  padding: clamp(1.5rem, 4vw, 3.5rem);
  max-width: 720px;
  width: 100%;
}
.join-form-wrap > h2 { font-size: 1.5rem; margin-bottom: 1.2rem; }
.leader-fixed { background: var(--gold-soft); border: 1px solid #f0d58a; border-radius: 8px; padding: .7rem 1rem; color: var(--gold-deep); }
.leader-fixed strong { color: var(--ink); }
.g-recaptcha { margin: 1rem 0; }

.site-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: .8rem; height: 48px; }

.thanks {
  max-width: 560px; margin: 0 auto; padding: 3rem 1.5rem; text-align: center;
  min-height: calc(100vh - 54px);
}
.thanks .brand-logo { width: 180px; margin: 0 auto 1.5rem; }
.thanks-mark {
  width: 72px; height: 72px; margin: 0 auto 1.2rem; border-radius: 50%;
  display: grid; place-items: center; color: #fff; background: var(--ok);
  box-shadow: 0 0 0 8px var(--ok-soft);
}
.thanks h1 { color: var(--royal); }
.thanks .lead { font-size: 1.15rem; }

@media (max-width: 820px) {
  .join-layout { grid-template-columns: 1fr; min-height: 0; }
  .join-intro { gap: .8rem; padding: 1.4rem 1.25rem 1.6rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand-logo { width: 150px; margin: 0 auto .3rem; }
  .join-intro h1, .join-intro .lead { text-align: center; margin-inline: auto; }
  .join-intro .lead { font-size: 1rem; }
  .sponsor-card { width: 100%; max-width: none; }
  .join-steps { display: none; }
  .join-form-wrap { padding: 1.5rem 1.25rem 2rem; }
}
@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
}

/* ---------- Admin ---------- */
body.admin { font-size: 16px; }
.admin-bar {
  background: var(--ink); color: #fff; border-bottom: 4px solid var(--gold);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .6rem 1.5rem;
  padding: .8rem clamp(1rem, 3vw, 2rem);
}
.admin-brand { font-family: var(--font-head); font-weight: 700; color: #fff; text-decoration: none; font-size: 1.1rem; display: inline-flex; align-items: center; gap: .6rem; }
.admin-brand img { width: 38px; height: 38px; display: block; }
.admin-brand span { color: var(--gold); font-weight: 500; }
.admin-bar nav { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.admin-bar nav a, .admin-bar .link-btn { color: #c8cdf2; text-decoration: none; }
.admin-bar nav a:hover, .admin-bar .link-btn:hover { color: #fff; }
.admin-bar nav a[aria-current=page] { color: #fff; box-shadow: inset 0 -2px 0 var(--gold); padding-bottom: 2px; }
.admin-main { padding: clamp(1rem, 3vw, 2rem); max-width: 1400px; margin: 0 auto; }
.page-title { font-size: 1.7rem; }

.auth-card {
  max-width: 420px; margin: 3rem auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem;
}
.auth-card h1 { font-size: 1.5rem; }
.auth-logo { width: 150px; height: auto; display: block; margin: 0 auto 1.2rem; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.2rem; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.2rem; display: flex; flex-direction: column;
}
.stat:first-child { border-color: var(--gold); background: var(--gold-soft); }
.stat-num { font-family: var(--font-head); font-size: 2rem; font-weight: 700; color: var(--ink); line-height: 1.1; }
.stat-label { color: var(--muted); }

.filters {
  display: grid; grid-template-columns: 2fr 1.4fr 1fr 1fr 1fr auto; gap: .8rem; align-items: end;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.2rem .2rem;
}
.filters .field { margin-bottom: .8rem; }
.filters input, .filters select { height: 46px; }
.filter-actions { display: flex; gap: .5rem; margin-bottom: .8rem; }
.quick-ranges { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin: .8rem 0 1.2rem; font-size: .92rem; color: var(--muted); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.2rem; align-items: start; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.2rem; margin-bottom: 1.2rem; min-width: 0;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .8rem; margin-bottom: 1rem; }
.panel-head h2 { margin: 0; }
.export { display: flex; gap: .5rem; flex-wrap: wrap; }
.empty { color: var(--muted); padding: 1.5rem 0; margin: 0; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: .85rem;
  padding: .5rem .7rem; border-bottom: 1.5px solid var(--line); white-space: nowrap;
}
table.data td { padding: .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tbody tr:hover { background: #f8fafc; }
tr.inactive td { opacity: .6; }
tr.editing td { background: var(--paper); }
.status-select { min-height: 36px; padding: .3rem .5rem; font-size: .9rem; min-width: 130px; }
.status-select[data-status="New"] { border-color: var(--gold); }
.status-select[data-status="First order"] { border-color: var(--ok); }
.tag { display: inline-block; font-size: .75rem; background: var(--bad-soft); color: var(--bad); border-radius: 4px; padding: 0 .4rem; margin-left: .3rem; }
.tag-warn { background: var(--gold-soft); color: var(--gold-deep); margin-left: 0; }
.actions { white-space: nowrap; }
.actions > * { margin-right: .7rem; }
.link-cell { display: flex; gap: .4rem; align-items: center; min-width: 380px; }
.link-cell input { min-height: 34px; padding: .3rem .5rem; font-size: .85rem; background: var(--paper); }

.inline-form { display: flex; flex-wrap: wrap; gap: .8rem; align-items: end; }
.inline-form .field { margin-bottom: 0; flex: 1 1 180px; }

.pager { display: flex; gap: 1rem; justify-content: center; align-items: center; padding-top: 1rem; }

.leader-bars { list-style: none; padding: 0; margin: 1rem 0 0; }
.leader-bars li { margin-bottom: .9rem; }
.lb-top { display: flex; justify-content: space-between; gap: .5rem; font-size: .92rem; }
.lb-track { height: 8px; background: var(--paper); border-radius: 4px; margin-top: .25rem; overflow: hidden; }
.lb-fill { height: 100%; background: var(--royal); border-radius: 4px; }
.leader-bars li:first-child .lb-fill { background: var(--gold); }

@media (max-width: 1100px) {
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .field:first-child { grid-column: 1 / -1; }
  .filter-actions { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
