/* ══════════════════════════════════════════════════════════════════
   bh.css — BHTrader 대시보드 공통 디자인 시스템
   기준: DOC/dashboard_renewal_목업.html 의 :root 토큰 + 공통 컴포넌트
   라이트 기본 + 다크 대응(prefers-color-scheme + data-theme 오버라이드)
   ════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --ink: #1e272e;
  --muted: #77828e;
  --line: #dfe4ea;
  --soft: #f4f6f9;
  --dark: #1e272e;
  --dark-ink: #f5f7fa;
  --gold: #fbc531;            /* 헤더/가격 */
  --up: #d94d45;             /* 국내 관례: 상승/수익 = 적색 */
  --up-soft: #fdeeed;
  --down: #4e8cf7;           /* 하락/손실 = 청색 */
  --down-soft: #edf3fe;
  --ok: #1b8a5a;
  --ok-soft: #e7f6ef;
  --warn: #e67e22;
  --warn-soft: #fdf3e7;
  --shadow: 0 1px 4px rgba(26,37,52,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14191e; --panel: #1d242b; --ink: #e8edf2; --muted: #8b97a3;
    --line: #2c353e; --soft: #232b33; --dark: #10151a; --dark-ink: #f5f7fa;
    --up-soft: #3a2422; --down-soft: #1f2a40; --ok-soft: #1d3229; --warn-soft: #38291a;
    --shadow: 0 1px 4px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #14191e; --panel: #1d242b; --ink: #e8edf2; --muted: #8b97a3;
  --line: #2c353e; --soft: #232b33; --dark: #10151a; --dark-ink: #f5f7fa;
  --up-soft: #3a2422; --down-soft: #1f2a40; --ok-soft: #1d3229; --warn-soft: #38291a;
  --shadow: 0 1px 4px rgba(0,0,0,.4);
}
:root[data-theme="light"] {
  --bg: #eef1f5; --panel: #ffffff; --ink: #1e272e; --muted: #77828e;
  --line: #dfe4ea; --soft: #f4f6f9; --dark: #1e272e; --dark-ink: #f5f7fa;
  --up-soft: #fdeeed; --down-soft: #edf3fe; --ok-soft: #e7f6ef; --warn-soft: #fdf3e7;
  --shadow: 0 1px 4px rgba(26,37,52,.08);
}

/* ── 기본 레이아웃 ─────────────────────────────────────────────── */
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  font-size: 14px; line-height: 1.55;
}
main { max-width: 1160px; margin: 0 auto; padding: 20px 16px 60px; display: grid; gap: 12px; }
a { color: var(--down); }
h1, h2, h3, h4 { letter-spacing: -0.3px; }

/* ── 상단 통합 내비게이션 (전 페이지 공통) ──────────────────────── */
.topbar {
  background: var(--dark); color: var(--dark-ink);
  display: flex; align-items: center; gap: 14px; padding: 10px 16px; flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 14px; letter-spacing: -0.2px; white-space: nowrap; }
.brand small { display: block; font-size: 9px; color: #7cb; font-weight: 600; letter-spacing: 1.2px; }
nav.gnb { display: flex; gap: 2px; flex-wrap: wrap; }
nav.gnb a {
  color: #b9c4cd; text-decoration: none; font-size: 12.5px; font-weight: 600;
  padding: 6px 10px; border-radius: 6px; white-space: nowrap;
}
nav.gnb a:hover { background: rgba(255,255,255,.09); color: #fff; }
nav.gnb a.on { background: rgba(255,255,255,.14); color: #fff; }
.top-price { margin-left: auto; text-align: right; }
.top-price strong { color: var(--gold); font-size: 15px; font-variant-numeric: tabular-nums; }
.top-price small { display: block; font-size: 10px; color: #8fa3ad; }

/* 신선도 배지 (bh.js 가 클래스 토글) */
.fresh { color: #8fa3ad; }
.fresh.stale-ok { color: #63c896; }
.fresh.stale-warn { color: var(--warn); font-weight: 700; }

/* ── KPI 카드 ──────────────────────────────────────────────────── */
.kpis, .sumgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; display: grid; gap: 2px; align-content: start;
}
.kpi .k { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .3px; }
.kpi .v { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }
.kpi .s { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.v.up { color: var(--up); } .v.down { color: var(--down); }

/* ── 상태 배지 pill ────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  border-radius: 20px; padding: 2px 9px; width: fit-content;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.up { background: var(--up-soft); color: var(--up); }
.pill.down { background: var(--down-soft); color: var(--down); }
.pill.flat { background: var(--soft); color: var(--muted); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── 패널 / 신호 보드 ──────────────────────────────────────────── */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px;
}
.panel h3 { margin: 0 0 10px; font-size: 13px; display: flex; justify-content: space-between; align-items: baseline; }
.panel h3 a { font-size: 11px; color: var(--muted); font-weight: 600; text-decoration: none; }
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .board { grid-template-columns: 1fr; } }
.sig-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.sig-row:first-of-type { border-top: none; }
.sig-row .tf { color: var(--muted); font-weight: 700; width: 74px; flex-shrink: 0; font-size: 11px; }
.sig-row .desc { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 메뉴 카드 ─────────────────────────────────────────────────── */
.menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.menu a {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; text-decoration: none; color: var(--ink); display: grid; gap: 2px;
}
.menu a b { font-size: 13px; }
.menu a span { font-size: 11px; color: var(--muted); }
.menu a:hover { border-color: var(--muted); }

/* ── 접이식 상세 섹션 ──────────────────────────────────────────── */
details.sec {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
details.sec summary {
  list-style: none; cursor: pointer; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 13px;
}
details.sec summary::-webkit-details-marker { display: none; }
details.sec summary .hint { margin-left: auto; font-size: 11px; color: var(--muted); font-weight: 600; }
details.sec summary::after { content: "▾"; color: var(--muted); font-size: 11px; transition: transform .15s; }
details.sec[open] summary::after { transform: rotate(180deg); }
details.sec .body { padding: 0 14px 14px; }

/* ── 표 ────────────────────────────────────────────────────────── */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
th { text-align: left; color: var(--muted); font-size: 11px; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 6px 10px; border-bottom: 1px solid var(--soft); white-space: nowrap; }
td.up { color: var(--up); font-weight: 600; } td.down { color: var(--down); font-weight: 600; }

@media (prefers-reduced-motion: reduce) { details.sec summary::after { transition: none; } }
