:root {
  --bg: #0f1419;
  --panel: #171e26;
  --panel2: #1e2731;
  --line: #2a3542;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #f5b800;
  --live: #e5484d;
  --up: #30a46c;
  --down: #e5484d;
  --warn: #f5a524;
  --info: #3e9bd8;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
code { font-size: 12px; color: #c9d1d9; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.bad { color: var(--warn) !important; font-style: italic; }
button { font: inherit; color: inherit; }
button.link { background: none; border: 0; color: var(--info); cursor: pointer; padding: 0; }

/* шапка */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 18px; color: var(--accent); }
.brand span { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 4px; }
.tabs { display: flex; background: var(--bg); border-radius: 8px; padding: 3px; }
.tabs button { border: 0; background: none; padding: 6px 14px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.tabs button.active { background: var(--panel2); color: var(--text); }
.tabs button[data-type="live"].active { color: #fff; background: var(--live); }
/* источник данных */
.tabs.source button.active { background: var(--up); color: #fff; }
.tabs.source button[data-source="mock"].active { background: var(--info); }
.tabs.source button.off { text-decoration: line-through; }
.demo-banner { display: none; background: var(--info); color: #fff; text-align: center; font-size: 12px; font-weight: 600; padding: 3px; }
body[data-source="mock"] .demo-banner { display: block; }
body[data-source="mock"] .topbar { border-bottom-color: var(--info); }
.src-tag { display: inline-block; border-radius: 4px; padding: 0 6px; font-size: 11px; color: #fff; background: var(--up); }
.src-tag.mock { background: var(--info); }
.diag-src { display: inline-flex; margin: 6px 0; }
.toggle { display: flex; gap: 6px; align-items: center; color: var(--muted); cursor: pointer; }
select, input[type="search"] {
  background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 6px 8px;
}
.search { flex: 1; max-width: 320px; }
.search input { width: 100%; }
.diag-link { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.diag-ico { display: none; }
.badge { background: var(--live); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }
.menu-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; }

/* макет */
.layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: calc(100vh - 52px); }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; max-height: calc(100vh - 52px); position: sticky; top: 52px; }
.sidebar-head { display: flex; justify-content: space-between; padding: 10px 12px; font-weight: 600; border-bottom: 1px solid var(--line); }
.main { padding: 16px 20px 80px; min-width: 0; }

/* меню */
.m-row { display: flex; align-items: center; gap: 6px; padding: 6px 10px; }
.m-row a, .m-row.t { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.m-row:hover { background: var(--panel2); }
.m-row.active { background: var(--panel2); box-shadow: inset 3px 0 var(--accent); }
.m-row.sub { padding-left: 30px; color: var(--muted); font-size: 13px; }
.m-row.t { padding-left: 54px; font-size: 13px; }
.m-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-exp { background: none; border: 0; cursor: pointer; color: var(--muted); width: 16px; padding: 0; }
.cnt { color: var(--muted); font-size: 12px; }

/* иконки */
.ico { width: 18px; height: 18px; object-fit: contain; flex: none; display: inline-block; vertical-align: middle; }
.ico.flag { width: 16px; height: 12px; }
.ico.big { width: 40px; height: 40px; }
.ico-empty { background: var(--panel2); border-radius: 50%; }

/* списки матчей */
.status-line { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.status-line a { color: var(--info); }
.tournament { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; overflow: hidden; }
.tournament h2 { margin: 0; padding: 8px 12px; background: var(--panel2); font-size: 13px; }
.game {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 470px) 56px; grid-template-areas: "main cells more" "info cells more";
  column-gap: 12px; row-gap: 2px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line);
}
.game:first-of-type { border-top: 0; }
.game.thead { grid-template-areas: "main cells more"; background: var(--panel2); font-size: 12px; font-weight: 600; padding: 7px 12px; }
.th-name { grid-area: main; display: flex; align-items: center; gap: 6px; min-width: 0; }
.game.thead .g-cells span { text-align: center; color: var(--muted); font-weight: 500; }
.g-main { grid-area: main; display: flex; align-items: center; gap: 10px; min-width: 0; }
.g-info { grid-area: info; font-size: 11px; color: var(--muted); }
.g-info .timer { color: var(--live); font-weight: 600; }
.period { font-size: 11px; color: var(--muted); }
.teams { flex: 1; min-width: 0; }
.team { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sgrid { display: grid; grid-auto-flow: row; column-gap: 10px; row-gap: 3px; font-size: 12px; text-align: right; }
.sgrid span { color: var(--muted); }
.sgrid b { color: var(--accent); }
.g-cells { grid-area: cells; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.g-cells .oc { flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 0; padding: 5px 4px; }
.g-cells .oc-name { font-size: 10px; }
.oc.empty { color: var(--muted); cursor: default; justify-content: center; }
.more { grid-area: more; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 2px; font-size: 12px; }
.more small { color: var(--muted); font-size: 10px; }
.game.thead .more, .game.thead > span:last-child { background: none; border: 0; }

/* кнопка исхода */
.oc {
  display: flex; justify-content: space-between; align-items: center; gap: 6px; min-width: 76px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; cursor: pointer;
  transition: background .3s;
}
.oc:hover:not(:disabled) { border-color: var(--accent); }
.oc:disabled { opacity: .45; cursor: not-allowed; }
.oc.sel { background: var(--accent); color: #111; }
.oc.up { background: rgba(48, 164, 108, .25); }
.oc.up .oc-rate::after { content: " ▲"; color: var(--up); font-size: 10px; }
.oc.down { background: rgba(229, 72, 77, .25); }
.oc.down .oc-rate::after { content: " ▼"; color: var(--down); font-size: 10px; }
.oc-name { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc.sel .oc-name { color: #333; }
.oc-rate { font-weight: 700; }

/* матч */
.ev-head { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 8px; }
.crumb-t { display: inline-flex; align-items: center; gap: 4px; }
.ev-crumbs { color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ev-teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center; margin: 14px 0; }
.ev-team { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.ev-team.right { justify-content: flex-end; text-align: right; }
.ev-score { text-align: center; }
.big-score { font-size: 28px; font-weight: 800; color: var(--accent); }
.big-time { font-size: 18px; font-weight: 700; }
.ev-score .timer { color: var(--live); font-weight: 600; }
.dop { text-align: center; color: var(--accent); }
.subgames { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 4px 10px; font-size: 12px; }
.chip:hover { border-color: var(--accent); }
table.stats, table.plan { width: 100%; max-width: 520px; margin: 8px auto; border-collapse: collapse; font-size: 13px; }
table.stats td { width: 60px; text-align: center; font-weight: 700; }
table.stats th { font-weight: 400; color: var(--muted); padding: 3px; }
.groups { display: flex; flex-direction: column; gap: 8px; }
.grp { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.grp-head { display: flex; justify-content: space-between; padding: 8px 12px; cursor: pointer; background: var(--panel2); font-weight: 600; }
.grp.collapsed .grp-body { display: none; }
.grp-body { display: grid; gap: 6px; padding: 8px; }
.col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

/* топ-матчи: карусель */
.top-block { margin-bottom: 18px; }
.top-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 8px; }
.top-head h1 { margin: 0; }
.top-nav { display: flex; gap: 6px; }
.tnav { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; font-size: 18px; line-height: 1; }
.tnav:hover { border-color: var(--accent); }
.carousel { display: grid; grid-auto-flow: column; grid-auto-columns: max(270px, calc((100% - 3 * 12px) / 4)); gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; scrollbar-width: thin; }
.tcard { scroll-snap-align: start; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tcard:hover { border-color: #3a4757; }
.tc-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); min-width: 0; }
.tc-tour { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.tc-tour span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-live { background: var(--live); color: #fff; font-weight: 700; border-radius: 10px; padding: 1px 8px; font-size: 11px; }
.tc-timer { color: var(--text); font-weight: 600; min-width: 34px; text-align: right; }
.tc-top { border: 1px solid var(--accent); color: var(--accent); border-radius: 10px; padding: 1px 8px; font-size: 11px; white-space: nowrap; }
.tc-body { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; }
.tc-team { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; min-width: 0; }
.tc-team span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-team.right { justify-content: flex-end; text-align: right; }
.tc-center { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.tc-score { font-size: 20px; color: var(--accent); white-space: nowrap; }
.tc-center small { font-size: 11px; color: var(--muted); white-space: nowrap; }
.ico.mid { width: 22px; height: 22px; }
.tc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.tc-stat { display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; gap: 2px 4px; align-items: center; font-size: 11px; min-width: 0; }
.tc-stat-name { grid-column: 1 / -1; color: var(--muted); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-stat-val { font-weight: 600; }
.tc-bar { height: 4px; background: var(--panel2); border-radius: 2px; overflow: hidden; }
.tc-bar i { display: block; height: 100%; background: var(--accent); }
.tc-odds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.tc-odds .oc { min-width: 0; padding: 6px; gap: 4px; }
.tc-odds .oc-name { font-size: 11px; }
.tc-body.line { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.tc-date { font-size: 12px; color: var(--muted); }
.tc-more { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
.tc-more:hover { color: var(--accent); }

/* состояния */
.state { padding: 24px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: 10px; margin: 8px 0; }
.state.error { color: #ffb4b4; border-color: var(--live); }
.state.warn { color: #ffd88a; border-color: var(--warn); }
.selection {
  position: fixed; right: 16px; bottom: 16px; max-width: 360px; background: var(--panel2); border: 1px solid var(--accent);
  border-radius: 10px; padding: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); z-index: 20;
}

/* диагностика */
.cards { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; min-width: 110px; display: flex; flex-direction: column; }
.card b { font-size: 22px; }
.card span { color: var(--muted); font-size: 12px; }
.card.ok b { color: var(--up); }
.card.err b { color: var(--live); }
.card.warn b { color: var(--warn); }
table.diag { width: 100%; border-collapse: collapse; font-size: 12px; background: var(--panel); border-radius: 8px; overflow: hidden; }
table.diag th, table.diag td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.diag th { background: var(--panel2); color: var(--muted); font-weight: 500; }
table.diag td.path { word-break: break-all; max-width: 380px; }
table.diag a { color: var(--info); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--info); }
.lvl-error .dot { background: var(--live); }
.lvl-warn .dot { background: var(--warn); }
.pill { display: inline-block; border-radius: 4px; padding: 1px 6px; background: var(--panel2); font-size: 11px; margin: 1px 0; }
.pill.ok, .pill.empty, .pill.message { color: var(--up); }
.pill.api_error, .pill.bad_shape, .pill.bad_json, .pill.network, .pill.timeout, .pill.lvl-error { color: #fff; background: var(--live); }
.pill.lvl-warn { color: #111; background: var(--warn); }
.pill.lvl-info { color: #fff; background: var(--info); }
tr.out-api_error, tr.out-network, tr.out-timeout, tr.out-bad_shape, tr.out-bad_json { background: rgba(229, 72, 77, .08); }
details summary { cursor: pointer; color: var(--info); }
.ex { margin: 4px 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 52px; bottom: 0; width: 290px; z-index: 15; transform: translateX(-100%); transition: transform .2s; max-height: none; }
  .sidebar.open { transform: none; }
  .menu-toggle { display: block; }
  .topbar { gap: 8px; padding: 8px 12px; }
  .brand span, .diag-text { display: none; }
  .diag-ico { display: inline; }
  .tabs button { padding: 6px 10px; }
  .search { display: none; }
  .toggle { display: none; }
  .main { padding: 12px 16px 80px; }
  .game { grid-template-columns: minmax(0, 1fr) 48px; grid-template-areas: "main more" "info more" "cells cells"; }
  .game.thead { grid-template-areas: "main more" "cells cells"; }
  .g-cells { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ev-team { font-size: 14px; }
}
/* календарь линии */
.tabs.calendar { flex-wrap: wrap; gap: 4px; margin: 0 0 12px; width: fit-content; max-width: 100%; }
.tabs.calendar a { padding: 6px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.tabs.calendar a.active { background: var(--panel2); color: var(--text); }

/* --- вход по ключу --- */
body.locked .topbar > :not(.brand), body.locked .layout, body.locked .demo-banner { visibility: hidden; }
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 50; padding: 16px; }
.login[hidden] { display: none; }
.login-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; background: var(--panel, #161d24); border: 1px solid var(--line, #263038); border-radius: 12px; padding: 24px; }
.login-card h1 { margin: 4px 0 0; font-size: 20px; }
.login-card p { margin: 0; line-height: 1.5; }
.login-card input[type=password], .login-card input[type=text] { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line, #263038); background: var(--bg); color: var(--text); font-family: ui-monospace, monospace; }
.login-card button { padding: 10px 14px; border: 0; border-radius: 8px; background: var(--accent); color: #111; font-weight: 700; cursor: pointer; }
.login-card button:disabled { opacity: .6; cursor: default; }
.login-error { color: #ff7b72; font-size: 13px; }
.account { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.account[hidden] { display: none; }
.account-info { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.logout { border: 1px solid var(--line, #263038); background: none; color: var(--muted); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.logout:hover { color: var(--accent); }
