﻿:root {
  color-scheme: light;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-soft: #eef4f2;
  --ink: #17211d;
  --muted: #65736d;
  --line: #dce6e1;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --good: #138a52;
  --warn: #b7791f;
  --bad: #c24135;
  --shadow: 0 18px 45px rgba(18, 35, 30, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft JhengHei", "Noto Sans TC", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 34px 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 16px;
  font-size: 20px;
}

h3 {
  margin-bottom: 10px;
  font-size: 17px;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
}

.layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 22px;
  padding: 0 34px 34px;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel,
.kpi-card,
.mini-chart-card,
.hero-analysis,
.status-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

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

.field.compact {
  margin-bottom: 0;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

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

.custom-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 10px;
  align-items: end;
}

.primary-button,
.icon-button,
.segmented button,
.chip button {
  border: 0;
  cursor: pointer;
}

.primary-button {
  min-height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 24px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.segmented button {
  min-height: 42px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.active {
  background: var(--accent);
  color: #fff;
}

.hint,
.source-list,
.timestamp-list {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.source-list {
  padding-left: 18px;
  margin: 0;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 6px 8px 6px 12px;
  font-size: 13px;
  font-weight: 800;
}

.chip button {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #dbe7e2;
  color: var(--muted);
}

.content {
  display: grid;
  gap: 18px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
}

.status-strip > div {
  padding: 16px 18px;
  background: var(--surface);
}

.label,
.kpi-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.grid {
  display: grid;
  gap: 16px;
}

.kpi-grid {
  grid-template-columns: repeat(3, 1fr);
}

.kpi-card {
  padding: 18px;
}

.kpi-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 26px;
}

.kpi-card small {
  color: var(--muted);
  line-height: 1.45;
}

.hero-analysis {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(360px, 1fr);
  gap: 18px;
  align-items: stretch;
  padding: 20px;
}

.hero-analysis h2 {
  margin-bottom: 12px;
  font-size: 28px;
}

.hero-analysis p {
  color: var(--muted);
  line-height: 1.7;
}

.mini-chart-card {
  padding: 14px;
  box-shadow: none;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  min-height: 240px;
}

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

.market-panel {
  box-shadow: var(--shadow);
}

.macro-grid,
.evidence-grid {
  display: grid;
  gap: 10px;
}

.macro-item,
.evidence-item {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.macro-item {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.macro-item b,
.evidence-item b {
  font-size: 14px;
}

.macro-item span,
.evidence-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.up {
  color: var(--good);
}

.down {
  color: var(--bad);
}

.flat {
  color: var(--warn);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px 10px;
  text-align: left;
  vertical-align: top;
}

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

td {
  font-size: 14px;
}

.ticker-name {
  display: grid;
  gap: 4px;
}

.ticker-name strong {
  font-size: 15px;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.pill.good {
  background: #e2f5ed;
  color: var(--good);
}

.pill.warn {
  background: #fff3d6;
  color: var(--warn);
}

.pill.bad {
  background: #fde8e4;
  color: var(--bad);
}

.report-area {
  display: grid;
  gap: 16px;
}

.report-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 16px;
}

.report-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.report-title small {
  color: var(--muted);
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.report-box {
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.report-box b {
  display: block;
  margin-bottom: 8px;
}

.report-box p,
.report-box li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.report-box ul {
  margin: 0;
  padding-left: 18px;
}

.timestamp-list {
  display: grid;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: #13201c;
  color: #fff;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  transition: 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1080px) {
  .layout,
  .hero-analysis,
  .market-grid {
    grid-template-columns: 1fr;
  }

  .side-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 760px) {
  .app-header {
    padding: 22px 18px 16px;
  }

  .layout {
    padding: 0 18px 24px;
  }

  .side-panel,
  .status-strip,
  .kpi-grid,
  .report-grid {
    grid-template-columns: 1fr;
  }

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

  .hero-analysis h2 {
    font-size: 24px;
  }
}
