:root {
  --bg1: #dfe8e4;
  --bg2: #eef3f0;
  --ink: #152028;
  --muted: #5d6f7a;
  --accent: #0d6b55;
  --accent-soft: #d7efe7;
  --accent-hover: #0a5644;
  --surface: rgba(255, 255, 255, 0.78);
  --line: #c5d2cb;
  --danger: #9b2c2c;
  --short: #b42318;
  --short-bg: #fde8e6;
  --long: #027a48;
  --long-bg: #e4f7ed;
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --font-display: "Outfit", "Source Sans 3", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 8% -8%, #c5ddd2 0%, transparent 55%),
    radial-gradient(900px 480px at 100% 0%, #c8d6e2 0%, transparent 48%),
    linear-gradient(165deg, var(--bg1), var(--bg2));
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--accent);
}

.hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

h1 {
  margin: 0.4rem 0 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 650;
}

h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 650;
}

/* --- Вход --- */
.page-login {
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-shell {
  width: min(100%, 380px);
  padding: 2rem 1.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px rgba(21, 32, 40, 0.06);
}

.login-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.login-form label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.login-form input {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: var(--ink);
}

.login-form button {
  margin-top: 0.35rem;
  padding: 0.85rem 1rem;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.login-form button:hover {
  background: var(--accent-hover);
}

.error {
  margin: 1rem 0 0;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: #fde8e8;
  color: var(--danger);
  font-size: 0.92rem;
}

/* --- Сигналы --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(197, 210, 203, 0.85);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left {
  display: grid;
  gap: 0.15rem;
}

.topbar-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.who {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.btn-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: var(--accent-soft);
}

.btn-link:hover {
  background: #c6e8dc;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem 0;
  max-width: 1100px;
  margin: 0 auto;
}

.exchange-nav {
  display: flex;
  gap: 0.4rem;
  padding: 0.85rem 1.5rem 0;
  max-width: 1100px;
  margin: 0 auto;
}

.exchange-tab {
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-family: var(--font-display);
  padding: 0.45rem 1.1rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
}

.exchange-tab:hover {
  color: var(--accent);
}

.exchange-tab.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.nav-link {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid transparent;
}

.nav-link:hover {
  color: var(--accent);
}

.nav-link.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(13, 107, 85, 0.15);
}

.paper-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.stat {
  padding: 1rem 1.05rem;
  border: 1px solid rgba(197, 210, 203, 0.95);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  display: grid;
  gap: 0.35rem;
}

.stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 650;
}

.down {
  color: var(--short);
  font-weight: 600;
}

.content {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.content-wide {
  max-width: 980px;
  display: grid;
  gap: 1.75rem;
}

.content-stats {
  max-width: 1200px;
}

/* --- Страница статистики --- */
.page-stats .exchange-nav {
  max-width: 1280px;
}

.stats-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 1.25rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
  align-items: start;
}

.stats-sidebar {
  position: sticky;
  top: 0.75rem;
  display: grid;
  gap: 0.35rem;
  max-height: calc(100vh - 1.5rem);
  overflow: auto;
  padding: 0.15rem;
}

.stats-ex-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.3rem;
  margin-bottom: 0.45rem;
}

.stats-ex-switch a {
  text-align: center;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.4rem 0.2rem;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
}

.stats-ex-switch a.is-on {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.stats-side-group {
  margin: 0.65rem 0 0.15rem;
  padding: 0 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats-side-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 0.5rem;
  row-gap: 0.1rem;
  align-items: center;
  text-decoration: none;
  color: inherit;
  padding: 0.55rem 0.65rem;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid transparent;
}

.stats-side-item:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--line);
}

.stats-side-item.is-on {
  background: #fff;
  border-color: rgba(13, 107, 85, 0.35);
  box-shadow: 0 6px 18px rgba(21, 32, 40, 0.05);
}

.ssi-name {
  grid-column: 1;
  grid-row: 1;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink);
}

.ssi-meta {
  grid-column: 1;
  grid-row: 2;
  font-size: 0.75rem;
  color: var(--muted);
}

.ssi-pnl {
  grid-column: 2;
  grid-row: 1 / span 2;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
}

.stats-main {
  display: grid;
  gap: 1.1rem;
  min-width: 0;
}

.stats-hero {
  display: grid;
  gap: 1rem;
  padding: 1.15rem 1.25rem 1.2rem;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(197, 210, 203, 0.95);
  border-radius: 18px;
}

.stats-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.stats-kicker {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
}

.stats-title {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
}

.stats-hero-nums {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.stats-big {
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  background: rgba(239, 246, 242, 0.9);
  border: 1px solid rgba(197, 210, 203, 0.7);
}

.stats-big-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats-big-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
}

.stats-big-sub {
  font-size: 0.82rem;
  color: var(--muted);
}

.stats-meta-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.65rem 1rem;
  margin: 0;
  padding-top: 0.15rem;
  border-top: 1px solid rgba(197, 210, 203, 0.75);
}

.stats-meta-row > div {
  display: grid;
  gap: 0.15rem;
}

.stats-meta-row dt {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats-meta-row dd {
  margin: 0;
  font-weight: 650;
  font-size: 0.95rem;
}

.stats-panel {
  display: grid;
  gap: 0.75rem;
  padding: 1.05rem 1.2rem 1.15rem;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(197, 210, 203, 0.95);
  border-radius: 18px;
}

.stats-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.stats-panel-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.stats-search {
  margin-left: auto;
  width: min(220px, 100%);
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: 0.9rem;
}

.stats-chart-wrap {
  height: 280px;
  padding: 0.35rem 0.25rem 0.1rem;
}

.stats-days-details {
  font-size: 0.92rem;
  color: var(--muted);
}

.stats-days-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  user-select: none;
}

.stats-days-details[open] summary {
  margin-bottom: 0.55rem;
}

.stats-coins th {
  cursor: pointer;
  white-space: nowrap;
}

.coin-ls {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  margin-top: 0.1rem;
}

.stats-coins tr.is-disabled td {
  opacity: 0.55;
}

.coin-toggle-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
}

.coin-toggle-btn.is-on {
  color: var(--short);
  border-color: rgba(180, 35, 24, 0.35);
  background: var(--short-bg);
}

.coin-toggle-btn.is-off {
  color: var(--long);
  border-color: rgba(2, 122, 72, 0.35);
  background: var(--long-bg);
}

.coin-toggle-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

@media (max-width: 900px) {
  .stats-layout {
    grid-template-columns: 1fr;
  }

  .stats-sidebar {
    position: static;
    max-height: none;
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-auto-columns: minmax(160px, 200px);
    overflow-x: auto;
    padding-bottom: 0.35rem;
  }

  .stats-ex-switch {
    grid-column: 1 / -1;
    min-width: 220px;
  }

  .stats-side-group {
    display: none;
  }

  .stats-hero-nums {
    grid-template-columns: 1fr;
  }
}

.signal-section {
  display: grid;
  gap: 0.85rem;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
}

.empty-box {
  padding: 1.2rem 1.25rem;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
  color: var(--muted);
}

.signals-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(197, 210, 203, 0.95);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 28px rgba(21, 32, 40, 0.05);
}

.signals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.signals-table th,
.signals-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid #e4ebe7;
  white-space: nowrap;
  vertical-align: middle;
}

.signals-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  background: rgba(247, 250, 248, 0.95);
}

.signals-table tbody tr:hover {
  background: rgba(13, 107, 85, 0.035);
}

.signals-table tr:last-child td {
  border-bottom: 0;
}

.coin-cell {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.coin-icon-wrap {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  background: #eef3f0;
  overflow: hidden;
}

.coin-icon {
  width: 28px;
  height: 28px;
  display: block;
}

.coin-icon-wrap.fallback::before {
  content: attr(data-letter);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-short {
  color: var(--short);
  background: var(--short-bg);
}

.badge-long {
  color: var(--long);
  background: var(--long-bg);
}

.up {
  color: var(--long);
  font-weight: 600;
}

.muted-cell {
  color: var(--muted);
  font-size: 0.88rem;
}

.paper-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.pager-btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.pager-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.pager-btn.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.pager-info {
  color: var(--muted);
  font-size: 0.9rem;
}

.paper-chart-wrap {
  margin-top: 0.35rem;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: none;
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
}

.chart-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--ink);
}

.chart-close-btn {
  border: 1px solid var(--line);
  background: rgba(239, 246, 242, 0.9);
  color: var(--ink);
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.chart-close-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chart-status {
  margin: 0 0 0.75rem;
}

.paper-chart {
  width: 100%;
  min-height: 360px;
}

.chart-hint {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
}

.page-paper .exchange-nav {
  max-width: 1280px;
}

.paper-side-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  min-width: 140px;
}

.paper-side-switch a {
  text-align: center;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(239, 246, 242, 0.9);
  border: 1px solid var(--line);
}

.paper-side-switch a.is-on {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.paper-rules-short {
  font-weight: 500 !important;
  font-size: 0.85rem !important;
  color: var(--muted);
  line-height: 1.35;
}

.chart-panel .paper-chart-wrap {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 0;
}

.chart-panel .paper-chart-wrap[hidden] {
  display: none !important;
}

.pager-btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid var(--line);
}

.pager-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pager-btn.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.paper-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

.pager-info {
  color: var(--muted);
  font-size: 0.9rem;
}

.grid-tab {
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.grid-tab:hover {
  background: rgba(255, 255, 255, 0.1);
}

.grid-tab.is-active {
  background: rgba(91, 156, 255, 0.18);
  border-color: rgba(91, 156, 255, 0.45);
  color: #9ec5ff;
}

.grid-mode-section {
  scroll-margin-top: 5rem;
}

.chart-symbol-btn {
  border: none;
  background: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.chart-symbol-btn:hover strong {
  color: #5b9cff;
  text-decoration: underline;
}

.stats-table th.sort-asc::after {
  content: " ↑";
  color: var(--accent);
}

.stats-table th.sort-desc::after {
  content: " ↓";
  color: var(--accent);
}

.muted {
  color: var(--muted);
  font-weight: 500;
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .signals-table th,
  .signals-table td {
    padding: 0.7rem 0.75rem;
  }
}
