:root {
  color-scheme: light;
  --bg: #f5f5f2;
  --panel: #ffffff;
  --ink: #1f2421;
  --muted: #68706a;
  --line: #dadcd3;
  --green: #167a4a;
  --red: #b13a2d;
  --amber: #a76512;
  --teal: #22736d;
  --shadow: 0 12px 30px rgba(31, 36, 33, 0.08);
}

* {
  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",
    "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
}

.button-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  text-decoration: none;
  font-size: 14px;
}

button:hover {
  border-color: var(--teal);
}

.button-link:hover {
  border-color: var(--teal);
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: 12px;
  font-weight: 700;
}

.sort-button:hover,
.sort-button.active {
  color: var(--teal);
}

.sort-mark {
  display: inline-block;
  width: 10px;
  color: var(--teal);
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

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

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

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

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

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

.metric {
  min-height: 116px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.metric span,
.metric em,
.panel-head span {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.metric strong {
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0;
}

.grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-wide {
  grid-column: span 3;
}

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

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

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

.wide-table {
  min-width: 1320px;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid #ecede8;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

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

tbody tr:hover {
  background: #fafaf7;
}

.mono {
  font-variant-numeric: tabular-nums;
}

.symbol-link {
  color: var(--ink);
  text-decoration: none;
}

.symbol-link:hover {
  color: var(--teal);
  text-decoration: underline;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tag.entry {
  background: #e6f4ed;
  color: var(--green);
}

.tag.armed {
  background: #fff2d8;
  color: var(--amber);
}

.tag.watch {
  background: #edf0ea;
  color: var(--muted);
}

.pnl-pos {
  color: var(--green);
  font-weight: 700;
}

.pnl-neg {
  color: var(--red);
  font-weight: 700;
}

.bars {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: 76px 1fr 44px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  background: #ecede8;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--teal);
}

.compact .bar-row {
  grid-template-columns: 86px 1fr 34px;
}

.signal-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.signal {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(120px, 0.6fr) 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid #ecede8;
  border-radius: 8px;
}

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

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

.reason {
  max-width: 720px;
  color: var(--muted);
  line-height: 1.45;
  word-break: break-word;
}

.empty {
  padding: 20px 16px;
  color: var(--muted);
  font-size: 13px;
}

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

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

  .panel-wide {
    grid-column: span 1;
  }

  .signal {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1440px);
    padding-top: 12px;
  }

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

  .metrics {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 94px;
  }
}
