:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c2230;
  --line: #2a3140;
  --text: #d8dee9;
  --dim: #8b96a8;
  --accent: #5aa9ff;
  --up: #3fb950;
  --down: #f85149;
  --warn: #d29922;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

/* ---------- header ---------- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-size: 17px;
  letter-spacing: .5px;
}

.head-right { display: flex; align-items: center; gap: 12px; }

.lang-picker {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  min-width: 0;
}
.lang-picker:hover { border-color: var(--accent); }

/* Arabic reads right to left; mirror the layout rather than the numbers. */
[dir="rtl"] .account-bar .btn { margin-inline-start: auto; }
[dir="rtl"] .steps li { padding: 16px 54px 16px 18px; }
[dir="rtl"] .steps li::before { left: auto; right: 18px; }
[dir="rtl"] table.bets .num { direction: ltr; }
[dir="rtl"] .plan-price { direction: ltr; }

.dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--down);
  margin-left: 8px;
  vertical-align: middle;
}
.dot.on { background: var(--up); box-shadow: 0 0 8px var(--up); }

/* ---------- shared ---------- */

h1 { font-size: 27px; line-height: 1.3; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 12px; margin: 24px 0 10px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; }

.lead { color: var(--dim); max-width: 68ch; }
.hint { color: var(--dim); font-size: 12px; }
.error { color: var(--down); font-size: 12px; min-height: 16px; }
.warn { color: var(--warn); }
.pos { color: var(--up); }
.neg { color: var(--down); }

code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }

/* The one control: green to start, blue to save, red to stop. */
.btn.act-start { background: var(--up); border-color: var(--up); color: #04140a; font-weight: 600; }
.btn.act-save  { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
.btn.act-stop  { background: var(--down); border-color: var(--down); color: #1a0605; font-weight: 600; }
.btn.act-start:hover, .btn.act-save:hover, .btn.act-stop:hover { filter: brightness(1.12); }
.btn.big { padding: 12px 26px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--line);
  color: var(--dim);
}
.badge.on { color: var(--up); border-color: var(--up); }
.badge.live { color: var(--warn); border-color: var(--warn); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- landing ---------- */

.landing { max-width: 1400px; margin: 0 auto; padding: 40px 24px 80px; }
.landing section { margin-bottom: 52px; }

/* Text runs the width of the page rather than a narrow column. */
.landing .lead { max-width: none; }

.hero { text-align: left; }
.hero .lead { margin-bottom: 26px; font-size: 15px; }

.steps { list-style: none; counter-reset: s; padding: 0; margin: 0; display: grid; gap: 16px; }
.steps li {
  counter-increment: s;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 16px 54px;
  position: relative;
}
.steps li::before {
  content: counter(s);
  position: absolute;
  left: 18px; top: 16px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 12px;
}
.steps b { display: block; margin-bottom: 3px; }
.steps span { color: var(--dim); font-size: 13px; }

footer {
  border-top: 1px solid var(--line);
  padding: 20px 24px;
  color: var(--dim);
  font-size: 12px;
  text-align: center;
}

/* ---------- stat tiles ---------- */

.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.tile b { display: block; font-size: 20px; line-height: 1.2; }
.tile span { font-size: 11px; color: var(--dim); }

/* Price and duration share one line, the button spans the whole card. */
.plan-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.plan {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color .15s;
}
.plan:hover { border-color: var(--accent); }

.plan-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.plan-price { font-size: 30px; font-weight: 600; line-height: 1; }
.plan-term { font-size: 13px; color: var(--dim); white-space: nowrap; }

.plan .btn { width: 100%; text-align: center; padding: 10px; font-size: 14px; }

.plan.owned { border-color: var(--up); }
.plan .was { color: var(--dim); text-decoration: line-through; font-size: 15px; margin-right: 6px; }

/* Auto-renewal mandates. The cancel button is a listing requirement. */
.sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}
.sub-row.past-due { border-color: var(--down); }
.sub-row .btn { padding: 6px 14px; font-size: 12px; }
.sub-hint { margin-top: 10px; }

.final-note { margin-top: 14px; }
.final-note b { color: var(--warn); }

.closing { display: flex; justify-content: center; padding: 10px 0 0; }

.stats-note { margin-top: 18px; font-size: 13px; }

/* Signed-in bar: identity, loyalty toggle and sign out, all on one line. */
.account-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 20px;
  margin-bottom: 8px;
}
.account-bar .who { color: var(--dim); font-size: 13px; white-space: nowrap; }
.account-bar .who b { color: var(--text); font-size: 15px; }
.account-bar .btn { padding: 6px 14px; font-size: 12px; white-space: nowrap; }

.loyalty {
  flex: 1;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.loyalty > span:first-of-type { flex: 1; }
.loyalty input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.loyalty b { color: var(--accent); font-weight: 600; }

.bar-note { margin: -2px 0 18px; padding: 0 20px; }
.bar-note:empty { display: none; }

/* ---------- cabinet ---------- */

.cabinet { max-width: 1400px; margin: 0 auto; padding: 28px 24px 80px; }

.block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 22px;
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.block-head h2 { margin: 0; }

#api-key { flex: 1; min-width: 280px; }

label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--dim); }
label small { color: var(--dim); opacity: .75; font-size: 11px; }

input, select {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius);
  font: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
input:disabled, select:disabled { opacity: .5; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid .wide { grid-column: 1 / -1; }

/* The five strategy fields belong on one line — bet size must not wrap. */
.grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1100px) {
  .grid-5 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

/* Selects must be allowed to shrink inside a grid track. */
.grid input, .grid select, .pairs-row input { min-width: 0; width: 100%; }

/* Long field for the selection, a small search box beside it. */
.pairs-row {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 12px;
  margin-bottom: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  align-content: flex-start;
}

.chip {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--dim);
  border-radius: 20px;
  padding: 4px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121f;
  font-weight: 600;
}
.chip.on::after { content: ' ×'; opacity: .7; }
.chip.all { border-style: dashed; }
/* Typed by hand but not on CRYPREX — a bet on it would fail with 503. */
.chip.unknown { border-color: var(--down); color: var(--down); }
.chip.on.unknown { background: var(--down); border-color: var(--down); color: #1a0605; }

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 7px 11px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--dim); font-weight: 500; background: var(--panel-2); }
tbody tr:hover { background: var(--panel-2); }

/*
 * Even columns, everything centred. Status keeps the slack because it carries
 * the error text; the rest are narrow and fixed so nothing huddles left.
 */
table.bets { table-layout: fixed; }
table.bets th, table.bets td { text-align: center; }

table.bets th:nth-child(1), table.bets td:nth-child(1) { width: 16%; }
table.bets th:nth-child(2), table.bets td:nth-child(2) { width: 11%; }
table.bets th:nth-child(3), table.bets td:nth-child(3) { width: 7%; }
table.bets th:nth-child(4), table.bets td:nth-child(4) { width: 8%; }
table.bets th:nth-child(5), table.bets td:nth-child(5) { width: 9%; }
table.bets th:nth-child(6), table.bets td:nth-child(6) { width: 9%; }
table.bets th:nth-child(7), table.bets td:nth-child(7) { width: auto; }
table.bets th:nth-child(8), table.bets td:nth-child(8) { width: 10%; }

table.bets .num { font-variant-numeric: tabular-nums; }
table.bets .dim { color: var(--dim); }
table.bets .status { white-space: normal; }

/* The log shows exactly the number of rows asked for — no inner scrolling. */
.bets-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.bets-wrap table { width: 100%; }

.pager { gap: 8px; }
.pager .inline { flex-direction: row; align-items: center; gap: 6px; }
.pager select { padding: 5px 8px; min-width: 0; }
.pager .btn { padding: 5px 12px; }

/* ---------- Подтверждение действия ----------
   Заменяет системный confirm(). Тот показывает кнопки «ОК / Отмена» на языке
   браузера, мимо переводов страницы, и выглядит чужеродно. Здесь нативный
   <dialog>: он сам даёт модальность, закрытие по Esc и подложку, поэтому
   поведение остаётся стандартным, а вид — свой. */
.confirm {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 380px;
  width: calc(100% - 32px);
}

.confirm::backdrop { background: rgba(6, 9, 14, .65); }

/* Текст вопроса — единственное содержимое окна, поэтому основной
   цвет, а не приглушённый: заголовка над ним нет. */
.confirm p {
  margin: 0 0 20px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
