/* UCLF portal — design tokens and components (R8A). Self-hosted; no external fonts or assets. */
:root {
  /* colour */
  --bg: #0b1310; --surface: #111c17; --surface-2: #16241e; --surface-3: #1c2e26; --line: #27392f;
  --text: #ecf4ef; --muted: #a9bfb3; --faint: #7f978a;
  --emerald: #1f9d6a; --emerald-deep: #13704b; --mint: #5fe3b0; --gold: #e8b64c; --danger: #ff8a7a; --warn: #f2c14e;
  --home: #5fe3b0; --draw: #9fb4aa; --away: #e8b64c;
  --focus: #e8b64c;
  /* spacing */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  /* type */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 26px;
  /* radii and elevation */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --e1: 0 1px 0 rgba(255, 255, 255, .03), 0 1px 3px rgba(0, 0, 0, .35);
  --e2: 0 6px 22px rgba(0, 0, 0, .35);
  /* motion */
  --t-fast: 160ms; --t-med: 220ms; --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; font: var(--fs-md)/1.45 var(--font); color: var(--text); background: var(--bg); overflow-wrap: anywhere; }
a { color: var(--mint); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
.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; }
.skip { position: absolute; left: var(--s2); top: -48px; background: var(--gold); color: #111; padding: var(--s2) var(--s3); border-radius: var(--r-sm); z-index: 10; }
.skip:focus { top: var(--s2); }
.muted { color: var(--muted); font-size: var(--fs-sm); }
.num { font-variant-numeric: tabular-nums; }
h1 { font-size: var(--fs-2xl); margin: 0 0 var(--s4); letter-spacing: -.01em; }
h2 { font-size: var(--fs-lg); margin: 0; }
h3 { font-size: var(--fs-md); margin: 0 0 var(--s2); }

/* ---------------------------------------------------------------- top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s5);
  padding: var(--s2) var(--s4); background: linear-gradient(90deg, #0e1a15, #10231b); border-bottom: 1px solid var(--line); box-shadow: var(--e2); }
.brand { display: flex; align-items: center; gap: var(--s2); color: var(--text); font-weight: 800; font-size: var(--fs-xl); letter-spacing: .06em; }
.brand:hover { text-decoration: none; }
.brand img { display: block; }
.status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); font-size: var(--fs-sm); color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: var(--fs-xs); white-space: nowrap; }
.pill.paper { border-color: var(--emerald); color: var(--mint); }
.pill.warn { border-color: var(--warn); color: var(--warn); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); display: inline-block; flex: none; }
.dot.ok { background: var(--mint); animation: breathe 3.2s var(--ease) infinite; }
.dot.stale { background: var(--danger); }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 0 rgba(95, 227, 176, .45); } 50% { box-shadow: 0 0 0 5px rgba(95, 227, 176, 0); } }
.logout { margin-left: auto; }
.btn { font: inherit; font-size: var(--fs-sm); color: var(--text); background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 6px 12px; cursor: pointer; transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.btn:hover { background: var(--emerald-deep); border-color: var(--emerald); }
.btn.primary { background: var(--emerald); border-color: var(--emerald); color: #04110b; font-weight: 700; }

/* ---------------------------------------------------------------- shell and left rail */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.rail { border-right: 1px solid var(--line); background: var(--surface); padding: var(--s4) var(--s2); }
.rail h2 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .12em; color: var(--faint); padding: 0 var(--s3); margin: var(--s4) 0 var(--s2); }
.rail h2:first-child { margin-top: 0; }
.rail nav + nav { margin-top: var(--s5); }
.rail ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rail a { display: flex; align-items: center; gap: var(--s3); padding: 8px var(--s3); border-radius: var(--r-md); color: var(--text);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.rail a:hover { background: var(--surface-3); text-decoration: none; }
.rail a[aria-current="page"] { background: var(--surface-3); box-shadow: inset 3px 0 0 var(--gold); color: #fff; font-weight: 600; }
.rail .count { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); background: var(--bg); border-radius: 999px; padding: 1px 8px; }
.flag { display: block; width: 24px; height: 16px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .18); flex: none; }
.glyph-fallback { display: inline-grid; place-items: center; width: 24px; height: 16px; font-size: 9px; font-weight: 800; border-radius: 2px; background: var(--surface-3); color: var(--gold); flex: none; }
main { padding: var(--s5); min-width: 0; }

/* ---------------------------------------------------------------- filters */
.filters { position: sticky; top: 56px; z-index: 4; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); align-items: end; margin: 0 0 var(--s5);
  padding: var(--s3); background: rgba(17, 28, 23, .94); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--e1); }
.filters label { display: grid; gap: 4px; font-size: var(--fs-xs); color: var(--muted); }
.filters input, .filters select, .login input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 10px; min-width: 0; }
.filters input { width: 160px; max-width: 100%; }

/* ---------------------------------------------------------------- competition groups and fixture cards */
.group { margin: 0 0 var(--s6); }
.group-head { display: flex; align-items: center; gap: var(--s3); margin: 0 0 var(--s3); padding-bottom: var(--s2); border-bottom: 1px solid var(--line); }
.group-head .meta { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); }
.cols { display: grid; grid-template-columns: 96px minmax(180px, 1.4fr) minmax(220px, 1.3fr) minmax(170px, 1fr); gap: var(--s3); padding: 0 var(--s4) var(--s1);
  font-size: var(--fs-xs); color: var(--faint); text-transform: uppercase; letter-spacing: .08em; }
.cols .pct3 { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--e1); transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.card:hover { border-color: #37503f; }
.card.pulse { animation: pulse 900ms var(--ease) 1; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(232, 182, 76, .55); } 100% { box-shadow: 0 0 0 12px rgba(232, 182, 76, 0); } }
.row { display: grid; grid-template-columns: 96px minmax(180px, 1.4fr) minmax(220px, 1.3fr) minmax(170px, 1fr); gap: var(--s3); align-items: center; padding: var(--s3) var(--s4); }
.when { display: grid; gap: 2px; }
.when .time { font-weight: 700; font-size: var(--fs-lg); }
.teams { display: grid; gap: 6px; min-width: 0; }
.team { display: flex; align-items: center; gap: var(--s2); min-width: 0; font-weight: 600; }
.team a { color: var(--text); }
.team .name { min-width: 0; }
.mono { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 10px; font-weight: 800; letter-spacing: .02em; flex: none;
  color: #06120d; border: 2px solid rgba(255, 255, 255, .22); }
.mono.lg { width: 44px; height: 44px; font-size: 15px; }
.m0 { background: #5fe3b0; } .m1 { background: #e8b64c; } .m2 { background: #7cc4ff; } .m3 { background: #f59fb1; }
.m4 { background: #b9a3ff; } .m5 { background: #9fe07a; } .m6 { background: #ffb37a; } .m7 { background: #d9e3de; }
.probs { display: grid; gap: 6px; }
.pct3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s1); text-align: center; }
.panel .pct3 { margin: var(--s2) 0 var(--s3); }
.pct { border-radius: var(--r-sm); padding: 4px 2px; background: var(--surface-2); border: 1px solid transparent; }
.pct b { display: block; font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.pct small { color: var(--muted); font-size: var(--fs-xs); }
.pct.pick { border-color: var(--gold); background: #2a2616; }
.pct.pick small::after { content: " · pick"; color: var(--gold); }
.bar { display: block; width: 100%; height: 8px; border-radius: 4px; overflow: hidden; }
.bar .h { fill: var(--home); } .bar .d { fill: var(--draw); } .bar .a { fill: var(--away); }
.bar.lg { height: 14px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: var(--fs-xs); background: var(--surface-3); color: var(--text); border: 1px solid var(--line); white-space: nowrap; }
.chip.market { border-color: var(--gold); color: var(--gold); }
.chip.model { border-color: var(--mint); color: var(--mint); }
.chip.kind { border-color: #4a6a5a; }
.chip.flag-warn { border-color: var(--danger); color: var(--danger); }
.chip.fresh { border-color: var(--mint); }
.band-VERY_HIGH, .band-HIGH { color: var(--mint); } .band-MEDIUM { color: var(--text); } .band-LOW, .band-VERY_LOW { color: var(--muted); }
details.more { border-top: 1px solid var(--line); }
details.more > summary { cursor: pointer; list-style: none; padding: 6px var(--s4); font-size: var(--fs-sm); color: var(--muted); transition: color var(--t-fast) var(--ease); }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸"; margin-right: 6px; display: inline-block; transition: transform var(--t-fast) var(--ease); }
details.more[open] > summary::before { transform: rotate(90deg); }
details.more > summary:hover { color: var(--text); }
.more-body { padding: 0 var(--s4) var(--s4); display: grid; gap: var(--s3); animation: reveal var(--t-med) var(--ease); }
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.srcgrid { display: grid; grid-template-columns: 110px minmax(0, 1fr) 150px; gap: var(--s2) var(--s3); align-items: center; font-size: var(--fs-sm); }
.flags { margin: 0; padding-left: var(--s4); color: var(--danger); font-size: var(--fs-xs); }

/* ---------------------------------------------------------------- fixture detail */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: var(--s4); align-items: center; padding: var(--s5); margin: 0 0 var(--s5);
  background: radial-gradient(circle at 50% 0, #1b3a2d, var(--surface) 70%); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--e2); }
.hero .side { display: flex; flex-direction: column; align-items: center; gap: var(--s2); text-align: center; font-weight: 700; font-size: var(--fs-lg); }
.hero .mid { text-align: center; color: var(--muted); font-size: var(--fs-sm); }
.hero .comp { display: flex; gap: var(--s2); align-items: center; justify-content: center; margin-bottom: var(--s2); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4); box-shadow: var(--e1); margin: 0 0 var(--s5); }
.panel > h2 { margin-bottom: var(--s3); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 var(--s5); position: relative; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 var(--s5); }
.timeline li::before { content: ""; position: absolute; left: -21px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface-3); border: 2px solid var(--mint); }
.timeline li.final::before { border-color: var(--gold); background: var(--gold); }
.timeline li.result::before { border-color: var(--text); background: var(--text); }
.tl-head { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-bottom: var(--s2); }
.delta.up { color: var(--mint); } .delta.down { color: var(--danger); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px var(--s4); margin: 0; font-size: var(--fs-sm); }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.note { border-left: 3px solid var(--gold); padding: var(--s2) var(--s3); background: var(--surface-2); border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: var(--fs-sm); }

/* ---------------------------------------------------------------- operations and performance */
.cardgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s3); margin: 0 0 var(--s5); }
.health { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4); box-shadow: var(--e1); }
.health h2 { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-md); margin-bottom: var(--s3); }
.big { font-size: var(--fs-2xl); font-weight: 800; font-variant-numeric: tabular-nums; }
.meter { display: block; width: 100%; height: 8px; margin: var(--s2) 0; }
.meter .track { fill: var(--surface-3); } .meter .fill { fill: var(--mint); } .meter .fill.hot { fill: var(--warn); }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: var(--surface); }
pre.json { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s3); overflow-x: auto; font-size: var(--fs-xs); color: var(--muted); }
.footer { margin-top: var(--s6); color: var(--faint); font-size: var(--fs-xs); }
.empty { padding: var(--s6); text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r-lg); }

/* ---------------------------------------------------------------- login */
.login { max-width: 380px; margin: 12vh auto; padding: var(--s6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--e2); display: grid; gap: var(--s4); }
.login .brand { justify-content: center; }
.login label { display: grid; gap: 6px; color: var(--muted); font-size: var(--fs-sm); }
.error { color: var(--danger); min-height: 1.2em; margin: 0; }

/* ---------------------------------------------------------------- loading skeleton (JS refresh) */
.skeleton { display: none; }
body.loading .skeleton { display: block; position: fixed; left: 0; right: 0; top: 0; height: 3px; z-index: 20;
  background: linear-gradient(90deg, transparent, var(--gold), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: sweep 1.1s linear infinite; }
@keyframes sweep { from { background-position: -50% 0; } to { background-position: 150% 0; } }
.sk-card { height: 84px; border-radius: var(--r-lg); background: linear-gradient(90deg, var(--surface), var(--surface-3), var(--surface)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .row, .cols { grid-template-columns: 80px minmax(0, 1.3fr) minmax(0, 1.3fr); }
  .row .side-meta { grid-column: 1 / -1; }
  .cols .c-meta { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); padding: var(--s2); overflow-x: auto; }
  .rail h2 { display: none; }
  .rail ul { display: flex; gap: var(--s1); }
  .rail li { flex: none; }
  .rail nav + nav { margin-top: var(--s1); }
  .rail .count { margin-left: var(--s1); }
  main { padding: var(--s4) var(--s3); }
  .filters { top: 0; position: static; }
  .cols { display: none; }
  .row { grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
  .when { display: flex; gap: var(--s2); align-items: baseline; }
  .srcgrid { grid-template-columns: 90px minmax(0, 1fr); }
  .srcgrid .srcmeta { grid-column: 1 / -1; }
  .hero { grid-template-columns: minmax(0, 1fr); padding: var(--s4); }
  .topbar { position: static; }
  .status .opt { display: none; }
}

/* ---------------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
