:root {
  --bg: #f4f5f7; --panel: #fff; --line: #e3e6ea; --text: #16191d; --muted: #6b7280; --brand: #b3261e; --brand-2: #8f1d17;
  --ok: #15803d; --ok-bg: #e7f6ec; --bad: #c62828; --bad-bg: #fdecec; --warn: #a16207; --warn-bg: #fdf4de; --one: #6b7280;
  --four: #1d4ed8; --six: #7c3aed; --chip: #eef0f3; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1114; --panel: #171a1f; --line: #2a2f37; --text: #e8eaed; --muted: #9aa1ab; --brand: #e0564c; --brand-2: #c9443b;
    --ok: #4ade80; --ok-bg: #12301f; --bad: #f87171; --bad-bg: #3a1616; --warn: #fbbf24; --warn-bg: #3a2c0c; --one: #9aa1ab;
    --four: #60a5fa; --six: #a78bfa; --chip: #232830; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif; }
a { color: inherit; }
main { max-width: 1180px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 16px; margin: 0 0 8px; } h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 6px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .ok { color: var(--ok); } .bad { color: var(--bad); } .warn { color: var(--warn); } .nowrap { white-space: nowrap; } .mt { margin-top: 10px; }
code, .json { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; }
.json { background: var(--chip); padding: 10px; border-radius: 8px; max-height: 60vh; overflow: auto; white-space: pre-wrap; word-break: break-word; }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; padding: 0 16px; height: 54px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; font-size: 16px; }
.brand.big { font-size: 22px; justify-content: center; margin-bottom: 8px; }
.logo { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #e57368, var(--brand) 60%, var(--brand-2)); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .15); }
.top nav { display: flex; gap: 4px; overflow-x: auto; }
.top nav a { text-decoration: none; padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.top nav a.on, .top nav a:hover { background: var(--chip); color: var(--text); }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 13px; }

/* building blocks */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px; padding: 7px 14px; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--muted); } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; } .btn.sm { padding: 5px 10px; font-size: 13px; } .btn.xs { padding: 3px 8px; font-size: 12px; } .btn.wide { width: 100%; padding: 11px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
input, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input.num { width: 64px; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.pill { font-size: 11px; background: var(--chip); padding: 2px 8px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.chip { display: inline-flex; gap: 4px; align-items: center; background: var(--chip); border-radius: 12px; padding: 2px 9px; margin: 2px 4px 2px 0; font-size: 12px; }
.btn-chip { border: 1px solid var(--line); cursor: pointer; font: inherit; color: inherit; }
.chips { display: flex; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; }
.alert { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 8px 12px; margin: 10px 0; }
.note { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 6px 10px; font-size: 12px; margin-top: 6px; }

/* status */
.status { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; background: var(--chip); color: var(--muted); }
.status.live { background: var(--bad-bg); color: var(--bad); } .status.break { background: var(--warn-bg); color: var(--warn); } .status.finished { background: var(--ok-bg); color: var(--ok); }
.src { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--chip); color: var(--muted); margin: 0 4px 4px 0; }
.src.ok { background: var(--ok-bg); color: var(--ok); } .src.error, .src.no_key { background: var(--bad-bg); color: var(--bad); } .src.stale, .src.quota { background: var(--warn-bg); color: var(--warn); } .src.sm { font-size: 10px; }

/* marks */
.mk { display: inline-block; margin-left: 3px; font-size: 11px; font-weight: 700; cursor: help; vertical-align: super; line-height: 1; }
.mk.ok, .mk.dec { color: var(--ok); } .mk.bad { color: var(--bad); } .mk.one { color: var(--one); }
.legend { color: var(--muted); margin: 0 0 12px; }

/* lists */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.tabs { display: flex; gap: 2px; background: var(--chip); padding: 3px; border-radius: 10px; overflow-x: auto; max-width: 100%; }
.tabs a { text-decoration: none; padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tabs a.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.tabs.sm { margin-bottom: 10px; display: inline-flex; }
.acts { display: flex; align-items: center; gap: 10px; }
.search { display: flex; gap: 6px; } .search input { width: 260px; max-width: 60vw; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.stats > div:not(.srcs) { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; display: flex; gap: 6px; align-items: baseline; }
.stats b { font-size: 20px; } .stats span { color: var(--muted); font-size: 12px; } .stats .bad b { color: var(--bad); }
.srcs { margin-left: auto; }
.mlist { display: flex; flex-direction: column; gap: 8px; }
.mrow { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) auto; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; text-decoration: none; }
.mrow:hover { border-color: var(--muted); }
.mr-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; } .mr-main .status { align-self: flex-start; }
.mr-score { display: flex; flex-direction: column; font-size: 13px; }
.mr-side { text-align: right; }

/* match header */
.mhead { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.mhead-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.scores { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 12px; }
.sline { display: flex; gap: 8px; align-items: baseline; font-size: 15px; } .sline b { font-size: 22px; } .sline .team { font-weight: 600; } .sline .ov, .sline .tg { color: var(--muted); font-size: 13px; }
.sline.on .team::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); margin-right: 6px; vertical-align: middle; }
.facts { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--muted); } .facts b { color: var(--text); } .facts .result { color: var(--ok); font-weight: 600; }

/* live */
.live { border-left: 3px solid var(--bad); }
.live-top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 15px; margin-bottom: 8px; }
.rates { margin-left: auto; font-size: 13px; color: var(--muted); } .rates b { color: var(--text); }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); animation: blink 1.4s infinite; align-self: center; }
@keyframes blink { 50% { opacity: .25; } }
.live-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.live-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.live-row .lbl { color: var(--muted); font-size: 12px; min-width: 90px; }
.live-row.small { gap: 18px; }

/* balls */
.ball { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 5px; border-radius: 13px; background: var(--chip); font-size: 12px; font-weight: 600; margin: 1px; cursor: default; }
.ball.dot { color: var(--muted); } .ball.s4 { background: var(--four); color: #fff; } .ball.s6 { background: var(--six); color: #fff; } .ball.w { background: var(--bad); color: #fff; } .ball.x { background: var(--warn-bg); color: var(--warn); }

/* tables */
.tbl { overflow-x: auto; }
.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); padding: 6px 8px; white-space: nowrap; }
.t td { border-bottom: 1px solid var(--line); padding: 7px 8px; vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t .r { text-align: right; } .t .c { text-align: center; }
.t .how { color: var(--muted); font-size: 12px; }
.t tr.notout td:first-child { font-weight: 600; }
.t tr.pending td { opacity: .6; }
.t.overs td.balls { white-space: nowrap; }
.inn-hd { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.inn-hd .tot { font-size: 18px; font-weight: 700; }
.exline { font-size: 13px; color: var(--muted); padding: 8px; } .exline b { color: var(--text); }

/* commentary */
.over-block { border-bottom: 1px solid var(--line); padding: 8px 0; } .over-block:last-child { border: 0; }
.ob-hd { font-weight: 600; margin-bottom: 4px; }
.cline { display: flex; gap: 10px; align-items: flex-start; padding: 3px 0; font-size: 13px; }
.cno { color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 12px; min-width: 34px; padding-top: 4px; }
.cline > span:last-child { padding-top: 3px; }
.wk { color: var(--bad); }

/* switch */
.switch { position: relative; display: inline-block; width: 34px; height: 20px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 20px; transition: .15s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--ok); } .switch input:checked + span::before { transform: translateX(14px); }

/* modal / toast */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 14px; width: 520px; max-width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal.wide { width: 860px; }
.modal-hd { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); } .modal-hd h3 { margin: 0; font-size: 15px; text-transform: none; color: var(--text); letter-spacing: 0; }
.modal-bd { padding: 16px; }
#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--panel); padding: 10px 14px; border-radius: 10px; font-size: 13px; max-width: 360px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); transition: opacity .3s; }
.toast.bad { background: var(--bad); color: #fff; } .toast.out { opacity: 0; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: 400px; max-width: 100%; text-align: center; box-shadow: var(--shadow); }
.login-box p { color: var(--muted); }

@media (max-width: 760px) {
  main { padding: 12px; }
  .top { gap: 10px; padding: 0 12px; } .who { display: none; }
  .mrow { grid-template-columns: 1fr; } .mr-side { text-align: left; }
  .live-grid { grid-template-columns: 1fr; }
  .srcs { margin-left: 0; }
  .search input { width: 100%; } .search { width: 100%; }
  .rates { margin-left: 0; width: 100%; }
}
.status { white-space: nowrap; }
