:root {
  --bg: #f6f7f9; --card: #ffffff; --fg: #1b1f24; --muted: #6a737d; --line: #e3e6ea;
  --accent: #2f6fde; --pos: #1a8a4a; --neg: #c73636; --warn: #b7791f; --live: #d12f2f;
  --chip: #eef1f5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216; --card: #171b21; --fg: #e6e9ed; --muted: #8b95a1; --line: #2a3038;
    --accent: #5b8ff0; --pos: #3fbf72; --neg: #ef6262; --warn: #e0a84a; --live: #ff5a5a;
    --chip: #222830;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .warn { color: var(--warn); }
h1 { margin: 0 0 8px; } h2 { font-size: 16px; margin: 20px 0 10px; } h3 { margin: 0 0 8px; }

header { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 8px 16px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
nav button { background: none; border: 0; color: var(--muted); padding: 8px 10px; border-radius: 6px;
  cursor: pointer; font: inherit; white-space: nowrap; }
nav button.active { color: var(--fg); background: var(--chip); font-weight: 600; }
.hdr-right { display: flex; gap: 8px; align-items: center; }
main { padding: 8px 16px 80px; max-width: 1280px; margin: 0 auto; }

.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--chip); color: var(--muted);
  vertical-align: middle; margin-left: 6px; }
.badge.live { background: var(--live); color: #fff; }
.badge.paper { background: var(--chip); color: var(--pos); }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--chip); }
.tag.live { background: var(--live); color: #fff; }

.btn { border: 1px solid var(--line); background: var(--card); color: var(--fg); padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--live); border-color: var(--live); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 10px; align-items: center; } .row.wrap { flex-wrap: wrap; } .row.end { justify-content: flex-end; }
.row h2 { margin-right: auto; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px;
  width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.login-card input { width: 100%; font-size: 20px; letter-spacing: 4px; text-align: center; margin-bottom: 8px; }
.msg { min-height: 1.2em; margin: 0; color: var(--neg); }
.msg.ok { color: var(--pos); }

.health { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.dot { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--card);
  border: 1px solid var(--line); border-radius: 20px; font-size: 13px; }
.dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ok::before { background: var(--pos); } .dot.bad::before { background: var(--neg); } .dot.warn::before { background: var(--warn); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.tile .l { color: var(--muted); font-size: 12px; } .tile .v { font-size: 22px; font-weight: 650; margin-top: 2px; }
.tile .s { color: var(--muted); font-size: 12px; margin-top: 2px; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--card); }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }
td a { color: var(--accent); text-decoration: none; }

.group { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; }
.group summary { padding: 12px 14px; cursor: pointer; font-weight: 600; list-style: none; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.group summary::-webkit-details-marker { display: none; }
.group summary .stat { font-weight: 400; font-size: 12px; color: var(--muted); }
.group .about { padding: 0 14px; margin: 0 0 8px; color: var(--muted); }
.params { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 16px; padding: 4px 14px 14px; }
.param label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.param .in { display: flex; gap: 6px; align-items: center; }
.param input[type=text] { width: 100%; }
.param.changed input { border-color: var(--warn); }
.param .hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.param .ovr { font-size: 11px; color: var(--warn); }
.param .reset { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 11px; padding: 0; }
.save-bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px; display: flex; gap: 10px; justify-content: flex-end; align-items: center; z-index: 6; }
.save-bar span { margin-right: auto; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; margin-top: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.card.on { border-color: var(--live); }
.dialog { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.dialog-card { background: var(--card); border-radius: 14px; padding: 20px; max-width: 420px; width: 100%; display: flex; flex-direction: column; gap: 10px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { background: var(--chip); padding: 4px 10px; border-radius: 14px; font-size: 12px; }
.report { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; white-space: pre-wrap;
  font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; min-height: 60px; }
.report-frame { width: 100%; height: 80vh; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.logs { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; max-height: 60vh; overflow: auto;
  font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.logs .WARNING { color: var(--warn); } .logs .ERROR, .logs .CRITICAL { color: var(--neg); }
.toast { position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: 90vw; white-space: pre-wrap; }
@media (max-width: 640px) {
  header { padding: 6px 10px; gap: 6px; } main { padding: 6px 10px 90px; }
  nav { order: 3; flex-basis: 100%; }
  .hdr-right { margin-left: auto; } #updated { display: none; }
  .tile .v { font-size: 18px; }
}
/* Ставки: проценты исходов в карточке матча */
.pgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 8px; }
.pcell { background: var(--chip); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.card.val { border-color: var(--pos); }
.pcell.val { outline: 2px solid var(--pos); }
.pcell .pl { color: var(--muted); font-size: 12px; } .pcell .pv { font-size: 22px; font-weight: 650; }
.pbar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--accent); }
.bfield { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; max-width: 720px; }
.bfield label { color: var(--muted); font-size: 12px; } .wide-in { width: 100%; }
