/* oddswatch — тёмная тема с красными акцентами. Без внешних шрифтов и ресурсов (CSP: только 'self'). */
:root {
  color-scheme: dark;
  --bg: #0b0c0f;
  --bg-2: #101217;
  --surface: #15171d;
  --surface-2: #1b1e25;
  --surface-3: #232731;
  --line: #262a33;
  --line-2: #323744;
  --fg: #eceef2;
  --fg-2: #c3c7d0;
  --muted: #858b97;
  --accent: #e5383b;
  --accent-2: #ff5a5f;
  --accent-deep: #a4161a;
  --accent-soft: rgba(229, 56, 59, .12);
  --accent-line: rgba(229, 56, 59, .35);
  --ok: #3ccf91;
  --ok-soft: rgba(60, 207, 145, .12);
  --warn: #f2a541;
  --warn-soft: rgba(242, 165, 65, .12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh;
  font: 14.5px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--fg);
  background:
    radial-gradient(900px 420px at 85% -120px, rgba(229, 56, 59, .10), transparent 70%),
    radial-gradient(700px 360px at -10% 0, rgba(164, 22, 26, .08), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
::selection { background: var(--accent); color: #fff; }
a { color: var(--accent-2); text-decoration: none; transition: color .15s; }
a:hover { color: #ff8a8d; }
code, pre, .mono { font-family: var(--mono); }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 18px; }
h2 { font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 32px 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 28px;
  padding: 0 28px; height: 60px;
  background: rgba(11, 12, 15, .82);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-line) 30%, var(--accent-line) 70%, transparent);
}
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; color: var(--fg); }
.brand:hover { color: var(--fg); text-decoration: none; }
.brand b { color: var(--accent); font-weight: 800; }
.logo { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 0 8px rgba(229, 19, 33, .35)); }
.wordmark { height: 19px; width: auto; display: block; }
.top nav { display: flex; gap: 4px; flex: 1; height: 100%; overflow-x: auto; scrollbar-width: none; }
.top nav a {
  position: relative; display: flex; align-items: center; padding: 0 12px;
  color: var(--fg-2); font-weight: 500; white-space: nowrap;
}
.top nav a:hover { color: var(--fg); text-decoration: none; }
.top nav a.active { color: var(--fg); }
.top nav a.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px;
  background: var(--accent); box-shadow: 0 0 12px var(--accent);
}
.logout { display: flex; gap: 12px; align-items: center; }
.who { display: inline-flex; align-items: center; gap: 8px; color: var(--fg-2); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #fff; font-weight: 700; font-size: 12px;
  text-transform: uppercase;
}

main { padding: 28px 28px 64px; max-width: 1320px; margin: 0 auto; }

/* ---------- раскладка ---------- */
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.bar h1 { margin: 6px 0 10px; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
section { margin-bottom: 18px; max-width: 820px; }
section.card-section {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 4px 22px 20px; margin-bottom: 18px;
}
section.card-section h2 { margin-top: 18px; }

/* ---------- формы ---------- */
label { display: block; margin: 10px 0; color: var(--fg-2); font-size: 13px; font-weight: 500; }
label input, label select { display: block; width: 100%; margin-top: 6px; }
label.check {
  display: inline-flex; align-items: center; gap: 8px; margin: 4px 8px 4px 0; padding: 7px 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  font-size: 13px; transition: border-color .15s, background .15s;
}
label.check:hover { border-color: var(--line-2); }
label.check:has(input:checked) { background: var(--accent-soft); border-color: var(--accent-line); color: var(--fg); }
label.check input { width: auto; margin: 0; }
input, select, textarea {
  font: inherit; color: var(--fg);
  padding: 9px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--bg-2); outline: none; transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #5d636e; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }
select { padding-right: 30px; cursor: pointer; }
input.tiny { width: 64px; display: inline-block; text-align: center; padding: 7px 8px; }

button, .button {
  font: inherit; font-weight: 600; font-size: 14px; line-height: 1.2;
  padding: 10px 18px; border-radius: var(--radius-sm); cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  color: #fff; border: 1px solid transparent;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 6px 18px rgba(229, 56, 59, .25), inset 0 1px 0 rgba(255, 255, 255, .15);
  transition: transform .08s, box-shadow .15s, filter .15s;
}
button:hover, .button:hover { filter: brightness(1.08); color: #fff; text-decoration: none; box-shadow: 0 8px 24px rgba(229, 56, 59, .35); }
button:active, .button:active { transform: translateY(1px); }
button.secondary, .button.secondary {
  background: var(--surface-2); color: var(--fg); border-color: var(--line-2); box-shadow: none;
}
button.secondary:hover, .button.secondary:hover { border-color: var(--accent-line); background: var(--surface-3); }
button.link {
  background: none; border: none; box-shadow: none; padding: 0; color: var(--fg-2); font-weight: 500; font-size: 13px;
}
button.link:hover { color: var(--fg); filter: none; box-shadow: none; }
button.link.danger, .danger { color: var(--accent-2); }
button.link.danger:hover { color: #ff8a8d; }
.button + .button { margin-left: 6px; }

/* ---------- сообщения ---------- */
.note {
  padding: 12px 16px; border-radius: var(--radius-sm); margin: 14px 0;
  background: var(--surface-2); border: 1px solid var(--line-2); color: var(--fg-2);
}
.note.err { background: var(--accent-soft); border-color: var(--accent-line); color: #ffc9ca; }
.note.ok { background: var(--ok-soft); border-color: rgba(60, 207, 145, .35); color: #b9f3d9; }

/* ---------- таблицы ---------- */
table.grid {
  width: 100%; border-collapse: separate; border-spacing: 0; margin: 10px 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
table.grid th, table.grid td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tr:last-child td { border-bottom: none; }
table.grid th {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  background: var(--bg-2); white-space: nowrap;
}
table.grid tbody tr { transition: background .12s; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid tr.muted td { color: var(--muted); }
.narrow-table { max-width: 680px; }
.actions { white-space: normal; min-width: 160px; }
.actions form { display: inline; margin-right: 12px; }
td a { color: var(--fg); font-weight: 500; }
td a:hover { color: var(--accent-2); }

/* ---------- значки ---------- */
.tag {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px;
  color: #ffd7d8; background: var(--accent-soft); border: 1px solid var(--accent-line); vertical-align: 1px;
}
.drop { color: var(--accent-2); font-weight: 700; }
.odds { font-family: var(--mono); font-size: 13.5px; }
.odds b { color: var(--fg); }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); }
.st-sent { color: var(--fg-2); } .st-sent::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.st-blocked::before, .st-error::before, .st-unlinked::before { background: var(--accent); }
.st-quiet::before, .st-limit::before, .st-paused::before, .st-muted::before { background: var(--warn); }

/* ---------- карточки ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin: 16px 0 8px; }
.card {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
}
.card > .muted.small:first-child { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 600; margin-bottom: 6px; }
.card b { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line-2); }
.card.good::before { background: var(--ok); box-shadow: 0 0 14px var(--ok); }
.card.bad::before { background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.card.warn::before { background: var(--warn); }
.card.accent { border-color: var(--accent-line); background: linear-gradient(180deg, rgba(229, 56, 59, .14), var(--surface)); }
.card.accent b { color: #fff; }

/* ---------- вход ---------- */
.auth { min-height: calc(100vh - 92px); display: grid; place-items: center; }
.narrow {
  width: 100%; max-width: 420px; margin: 24px auto;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: 16px; padding: 30px 30px 26px; box-shadow: var(--shadow);
  position: relative;
}
.narrow::before {
  content: ""; position: absolute; left: 24px; right: 24px; top: -1px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.narrow h1 { margin-top: 0; }
.narrow form button { width: 100%; justify-content: center; margin-top: 10px; }
.narrow ol { padding-left: 18px; color: var(--fg-2); }
.auth-brand { display: flex; justify-content: center; margin-bottom: 22px; }
.auth-logo { width: 210px; height: auto; filter: drop-shadow(0 0 18px rgba(229, 19, 33, .25)); }
.qr { display: flex; justify-content: center; margin: 14px 0; }
.qr svg {
  display: block; width: min(240px, 100%); height: auto; aspect-ratio: 1; border-radius: 10px; background: #fff;
  box-shadow: 0 0 0 1px var(--line-2), 0 0 30px rgba(229, 56, 59, .15);
}
code.secret {
  font-size: 14.5px; padding: 4px 8px; color: #ffd7d8; background: var(--accent-soft);
  border: 1px solid var(--accent-line); border-radius: 6px; word-break: break-all;
}
pre.codes {
  font-size: 17px; line-height: 1.8; columns: 2; background: var(--bg-2); color: var(--fg);
  border: 1px dashed var(--line-2); padding: 14px 18px; border-radius: var(--radius-sm);
}

/* ---------- редактор профиля ---------- */
.profile-form { max-width: 1040px; }
fieldset {
  border: 1px solid var(--line); border-radius: var(--radius); margin: 14px 0; padding: 6px 18px 12px;
  display: flex; flex-wrap: wrap; gap: 0 18px; background: var(--surface);
}
legend {
  padding: 3px 10px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-2); background: var(--bg); border: 1px solid var(--accent-line); border-radius: 999px;
}
fieldset label { flex: 1 1 200px; }
fieldset label.wide, .profile-form > label.wide { flex: 1 1 100%; }
fieldset label.check { flex: 0 0 auto; }
.form-actions {
  position: sticky; bottom: 0; z-index: 5; margin-top: 16px; padding: 14px 18px;
  background: rgba(21, 23, 29, .92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; align-items: center; gap: 8px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#backtest:not(:empty) { margin-top: 18px; }
.days { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.days span { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--fg-2); }

/* ---------- график ---------- */
.chart-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 12px 6px; }
.chart-range { padding: 5px 12px; border-radius: 999px; font-size: 12.5px; }
.chart-range.on { background: var(--accent-soft); border-color: var(--accent-line); color: #ffd7d8; }
#chart { min-height: 380px; }
.u-legend { color: var(--fg-2); font-size: 12.5px; }
.u-legend .u-marker { border-radius: 3px; }
.u-select { background: rgba(229, 56, 59, .12); }

/* ---------- пустые состояния и пр. ---------- */
.empty { padding: 36px 14px !important; text-align: center; color: var(--muted); }
details summary { cursor: pointer; color: var(--fg-2); }
details code { display: block; margin-top: 6px; white-space: pre-wrap; color: var(--fg-2); font-size: 12px; }
.pager { margin-top: 14px; }
.err-code { font-size: 72px; font-weight: 800; letter-spacing: -.04em; color: var(--accent); text-shadow: 0 0 40px rgba(229, 56, 59, .35); margin: 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--line-2); }

@media (max-width: 760px) {
  .top { height: auto; flex-wrap: wrap; padding: 10px 14px 0; gap: 6px 14px; }
  .logout { margin-left: auto; }
  .top nav { order: 3; flex: 1 1 100%; height: 42px; margin: 0 -6px; }
  .top nav a { padding: 0 8px; }
  .who span:not(.avatar) { display: none; }
  main { padding: 18px 14px 48px; }
  table.grid { font-size: 13px; display: block; overflow-x: auto; }
  table.grid th, table.grid td { padding: 10px; }
  .narrow { padding: 24px 20px; }
  pre.codes { columns: 1; }
}
.center { text-align: center; }
.auth > div { width: 100%; max-width: 440px; }

/* ---------- подсказки и выпадающие списки ---------- */
.hint { display: block; margin-top: 5px; font-size: 12px; font-weight: 400; color: var(--muted); line-height: 1.4; }
.checks { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; flex: 1 1 100%; margin: 6px 0 2px; }
.checks .hint { display: inline; margin: 0 0 0 6px; }
fieldset > .hint { flex: 1 1 100%; margin: 0 0 8px; }
.picker-field { flex: 1 1 100%; margin: 12px 0 4px; }
.picker-title { color: var(--fg-2); font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.picker { position: relative; }
.chips {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 42px; padding: 5px 8px;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); cursor: text;
  transition: border-color .15s, box-shadow .15s;
}
.picker:focus-within .chips { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--fg); font-size: 13px;
}
.chip small { color: var(--muted); font-size: 11.5px; }
.chip-x {
  width: 20px; height: 20px; padding: 0; justify-content: center; border-radius: 50%; font-size: 15px; line-height: 1;
  background: transparent; border: none; box-shadow: none; color: var(--fg-2);
}
.chip-x:hover { background: var(--accent); color: #fff; box-shadow: none; filter: none; }
.picker-input { flex: 1 1 160px; min-width: 120px; border: none; background: transparent; padding: 6px 4px; box-shadow: none !important; }
.picker-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); max-height: 300px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 4px;
}
.opt {
  display: flex; width: 100%; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 6px;
  background: transparent; border: none; box-shadow: none; color: var(--fg); font-weight: 500; text-align: left;
}
.opt small { color: var(--muted); font-weight: 400; }
.opt:hover, .opt.on { background: var(--accent-soft); filter: none; box-shadow: none; color: #fff; }
.opt-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.small-btn { padding: 6px 12px; font-size: 13px; }
.lbl { display: flex; align-items: flex-end; min-height: 2.9em; }
@media (max-width: 760px) { .lbl { min-height: 0; } }
.drop-field { flex: 1 1 200px; display: flex; }
.drop-field[hidden] { display: none; }
.drop-field > label { flex: 1; }
.drop-mode .picker-title { margin: 0 8px 0 0; }

/* ---------- настройка 2FA ---------- */
.secret-box { margin: 16px 0; padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.secret-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.secret-row code.secret { flex: 1 1 200px; font-size: 14px; line-height: 1.6; }
.narrow form .copy-btn, .copy-btn { width: auto; margin: 0; padding: 8px 14px; font-size: 13px; }
.copy-btn.done { border-color: rgba(60, 207, 145, .5); color: #b9f3d9; }
.mobile-only { display: none; }
@media (hover: none) and (pointer: coarse) { .mobile-only { display: block; } }
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }
