:root {
  --primary: #fcd535;
  --primary-active: #f0b90b;
  --canvas: #0b0e11;
  --surface: #1e2329;
  --surface-soft: #2b3139;
  --line: #2b3139;
  --line-strong: #3b424d;
  --ink: #f5f5f5;
  --body: #eaecef;
  --muted: #707a8a;
  --muted-strong: #929aa5;
  --green: #0ecb81;
  --red: #f6465d;
  --yellow-soft: #3a3316;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--body);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 58px;
  padding: 0 clamp(14px, 3vw, 28px);
  background: rgba(11, 14, 17, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--primary);
  font-weight: 750;
}

.brand-mark {
  width: 20px;
  height: 20px;
  background:
    linear-gradient(45deg, transparent 30%, var(--primary) 30% 70%, transparent 70%),
    linear-gradient(-45deg, transparent 30%, var(--primary) 30% 70%, transparent 70%);
  transform: rotate(45deg);
}

.nav-links {
  display: flex;
  gap: 6px;
  margin-left: auto;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 600;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 7px;
}

.nav-links a:hover {
  color: var(--ink);
  background: var(--surface);
}

.nav-links a.is-active {
  color: #181a20;
  background: var(--primary);
  border-color: var(--primary);
}

.nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--body);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.icon-button svg,
.search-field svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 15%, rgba(252, 213, 53, 0.14), transparent 28%),
    linear-gradient(135deg, #0b0e11 0%, #151a21 55%, #0b0e11 100%);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 30px;
  background: rgba(30, 35, 41, 0.94);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

.login-brand {
  margin-bottom: 30px;
}

.login-copy {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.login-copy h1 {
  margin: 0;
  color: var(--ink);
  font-size: 28px;
  line-height: 1.15;
}

.login-copy p {
  margin: 0;
  color: var(--muted-strong);
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--body);
  background: var(--canvas);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: none;
}

.login-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(252, 213, 53, 0.12);
}

.login-submit {
  height: 44px;
  color: #181a20;
  font-weight: 800;
  background: var(--primary);
  border: 0;
  border-radius: 7px;
}

.login-submit:disabled {
  cursor: progress;
  opacity: 0.72;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.page-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 2vw, 24px) 56px;
}

.market-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.market-strip a {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.market-strip span {
  color: var(--muted);
  font-size: 12px;
}

.market-strip strong {
  color: var(--ink);
  font-family: "IBM Plex Mono", "JetBrains Mono", Consolas, monospace;
  font-size: 15px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.market-strip em {
  font-style: normal;
  font-family: "IBM Plex Mono", "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
}

.btc-ai-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.btc-ai-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.btc-ai-header h2 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.2;
}

.btc-ai-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.btc-ai-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-shrink: 0;
}

.btc-ai-model {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.btc-ai-model input {
  width: 150px;
  height: 34px;
  padding: 0 10px;
  color: var(--body);
  background: var(--canvas);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: none;
}

.btc-ai-model input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(252, 213, 53, 0.12);
}

.btc-ai-run:disabled {
  cursor: progress;
  opacity: 0.68;
}

.btc-ai-toggle {
  min-width: 58px;
}

.btc-ai-grid[hidden] {
  display: none;
}

.btc-ai-status {
  min-height: 28px;
  padding: 7px 10px;
  color: var(--muted-strong);
  font-size: 13px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.btc-ai-status.is-loading {
  color: var(--primary);
}

.btc-ai-status.is-error {
  color: var(--red);
}

.btc-ai-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 12px;
}

.btc-ai-column {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
}

.btc-ai-column-title,
.btc-ai-rank-head,
.btc-ai-rank-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.btc-ai-column-title span {
  color: var(--ink);
  font-weight: 750;
}

.btc-ai-column-title strong {
  color: var(--muted);
  font-family: "IBM Plex Mono", "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
}

.btc-ai-ranking {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 94px;
}

.btc-ai-rank-item {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 10px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.btc-ai-rank-head strong {
  min-width: 0;
  color: var(--ink);
  font-family: "IBM Plex Mono", "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.btc-ai-rank-head span,
.btc-ai-rank-meta span {
  color: var(--primary);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.btc-ai-rank-item p {
  margin: 0;
  color: var(--muted-strong);
  font-size: 13px;
  line-height: 1.5;
}

.btc-ai-levels,
.btc-ai-raw {
  color: var(--muted);
  font-family: "IBM Plex Mono", "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.btc-ai-empty {
  display: grid;
  align-self: start;
  min-height: 88px;
  place-items: center;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  background: var(--canvas);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
}

.btc-ai-empty.is-error {
  color: var(--red);
}

.btc-ai-text-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.btc-ai-text-grid div {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 10px;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.btc-ai-text-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.btc-ai-text-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  padding: 0;
  background: transparent;
  border: 0;
}

.btc-ai-text-time {
  color: var(--primary);
  font-family: "IBM Plex Mono", "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.btc-ai-text-grid p {
  margin: 0;
  color: var(--body);
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px 14px;
}

h1,
p {
  margin: 0;
}

h1 {
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
}

.page-title-row p {
  max-width: 760px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted-strong);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--muted);
  border-radius: 50%;
}

.status-dot.live {
  background: var(--green);
}

.status-dot.sample {
  background: var(--primary-active);
}

.status-dot.error {
  background: var(--red);
}

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

.range-control {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.range-button {
  height: 32px;
  padding: 0 14px;
  color: var(--muted-strong);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
}

.range-button:hover {
  background: var(--surface-soft);
}

.range-button.is-active {
  color: #181a20;
  background: var(--primary);
  border-color: var(--primary);
}

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

.favorite-filter,
.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 10px;
  color: var(--muted-strong);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  white-space: nowrap;
  font-size: 13px;
}

.favorite-filter input,
.toggle-chip input {
  width: 14px;
  height: 14px;
  accent-color: var(--primary-active);
}

.alert-settings {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: #171b21;
}

.alert-switches,
.mail-settings {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mail-settings {
  flex: 1;
  justify-content: flex-end;
}

.mail-input {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  color: var(--muted);
  background: #0f141a;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 12px;
}

.mail-input:focus-within {
  border-color: var(--primary-active);
  box-shadow: 0 0 0 2px rgba(252, 213, 53, 0.14);
}

.mail-input span {
  white-space: nowrap;
}

.mail-input input {
  width: 150px;
  min-width: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
}

.mail-input input::placeholder {
  color: var(--muted);
}

.mini-button {
  height: 32px;
  padding: 0 12px;
  color: var(--body);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
}

.mini-button:hover {
  color: var(--primary);
  border-color: var(--line-strong);
}

.search-field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: 220px;
  height: 32px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.search-field input {
  width: 100%;
  min-width: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.table-scroll {
  overflow-x: auto;
}

.pain-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
}

.pain-table th,
.pain-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
}

.pain-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12.5px;
  font-weight: 650;
}

.pain-table tbody tr:hover {
  background: #252b33;
}

.pain-table th:nth-child(3),
.pain-table td:nth-child(3),
.pain-table th:nth-child(6),
.pain-table td:nth-child(6),
.pain-table th:nth-child(8),
.pain-table td:nth-child(8) {
  text-align: left;
}

.star-col {
  width: 42px;
  text-align: center !important;
}

.star-button {
  width: 26px;
  height: 26px;
  padding: 0;
  color: #b8c0cc;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
}

.star-button.is-active {
  color: var(--primary-active);
}

.rank-cell,
.number-cell,
.pain-price,
.pain-amount,
.distance-cell {
  font-family: "IBM Plex Mono", "JetBrains Mono", Consolas, monospace;
}

.rank-cell {
  color: var(--muted);
  font-size: 13.5px;
}

.symbol-cell a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

.coin-logo {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.coin-logo.fallback {
  display: inline-grid;
  place-items: center;
  color: var(--ink);
  background: var(--yellow-soft);
  border: 1px solid #f5d66b;
  font-size: 12px;
}

.number-cell {
  color: var(--ink);
  font-size: 15px;
  font-weight: 760;
  letter-spacing: 0;
}

.pain-block {
  display: grid;
  gap: 10px;
  min-width: 220px;
}

.pain-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
}

.pain-price {
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 760;
  letter-spacing: 0;
}

.pain-amount {
  min-width: 76px;
  color: var(--body);
  font-size: 14px;
  font-weight: 740;
  letter-spacing: 0;
  text-align: right;
}

.pain-meter {
  position: relative;
  height: 8px;
  overflow: visible;
  background: #353c45;
  border-radius: 999px;
}

.pain-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
}

.pain-meter.short .pain-fill {
  background: var(--green);
}

.pain-meter.long .pain-fill {
  background: var(--red);
}

.pain-bomb {
  position: absolute;
  top: -15px;
  transform: translateX(-50%);
  font-size: 17px;
  line-height: 1;
}

.distance-cell {
  display: grid;
  gap: 3px;
  justify-items: end;
  font-size: 14px;
  font-weight: 720;
}

.distance-cell strong {
  font-size: 12.5px;
  font-weight: 720;
}

.up,
.distance-cell.up,
.distance-cell.up strong {
  color: var(--green);
}

.down,
.distance-cell.down,
.distance-cell.down strong {
  color: var(--red);
}

.empty-cell {
  height: 160px;
  color: var(--muted);
  text-align: center !important;
}

.table-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  color: var(--muted);
  font-size: 12px;
}

.table-footer strong {
  color: var(--muted-strong);
  font-weight: 600;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(14px, 3vw, 28px);
  color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.alert-cell {
  min-width: 250px;
}

.alert-control {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.alert-condition,
.alert-reset-button {
  height: 36px;
  color: var(--body);
  background: #0f141a;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.alert-condition {
  width: 48px;
  padding: 0 8px;
  font-size: 15px;
  font-weight: 760;
}

.alert-reset-button {
  min-width: 52px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.alert-reset-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.alert-triggered-badge {
  color: var(--primary-active);
  font-size: 12px;
  font-weight: 750;
}

.alert-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 148px;
  height: 36px;
  padding: 0 9px;
  color: var(--muted);
  background: #0f141a;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.alert-control.is-triggered .alert-input-wrap,
.alert-control.is-triggered .alert-condition {
  border-color: rgba(252, 213, 53, 0.56);
}

.alert-input-wrap:focus-within {
  border-color: var(--primary-active);
  box-shadow: 0 0 0 2px rgba(252, 213, 53, 0.16);
}

.alert-input {
  width: 100%;
  min-width: 0;
  padding: 0;
  color: var(--body);
  background: transparent;
  border: 0;
  outline: 0;
  font-family: "IBM Plex Mono", "JetBrains Mono", Consolas, monospace;
  font-size: 14px;
  font-weight: 650;
}

.alert-input::placeholder {
  color: var(--muted);
}

.live-price {
  transition: color 160ms ease, background-color 160ms ease;
}

.live-price.up {
  color: var(--green);
}

.live-price.down {
  color: var(--red);
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  gap: 10px;
  width: min(340px, calc(100vw - 28px));
}

.toast {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  color: var(--body);
  background: var(--surface);
  border: 1px solid var(--primary-active);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

.toast strong {
  color: var(--primary);
  font-size: 14px;
}

.toast span {
  color: var(--muted-strong);
  font-size: 13px;
}

@media (max-width: 920px) {
  .market-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-title-row,
  .toolbar,
  .btc-ai-header,
  .alert-settings {
    flex-direction: column;
    align-items: stretch;
  }

  .btc-ai-actions {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .btc-ai-grid,
  .btc-ai-text-grid {
    grid-template-columns: 1fr;
  }

  .toolbar-actions,
  .alert-switches,
  .mail-settings {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .search-field {
    width: min(260px, 100%);
  }

  .mail-settings {
    justify-content: flex-start;
  }

  .btc-ai-model input {
    width: min(220px, 100%);
  }
}

@media (max-width: 640px) {
  .nav-links {
    display: none;
  }

  .market-strip {
    grid-template-columns: 1fr;
  }

  .page-shell {
    padding-inline: 10px;
  }

  .page-title-row,
  .toolbar,
  .btc-ai-panel,
  .alert-settings {
    padding-inline: 14px;
  }

  .range-control {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .range-button {
    padding: 0 8px;
  }

  .toolbar-actions,
  .btc-ai-actions,
  .alert-switches,
  .mail-settings,
  .footer,
  .table-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .btc-ai-model input {
    width: 100%;
  }

  .mail-input {
    width: 100%;
  }

  .mail-input input {
    width: 100%;
  }
}
