:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #20242a;
  --muted: #68707c;
  --border: #dbe1e8;
  --accent: #1769aa;
  --accent-strong: #0f4f82;
  --gain: #0a7a4b;
  --warn-bg: #fff6db;
  --warn-border: #ecd27b;
  --shadow: 0 14px 36px rgba(31, 42, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

button:hover {
  border-color: #aebdcc;
}

button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.shell {
  width: min(1680px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
  letter-spacing: 0;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.actions button {
  padding: 0 16px;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.metric,
.panel,
.notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 14px 16px;
  min-height: 78px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  font-size: 18px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.notice {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding: 14px 16px;
  background: var(--warn-bg);
  border-color: var(--warn-border);
  box-shadow: none;
}

.hidden {
  display: none !important;
}

.panel {
  overflow: hidden;
  margin-bottom: 14px;
}

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

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

.controls {
  display: grid;
  gap: 10px;
}

.compact-tabs .tab {
  min-width: 70px;
  min-height: 34px;
  font-size: 13px;
}

.tab {
  min-width: 54px;
  padding: 0 12px;
  background: var(--surface-2);
}

.tab.is-active {
  background: #d9ecfb;
  border-color: #8cc3ec;
  color: var(--accent-strong);
}

.baseline {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.message {
  margin: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #eef8f2;
  border: 1px solid #c3e5d0;
  color: #245b3b;
}

.message.error {
  background: #fff1ee;
  border-color: #f2c4bc;
  color: #8a2c1c;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #fafbfc;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

tbody tr:hover {
  background: #fbfcfd;
}

.coin {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 170px;
}

.coin a {
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
}

.coin a:hover {
  color: var(--accent);
}

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

.gain {
  color: var(--gain);
  font-weight: 800;
}

.positive {
  color: var(--gain);
  font-weight: 800;
}

.negative {
  color: #b33424;
  font-weight: 800;
}

.neutral,
.muted-value {
  color: var(--muted);
  font-weight: 700;
}

.setup-panel {
  border-color: #bfe0f6;
}

.setup-table {
  min-width: 980px;
  table-layout: fixed;
}

.setup-table th,
.setup-table td {
  padding: 10px 10px;
  white-space: normal;
  vertical-align: top;
}

.setup-table th:first-child,
.setup-table td:first-child {
  width: 38px;
}

.setup-table th:nth-child(2),
.setup-table td:nth-child(2) {
  width: 78px;
}

.setup-table th:nth-child(3),
.setup-table td:nth-child(3) {
  width: 170px;
}

.setup-table th:nth-child(4),
.setup-table td:nth-child(4) {
  width: 72px;
}

.setup-table th:nth-child(5),
.setup-table td:nth-child(5),
.setup-table th:nth-child(6),
.setup-table td:nth-child(6) {
  width: 120px;
}

.setup-table th:nth-child(7),
.setup-table td:nth-child(7) {
  width: 130px;
}

.setup-table .coin {
  min-width: 0;
}

.setup-table .coin a,
.setup-table .coin span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.setup-table .badges {
  justify-content: flex-start;
}

.setup-table .reasons {
  display: -webkit-box;
  max-width: none;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.direction {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 24px;
  border-radius: 8px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

.direction.long {
  color: #0b5738;
  background: #dff4e8;
}

.direction.short {
  color: #8a2c1c;
  background: #ffe4de;
}

.strategy-table {
  min-width: 0;
  table-layout: fixed;
}

.strategy-table th,
.strategy-table td {
  padding: 10px 8px;
  font-size: 13px;
  line-height: 1.32;
  white-space: normal;
  overflow-wrap: anywhere;
  vertical-align: top;
}

.strategy-table th {
  font-size: 11px;
  line-height: 1.2;
}

.strategy-table td:first-child,
.strategy-table th:first-child {
  width: 38px;
}

.strategy-table td:nth-child(2),
.strategy-table th:nth-child(2) {
  width: 86px;
}

.strategy-table td:nth-child(3),
.strategy-table th:nth-child(3) {
  width: 150px;
}

.strategy-table td:nth-child(4),
.strategy-table th:nth-child(4) {
  width: 62px;
}

.strategy-table .coin {
  min-width: 0;
}

.strategy-table .coin a,
.strategy-table .coin span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.strategy-table .score {
  font-size: 18px;
  line-height: 1.1;
  white-space: nowrap;
}

.strategy-table .signal {
  min-width: 66px;
  white-space: nowrap;
}

.strategy-table .badges {
  justify-content: flex-start;
}

.strategy-table .badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strategy-table .stacked {
  white-space: normal;
}

.long-strategy-table td:nth-child(5),
.long-strategy-table th:nth-child(5) {
  width: 112px;
}

.long-strategy-table td:nth-child(6),
.long-strategy-table th:nth-child(6) {
  width: 122px;
}

.long-strategy-table td:nth-child(7),
.long-strategy-table th:nth-child(7) {
  width: 138px;
}

.long-strategy-table td:nth-child(8),
.long-strategy-table th:nth-child(8),
.long-strategy-table td:nth-child(9),
.long-strategy-table th:nth-child(9) {
  width: 118px;
}

.long-strategy-table td:nth-child(10),
.long-strategy-table th:nth-child(10) {
  width: 110px;
}

.short-strategy-table td:nth-child(5),
.short-strategy-table th:nth-child(5) {
  width: 112px;
}

.short-strategy-table td:nth-child(6),
.short-strategy-table th:nth-child(6) {
  width: 138px;
}

.short-strategy-table td:nth-child(7),
.short-strategy-table th:nth-child(7) {
  width: 112px;
}

.short-strategy-table td:nth-child(8),
.short-strategy-table th:nth-child(8) {
  width: 92px;
}

.short-strategy-table td:nth-child(9),
.short-strategy-table th:nth-child(9),
.short-strategy-table td:nth-child(10),
.short-strategy-table th:nth-child(10) {
  width: 112px;
}

.section-kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.strategy-rules {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfd;
}

.strategy-rules span,
.badge,
.signal {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 8px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 750;
}

.strategy-rules span {
  color: #344254;
  background: #eef2f6;
}

.badges {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.badge {
  color: #16486d;
  background: #e7f4fd;
  border: 1px solid #bfe0f6;
}

.signal {
  min-width: 58px;
  justify-content: center;
}

.signal.setup {
  color: #0b5738;
  background: #dff4e8;
}

.signal.watch {
  color: #7a4b00;
  background: #fff0c8;
}

.signal.weak {
  color: #5e6673;
  background: #edf0f4;
}

.score {
  color: var(--accent-strong);
  font-weight: 850;
}

.reasons {
  max-width: 320px;
  color: #3d4652;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
}

.strategy-table .reasons {
  display: -webkit-box;
  max-width: none;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.stacked {
  color: #344254;
  font-size: 13px;
  line-height: 1.35;
}

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

.compact-empty {
  height: 74px;
  padding-left: 14px !important;
  text-align: left !important;
}

@media (max-width: 780px) {
  .shell {
    width: min(100vw - 20px, 1680px);
    padding-top: 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button {
    flex: 1 1 150px;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .baseline {
    text-align: left;
  }
}

@media (max-width: 1180px) {
  .strategy-panel .table-wrap,
  .setup-panel .table-wrap {
    overflow-x: auto;
  }

  .strategy-table {
    min-width: 1120px;
  }
}

@media (max-width: 460px) {
  .status-grid {
    grid-template-columns: 1fr;
  }

  .notice {
    align-items: flex-start;
    flex-direction: column;
  }
}
