:root {
  --bg: #0b0f14;
  --bg-2: #11161d;
  --bg-3: #161d26;
  --line: #222c38;
  --text: #e6edf3;
  --muted: #8b97a5;
  --accent: #39d353;
  --accent-2: #2f81f7;
  --danger: #f85149;
  --warn: #d29922;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  background-image: radial-gradient(1200px 400px at 20% -10%, #16202b 0%, rgba(11, 15, 20, 0) 60%);
  padding-bottom: 40px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ------------------------------- верхняя панель ------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 18, 24, 0.9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(160deg, #1c2a38, #0e1620);
  color: var(--accent);
  font-size: 19px;
  border: 1px solid #26333f;
}
.brand-name { font-weight: 700; letter-spacing: 0.08em; font-size: 13px; }
.brand-sub { font-size: 11px; color: var(--muted); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  white-space: nowrap;
}
.chip b { color: var(--text); }
.chip-arb { border-color: #1d3b2a; background: #0f1c15; color: #7ee2a0; }
.chip-arb.has { border-color: #2ea043; background: #10261a; color: #56d364; }

.vault { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vault input { width: 170px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 8px rgba(248, 81, 73, 0.6); }
.dot-ok { background: var(--accent); box-shadow: 0 0 8px rgba(57, 211, 83, 0.6); }
#vault-label { font-size: 12px; color: var(--muted); }

/* ---------------------------------- поля ---------------------------------- */

input, select, textarea {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 7px;
  padding: 7px 9px;
  font: inherit;
  font-size: 13px;
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: #33557a; box-shadow: 0 0 0 2px rgba(47, 129, 247, 0.15); }
input[type="number"] { -moz-appearance: textfield; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.field > span { font-size: 11px; color: var(--muted); }
.field-wide { grid-column: 1 / -1; }

.btn {
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 7px;
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  white-space: nowrap;
  transition: 0.12s ease;
}
.btn:hover { border-color: #3a4959; background: #1b232d; }
.btn-primary { background: #133a22; border-color: #2ea043; color: #7ee787; }
.btn-primary:hover { background: #17492a; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 8px; font-size: 11.5px; }

/* --------------------------------- разметка -------------------------------- */

main { max-width: 1500px; margin: 0 auto; padding: 18px 22px; }

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; }
.toolbar-note { width: 100%; font-size: 11px; color: var(--muted); }

.books {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 1180px) { .books { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 680px) { .books { grid-template-columns: 1fr; } }

.book {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.book-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #0f151c;
}
.book-mark { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.book-name { font-weight: 650; font-size: 13.5px; }
.book-feed { margin-left: auto; font-size: 10.5px; color: var(--muted); text-align: right; }
.book-feed .live { color: var(--accent); }
.book-feed .stale { color: var(--warn); }
.book-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.book-body .row { display: flex; gap: 6px; }
.book-foot {
  margin-top: auto;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: #0f151c;
}
.acc-state { font-size: 11px; color: var(--muted); min-height: 14px; }
.acc-state.ok { color: #7ee787; }

/* --------------------------------- таблицы -------------------------------- */

.panel {
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.panel-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.panel h2 { font-size: 14px; margin: 0; letter-spacing: 0.01em; }
.panel h3 { font-size: 13px; margin: 14px 0 6px; }
.panel-hint { font-size: 11.5px; color: var(--muted); margin-left: auto; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 8px; border-bottom: 1px solid #1a222c; vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #131a22; }

.odds { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.odds-over { color: #79c0ff; }
.odds-under { color: #d2a8ff; }
.book-tag { font-size: 10.5px; color: var(--muted); }
.profit-pos { color: var(--accent); font-weight: 700; }
.profit-flat { color: var(--muted); }
.stake-main { font-variant-numeric: tabular-nums; }
.stake-guarantee { font-size: 11px; color: var(--accent); }

.empty { color: var(--muted); font-size: 12px; padding: 12px 4px; }

/* --------------------------------- матчи ---------------------------------- */

.matches { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 10px; }
.match {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f151c;
  padding: 10px 12px;
}
.match-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.match-teams { font-weight: 600; font-size: 13px; }
.match-meta { font-size: 10.5px; color: var(--muted); margin-left: auto; text-align: right; }
.match table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.match th { color: var(--muted); font-weight: 500; text-align: left; padding: 3px 4px; font-size: 10.5px; }
.match td { padding: 3px 4px; border-top: 1px solid #1a222c; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 999px; font-size: 10px; font-weight: 600; white-space: nowrap; }
.badge-arb { background: #12351f; color: #56d364; border: 1px solid #2ea043; }
.badge-near { background: #2b2312; color: #e3b341; border: 1px solid #4d3a12; }
.badge-no { background: #1a1f26; color: var(--muted); border: 1px solid var(--line); }
.badge-risk { background: #2d1a12; color: #ffa657; border: 1px solid #5a3418; }

.middles { display: flex; flex-direction: column; gap: 6px; }
.middle-row {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #0f151c;
  font-size: 12px;
}

/* -------------------------------- предупреждение --------------------------- */

.warning { border-color: #3d2b16; background: linear-gradient(180deg, #1a1409, #12100c); }
.warning-title { font-weight: 700; color: #e3b341; font-size: 13px; margin-bottom: 6px; }
.warning p { margin: 6px 0; font-size: 12.5px; color: #d6cbb5; }
.formula {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #0e1219;
  border: 1px solid #2b2413;
  border-radius: 6px;
  padding: 8px 10px;
  color: #f0d58c !important;
}

/* -------------------------------- настройки -------------------------------- */

.settings summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.settings-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.sep { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
.steps { margin: 6px 0 0 18px; padding: 0; font-size: 12.5px; color: #c7d1db; }
.steps li { margin: 4px 0; }
.steps a { color: #79c0ff; }
.token-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #0e1219; border: 1px solid var(--line); padding: 4px 8px; border-radius: 6px; font-size: 12px; }

.footer {
  display: flex; justify-content: space-between; gap: 12px;
  color: var(--muted); font-size: 11px; padding: 8px 2px 0;
}

/* ---------------------------------- тост ---------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: #1b2430;
  border: 1px solid #33414f;
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: 0.18s ease;
  z-index: 50;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: #6b2b2b; background: #2a1414; }
