:root {
  color-scheme: light;
  --bg: #f5f5f5;
  --panel: #ffffff;
  --panel-soft: #fafafa;
  --border: #f0f0f0;
  --border-strong: #d9d9d9;
  --text: #000000d9;
  --muted: #00000073;
  --muted-2: #00000040;
  --primary: #1677ff;
  --primary-hover: #4096ff;
  --red: #cf1322;
  --green: #3f8600;
  --orange: #fa8c16;
  --gold: #faad14;
  --blue-soft: #e6f4ff;
  --red-soft: #fff1f0;
  --green-soft: #f6ffed;
  --orange-soft: #fff7e6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5715 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
}

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

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav button,
.toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 4px 15px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.02);
}

.nav button:hover,
.toolbar button:hover {
  color: var(--primary);
  border-color: var(--primary-hover);
}

.nav button.active,
.toolbar button.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.statusbar {
  display: grid;
  grid-template-columns: repeat(7, minmax(128px, 1fr));
  gap: 16px;
  padding: 24px 24px 0;
}

.status-item {
  min-height: 86px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: var(--shadow);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.value {
  display: block;
  margin-top: 8px;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
}

.content {
  padding: 24px;
  overflow: hidden;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar input {
  width: min(360px, 100%);
  height: 40px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 4px 11px;
  outline: none;
}

.toolbar input:focus {
  border-color: var(--primary-hover);
  box-shadow: 0 0 0 2px rgba(5, 145, 255, 0.1);
}

.table-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: auto;
  max-height: calc(100vh - 286px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1180px;
  background: #fff;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fafafa;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

td {
  color: var(--text);
  font-size: 13px;
}

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

tbody tr:hover {
  background: #fafafa;
}

.symbol-link {
  color: var(--primary);
  background: transparent;
  border: 0;
  padding: 0;
  font-weight: 500;
  cursor: pointer;
}

.symbol-link:hover {
  color: var(--primary-hover);
}

.positive {
  color: var(--red);
}

.negative {
  color: var(--green);
}

.muted {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 12px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  background: #fafafa;
}

.pill.triggered {
  color: var(--red);
  border-color: #ffa39e;
  background: var(--red-soft);
}

.pill.cooldown {
  color: var(--orange);
  border-color: #ffd591;
  background: var(--orange-soft);
}

.pill.watching {
  color: #ad6800;
  border-color: #ffe58f;
  background: #fffbe6;
}

.pill.market_filtered {
  color: var(--primary);
  border-color: #91caff;
  background: var(--blue-soft);
}

.detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(128px, 1fr));
  gap: 16px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.chart-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px 18px;
  min-height: 268px;
  box-shadow: var(--shadow);
}

.chart-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
  margin-bottom: 12px;
  font-size: 14px;
}

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

svg {
  display: block;
  width: 100%;
  height: 205px;
}

.empty {
  color: var(--muted);
  padding: 36px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

@media (max-width: 1180px) {
  .statusbar,
  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 10px 12px;
  }

  .brand {
    flex-direction: column;
    gap: 4px;
  }

  .brand h1 {
    font-size: 20px;
  }

  .statusbar,
  .summary-grid,
  .chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .statusbar {
    padding: 12px 12px 0;
  }

  .content {
    padding: 12px;
  }

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

  .table-wrap {
    max-height: calc(100vh - 280px);
  }
}
