:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --panel: #ffffff;
  --ink: #17201c;
  --muted: #66736c;
  --line: #dce2dc;
  --soft: #edf1ec;
  --green: #0f766e;
  --green-soft: #d9f2ed;
  --red: #c24135;
  --red-soft: #fae5e0;
  --amber: #a16207;
  --amber-soft: #f8edc8;
  --blue: #2563eb;
  --shadow: 0 18px 50px rgba(23, 32, 28, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 14px 4px 20px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  align-items: end;
  grid-template-columns: repeat(3, 7px);
  gap: 4px;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand-mark span {
  display: block;
  border-radius: 2px 2px 0 0;
  background: var(--green);
}

.brand-mark span:nth-child(1) {
  height: 14px;
}

.brand-mark span:nth-child(2) {
  height: 22px;
  background: var(--blue);
}

.brand-mark span:nth-child(3) {
  height: 10px;
  background: var(--amber);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.primary-button,
.icon-button {
  height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
}

.primary-button {
  padding: 0 16px;
  background: var(--ink);
  color: white;
}

.primary-button:hover {
  background: #2b3832;
}

.icon-button {
  width: 40px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}

.icon-button:hover {
  border-color: var(--green);
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.control-panel,
.main-panel,
.ranking-board,
.signal-card,
.chart-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.control-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 18px;
  padding: 16px;
}

.panel-section {
  display: grid;
  gap: 12px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pool-tabs {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding-right: 2px;
}

.pool-tab {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  text-align: left;
}

.pool-tab strong {
  font-size: 14px;
}

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

.pool-tab[aria-selected="true"] {
  border-color: var(--green);
  background: var(--green-soft);
}

.rule-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.rule-grid label:last-child {
  grid-column: 1 / -1;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 8px 10px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

.return-editor {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}

.return-row {
  display: grid;
  grid-template-columns: 64px repeat(6, minmax(0, 1fr));
  gap: 6px;
  align-items: center;
}

.return-row strong {
  font-size: 12px;
}

.return-row input {
  min-height: 32px;
  padding: 6px;
  text-align: right;
}

.main-panel {
  padding: 16px;
  display: grid;
  gap: 16px;
  min-width: 0;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.summary-strip article {
  min-height: 72px;
  display: grid;
  gap: 6px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
}

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

.summary-strip strong {
  min-width: 0;
  font-size: clamp(18px, 2.2vw, 25px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.board-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
}

.ranking-board,
.signal-card,
.chart-panel {
  box-shadow: none;
}

.ranking-board,
.chart-panel {
  padding: 14px;
}

.table-wrap {
  margin-top: 12px;
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
}

td {
  font-size: 14px;
}

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

.rank-pill,
.action-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.rank-pill.top {
  background: var(--green-soft);
  color: var(--green);
}

.rank-pill.watch {
  background: var(--amber-soft);
  color: var(--amber);
}

.rank-pill.out {
  background: var(--soft);
  color: var(--muted);
}

.action-buy {
  background: var(--green-soft);
  color: var(--green);
}

.action-hold {
  background: #dfeafb;
  color: var(--blue);
}

.action-watch {
  background: var(--amber-soft);
  color: var(--amber);
}

.action-sell {
  background: var(--red-soft);
  color: var(--red);
}

.signal-rail {
  display: grid;
  gap: 12px;
}

.signal-card {
  padding: 13px;
}

.signal-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.signal-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.signal-item strong {
  font-size: 14px;
}

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

.empty-state {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

.chart-panel {
  display: grid;
  gap: 12px;
}

.momentum-chart {
  display: grid;
  gap: 9px;
}

.chart-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 64px;
  gap: 10px;
  align-items: center;
}

.chart-label {
  font-weight: 800;
  font-size: 13px;
}

.bar-track {
  position: relative;
  height: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: var(--green);
}

.bar-fill.negative {
  background: var(--red);
}

.chart-value {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

@media (max-width: 1100px) {
  .dashboard,
  .board-layout {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }

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

@media (max-width: 680px) {
  .app-shell {
    padding: 14px;
  }

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

  .topbar-actions {
    justify-content: flex-end;
  }

  .summary-strip,
  .rule-grid {
    grid-template-columns: 1fr;
  }

  .return-row {
    grid-template-columns: 56px repeat(3, minmax(0, 1fr));
  }

  .return-row input:nth-of-type(n + 4) {
    grid-column: span 1;
  }

  .chart-row {
    grid-template-columns: 58px minmax(0, 1fr) 54px;
  }
}
