/* ════════════════════════════════════════════════
   InvestorFlow AI V8 Enterprise — Design System
   PC 기반 + 모바일 연동
   ════════════════════════════════════════════════ */

/* ── CSS 변수 (토큰) ── */
:root {
  /* 컬러 팔레트 */
  --bg-base:       #0d1117;
  --bg-surface:    #161b22;
  --bg-card:       #1c2128;
  --bg-hover:      #222831;
  --border:        #30363d;
  --border-subtle: #21262d;

  --text-primary:  #e6edf3;
  --text-secondary:#8b949e;
  --text-muted:    #484f58;

  /* 액센트 */
  --accent-blue:   #58a6ff;
  --accent-green:  #3fb950;
  --accent-red:    #f85149;
  --accent-yellow: #d29922;
  --accent-purple: #bc8cff;
  --accent-cyan:   #39d353;

  /* 투자자 컬러 */
  --color-foreign:     #58a6ff;
  --color-institution: #3fb950;
  --color-pension:     #bc8cff;
  --color-combined:    #f0883e;
  --color-ai:          #39d353;

  /* AI 등급 */
  --grade-sp: linear-gradient(135deg, #ffd700, #ff8c00);
  --grade-s:  linear-gradient(135deg, #c0c0c0, #808080);
  --grade-a:  linear-gradient(135deg, #58a6ff, #1f6feb);
  --grade-b:  linear-gradient(135deg, #3fb950, #2ea043);
  --grade-c:  linear-gradient(135deg, #8b949e, #6e7681);

  /* 사이드바 */
  --sidebar-w: 240px;
  --header-h:  56px;
  --mobile-nav-h: 60px;

  /* 타이포 */
  --font-main: 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  --font-mono: 'Cascadia Code', 'Consolas', monospace;

  /* 반경 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* 그림자 */
  --shadow-card: 0 1px 3px rgba(0,0,0,.5), 0 0 0 1px var(--border);
  --shadow-modal: 0 24px 60px rgba(0,0,0,.8);

  /* 트랜지션 */
  --t-fast: 150ms ease;
  --t-mid:  250ms ease;
}

/* ── 리셋 & 베이스 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select { font-family: inherit; }
canvas { display: block; }
::selection { background: rgba(88,166,255,.3); }

/* ════════════════════════════════════════════
   APP SHELL — PC 레이아웃
   ════════════════════════════════════════════ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── 사이드바 ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--t-mid);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.logo-icon { font-size: 28px; }
.logo-text strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-blue);
  letter-spacing: -.3px;
}
.logo-text small {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: .5px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: rgba(88,166,255,.12);
  color: var(--accent-blue);
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.market-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-red);
  animation: pulse 2s infinite;
}
.status-dot.open { background: var(--accent-green); }
@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: .4; }
}
.last-update { font-size: 11px; color: var(--text-muted); }

/* ── 메인 콘텐츠 ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg-base);
}

/* ── 상단 헤더 ── */
.top-header {
  position: sticky;
  top: 0; z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--header-h);
  padding: 0 20px;
  background: rgba(13,17,23,.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.menu-toggle {
  display: none;
  font-size: 20px;
  color: var(--text-secondary);
  padding: 4px 8px;
}
.header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  font-size: 16px;
  transition: background var(--t-fast);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* 기간 선택 */
.period-selector {
  display: flex;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.period-btn {
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--t-fast);
}
.period-btn.active {
  background: var(--accent-blue);
  color: #fff;
}
.period-btn:hover:not(.active) { background: var(--bg-hover); color: var(--text-primary); }

/* ── 페이지 컨테이너 ── */
.page-container {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}
.page { display: none; }
.page.active { display: block; }

/* ════════════════════════════════════════════
   KPI 요약 바
   ════════════════════════════════════════════ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  transition: border-color var(--t-fast);
}
.kpi-card:hover { border-color: var(--accent-blue); }
.kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}
.kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.kpi-value.ai-highlight { color: var(--accent-cyan); }
.kpi-change {
  font-size: 12px;
  margin-top: 4px;
}
.kpi-change.up   { color: var(--accent-red); }
.kpi-change.down { color: var(--accent-blue); }

/* ════════════════════════════════════════════
   대시보드 그리드
   ════════════════════════════════════════════ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--t-fast), transform var(--t-fast);
}
.card:hover { border-color: var(--border); transform: translateY(-1px); }
.card-wide { grid-column: span 2; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.card-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.card-badge.foreign     { background: rgba(88,166,255,.15); color: var(--color-foreign); }
.card-badge.institution { background: rgba(63,185,80,.15);  color: var(--color-institution); }
.card-badge.pension     { background: rgba(188,140,255,.15);color: var(--color-pension); }
.card-badge.combined    { background: rgba(240,136,62,.15); color: var(--color-combined); }
.card-badge.ai          { background: rgba(57,211,83,.15);  color: var(--color-ai); }

.card-body { padding: 12px 16px; }

/* ── 종목 리스트 ── */
.stock-list { display: flex; flex-direction: column; gap: 6px; }
.stock-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  transition: background var(--t-fast);
  cursor: pointer;
}
.stock-row:hover { background: var(--bg-hover); }
.stock-rank {
  width: 20px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
}
.stock-rank.top1 { color: var(--accent-yellow); }
.stock-rank.top2 { color: var(--text-secondary); }
.stock-rank.top3 { color: #c9703a; }

.stock-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stock-code { font-size: 10px; color: var(--text-muted); }
.stock-amount {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-red);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stock-amount.sell { color: var(--accent-blue); }
.stock-days {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
.stock-grade {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.grade-sp { background: var(--grade-sp); color: #000; }
.grade-s  { background: var(--grade-s);  color: #000; }
.grade-a  { background: var(--grade-a);  color: #fff; }
.grade-b  { background: var(--grade-b);  color: #fff; }
.grade-c  { background: var(--grade-c);  color: #fff; }

/* ── AI 추천 Featured ── */
.ai-featured {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.ai-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  transition: border-color var(--t-fast);
}
.ai-card:hover { border-color: var(--accent-blue); }
.ai-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}
.ai-stock-name { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.ai-stock-code { font-size: 11px; color: var(--text-muted); }
.ai-score-circle {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  font-size: 16px;
  font-weight: 800;
  flex-shrink: 0;
}
.ai-score-circle.sp { background: var(--grade-sp); color: #000; }
.ai-score-circle.s  { background: var(--grade-s);  color: #000; }
.ai-score-circle.a  { background: var(--grade-a);  color: #fff; }
.ai-score-circle small { font-size: 8px; font-weight: 400; }

.ai-factors { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.ai-factor {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-hover);
  color: var(--text-secondary);
}
.ai-factor.strong { color: var(--accent-green); background: rgba(63,185,80,.12); }

/* ════════════════════════════════════════════
   투자자 수급 페이지
   ════════════════════════════════════════════ */
.page-header {
  margin-bottom: 20px;
}
.page-header h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-sub { font-size: 13px; color: var(--text-secondary); }

.investor-tabs, .news-filter {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tab-btn, .filter-btn {
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  transition: all var(--t-fast);
}
.tab-btn:hover, .filter-btn:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.tab-btn.active, .filter-btn.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}

/* ── 데이터 테이블 ── */
.table-wrapper { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--t-fast);
  cursor: pointer;
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table td {
  padding: 10px 12px;
  white-space: nowrap;
}
.empty-row { text-align: center; color: var(--text-muted); padding: 40px !important; }

/* ── AI 그리드 ── */
.ai-score-legend {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.grade-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 99px;
}
.grade-badge.s-plus { background: var(--grade-sp); color: #000; }
.grade-badge.s  { background: var(--grade-s);  color: #000; }
.grade-badge.a  { background: var(--grade-a);  color: #fff; }
.grade-badge.b  { background: var(--grade-b);  color: #fff; }
.grade-badge.c  { background: var(--grade-c);  color: #fff; }

.ai-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

/* ════════════════════════════════════════════
   관심종목
   ════════════════════════════════════════════ */
.count-badge {
  font-size: 13px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 99px;
  margin-left: 8px;
  color: var(--text-secondary);
}
.page-header { display: flex; align-items: center; justify-content: space-between; }
.btn-primary {
  padding: 8px 18px;
  background: var(--accent-blue);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: opacity var(--t-fast);
}
.btn-primary:hover { opacity: .85; }
.btn-secondary {
  padding: 8px 18px;
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--t-fast);
}
.btn-secondary:hover { border-color: var(--accent-blue); color: var(--accent-blue); }

.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.empty-watchlist {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px;
  color: var(--text-muted);
}
.empty-watchlist span { font-size: 48px; display: block; margin-bottom: 12px; }
.watch-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  position: relative;
}
.watch-card:hover { border-color: var(--accent-blue); }
.watch-remove {
  position: absolute;
  top: 8px; right: 8px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.watch-card:hover .watch-remove { opacity: 1; }

/* ════════════════════════════════════════════
   뉴스
   ════════════════════════════════════════════ */
.news-list { display: flex; flex-direction: column; gap: 10px; }
.news-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  gap: 14px;
  transition: border-color var(--t-fast);
  cursor: pointer;
}
.news-item:hover { border-color: var(--accent-blue); }
.news-sentiment {
  width: 4px;
  border-radius: 2px;
  flex-shrink: 0;
  align-self: stretch;
}
.news-sentiment.positive { background: var(--accent-green); }
.news-sentiment.negative { background: var(--accent-red); }
.news-sentiment.neutral  { background: var(--text-muted); }
.news-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.4;
}
.news-summary {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  line-height: 1.5;
}
.news-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
}
.news-tag {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-hover);
  color: var(--text-secondary);
}

/* ════════════════════════════════════════════
   차트
   ════════════════════════════════════════════ */
.chart-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}
.stock-search {
  flex: 1;
  max-width: 300px;
  padding: 8px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
.stock-search:focus { border-color: var(--accent-blue); }
.chart-period-btns { display: flex; gap: 4px; }
.chart-area, .chart-sub-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 12px;
}
canvas { width: 100% !important; }

/* ════════════════════════════════════════════
   설정
   ════════════════════════════════════════════ */
.settings-sections { display: flex; flex-direction: column; gap: 20px; }
.settings-group {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}
.settings-group h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.setting-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.setting-item label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.setting-item input {
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
.setting-item input:focus { border-color: var(--accent-blue); }
.setting-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-primary);
}
.setting-toggle input[type=checkbox] {
  width: 36px; height: 20px;
  appearance: none;
  background: var(--border);
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  transition: background var(--t-fast);
}
.setting-toggle input[type=checkbox]:checked { background: var(--accent-blue); }
.setting-toggle input[type=checkbox]::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  transition: left var(--t-fast);
}
.setting-toggle input[type=checkbox]:checked::after { left: 19px; }

.api-status { margin-top: 10px; font-size: 12px; }
.api-status.ok    { color: var(--accent-green); }
.api-status.error { color: var(--accent-red); }

.sys-info { display: flex; flex-direction: column; gap: 0; }
.sys-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
}
.sys-row span:first-child { color: var(--text-muted); }
.sys-row span:last-child  { color: var(--text-secondary); font-weight: 600; }

/* ════════════════════════════════════════════
   모달
   ════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: min(480px, 94vw);
  box-shadow: var(--shadow-modal);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.modal-body { padding: 16px 20px 20px; }
.modal-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  margin-bottom: 12px;
}
.modal-input:focus { border-color: var(--accent-blue); }
.search-results { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; }
.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  cursor: pointer;
  transition: background var(--t-fast);
}
.search-result-item:hover { background: var(--bg-hover); }

/* ════════════════════════════════════════════
   토스트
   ════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 80px; right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow-modal);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn .2s ease;
  min-width: 240px;
}
.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error   { border-left: 3px solid var(--accent-red); }
.toast.info    { border-left: 3px solid var(--accent-blue); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

/* ── 스켈레톤 로딩 ── */
.loading-skeleton {
  height: 180px;
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-hover) 50%, var(--bg-surface) 75%);
  background-size: 400% 100%;
  border-radius: var(--radius-sm);
  animation: shimmer 1.4s infinite;
}
.loading-skeleton.tall { height: 260px; }
@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ════════════════════════════════════════════
   모바일 하단 네비
   ════════════════════════════════════════════ */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--mobile-nav-h);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  z-index: 300;
  justify-content: space-around;
  align-items: center;
}
.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 16px;
  color: var(--text-muted);
  font-size: 10px;
  transition: color var(--t-fast);
  border-radius: var(--radius-sm);
}
.mobile-nav-item:first-child { font-size: 22px; }
.mobile-nav-item span:first-child { font-size: 22px; }
.mobile-nav-item.active { color: var(--accent-blue); }
.mobile-nav-item:hover  { color: var(--text-primary); }

/* ════════════════════════════════════════════
   스크롤바
   ════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ════════════════════════════════════════════
   반응형 — 태블릿 (≤1024px)
   ════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .card-wide { grid-column: span 1; }
  .ai-featured { grid-template-columns: repeat(2, 1fr); }
}

/* ════════════════════════════════════════════
   반응형 — 모바일 (≤768px)
   ════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* 사이드바 → 슬라이드 오버레이 */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-modal);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  /* 사이드바 오버레이 배경 */
  .sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 150;
    display: none;
  }
  .sidebar-overlay.open { display: block; }

  .menu-toggle { display: flex; }
  .main-content { margin-left: 0; padding-bottom: var(--mobile-nav-h); }
  .mobile-nav { display: flex; }
  .page-container { padding: 14px; }

  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi-value { font-size: 18px; }

  .period-selector .period-btn { padding: 4px 8px; font-size: 11px; }
  .header-actions { gap: 4px; }

  .ai-featured { grid-template-columns: 1fr; }
  .ai-grid     { grid-template-columns: 1fr; }
  .watchlist-grid { grid-template-columns: 1fr; }

  .toast-container { bottom: calc(var(--mobile-nav-h) + 12px); right: 12px; left: 12px; }

  .data-table { font-size: 12px; }
  .data-table td, .data-table th { padding: 8px; }
}

@media (max-width: 480px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .header-title { font-size: 14px; }
  .top-header { padding: 0 12px; }
}
