:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #67738a;
  --line: #dce3ee;
  --accent: #0f766e;
  --accent-soft: #e7f5f3;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --shadow: 0 10px 28px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 18px;
  overflow-y: auto;
}

.brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.brand-row h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.brand-row p {
  margin: 6px 0 0;
  color: var(--muted);
}

.status-pill,
.market-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 9px;
  white-space: nowrap;
}

.search-box {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-box input,
.toolbar select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

.search-box input:focus,
.toolbar select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.toolbar {
  display: none;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 6px;
  align-items: center;
}

.pager span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.pager button,
.chart-header button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

.pager button:disabled {
  color: #a8b1c2;
  cursor: not-allowed;
}

.symbol-list {
  display: grid;
  gap: 5px;
}

.symbol-item {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(112px, 0.8fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
}

.symbol-item:hover,
.symbol-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.symbol-code {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  font-weight: 800;
}

.symbol-code span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.symbol-name {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.symbol-quote {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 0;
}

.symbol-quote strong {
  min-width: 70px;
  font-size: 15px;
  line-height: 1.1;
  text-align: right;
}

.symbol-quote em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
}

.symbol-quote em.positive {
  color: var(--success);
}

.symbol-quote em.negative {
  color: var(--danger);
}

.content {
  min-width: 0;
  padding: 28px;
}

.alert {
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff1f2;
  color: #991b1b;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.detail-header h2 {
  margin: 10px 0 6px;
  font-size: 32px;
  line-height: 1.15;
}

.detail-header p {
  margin: 0;
  color: var(--muted);
}

.connection-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  box-shadow: var(--shadow);
}

.connection-card small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #9ca3af;
}

.dot.ok {
  background: var(--success);
}

.dot.warn {
  background: var(--warning);
}

.dot.bad {
  background: var(--danger);
}

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

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

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

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

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

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

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

.chart-panel {
  padding: 18px;
}

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

.chart-header h3,
.raw-panel h3 {
  margin: 0;
  font-size: 18px;
}

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

#klineCanvas {
  display: block;
  width: 100%;
  height: 420px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdff;
}

.raw-panel {
  margin-top: 18px;
  padding: 16px;
}

.raw-panel pre {
  max-height: 220px;
  overflow: auto;
  margin: 12px 0 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdff;
  color: var(--text);
  padding: 14px;
  font-size: 12px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .detail-header,
  .chart-header {
    flex-direction: column;
    align-items: stretch;
  }

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

@media (max-width: 560px) {
  .sidebar,
  .content {
    padding: 18px;
  }

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

  .symbol-item {
    grid-template-columns: minmax(0, 1fr) minmax(106px, 0.8fr);
  }

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

  .detail-header h2 {
    font-size: 26px;
  }

  #klineCanvas {
    height: 340px;
  }
}
