:root {
  color-scheme: dark;
  --bg: #050812;
  --panel: #09101d;
  --panel-2: #0d1726;
  --line: #263d63;
  --line-strong: #3d6da6;
  --text: #edf5ff;
  --muted: #a4b4c8;
  --red: #ff525f;
  --green: #3bd572;
  --yellow: #f2d36b;
  --cyan: #46d9ef;
  --purple: #a86dff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(70, 217, 239, 0.14), transparent 26rem),
    linear-gradient(180deg, #040711 0%, #08111f 100%);
  color: var(--text);
  font-family: "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
}

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

.selector-panel {
  margin-bottom: 8px;
  padding: 10px 12px;
}

.selector-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.selector-label {
  color: #9ee8ff;
  font-weight: 900;
  white-space: nowrap;
}

.stock-input,
.date-input {
  width: min(240px, 100%);
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #050812;
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  font-weight: 800;
  outline: none;
}

.date-input {
  width: 158px;
  color-scheme: dark;
}

.stock-input:focus,
.date-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(70, 217, 239, 0.15);
}

.load-button,
.quick-stocks button {
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: linear-gradient(180deg, #123459, #0a1a2f);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.load-button {
  padding: 0 18px;
}

.load-button.secondary {
  background: linear-gradient(180deg, #17243a, #0a121f);
  color: #b9d4ed;
}

.load-button:disabled,
.stock-input:disabled,
.date-input:disabled {
  cursor: wait;
  opacity: 0.62;
}

.quick-stocks {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.period-selector {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 38px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: rgba(5, 8, 18, 0.72);
}

.period-selector button {
  min-width: 54px;
  height: 30px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.period-selector button.active {
  background: linear-gradient(180deg, #1d6a86, #0b2f45);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(158, 232, 255, 0.4);
}

.quick-stocks button {
  padding: 0 10px;
  color: #d8efff;
}

.source-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.source-status.error {
  color: var(--red);
  font-weight: 800;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(560px, 1.35fr) minmax(300px, 0.6fr) minmax(320px, 0.7fr);
  gap: 8px;
}

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

.top-strip {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) repeat(5, minmax(120px, auto));
  gap: 8px;
  margin-bottom: 8px;
}

.panel,
.metric {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(13, 23, 38, 0.98), rgba(5, 8, 18, 0.98));
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(68, 124, 185, 0.16), 0 0 16px rgba(21, 81, 145, 0.14);
  overflow: hidden;
}

.metric {
  min-height: 54px;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.ticker-card {
  justify-content: flex-start;
}

.ticker-name {
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  font-weight: 800;
  white-space: nowrap;
}

.ticker-code {
  color: var(--muted);
  font-size: 0.95rem;
  margin-left: 4px;
}

.price {
  color: var(--red);
  font-size: clamp(1.7rem, 3vw, 2.45rem);
  font-weight: 800;
  margin-left: 16px;
}

.change {
  color: var(--red);
  font-weight: 700;
  white-space: nowrap;
}

.metric-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.metric-value {
  font-size: 1.05rem;
  font-weight: 800;
  white-space: nowrap;
}

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

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

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

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

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

.panel-title {
  min-height: 28px;
  padding: 4px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(11, 42, 74, 0.92), rgba(8, 18, 32, 0.94));
  color: #9ee8ff;
  font-weight: 800;
  letter-spacing: 0;
}

.panel-body {
  padding: 10px 12px;
}

.chart-panel {
  min-height: 360px;
}

.chart-wrap {
  position: relative;
  height: 320px;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-tags {
  position: absolute;
  inset: 10px 12px auto auto;
  display: grid;
  gap: 88px;
  pointer-events: none;
}

.zone-tag {
  padding: 3px 10px;
  border-radius: 3px;
  background: rgba(5, 8, 18, 0.72);
  border: 1px solid currentColor;
  font-weight: 800;
}

.subcharts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.mini-chart {
  height: 120px;
}

.mini-title {
  color: #fff;
  font-weight: 800;
  margin-bottom: 4px;
}

.mini-caption {
  position: absolute;
  right: 14px;
  top: 44px;
  width: 90px;
  color: #fff;
  font-size: 1.2rem;
  line-height: 1.35;
  font-weight: 800;
}

.mini-panel {
  position: relative;
}

.stack {
  display: grid;
  gap: 8px;
}

.fact-list,
.levels,
.strategy {
  display: grid;
  gap: 9px;
}

.fact-row,
.level-row,
.strategy-row {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
  align-items: baseline;
  border-bottom: 1px dashed rgba(138, 164, 194, 0.25);
  padding-bottom: 6px;
}

.fact-row:last-child,
.level-row:last-child,
.strategy-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.label {
  color: #d9e4f5;
  font-weight: 700;
}

.value {
  font-weight: 900;
}

.status-box {
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: center;
  gap: 12px;
}

.safe {
  color: #34e477;
  font-size: 3rem;
  font-weight: 900;
  text-align: center;
}

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

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

.safe.yellow {
  color: var(--yellow);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.table th,
.table td {
  border-bottom: 1px solid rgba(138, 164, 194, 0.2);
  padding: 4px 6px;
  text-align: right;
  white-space: nowrap;
}

.table th:first-child,
.table td:first-child {
  text-align: left;
}

.conclusion {
  margin-top: 8px;
  color: #ffeaa0;
  font-size: 1.08rem;
  font-weight: 800;
}

.pattern-grid {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 14px;
  align-items: center;
}

.divider {
  align-self: stretch;
  background: rgba(210, 225, 245, 0.55);
}

.pattern-title {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 900;
}

.pattern-state {
  text-align: center;
  color: var(--yellow);
  line-height: 1.45;
}

.indicator-table td:nth-child(2) {
  text-align: center;
  font-weight: 900;
}

.gauge-box {
  display: grid;
  grid-template-columns: 142px 1fr;
  align-items: center;
  gap: 10px;
}

.gauge-score {
  font-size: 2rem;
  color: var(--yellow);
  font-weight: 900;
}

.muted,
.empty-state {
  color: var(--muted);
}

.empty-state {
  padding: 16px 4px;
  font-weight: 700;
}

.donut-box {
  display: grid;
  grid-template-columns: 145px 1fr;
  align-items: center;
  gap: 14px;
}

.legend {
  display: grid;
  gap: 8px;
}

.legend-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 1.06rem;
  font-weight: 800;
}

.swatch {
  width: 14px;
  height: 14px;
}

.news-list {
  display: grid;
  gap: 10px;
}

.news-item {
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px dashed rgba(138, 164, 194, 0.25);
  color: var(--text);
  text-decoration: none;
}

.news-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.news-item:hover .news-title {
  color: var(--cyan);
}

.news-title {
  font-weight: 900;
  line-height: 1.35;
}

.news-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.analysis-footer {
  margin-top: 10px;
  color: #8fa3bb;
  font-size: 0.82rem;
  text-align: right;
}

@media (max-width: 1180px) {
  .dashboard {
    grid-template-columns: 1fr 1fr;
  }

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

  .left-column {
    grid-column: 1 / -1;
  }

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

  .ticker-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .stock-shell {
    padding: 8px;
  }

  .dashboard,
  .two-col,
  .top-strip,
  .subcharts,
  .donut-box,
  .gauge-box,
  .status-box {
    grid-template-columns: 1fr;
  }

  .chart-wrap {
    height: 280px;
  }

  .metric {
    min-height: 48px;
  }

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

  .price {
    margin-left: 0;
  }

  .period-selector {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }

  .mini-caption {
    font-size: 1rem;
    width: 78px;
  }

  .fact-row,
  .level-row,
  .strategy-row {
    grid-template-columns: 76px 1fr;
  }
}
