/* Platform Reports — console UI system */

:root {
  color-scheme: dark;
  --bg: #13161d;
  --surface: #191d26;
  --surface-2: #1e232e;
  --border: #272d39;
  --border-strong: #333a48;
  --text: #d7dbe3;
  --text-muted: #939bab;
  --text-faint: #626a79;
  --accent: #6f86c9;
  --accent-hover: #8397d5;
  --accent-soft: #1c2333;
  --success: #6faf98;
  --success-soft: #17241f;
  --warning: #bfa06a;
  --warning-soft: #241f15;
  --danger: #c77b80;
  --danger-hover: #d68a8f;
  --danger-soft: #241619;
  --navbar: #0f1218;
  --navbar-2: #0c0e14;
  --navbar-text: #939bab;
  --navbar-text-strong: #eef1f6;
  --navbar-border: #1c212d;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, .4);
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ---------- Navbar ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, var(--navbar), var(--navbar-2));
  border-bottom: 1px solid var(--navbar-border);
}

.nav__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--navbar-text-strong);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(150deg, var(--accent), #7d6fb0);
  display: grid;
  place-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
  flex: 1;
}
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 100%;
  padding: 0 12px;
  color: var(--navbar-text);
  font-size: 14px;
  font-weight: 500;
  border: 0;
  background: none;
}
.tab:hover { color: var(--navbar-text-strong); text-decoration: none; }
.tab::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform .18s ease;
}
.tab.is-active { color: var(--navbar-text-strong); }
.tab.is-active::after { transform: scaleX(1); }
.tab.is-disabled { color: #5a6379; pointer-events: none; }

.tab__soon {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #7f8aa3;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
  padding: 1px 6px;
  border-radius: 999px;
}

.nav__user {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--navbar-text);
  font-size: 13px;
}
.user-chip__avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  color: var(--navbar-text-strong);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

/* ---------- Layout ---------- */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.page__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page__title {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -.02em;
}
.page__meta {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 550;
  line-height: 1;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .05s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(.5px); }

.btn-primary {
  background: var(--accent);
  color: #0f1218;
  box-shadow: none;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--text-faint); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover { background: var(--danger-soft); }

.btn--block { width: 100%; }
.btn--sm { height: 32px; padding: 0 11px; font-size: 13px; }

.btn__icon { width: 16px; height: 16px; flex: none; }

.btn.is-loading { cursor: progress; opacity: .85; }
.spinner {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  display: inline-block;
  vertical-align: -2px;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Card & table ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
table.data td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s ease; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td:last-child, table.data th:last-child { text-align: right; }

.cell-name { font-weight: 550; letter-spacing: -.01em; }

.endpoint {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}
.endpoint b { color: var(--text); font-weight: 500; }

/* ---------- Backend pill ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  border: 1px solid transparent;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}
.pill--new { color: var(--success); background: var(--success-soft); }
.pill--old { color: var(--warning); background: var(--warning-soft); }

/* ---------- Connection status ---------- */

.head-actions { display: flex; align-items: center; gap: 10px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
}
.status small { color: var(--text-faint); font-weight: 400; }
.status--idle { color: var(--text-faint); font-weight: 400; }
.status--ok { color: var(--success); }
.status--err { color: var(--danger); }
.status--ok::before,
.status--err::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  flex: none;
}
.status--loading { color: #64748b; }

/* ---------- Row actions ---------- */

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .13s ease, color .13s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn--danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn svg { width: 16px; height: 16px; }
.inline-form { display: inline; margin: 0; }

/* ---------- Empty state ---------- */

.empty {
  text-align: center;
  padding: 56px 24px;
}
.empty__glyph {
  width: 46px; height: 46px;
  margin: 0 auto 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
}
.empty h2 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.empty p { margin: 0 0 20px; color: var(--text-muted); }

/* ---------- Forms ---------- */

.form-card {
  max-width: 460px;
  margin: 0 auto;
  padding: 28px;
}
.field { margin-bottom: 18px; }
.field:last-of-type { margin-bottom: 0; }
.label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 550;
  color: var(--text);
}
.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--text-faint); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input--mono { font-family: var(--mono); }
.hint { margin-top: 6px; font-size: 12px; color: var(--text-faint); }

/* toggle switch for backend flag */
.switch-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.switch-field__text { font-size: 13px; }
.switch-field__text small { display: block; color: var(--text-faint); font-weight: 400; margin-top: 2px; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track {
  position: absolute; inset: 0;
  background: var(--border-strong);
  border-radius: 999px;
  transition: background .18s ease;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  transition: transform .18s ease;
}
.switch input:checked + .switch__track { background: var(--success); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}
.form-actions .btn { flex: 1; }

/* ---------- Mappings (tree) ---------- */

.section-title {
  margin: 30px 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: -.01em;
}
.input--sm { height: 32px; font-size: 13px; }
.muted { color: var(--text-muted); }

.tree { padding: 6px 0; }

.tree__op {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px 8px;
  font-weight: 650;
  font-size: 14px;
  letter-spacing: -.01em;
}
.tree__op:not(:first-child) { border-top: 1px solid var(--border); margin-top: 4px; }
.tree__opicon { width: 15px; height: 15px; color: var(--accent); flex: none; }
.tree__count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
}

.tree__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 20px 7px 40px;
  position: relative;
}
.tree__row::before {
  content: "";
  position: absolute;
  left: 26px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.tree__row:hover { background: var(--surface-2); }

.tree__prov { font-weight: 500; min-width: 200px; }
.tree__raw {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-faint);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  margin-left: 6px;
  white-space: nowrap;
}
.tree__arrow { color: var(--text-faint); }
.tree__meta { color: var(--text-faint); font-size: 12.5px; flex: 1; }
.tree__actions { margin-left: auto; display: inline-flex; gap: 4px; }

.tree__rename {
  margin: 0 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: center;
}
.tree__rename .input { max-width: 170px; }

@media (max-width: 720px) {
  .tree__row { flex-wrap: wrap; padding-left: 32px; }
  .tree__prov { min-width: 0; }
  .tree__meta { flex-basis: 100%; }
  .tree__rename { margin-left: 0; flex-wrap: wrap; }
}

/* ---------- Alert ---------- */

.alert {
  margin-bottom: 20px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
  font-size: 13px;
}
.alert ul { margin: 0; padding-left: 18px; }
.alert li + li { margin-top: 2px; }

/* ---------- Auth screen ---------- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth__box { width: 100%; max-width: 360px; }
.auth__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -.01em;
}
.auth__card { padding: 26px; }
.auth__title { margin: 0 0 2px; font-size: 18px; font-weight: 650; }
.auth__sub { margin: 0 0 22px; color: var(--text-muted); font-size: 13px; }

/* ---------- Misc ---------- */

.notfound {
  min-height: 70vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
}
.notfound h1 { font-size: 20px; margin: 0 0 6px; }
.notfound p { color: var(--text-muted); margin: 0 0 20px; }

@media (max-width: 560px) {
  .nav__inner { gap: 12px; padding: 0 16px; }
  .brand span { display: none; }
  .page { padding: 24px 16px 64px; }
  .page__head { flex-direction: column; align-items: stretch; }
  .user-chip__name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Open bets ---------- */

/* Селект месяца — тот же контур, что у .input, но по ширине содержимого. */
.select {
  height: 38px;
  padding: 0 32px 0 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface)
    url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23939bab' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")
    no-repeat right 11px center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  appearance: none;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  margin-bottom: 20px;
  overflow: hidden;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.summary__item {
  display: flex;
  flex: 1 1 160px;
  flex-direction: column;
  gap: 5px;
  padding: 14px 20px;
  background: var(--surface);
}
.summary__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.summary__value {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 550;
  letter-spacing: -.01em;
}

/* Числовые колонки выравниваются вправо и набираются моноширинным, чтобы
   разряды стояли столбиком (правило для last-child этого не покрывает). */
table.data th.num { text-align: right; }
table.data td.num {
  font-family: var(--mono);
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}
.cur { color: var(--text-faint); }

/* Справочник спортивных провайдеров на странице открытых ставок. */
.sport-list { padding: 18px 20px; margin-bottom: 18px; }
.sport-list__head {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
}
.sport-list__head form { flex: 0 0 auto; }
.sport-list__title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}
.sport-list .table-wrap { margin-top: 14px; }

/* Заметки под кнопкой: результат обновления и предупреждения о платформах,
   для которых списка нет. */
.note {
  margin: 12px 0 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
}
.note--ok { border-color: var(--success); background: var(--success-soft); }
.note--warn { border-color: var(--warning); background: var(--warning-soft); }

/* Чип провайдера/класса ставки. Доля отделена цветом, чтобы код провайдера
   читался первым. */
.chip {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 2px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}
.chip--sport { border-color: var(--warning); color: var(--warning); }
.chip__pct { font-family: var(--mono); color: var(--text-faint); }
.chip--sport .chip__pct { color: inherit; opacity: .75; }
