:root {
  font-family: 'Noto Sans TC', system-ui, sans-serif;
  background-color: #0a0f1d;
  color: #f4f6fb;
}

body {
  margin: 0;
  background: linear-gradient(135deg, #0c1027, #0d2732 60%, #162b46);
}

.app-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 3rem 1.25rem 4rem;
}

header h1 {
  margin: 0;
  font-size: 2rem;
}

header p {
  margin: 0.25rem 0 1.5rem;
  color: #b3c0d4;
}

.panel {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}

button {
  padding: 0.45rem 1rem;
  border: 0;
  border-radius: 0.45rem;
  cursor: pointer;
  font-weight: 600;
  background: linear-gradient(135deg, #38b6ff, #7d5cff);
  color: #fff;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.controls button {
  margin-right: 0.5rem;
}

#statusBar {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  color: #d5e0ff;
  line-height: 1.6;
}

#pipelineResult,
#futuresProductsResult,
#streamContainer {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.4rem;
  background: rgba(0, 0, 0, 0.2);
  color: #c8d5ee;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.hint {
  color: #b3c0d4;
  line-height: 1.5;
}

#futuresProductsResult {
  margin-top: 0.75rem;
  overflow-x: auto;
}

#streamContainer {
  min-height: 3rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}

.safety-state {
  font-weight: 700;
}

.safety-state.active {
  color: #9eff6b;
}

.safety-state.paused,
.error {
  color: #ff8b8b;
}

.row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
}

label {
  font-size: 0.9rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

select,
input {
  padding: 0.4rem 0.6rem;
  border-radius: 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th,
td {
  padding: 0.55rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
  vertical-align: top;
  white-space: pre-wrap;
}

th {
  color: #8cf1b4;
}

.chart-panel {
  position: relative;
  overflow: hidden;
  border-color: rgba(56, 182, 255, 0.24);
  background:
    linear-gradient(140deg, rgba(24, 49, 85, 0.72), rgba(9, 19, 35, 0.82)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 32px);
}

.chart-heading-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.chart-heading-row h2 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0.04em;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: #70c9ff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.chart-controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chart-controls label {
  color: #b3c0d4;
  white-space: nowrap;
}

.chart-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 0.8rem;
  color: #c8d5ee;
}

.chart-meta p {
  margin: 0;
}

#candleStatus {
  color: #e4edff;
  font-size: 0.9rem;
  font-weight: 650;
}

#candleCoverage {
  color: #8fa4c2;
  font-size: 0.78rem;
  text-align: right;
}

.candle-chart {
  min-width: 0;
  min-height: 320px;
  position: relative;
  border: 1px solid rgba(164, 190, 222, 0.14);
  border-radius: 0.55rem;
  background: rgba(4, 11, 24, 0.56);
  overflow: hidden;
}

.chart-navigation {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 0.7rem;
  color: #8fa4c2;
  font-size: 0.78rem;
}

.chart-navigation button {
  padding: 0.35rem 0.7rem;
  background: rgba(56, 182, 255, 0.16);
  border: 1px solid rgba(112, 201, 255, 0.25);
}

.candle-chart-surface {
  touch-action: none;
  cursor: grab;
}

.candle-chart-surface.is-dragging {
  cursor: grabbing;
}

.candle-chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.candle-crosshair {
  stroke: #a4c3d3;
  stroke-width: 1;
  stroke-dasharray: 4 4;
  pointer-events: none;
}

.macd-zero-line {
  stroke: rgba(177, 194, 218, 0.5);
}

.candle-grid-line {
  stroke: rgba(177, 194, 218, 0.17);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.candle-axis-label,
.candle-axis-title {
  fill: #91a6c5;
  font-family: 'Noto Sans TC', system-ui, sans-serif;
  font-size: 12px;
}

.candle-axis-title {
  fill: #b9c9e3;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.candle-wick {
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.candle-wick.up,
.candle-body.up {
  stroke: #ff6f67;
  fill: #ff6f67;
}

.candle-wick.down,
.candle-body.down {
  stroke: #40d296;
  fill: #40d296;
}

.candle-wick.doji,
.candle-body.doji {
  stroke: #f2c66d;
  fill: #f2c66d;
}

.candle-body {
  cursor: crosshair;
  stroke-width: 1;
  outline: none;
  transition: filter 120ms ease, stroke-width 120ms ease;
}

.candle-body:hover,
.candle-body:focus-visible {
  filter: brightness(1.28);
  stroke: #fff4c7;
  stroke-width: 2;
}

.candle-empty {
  min-height: 320px;
  display: grid;
  place-items: center;
  padding: 1rem;
  color: #9eb0ca;
  font-size: 0.92rem;
  text-align: center;
}

.candle-summary {
  display: grid;
  grid-template-columns: auto repeat(5, minmax(0, 1fr));
  gap: 0.5rem 0.8rem;
  align-items: baseline;
  padding: 0.68rem 0.8rem;
  border-top: 1px solid rgba(164, 190, 222, 0.13);
  background: rgba(2, 8, 18, 0.58);
  color: #dce7fa;
  font-size: 0.78rem;
}

.candle-summary-label {
  color: #88a2c6;
  font-weight: 650;
}

.candle-summary-value {
  min-width: 0;
  color: #f2f6ff;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.candle-summary-hint {
  grid-column: 1 / -1;
  margin: 0;
  color: #8497b7;
  font-size: 0.72rem;
}

.candle-summary-indicators {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  font-variant-numeric: tabular-nums;
  color: #b9c9e3;
}

@media (max-width: 620px) {
  .chart-heading-row,
  .chart-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .chart-controls {
    justify-content: flex-start;
  }

  #candleCoverage {
    text-align: left;
  }

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

  .candle-summary-label {
    grid-column: 1 / -1;
  }

  .candle-summary-hint {
    grid-column: 1 / -1;
  }
}

@media (max-width: 420px) {
  .chart-panel {
    padding: 0.9rem;
  }

  .chart-controls {
    width: 100%;
  }

  .chart-controls label {
    flex: 1 1 9rem;
  }

  .chart-controls select {
    min-width: 0;
    width: 100%;
  }

  .chart-navigation {
    flex-wrap: wrap;
  }

}
