/* =============================================
   美股盤前日報 — Global Stylesheet
   ============================================= */

:root {
  --bg-base:       #0d1117;
  --bg-surface:    #161b22;
  --bg-card:       #1c2128;
  --bg-card-hover: #222930;
  --border:        #30363d;
  --border-strong: #484f58;

  --text-primary:  #e6edf3;
  --text-secondary:#8b949e;
  --text-muted:    #6e7681;

  --accent-gold:   #d4a843;
  --accent-gold-dim:#a07830;

  --green:  #00c853;
  --green-bg: rgba(0, 200, 83, 0.08);
  --red:    #ff1744;
  --red-bg: rgba(255, 23, 68, 0.08);
  --yellow: #f0b90b;
  --yellow-bg: rgba(240, 185, 11, 0.08);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font: -apple-system, "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Fira Code", "Consolas", monospace;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  line-height: 1.75;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-gold); text-decoration: none; }
a:hover { color: var(--yellow); text-decoration: underline; }
img { max-width: 100%; }

/* ---- Layout ---- */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
}

/* =============================================
   SITE HEADER
   ============================================= */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 48px 0 40px;
  margin-bottom: 48px;
  text-align: center;
}
.site-header .logo {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent-gold);
  line-height: 1.2;
}
.site-header .tagline {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

/* =============================================
   INDEX PAGE — Report Cards
   ============================================= */
.report-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 80px;
}

.report-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  cursor: pointer;
}
.report-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}
.report-card a {
  display: block;
  padding: 22px 24px;
  color: inherit;
  text-decoration: none;
}
.report-card .card-date {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--accent-gold);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.report-card .card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.5;
}
.report-card:hover .card-title {
  color: var(--accent-gold);
}

.loading-msg, .error-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 0.95rem;
}
.error-msg { color: var(--red); }

/* =============================================
   REPORT PAGE — Layout
   ============================================= */
.report-nav {
  padding: 24px 0 0;
}
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.back-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-surface);
  text-decoration: none;
}
.back-btn svg { flex-shrink: 0; }

/* Report Header */
.report-header {
  padding: 40px 0 36px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}
.report-header .report-date {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--accent-gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.report-header h1 {
  font-size: clamp(1.35rem, 4vw, 1.9rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 20px;
}
.report-summary {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 18px 22px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.8;
}

/* Report Body */
.report-body {
  padding-bottom: 80px;
}

/* ---- Section ---- */
.report-section {
  margin-bottom: 52px;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Prose ---- */
.report-body p {
  margin-bottom: 16px;
  color: var(--text-primary);
  font-size: 0.975rem;
}
.report-body p:last-child { margin-bottom: 0; }

/* ---- Divider ---- */
.report-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

/* ---- Key Price Table ---- */
.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin: 20px 0;
}
.price-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.price-item .pi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.price-item .pi-value {
  font-size: 1.05rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* ---- Numbers — up/down ---- */
.up   { color: var(--green); font-weight: 600; }
.down { color: var(--red);   font-weight: 600; }
.neutral { color: var(--text-secondary); }

/* ---- Key Insight Block ---- */
.key-insight {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--yellow);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 18px 22px;
  margin: 24px 0;
  position: relative;
}
.key-insight::before {
  content: "🔑 解讀";
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--yellow);
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  text-transform: uppercase;
}
.key-insight p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin: 0 !important;
}

/* ---- Scenario Cards ---- */
.scenario-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
}
.scenario-card {
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  border: 1px solid;
  font-size: 0.95rem;
  line-height: 1.7;
}
.scenario-card .sc-label {
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}
.scenario-card.bull {
  background: var(--green-bg);
  border-color: rgba(0, 200, 83, 0.3);
}
.scenario-card.bull .sc-label { color: var(--green); }
.scenario-card.base {
  background: var(--yellow-bg);
  border-color: rgba(240, 185, 11, 0.3);
}
.scenario-card.base .sc-label { color: var(--yellow); }
.scenario-card.bear {
  background: var(--red-bg);
  border-color: rgba(255, 23, 68, 0.3);
}
.scenario-card.bear .sc-label { color: var(--red); }

/* ---- Watchlist Cards ---- */
.watchlist {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}
.watch-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.watch-item .wi-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-gold-dim);
  color: var(--bg-base);
  font-size: 0.8rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  margin-top: 1px;
}
.watch-item .wi-body {}
.watch-item .wi-title {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.975rem;
  margin-bottom: 4px;
}
.watch-item .wi-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* ---- Calendar / Data Table ---- */
.data-calendar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}
.cal-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.92rem;
}
.cal-row .cal-day {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-gold);
  min-width: 44px;
  flex-shrink: 0;
}
.cal-row .cal-items {
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ---- Key Price Levels List ---- */
.price-levels {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 16px 0;
  font-size: 0.92rem;
}
.price-levels ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.price-levels li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.price-levels li:last-child {
  padding-bottom: 0;
  border-bottom: none;
}
.price-levels .pl-label { color: var(--text-secondary); }
.price-levels .pl-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

/* ---- Inline highlight ---- */
.hl-gold { color: var(--accent-gold); font-weight: 600; }
.hl-num  { font-family: var(--font-mono); color: var(--text-primary); font-weight: 600; }

/* ---- Report Footer ---- */
.report-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
.report-footer .timestamp {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ---- Site Footer ---- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* =============================================
   MARKET TABS — 市場切換
   ============================================= */
.market-tabs {
  display: flex;
  gap: 8px;
  margin: 28px 0 32px;
}

.market-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.market-tab:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-surface);
}
.market-tab.active {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #0d1117;
}
.market-tab.active:hover {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: #0d1117;
}

/* Market badge on report cards */
.market-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  line-height: 1.7;
  margin-right: 8px;
  vertical-align: middle;
}
.market-badge.us {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}
.market-badge.tw {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Empty state for tabs with no reports */
.tab-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 0;
  font-size: 0.9rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

/* =============================================
   STOCK MOVERS — 異動股卡片
   ============================================= */
.stock-movers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.stock-mover {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.stock-mover:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

/* 方向邊條：左側 3px */
.stock-mover.up   { border-left: 3px solid var(--green); }
.stock-mover.down { border-left: 3px solid var(--red); }

.stock-mover .sm-ticker {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-gold);
  letter-spacing: 0.04em;
  line-height: 1;
}

.stock-mover .sm-change {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}
.stock-mover.up   .sm-change { color: var(--green); }
.stock-mover.down .sm-change { color: var(--red); }

.stock-mover .sm-reason {
  font-size: 0.83rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-top: 2px;
}

/* 盤後標籤（用於 earnings-reaction 變體） */
.sm-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  line-height: 1.6;
  background: rgba(212, 168, 67, 0.15);
  color: var(--accent-gold);
  border: 1px solid rgba(212, 168, 67, 0.3);
  width: fit-content;
}
.sm-badge.after-hours {
  background: rgba(130, 100, 220, 0.15);
  color: #a78bfa;
  border-color: rgba(130, 100, 220, 0.3);
}
.sm-badge.pre-market {
  background: rgba(0, 200, 83, 0.1);
  color: var(--green);
  border-color: rgba(0, 200, 83, 0.25);
}

/* =============================================
   INDUSTRY OUTLOOK — 行業前瞻
   ============================================= */
.industry-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
}

.industry-block {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}

.industry-block .ib-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.industry-block .ib-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.industry-block .ib-tag {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 3px;
  text-transform: uppercase;
}
.ib-tag.bullish {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(0, 200, 83, 0.25);
}
.ib-tag.bearish {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(255, 23, 68, 0.25);
}
.ib-tag.neutral {
  background: var(--yellow-bg);
  color: var(--yellow);
  border: 1px solid rgba(240, 185, 11, 0.25);
}

.industry-block .ib-body {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 600px) {
  .container { padding: 0 16px; }

  .site-header { padding: 32px 0 28px; margin-bottom: 32px; }
  .report-header { padding: 28px 0 28px; margin-bottom: 36px; }

  .report-card a { padding: 18px; }
  .report-card .card-title { font-size: 1rem; }

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

  .report-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .watch-item { padding: 14px 16px; }

  /* 手機上兩欄並排，讓卡片不過度縱向拉長 */
  .stock-movers { grid-template-columns: 1fr 1fr; }
}
