:root {
  --bg: #0F1620;
  --surface: #131B26;
  --row: #161F2C;
  --border: #263140;
  --text: #E7ECF2;
  --text-muted: #7C8A9B;
  --text-faint: #4C5766;
  --long: #35C787;
  --short: #E5566B;
  --accent: #5B8DEF;
  --radius: 6px;
  font-family: "IBM Plex Sans", -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: 48px;
}

.mono, .num {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

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

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

header.top .brand {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}

header.top .brand .dot {
  color: var(--long);
}

header.top nav {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}

header.top nav::-webkit-scrollbar { display: none; }

header.top nav a {
  color: var(--text-muted);
  margin-left: 16px;
  font-size: 14px;
  white-space: nowrap;
}

header.top nav a:first-child { margin-left: 0; }

header.top nav a.active { color: var(--text); }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}

.section-label {
  color: var(--text-muted);
  font-size: 13px;
  margin: 28px 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.section-label .count {
  color: var(--text-faint);
}

.list {
  border-top: 1px solid var(--border);
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px 12px 12px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
}

.row.long { border-left-color: var(--long); }
.row.short { border-left-color: var(--short); }

.row .symbol {
  font-weight: 600;
  min-width: 84px;
}

.row .meta {
  color: var(--text-muted);
  font-size: 13px;
  flex: 1;
}

.row .figures {
  text-align: right;
}

.row .spread {
  font-size: 15px;
}

.row .spread.long { color: var(--long); }
.row .spread.short { color: var(--short); }

.row .delta {
  color: var(--text-muted);
  font-size: 12px;
}

.row .delta.long { color: var(--long); }
.row .delta.short { color: var(--short); }

.empty {
  padding: 32px 4px;
  color: var(--text-muted);
  font-size: 14px;
  border-top: 1px solid var(--border);
}

form.auth {
  max-width: 320px;
  margin: 96px auto;
  padding: 0 20px;
}

form.auth h1 {
  font-size: 18px;
  margin-bottom: 24px;
}

form.auth label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

form.auth input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 15px;
  margin-bottom: 16px;
}

form.auth input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

form.auth button {
  width: 100%;
  background: var(--accent);
  color: #0B1420;
  border: none;
  border-radius: var(--radius);
  padding: 11px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

form.auth .error {
  color: var(--short);
  font-size: 13px;
  margin-bottom: 16px;
}

.a2hs-hint {
  margin: 20px 16px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-muted);
}

.flash {
  margin: 16px 0;
  padding: 10px 14px;
  background: rgba(53, 199, 135, 0.12);
  border: 1px solid var(--long);
  border-radius: var(--radius);
  color: var(--long);
  font-size: 13px;
}

main .error {
  margin: 16px 0;
  padding: 10px 14px;
  background: rgba(229, 86, 107, 0.1);
  border: 1px solid var(--short);
  border-radius: var(--radius);
  color: var(--short);
  font-size: 13px;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.inline-form input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 11px;
  font-size: 14px;
  min-width: 0;
}

.btn-primary {
  background: var(--accent);
  color: #0B1420;
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
}

.btn-text:hover { color: var(--short); }
.btn-text.positive:hover { color: var(--long); }

.row.plain { border-left-color: transparent; }

.list a.row {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.list a.row:active { background: var(--surface); }

.back-link {
  display: inline-block;
  color: var(--text-muted);
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  margin: 16px 0 4px;
  text-decoration: none;
}

.detail-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 4px 0 8px;
}

.detail-header h1 {
  font-size: 22px;
  margin: 0;
}

.pos-badge {
  font-size: 12px;
  color: var(--long);
  background: rgba(53, 199, 135, 0.12);
  border: 1px solid var(--long);
  border-radius: var(--radius);
  padding: 3px 8px;
}

.detail-actions {
  display: flex;
  gap: 10px;
  margin: 16px 0 8px;
}

.detail-actions form { flex: 1; }
.detail-actions button { width: 100%; }

.btn-danger {
  background: none;
  border: 1px solid var(--short);
  color: var(--short);
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.link-row {
  display: flex;
  gap: 8px;
  margin: 4px 0 8px;
}

.link-row a {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-row a:active { border-color: var(--accent); }

.trend-grid {
  border-top: 1px solid var(--border);
}

.trend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.trend-row .tf-name {
  width: 32px;
  color: var(--text-muted);
}

.trend-row .tf-change { width: 68px; }
.trend-row .tf-change.long { color: var(--long); }
.trend-row .tf-change.short { color: var(--short); }

.trend-row .tf-extra {
  color: var(--text-faint);
  flex: 1;
  text-align: right;
}

.row .left { flex: 1; min-width: 0; }

.row .symbol-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.row .symbol-line .symbol { font-weight: 600; }

.row .left .meta {
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.badge {
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: "IBM Plex Mono", monospace;
}

.badge.long { color: var(--long); border-color: var(--long); }
.badge.short { color: var(--short); border-color: var(--short); }

.row .pnl { font-size: 16px; }
.row .pnl.long { color: var(--long); }
.row .pnl.short { color: var(--short); }

.row .real { font-size: 12px; opacity: 0.75; }
.row .real.long { color: var(--long); }
.row .real.short { color: var(--short); }

.settings-group {
  border-top: 1px solid var(--border);
  padding: 4px 0 8px;
  margin-bottom: 8px;
}

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}

.field-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.field label {
  font-size: 14px;
  color: var(--text);
}

.hint {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.4;
  font-weight: 400;
}

.field input[type="text"] {
  width: 110px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 10px;
  font-size: 14px;
  text-align: right;
}

.field.toggle label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.field.toggle input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.form-fields label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin: 14px 0 6px;
}

.form-fields input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 15px;
}

.range-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.range-tabs::-webkit-scrollbar { display: none; }

.range-tab {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  text-decoration: none;
  white-space: nowrap;
}

.range-tab.active {
  color: var(--text);
  border-color: var(--accent);
}

.date-range-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin: 14px 0 4px;
}

.date-range-form label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.date-range-form input[type="date"] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  font-family: "IBM Plex Sans", sans-serif;
  color-scheme: dark;
}

.date-range-form button {
  padding: 8px 14px;
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.modal-header h1 { font-size: 18px; margin: 0; font-weight: 600; }
.modal-header .close { color: var(--text-muted); font-size: 22px; cursor: pointer; line-height: 1; padding: 4px; }

.ref-prices {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.ref-prices div { padding: 2px 0; }
.ref-prices .mono { color: var(--text); }

.chart-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }

.direction-toggle {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}
.direction-toggle .dir-btn {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.direction-toggle .dir-btn.active.long { border-color: var(--long); color: var(--long); background: rgba(53,199,135,0.1); }
.direction-toggle .dir-btn.active.short { border-color: var(--short); color: var(--short); background: rgba(229,86,107,0.1); }

.submit-btn {
  width: 100%;
  margin-top: 18px;
  background: var(--accent);
  color: #0B1420;
  border: none;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.row .quick-pos {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  margin-right: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.row .quick-pos:active { border-color: var(--accent); color: var(--accent); }

.row a.row-link {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

/* ===== Профиль: однострочные токены с шестерёнкой (2026-09) ===== */
.btn-secondary {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 9px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.btn-secondary:hover { border-color: var(--text-faint); }

.token-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 13px 4px; flex-wrap: wrap;
}
.token-label { display: flex; align-items: center; gap: 2px; font-size: 14px; color: var(--text); position: relative; min-width: 0; }
.token-value { display: flex; align-items: center; gap: 2px; position: relative; flex-shrink: 0; }

.icon-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; border-radius: var(--radius);
}
.icon-btn.help { width: 32px; height: 32px; }
.icon-btn.help svg { width: 19px; height: 19px; }
.icon-btn.gear { width: 36px; height: 36px; }
.icon-btn.gear svg { width: 21px; height: 21px; }
.icon-btn:hover { color: var(--accent); background: rgba(91, 141, 239, 0.1); }

.popover {
  display: none; position: absolute; top: 38px; z-index: 20;
  background: var(--row); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(0,0,0,0.4);
}
.popover.open { display: block; }
.popover.menu { right: 0; min-width: 150px; padding: 4px; }
.popover.menu button { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text); font-size: 13px; padding: 9px 10px; border-radius: 4px; cursor: pointer; }
.popover.menu button:hover { background: var(--surface); }
.popover.menu button.danger { color: var(--short); }
.popover.info { left: 0; width: 220px; padding: 10px 12px; font-size: 12px; color: var(--text-muted); line-height: 1.4; }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(6,9,14,0.72); align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; max-width: 320px; width: 100%; }
.modal-card h3 { margin: 0 0 6px; font-size: 16px; }
.modal-card p { margin: 0 0 18px; color: var(--text-muted); font-size: 13px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions button { flex: 1; }

/* ===== Монеты: поиск по тикеру с выпадающими подсказками (2026-09) ===== */
.coin-search-wrap { position: relative; margin-top: 8px; }
.coin-search-input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); padding: 12px 14px;
  font-size: 16px; font-family: "IBM Plex Mono", ui-monospace, monospace;
}
.coin-search-input:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.coin-search-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20;
  background: var(--row); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(0,0,0,0.4); overflow: hidden;
}
.coin-search-dropdown.open { display: block; }
.coin-search-dropdown button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  border-bottom: 1px solid var(--border); color: var(--text); font-size: 15px;
  font-family: "IBM Plex Mono", ui-monospace, monospace; padding: 11px 14px; cursor: pointer;
}
.coin-search-dropdown button:last-child { border-bottom: none; }
.coin-search-dropdown button:hover { background: var(--surface); }
.coin-search-empty { padding: 11px 14px; font-size: 13px; color: var(--text-faint); }

/* ===== Сигналы: приглушить монеты, которые уже в позиции (2026-09) =====
   Вариант B: вся строка тускнеет (opacity), включая сам бейдж — тут не
   нужно ничего исключать, в отличие от прошлой попытки с точкой. */
.row.in-pos { opacity: 0.55; }
.row .pos-badge { font-size: 10px; padding: 2px 6px; white-space: nowrap; }

/* ===== Тренд: резюме ярче + streak-статус (2026-09) ===== */
.trend-summary { color: var(--text); font-size: 14px; padding: 12px 4px 6px; }
.streak-note { font-size: 13px; padding: 8px 4px; margin: 0; }
.streak-note.risk-high { color: var(--short); }
.streak-note.risk-medium { color: var(--text-muted); }
.streak-note.risk-low { color: var(--long); }
