/* Legacy5 — design system. Brand palette from brand/legacy5.css; Exo 2 headings. */
:root {
  --purple: #5B2C83; --purple-700: #43206a; --purple-900: #1c0d33; --purple-100: #efe8f6; --purple-50: #f7f3fb;
  --black: #111111; --silver: #C0C0C0; --cyan: #35C5EC; --cyan-600: #14a3cc; --white: #FFFFFF;
  --bg: #f5f3f8; --card: #ffffff; --ink: #1a1523; --muted: #6b6478; --line: #e5e0ec;
  --ok: #17824f; --ok-bg: #e4f5ec; --warn: #a96300; --warn-bg: #fdf1dc; --bad: #c0283d; --bad-bg: #fde8eb; --info-bg: #e3f6fc;
  --riley: #8b4fd0; --cadence: #1fb2dc; --zepplin: #e29a12; --mila: #d9488f; --kobe: #1f9d73;
  --font-head: "Exo 2", "Oswald", system-ui, sans-serif; --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px; --shadow: 0 1px 2px rgba(28,13,51,.06), 0 6px 20px rgba(28,13,51,.06);
  --side: 268px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font-body); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; letter-spacing: .005em; }
h1 { font-size: 1.75rem; font-weight: 800; font-style: italic; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
a { color: var(--purple); }
button { font: inherit; cursor: pointer; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .xs { font-size: .76rem; }
.right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; } .row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; } .gap-sm { gap: 6px; } .mt { margin-top: 16px; } .mt-sm { margin-top: 8px; } .mb { margin-bottom: 16px; }
.stack > * + * { margin-top: 12px; }

/* ---------- shell ---------- */
#app { display: flex; min-height: 100vh; }
.side { width: var(--side); background: linear-gradient(180deg, #24103f 0%, #3a1b5e 55%, #2b1449 100%); color: #e9defa; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 40; transition: transform .2s; }
.side .brand { padding: 18px 20px 12px; display: flex; align-items: center; gap: 10px; }
.side .brand img { height: 44px; width: auto; display: block; }
.side nav { overflow-y: auto; padding: 4px 10px 20px; flex: 1; scrollbar-width: thin; scrollbar-color: #5b3a85 transparent; }
.side .sys { margin-top: 14px; }
.side .sys-head { padding: 6px 10px 4px; display: flex; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 800; font-size: .78rem; letter-spacing: .14em; color: #fff; }
.side .sys-head i { width: 9px; height: 9px; border-radius: 3px; background: var(--c); box-shadow: 0 0 10px var(--c); display: inline-block; transform: skewX(-12deg); }
.side .sys-sub { padding: 0 10px 4px 27px; font-size: .7rem; color: #a592c4; }
.side a.nav { display: flex; align-items: center; gap: 10px; padding: 7px 12px 7px 27px; border-radius: 9px; color: #d8caf0; text-decoration: none; font-size: .9rem; position: relative; }
.side a.nav:hover { background: rgba(255,255,255,.07); color: #fff; }
.side a.nav.active { background: rgba(53,197,236,.16); color: #fff; font-weight: 600; }
.side a.nav.active::before { content: ""; position: absolute; left: 12px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--cyan); }
.side a.nav .count { margin-left: auto; background: var(--cyan); color: #06222b; font-size: .7rem; font-weight: 700; border-radius: 99px; padding: 1px 7px; }
.side .top-link { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 9px; color: #fff; text-decoration: none; font-weight: 600; }
.side .top-link.active { background: rgba(53,197,236,.16); } .side .top-link:hover { background: rgba(255,255,255,.07); }
.side .me { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 10px; font-size: .85rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--cyan); color: #06222b; display: grid; place-items: center; font-weight: 800; font-family: var(--font-head); flex: none; }
.side .me .who { min-width: 0; flex: 1; } .side .me .who b, .side .me .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .me .who span { color: #a592c4; font-size: .75rem; text-transform: capitalize; }
.side .me button { background: transparent; border: 1px solid rgba(255,255,255,.25); color: #e9defa; border-radius: 8px; padding: 4px 9px; font-size: .78rem; }
.main { margin-left: var(--side); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 28px; position: sticky; top: 0; z-index: 20; }
.topbar .crumb { font-family: var(--font-head); font-weight: 700; color: var(--purple); font-size: .95rem; }
.topbar .league { margin-left: auto; color: var(--muted); font-size: .85rem; }
.burger { display: none; background: none; border: 0; font-size: 1.5rem; color: var(--purple); }
.bell { position: relative; background: var(--purple-50); border: 0; border-radius: 10px; width: 38px; height: 38px; font-size: 1.05rem; }
.bell .dot { position: absolute; top: 5px; right: 6px; background: var(--bad); color: #fff; font-size: .62rem; border-radius: 99px; padding: 0 5px; font-weight: 700; }
.content { padding: 26px 28px 60px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sys-tag { display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-head); font-weight: 800; letter-spacing: .14em; font-size: .72rem; color: var(--c, var(--purple)); margin-bottom: 4px; }
.page-head .sys-tag i { width: 8px; height: 8px; border-radius: 2px; background: var(--c); transform: skewX(-12deg); }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.scrim { display: none; }

/* ---------- components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card.flush { padding: 0; overflow: hidden; }
.card > h2, .card-head h2 { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px 0; margin-bottom: 4px; } .card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; } .g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); } .g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stat { padding: 16px 18px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; right: -18px; top: -18px; width: 70px; height: 70px; border-radius: 50%; background: var(--c, var(--purple)); opacity: .09; }
.stat .n { font-family: var(--font-head); font-weight: 800; font-size: 2rem; line-height: 1.1; } .stat .l { color: var(--muted); font-size: .82rem; margin-top: 2px; } .stat .s { font-size: .78rem; margin-top: 4px; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: .9rem; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; line-height: 1.2; }
.btn:hover { border-color: var(--purple); color: var(--purple); }
.btn.primary { background: var(--purple); border-color: var(--purple); color: #fff; } .btn.primary:hover { background: var(--purple-700); color: #fff; }
.btn.cta { background: var(--cyan); border-color: var(--cyan); color: #06222b; } .btn.cta:hover { background: var(--cyan-600); border-color: var(--cyan-600); color: #fff; }
.btn.danger { color: var(--bad); } .btn.danger:hover { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: .8rem; border-radius: 8px; } .btn[disabled] { opacity: .5; pointer-events: none; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: .74rem; font-weight: 700; background: #eee; color: #444; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.info { background: var(--info-bg); color: #0b6e8a; } .badge.purple { background: var(--purple-100); color: var(--purple); }
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 14px; background: var(--purple-50); border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; }
table.t td { padding: 10px 14px; border-bottom: 1px solid #f0edf4; vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; } table.t tbody tr:hover { background: #fbf9fd; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 38px 16px; color: var(--muted); } .empty b { display: block; color: var(--ink); font-family: var(--font-head); font-size: 1.05rem; margin-bottom: 4px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
input, select, textarea { font: inherit; padding: 8px 11px; border: 1px solid #d6cfe0; border-radius: 10px; background: #fff; color: var(--ink); max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(53,197,236,.55); border-color: var(--cyan); }
.toolbar input[type=search] { min-width: 220px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; font-size: .92rem; }
.tabs a.active { color: var(--purple); border-color: var(--cyan); }
.alert { padding: 12px 16px; border-radius: 12px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid; font-size: .92rem; }
.alert.warn { background: var(--warn-bg); border-color: #f1d49b; color: #6b4200; } .alert.bad { background: var(--bad-bg); border-color: #f4bcc5; color: #7d1626; } .alert.info { background: var(--info-bg); border-color: #b8e6f4; color: #0b4f63; } .alert.ok { background: var(--ok-bg); border-color: #b6e3c9; color: #0f5a37; }
.progress { height: 9px; border-radius: 99px; background: #ece7f3; overflow: hidden; } .progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--purple), var(--cyan)); border-radius: 99px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: .9rem; } .kv dt { color: var(--muted); } .kv dd { margin: 0; }
.list-item { padding: 12px 20px; border-bottom: 1px solid #f0edf4; } .list-item:last-child { border-bottom: 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--purple)); margin-right: 6px; }

/* games */
.game { display: grid; grid-template-columns: 78px 1fr auto; gap: 14px; align-items: center; padding: 12px 20px; border-bottom: 1px solid #f0edf4; }
.game:last-child { border-bottom: 0; }
.game .when { font-size: .8rem; color: var(--muted); line-height: 1.25; } .game .when b { display: block; color: var(--ink); font-size: .95rem; }
.game .teams { font-weight: 600; } .game .teams .vs { color: var(--muted); font-weight: 400; margin: 0 6px; font-size: .85rem; }
.game .meta { font-size: .8rem; color: var(--muted); }
.score { font-family: var(--font-head); font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.winner { color: var(--purple); }
.daybar { background: var(--purple-50); padding: 7px 20px; font-family: var(--font-head); font-weight: 700; font-size: .85rem; color: var(--purple); border-bottom: 1px solid var(--line); position: sticky; top: 0; }

/* bracket */
.bracket { display: flex; gap: 34px; overflow-x: auto; padding: 10px 4px 20px; align-items: stretch; }
.bracket .round { display: flex; flex-direction: column; min-width: 214px; }
.bracket .round h4 { margin-bottom: 10px; }
.bracket .rgames { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 14px; }
.bracket .round h4 { text-align: center; font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.bgame { background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; font-size: .88rem; position: relative; }
.bgame .side-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 11px; } .bgame .side-row + .side-row { border-top: 1px solid #f0edf4; }
.bgame .side-row.win { background: var(--purple-50); font-weight: 700; color: var(--purple); } .bgame .side-row.tbd { color: var(--silver); font-style: italic; }
.bgame .foot { background: #faf8fc; padding: 3px 11px; font-size: .7rem; color: var(--muted); border-top: 1px solid #f0edf4; display: flex; justify-content: space-between; gap: 6px; }
.bgame.champ { border: 2px solid var(--zepplin); }

/* field board */
.fboard { overflow-x: auto; } .fboard .grid-f { display: grid; min-width: 760px; }
.fcol { border-left: 1px solid var(--line); } .fcol h4 { padding: 9px 10px; font-size: .78rem; background: var(--purple-50); border-bottom: 1px solid var(--line); text-align: center; }
.fcol h4 small { display: block; color: var(--muted); font-weight: 400; font-family: var(--font-body); }
.slot { position: absolute; left: 4px; right: 4px; border-radius: 8px; padding: 4px 7px; font-size: .74rem; overflow: hidden; color: #fff; background: var(--purple); line-height: 1.2; box-shadow: 0 1px 3px rgba(0,0,0,.2); cursor: pointer; }
.slot.event { background: var(--cadence); color: #04222b; } .slot.delayed, .slot.postponed { background: var(--warn); } .slot.final { background: #6b6478; } .slot.conflict { outline: 3px solid var(--bad); }
.hours { position: relative; } .hline { position: absolute; left: 0; right: 0; border-top: 1px dashed #e6e0ee; font-size: .68rem; color: var(--muted); padding-left: 4px; }

/* modal & toast */
.modal-back { position: fixed; inset: 0; background: rgba(20,8,38,.55); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .12s; }
.modal { background: #fff; border-radius: 18px; width: min(560px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal.wide { width: min(880px, 100%); }
.modal-head { padding: 18px 22px 8px; display: flex; justify-content: space-between; align-items: center; } .modal-head h2 { font-size: 1.25rem; font-style: italic; font-weight: 800; }
.modal-head button { border: 0; background: none; font-size: 1.5rem; color: var(--muted); line-height: 1; }
.modal-body { padding: 8px 22px 6px; } .modal-foot { padding: 14px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; }
.field { margin-bottom: 13px; } .field label { display: block; font-weight: 600; font-size: .84rem; margin-bottom: 4px; } .field input, .field select, .field textarea { width: 100%; } .field .help { font-size: .76rem; color: var(--muted); margin-top: 3px; }
.field.check label { display: flex; gap: 8px; align-items: center; font-weight: 500; } .field.check input { width: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; } .form-grid .full { grid-column: 1 / -1; }
.form-error { color: var(--bad); background: var(--bad-bg); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-size: .88rem; }
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--black); color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.3); animation: up .18s; max-width: 380px; font-size: .9rem; border-left: 4px solid var(--cyan); }
.toast.err { border-color: var(--bad); } .toast.ok { border-color: #4ade80; }
@keyframes fade { from { opacity: 0 } } @keyframes up { from { transform: translateY(8px); opacity: 0 } }
.spinner { width: 28px; height: 28px; border: 3px solid var(--purple-100); border-top-color: var(--purple); border-radius: 50%; animation: spin .7s linear infinite; margin: 60px auto; } @keyframes spin { to { transform: rotate(360deg) } }
.menu-pop { position: absolute; right: 0; top: 44px; width: 340px; max-height: 70vh; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.2); z-index: 60; }

/* auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: radial-gradient(1200px 600px at 20% 0%, #7a3fb0 0%, transparent 60%), linear-gradient(160deg, #1c0d33, #3a1b5e 60%, #0f4a60); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.auth-hero::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; border: 36px solid rgba(53,197,236,.18); }
.auth-hero img.logo { width: min(420px, 80%); margin-bottom: 30px; filter: drop-shadow(0 6px 20px rgba(0,0,0,.35)); }
.auth-hero h1 { font-size: 2.3rem; line-height: 1.1; max-width: 520px; } .auth-hero p { color: #d6c7ee; max-width: 520px; font-size: 1.02rem; }
.sys-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; max-width: 560px; } .sys-pills span { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); border-radius: 99px; padding: 5px 13px; font-family: var(--font-head); font-weight: 700; font-size: .78rem; letter-spacing: .08em; }
.sys-pills span { display: inline-flex; align-items: center; gap: 6px; }
.sys-pills span .kid { width: 17px; height: 17px; margin: -2px 0 -2px -3px; }
.sys-pills span i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--c); margin-right: 7px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px; background: #fff; } .auth-form form { width: min(400px, 100%); }
.auth-form h2 { font-size: 1.6rem; font-style: italic; font-weight: 800; margin-bottom: 4px; }
.demo-logins { margin-top: 20px; border: 1px dashed #cdbfe0; border-radius: 12px; padding: 12px 14px; background: var(--purple-50); font-size: .82rem; } .demo-logins button { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; margin: 3px 4px 0 0; font-size: .78rem; font-weight: 600; color: var(--purple); }

/* public site */
.site-hero { background: linear-gradient(135deg, #24103f, #5B2C83 60%, #1a7a99); color: #fff; padding: 44px 28px; }
.site-wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.site-nav { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; } .site-nav .site-wrap { display: flex; align-items: center; gap: 18px; height: 60px; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .side { transform: translateX(-100%); } .side.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.5); } .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; }
  .main { margin-left: 0; } .burger { display: block; } .topbar { padding: 0 14px; } .content { padding: 18px 14px 50px; } .topbar .league { display: none; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; } .auth { grid-template-columns: 1fr; } .auth-hero { padding: 32px 24px; } .auth-hero h1 { font-size: 1.7rem; }
  .form-grid { grid-template-columns: 1fr; } .game { grid-template-columns: 64px 1fr; } .game > :last-child { grid-column: 2; }
  h1 { font-size: 1.45rem; } .kv { grid-template-columns: 1fr; }
}
@media print { .side, .topbar, .toolbar, .btn, .tabs { display: none !important; } .main { margin: 0; } body { background: #fff; } .card { box-shadow: none; } }

/* Dashboard quick actions (coach) */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick .btn { justify-content: center; padding: 12px 10px; text-align: center; }
.quick .btn .count { background: #06222b; color: #fff; border-radius: 99px; padding: 0 7px; font-size: .75rem; margin-left: 4px; }
@media (max-width: 700px) { .quick { grid-template-columns: repeat(2, 1fr); } }

/* Grandchild person icons for the five systems (see sysIcon in ui.js) */
.kid { display: inline-block; flex: none; width: 15px; height: 15px; color: var(--c, var(--purple)); }
.side .sys-head .kid { width: 18px; height: 18px; margin: -3px 0 -3px -2px; filter: drop-shadow(0 0 6px var(--c)); }
.page-head .sys-tag .kid { width: 17px; height: 17px; margin: -3px 0; }
