/* Components — spec §11 */
.ico { display: inline-block; vertical-align: middle; width: 20px; height: 20px; flex: none; }
.ico svg { width: 100%; height: 100%; }

/* Brand mark */
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand .mark { width: 40px; height: 40px; flex: none; }
.brand b { display: block; font-size: 1.5rem; line-height: 1.5rem; font-weight: 900; letter-spacing: -0.03em; font-style: italic; }
.brand small { display: block; font-size: 0.6875rem; line-height: 0.875rem; font-weight: 600; color: var(--muted); letter-spacing: 0.01em; }
.topbar .brand .mark { width: 34px; height: 34px; }
.topbar .brand b { font-size: 1.25rem; line-height: 1.25rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s5);
  border-radius: var(--radius-btn); border: 1px solid transparent; font-weight: 700; text-decoration: none; white-space: nowrap;
  background: var(--surface-raised); color: var(--text); transition: transform .12s ease, background-color .12s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); min-height: 48px; font-weight: 800; }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.btn-outline { background: transparent; border-color: var(--accent-line); color: var(--accent-text); }
.btn-outline:hover { background: var(--accent-soft); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface-raised); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 var(--s3); font-size: var(--fs-small); border-radius: 10px; }
.btn .ico { width: 18px; height: 18px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--text); position: relative;
}
.icon-btn:hover { background: var(--surface-raised); }
.icon-btn .ico { width: 24px; height: 24px; }
.badge-count {
  position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; border: 2px solid var(--bg);
}
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-text); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; }
.see-all { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: var(--fs-small); text-decoration: none; min-height: 44px; }
.see-all:hover { text-decoration: underline; }
.see-all .ico { width: 16px; height: 16px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--s4); box-shadow: var(--shadow); min-width: 0; }
@media (min-width: 600px) { .card { padding: var(--s5); } }
.card-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); min-height: 32px; }
.card-head h2 { font-size: var(--fs-body); line-height: var(--lh-body); display: flex; align-items: center; gap: var(--s2); }
.card-head h2 .ico { color: var(--accent-text); }
.card-head .see-all { margin-left: auto; min-height: 32px; }
.card-sub { color: var(--muted); font-size: var(--fs-small); margin-top: -8px; margin-bottom: var(--s3); }

/* Status labels — never colour-only: always text + icon */
.status {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: var(--radius-pill);
  font-size: var(--fs-meta); font-weight: 800; white-space: nowrap; border: 1px solid transparent; letter-spacing: .01em;
}
.status .ico { width: 14px; height: 14px; }
.status-in { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }
.status-out { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.status-wait { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.status-neutral { background: var(--surface-raised); color: var(--muted); border-color: var(--border); }
.status-win { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.status-champ { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.status-live { background: var(--accent); color: var(--on-accent); }
.status-live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* Crest (generated monogram badge — no club logos) */
.crest {
  --c1: #334155; --c2: #fff; width: 32px; height: 32px; flex: none; border-radius: 50% 50% 46% 46% / 42% 42% 58% 58%;
  background: linear-gradient(135deg, var(--c1) 0 62%, var(--c2) 62% 100%); display: grid; place-items: center;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.18), 0 0 0 1px rgba(0,0,0,.25);
}
.crest span { font-size: 9px; font-weight: 900; letter-spacing: .02em; color: #fff; background: rgba(0,0,0,.55); padding: 1px 3px; border-radius: 4px; line-height: 11px; }
.crest-lg { width: 44px; height: 44px; }
.crest-lg span { font-size: 11px; line-height: 13px; }
.crest-sm { width: 24px; height: 24px; }
.crest-sm span { font-size: 7px; line-height: 9px; padding: 0 2px; }

/* Avatar */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 15px;
  background: linear-gradient(140deg, #2B4A6B, #1B3350); color: #F8FAFC; border: 2px solid var(--accent-line);
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; border-width: 1px; }
.avatar-xl { width: 96px; height: 96px; font-size: 34px; border-width: 3px; }

.league-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent-line); }
.league-icon .ico { width: 22px; height: 22px; }
.league-icon.champ { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.league-icon.out { background: var(--surface-raised); color: var(--muted); border-color: var(--border); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list > li { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--border); min-width: 0; }
.list > li:first-child { border-top: 0; padding-top: 0; }
.list > li:last-child { padding-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list a.title { color: var(--text); text-decoration: none; display: block; }
.list a.title:hover { text-decoration: underline; }

/* Forms */
.field { display: grid; gap: 6px; }
.field label, .field .label { font-weight: 700; font-size: var(--fs-small); }
.field .hint { font-size: var(--fs-small); color: var(--muted); }
.field .error { font-size: var(--fs-small); color: var(--danger); font-weight: 600; display: flex; gap: 6px; align-items: flex-start; }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--radius-btn); border: 1px solid var(--control-border);
  background: var(--bg); color: var(--text);
}
textarea.input { min-height: 96px; resize: vertical; }
.input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.input[aria-invalid='true'] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.form-error { padding: var(--s3) var(--s4); border-radius: var(--radius-btn); background: var(--danger-soft); color: var(--danger); font-weight: 600; border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
.notice { padding: var(--s3) var(--s4); border-radius: var(--radius-btn); background: var(--surface-raised); border: 1px solid var(--border); display: flex; gap: var(--s3); align-items: flex-start; }
.notice .ico { margin-top: 2px; }
.notice-warn { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.notice-warn .ico { color: var(--warning); }
.notice-ok { background: var(--accent-soft); border-color: var(--accent-line); }
.notice-ok .ico { color: var(--accent-text); }
.check { display: flex; gap: var(--s3); align-items: flex-start; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.choice-grid { display: grid; gap: var(--s3); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice .choice-body { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s4); border-radius: var(--radius-card); border: 2px solid var(--control-border); background: var(--surface); }
.choice input:checked + .choice-body { border-color: var(--accent); background: var(--accent-soft); }
.choice input:focus-visible + .choice-body { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice .tick { margin-left: auto; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--control-border); flex: none; display: grid; place-items: center; }
.choice input:checked + .choice-body .tick { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.choice input:checked + .choice-body .tick::after { content: '✓'; font-weight: 900; font-size: 14px; }

/* Segmented / tabs */
.segmented { display: inline-flex; padding: 4px; border-radius: var(--radius-pill); background: var(--surface-raised); border: 1px solid var(--control-border); gap: 2px; }
.segmented button, .segmented a {
  border: 0; background: transparent; color: var(--muted); border-radius: var(--radius-pill); min-height: 38px; padding: 0 16px;
  font-weight: 700; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-size: var(--fs-small);
}
.segmented [aria-pressed='true'], .segmented [aria-selected='true'], .segmented [aria-current='page'] { background: var(--accent); color: var(--on-accent); font-weight: 800; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); margin-bottom: var(--s5); }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s4); color: var(--muted); text-decoration: none; font-weight: 700;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current='page'] { color: var(--text); border-bottom-color: var(--accent); }

/* Progress */
.bar { height: 8px; border-radius: 99px; background: var(--surface-raised); overflow: hidden; border: 1px solid var(--border); }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.ring { --p: 0; width: 96px; height: 96px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-raised) 0); position: relative; }
.ring::before { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.ring > div { position: relative; text-align: center; line-height: 1.1; }
.ring b { display: block; font-size: 1.25rem; font-weight: 800; }
.ring small { font-size: 11px; color: var(--muted); font-weight: 600; }

/* Countdown */
.countdown { display: flex; align-items: stretch; gap: 0; }
.countdown .unit { text-align: center; min-width: 58px; padding: 0 var(--s2); }
.countdown .unit + .unit { border-left: 1px solid rgba(255,255,255,.16); }
.countdown b { display: block; font-family: var(--mono); font-size: 2rem; line-height: 2.375rem; font-weight: 600; letter-spacing: -0.02em; }
.countdown small { display: block; font-size: var(--fs-meta); color: var(--stadium-muted); font-weight: 600; }

/* Stadium art — CSS only; never carries essential text. */
.stadium {
  position: relative; overflow: hidden; color: var(--stadium-text); isolation: isolate;
  background:
    radial-gradient(60% 50% at 18% -8%, rgba(255,255,255,.22), transparent 60%),
    radial-gradient(50% 45% at 82% -12%, rgba(255,255,255,.2), transparent 60%),
    radial-gradient(120% 70% at 50% 120%, rgba(91, 160, 46, .55), transparent 60%),
    linear-gradient(180deg, var(--stadium-1), var(--stadium-0));
}
.stadium::before { /* crowd tiers */
  content: ''; position: absolute; inset: 0; z-index: -1; opacity: .5;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 2px, transparent 2px 7px),
    linear-gradient(180deg, transparent 22%, rgba(255,255,255,.07) 23%, transparent 24%, transparent 40%, rgba(255,255,255,.06) 41%, transparent 42%);
  mask-image: linear-gradient(180deg, transparent 5%, #000 25%, #000 52%, transparent 70%);
}
.stadium::after { /* pitch stripes */
  content: ''; position: absolute; left: -10%; right: -10%; bottom: -30%; height: 55%; z-index: -1; transform: perspective(300px) rotateX(55deg);
  background: repeating-linear-gradient(90deg, rgba(120, 200, 70, .22) 0 40px, rgba(90, 170, 50, .12) 40px 80px);
  mask-image: linear-gradient(180deg, transparent, #000 40%);
}
.ball { position: absolute; z-index: -1; pointer-events: none; }

/* Dialog */
dialog.sheet {
  border: 1px solid var(--border); border-radius: 20px; padding: 0; background: var(--surface); color: var(--text);
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 48px); box-shadow: 0 24px 64px rgba(0,0,0,.45);
}
dialog.sheet::backdrop { background: var(--scrim); }
@media (max-width: 599px) {
  dialog.sheet { margin: auto auto 0; width: 100vw; max-width: 100vw; border-radius: 20px 20px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom); }
}
dialog.sheet[open] { animation: rise .2s ease-out; }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s4) 0 var(--s5); }
.sheet-head h2 { flex: 1; }
.sheet-body { padding: var(--s4) var(--s5) var(--s5); display: grid; gap: var(--s4); overflow-y: auto; }
.sheet-actions { display: flex; gap: var(--s3); flex-wrap: wrap-reverse; }
.sheet-actions .btn { flex: 1 1 140px; }
.sheet-hero { margin: 0; padding: var(--s8) var(--s5) var(--s6); text-align: center; border-radius: 20px 20px 0 0; }
.sheet-hero h2 { font-size: var(--fs-hero); line-height: var(--lh-hero); font-weight: 900; margin-top: var(--s3); }
.sheet-hero p { color: var(--stadium-muted); margin-top: var(--s2); }

/* Toast */
.toasts { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 16px); display: grid; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
@media (min-width: 1024px) { .toasts { bottom: 24px; left: calc(50% + var(--sidebar-w) / 2); } }
.toast { pointer-events: auto; display: flex; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4); border-radius: 14px; background: var(--text); color: var(--bg); font-weight: 600; box-shadow: 0 12px 30px rgba(0,0,0,.35); animation: rise .2s ease-out; }
.toast .ico { width: 20px; height: 20px; }

/* Skeletons, empty and error states */
.skel { background: var(--skeleton); border-radius: 10px; position: relative; overflow: hidden; }
.skel::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.empty { text-align: center; padding: var(--s8) var(--s4); display: grid; gap: var(--s3); justify-items: center; }
.empty .ico { width: 40px; height: 40px; color: var(--muted); }
.empty p { color: var(--muted); max-width: 42ch; }
.error-state { display: grid; gap: var(--s3); justify-items: start; }

/* Notifications panel */
.notif-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.notif-list li { padding: var(--s3); border-radius: 12px; display: grid; gap: 2px; }
.notif-list li.unread { background: var(--accent-soft); }
.notif-list a { color: var(--text); font-weight: 600; text-decoration: none; }
.notif-list a:hover { text-decoration: underline; }

/* Theme switch (sidebar) */
.theme-switch { display: grid; gap: 6px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
table.data th { text-align: left; color: var(--muted); font-weight: 700; font-size: var(--fs-meta); text-transform: uppercase; letter-spacing: .06em; padding: 8px; border-bottom: 1px solid var(--border); }
table.data td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }

details.disclosure > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--s2); min-height: 44px; font-weight: 700; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary .chev { transition: transform .15s; }
details.disclosure[open] > summary .chev { transform: rotate(90deg); }
/* Light theme: lime fills on white need a 3:1 edge to read as data graphics */
html[data-theme='light'] .bar > span, html[data-theme='light'] .survival-chart .col .b { box-shadow: inset 0 0 0 1.5px #4D7C0F; }
html[data-theme='light'] .ring { background: conic-gradient(#65A30D calc(var(--p) * 1%), var(--surface-raised) 0); }
