/* Stock Portfolio Dashboard — visual style aligned with kkday-analysis-reports */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #1a1a1a;
  --ink-2: #3a3a3a;
  --ink-3: #6a6a6a;
  --ink-4: #9a9a9a;
  --ink-5: #bdbdbd;

  --paper: #fafaf7;
  --card: #ffffff;
  --inset: #f3f2ee;
  --hairline: #ebe9e3;
  --hairline-soft: #f0eeea;

  --accent: #4a5d4f;
  --accent-soft: #eef1ec;
  --warn: #b34a3a;
  --warn-soft: #f8ece9;
  --ok: #4a6b3c;
  --ok-soft: #ecf2e7;
  --mid: #b08e3a;
  --mid-soft: #f5efde;

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

  --shadow-1: 0 1px 2px rgba(24,22,18,0.04), 0 0 0 1px rgba(24,22,18,0.04);
  --shadow-hover: 0 6px 20px rgba(24,22,18,0.07), 0 0 0 1px rgba(24,22,18,0.06);
}

body {
  font-family: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a.link { color: var(--accent); font-weight: 500; }
a.link:hover { text-decoration: underline; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 32px; }

.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }

.up   { color: var(--ok); }
.down { color: var(--warn); }

/* ── Topbar ── */
.topbar {
  padding: 22px 0;
  border-bottom: 1px solid var(--hairline);
  background: rgba(250,250,247,0.92);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: saturate(140%) blur(8px);
}
.topbar-inner {
  display: flex; justify-content: space-between; align-items: center;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; letter-spacing: -0.01em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--ink); color: var(--paper);
  display: grid; place-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.brand-title { font-weight: 600; font-size: 15.5px; letter-spacing: -0.005em; }
.brand-sub { color: var(--ink-3); font-size: 12.5px; margin-top: 1px; }

.topbar-actions { display: flex; align-items: center; gap: 16px; }
.topbar-note { color: var(--ink-3); font-size: 12.5px; }

/* ── Layout blocks ── */
main.container { padding-top: 36px; padding-bottom: 96px; }
.block { margin-bottom: 36px; }
.section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 12px;
}
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 18px 20px;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--hairline);
}
.tab {
  background: none;
  border: none;
  padding: 10px 20px;
  font-size: 14px;
  cursor: pointer;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-weight: 500;
  margin-bottom: -1px;
  transition: color 0.15s;
}
.tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.tab:hover { color: var(--ink-2); }
.tab-pane.hidden { display: none; }

/* ── KPI cards ── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-1);
}
.kpi-label {
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.kpi-value {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.kpi-value.up { color: var(--ok); }
.kpi-value.down { color: var(--warn); }
.kpi-value.muted { color: var(--ink-3); font-weight: 500; }
.kpi-sub {
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  color: var(--ink-3);
}
.kpi-sub.up { color: var(--ok); }
.kpi-sub.down { color: var(--warn); }

.fx-note {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-4);
  margin-left: 8px;
  background: var(--inset);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ── Tables ── */
.ticker-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.ticker-table th, .ticker-table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--hairline-soft);
  vertical-align: middle;
}
.ticker-table th {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}
.ticker-table tbody tr:last-child td { border-bottom: none; }
.ticker-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ticker-table tbody tr:hover { background: var(--inset); }
.ticker-table .empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }

.ticker { display: flex; flex-direction: column; }
.ticker strong { font-weight: 600; }
.ticker .muted { font-size: 12px; }

.signal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 13px;
}

/* ── Health bar ── */
.health-row {
  display: flex; align-items: center; gap: 10px;
  width: 140px;
}
.health-bar {
  flex: 1;
  height: 6px;
  background: var(--inset);
  border-radius: 999px;
  overflow: hidden;
}
.health-bar > div {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.health-good > div { background: var(--ok); }
.health-mid  > div { background: var(--mid); }
.health-bad  > div { background: var(--warn); }
.health-num {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink-2);
  min-width: 28px;
  text-align: right;
}

/* ── Theme chips ── */
.theme-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.theme-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--inset);
  font-size: 13px;
  border: 1px solid transparent;
  transition: all 0.18s;
}
.theme-chip:hover { background: var(--card); border-color: var(--hairline); box-shadow: var(--shadow-1); }
.theme-chip span { color: var(--ink-3); font-variant-numeric: tabular-nums; font-size: 12px; }
.theme-chip.good { background: var(--ok-soft); }
.theme-chip.mid  { background: var(--mid-soft); }
.theme-chip.bad  { background: var(--warn-soft); }
.theme-chip.muted { background: var(--inset); color: var(--ink-3); }

/* ── Per-ticker page ── */
.ticker-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 16px;
  gap: 24px;
}
.ticker-title { font-size: 28px; font-weight: 700; letter-spacing: -0.015em; }
.ticker-title .muted { font-size: 16px; font-weight: 400; margin-left: 8px; }
.ticker-sub { font-size: 18px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.ticker-score { min-width: 200px; }

.kvs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 28px; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--hairline-soft); }
.kv .k { color: var(--ink-3); font-size: 13px; }
.kv .v { font-variant-numeric: tabular-nums; font-weight: 500; }

.readings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.reading-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 16px 18px;
}
.reading-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.reading-head h3 { font-size: 14px; font-weight: 600; }
.reading-head .signal { font-size: 18px; }
.val-big { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; margin: 6px 0 8px; }
.vals { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin: 8px 0; font-size: 13px; }
.vals dt { color: var(--ink-3); }
.vals dd { font-variant-numeric: tabular-nums; font-weight: 500; }
.reading-reason {
  font-size: 13px;
  color: var(--ink-2);
  margin: 8px 0;
  padding: 8px 10px;
  background: var(--inset);
  border-radius: var(--radius-sm);
}
.reading-edu { font-size: 13px; margin-top: 8px; }
.reading-edu summary { cursor: pointer; color: var(--accent); font-weight: 500; padding: 4px 0; }
.reading-edu p { margin: 6px 0; color: var(--ink-2); }
.reading-edu strong { color: var(--ink); }

.commentary {
  line-height: 1.75;
  font-size: 14px;
}
.commentary p { margin: 8px 0; }
.commentary p:first-child { margin-top: 0; }
.commentary p:last-child { margin-bottom: 0; }
.commentary strong { color: var(--ink); font-weight: 600; }
.empty-commentary {
  text-align: center;
  color: var(--ink-3);
  padding: 24px;
}
.empty-commentary code {
  background: var(--inset);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
}

/* ── Footer ── */
.foot {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--hairline);
  color: var(--ink-3);
  font-size: 12.5px;
  text-align: center;
}
.foot p { margin: 4px 0; }
.foot a { color: var(--accent); }

/* ── Responsive ── */
@media (max-width: 720px) {
  .container { padding: 0 18px; }
  .ticker-table th:nth-child(5), .ticker-table td:nth-child(5) { display: none; }
  .ticker-head { flex-direction: column; align-items: flex-start; }
  .ticker-score { width: 100%; }
  .kvs { grid-template-columns: 1fr; }
  .kpi-value { font-size: 18px; }
  .tab { padding: 8px 14px; font-size: 13px; }
}
