/* ═══════════════════════════════════════════════════════════
   RN봇 v3 — 데스크탑 우선 사이드바 레이아웃
   ═══════════════════════════════════════════════════════════ */

/* ── 변수 ─────────────────────────────────────────────────── */
:root {
  --bg:          #0a0e1a;
  --sidebar:     #0f1629;
  --card:        #131d32;
  --card-hover:  #1a2640;
  --border:      rgba(255,255,255,0.07);
  --border-med:  rgba(255,255,255,0.12);
  --text:        #e2e8f0;
  --sub:         #64748b;
  --sub-lt:      #94a3b8;
  --violet:      #a78bfa;
  --violet-dark: #7c3aed;
  --violet-dim:  rgba(167,139,250,0.12);
  --emerald:     #34d399;
  --emerald-dim: rgba(52,211,153,0.12);
  --red:         #f87171;
  --red-dim:     rgba(248,113,113,0.12);
  --amber:       #fbbf24;
  --amber-dim:   rgba(251,191,36,0.12);
  --blue:        #60a5fa;
  --blue-dim:    rgba(96,165,250,0.12);
  --sidebar-w:   220px;
  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   16px;
}

/* ── 리셋 ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  font-family: -apple-system, "Malgun Gothic", "Apple SD Gothic Neo",
               BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, select, textarea { font: inherit; }
.mono { font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace; }

/* ══════════════════════════════════════════════════════════
   앱 레이아웃 (사이드바 + 메인)
   ══════════════════════════════════════════════════════════ */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── 사이드바 ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 20;
}

.sidebar-logo {
  padding: 28px 20px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--violet), var(--violet-dark));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-icon svg { width: 18px; height: 18px; }
.logo-text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.logo-version {
  font-size: 10px;
  color: var(--sub);
  margin-top: 2px;
}

/* 사이드바 내비 */
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section {
  margin-bottom: 4px;
}
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--sub-lt);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.nav-item:hover {
  background: var(--card);
  color: var(--text);
}
.nav-item.active {
  background: var(--violet-dim);
  color: var(--violet);
}
.nav-item svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
  opacity: 0.8;
}
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--violet-dim);
  color: var(--violet);
  font-weight: 600;
}

/* 사이드바 하단 유저 영역 */
.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--violet-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-role {
  font-size: 10px;
  color: var(--sub);
}
.btn-logout {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--sub-lt);
  font-size: 12px;
  font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  transition: all 0.15s;
}
.btn-logout:hover { background: var(--red-dim); color: var(--red); }
.btn-logout svg { width: 14px; height: 14px; }

/* ── 메인 컨텐츠 ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* 페이지 헤더 */
.page-header {
  padding: 28px 32px 0;
  flex-shrink: 0;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.page-subtitle {
  font-size: 13px;
  color: var(--sub);
  margin-top: 2px;
}
.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 페이지 컨텐츠 패딩 */
.page-body {
  padding: 24px 32px 32px;
  flex: 1;
}

/* 페이지 전환 */
.page { display: none; height: 100%; }
.page.active { display: flex; flex-direction: column; min-height: 100%; }

/* ── 모바일 햄버거 상단바 ─────────────────────────────────── */
.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 52px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 30;
}
.mobile-logo { font-size: 16px; font-weight: 700; }
.hamburger {
  width: 36px; height: 36px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 5px; border-radius: 8px;
  transition: background 0.15s;
}
.hamburger:hover { background: var(--card); }
.hamburger span {
  display: block; width: 18px; height: 2px;
  background: var(--text); border-radius: 2px;
  transition: all 0.2s;
}

/* 사이드바 오버레이 (모바일) */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 19;
}

/* ══════════════════════════════════════════════════════════
   공통 컴포넌트
   ══════════════════════════════════════════════════════════ */

/* 카드 */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card-sm { padding: 16px; }
.card-hover { transition: background 0.15s, border-color 0.15s; }
.card-hover:hover { background: var(--card-hover); border-color: var(--border-med); }

/* 메트릭 카드 */
.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
}
.metric-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent-color, var(--violet));
}
.metric-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.metric-value {
  font-size: 26px;
  font-weight: 700;
  font-family: "SF Mono", "Fira Code", monospace;
  letter-spacing: -0.02em;
  line-height: 1;
}
.metric-sub {
  font-size: 12px;
  color: var(--sub);
  margin-top: 6px;
}
.metric-icon {
  position: absolute;
  right: 20px; top: 50%;
  transform: translateY(-50%);
  opacity: 0.08;
  width: 48px; height: 48px;
}

/* 섹션 타이틀 */
.section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* 그리드 */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }

/* 태그 */
.tag {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
  white-space: nowrap;
}
.tag-violet { background: var(--violet-dim); color: var(--violet); }
.tag-emerald { background: var(--emerald-dim); color: var(--emerald); }
.tag-red { background: var(--red-dim); color: var(--red); }
.tag-amber { background: var(--amber-dim); color: var(--amber); }
.tag-blue { background: var(--blue-dim); color: var(--blue); }
.tag-gray { background: rgba(255,255,255,0.06); color: var(--sub); }

/* 손익 색상 */
.pos { color: var(--emerald); }
.neg { color: var(--red); }
.zer { color: var(--sub); }

/* 구분선 */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── 버튼 ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 14px; height: 14px; }

.btn-primary {
  background: linear-gradient(135deg, var(--violet), var(--violet-dark));
  color: #fff;
  box-shadow: 0 0 20px rgba(124,58,237,0.3);
}
.btn-primary:hover { box-shadow: 0 0 28px rgba(124,58,237,0.5); filter: brightness(1.05); }

.btn-emerald {
  background: var(--emerald-dim);
  color: var(--emerald);
  border: 1px solid rgba(52,211,153,0.2);
}
.btn-emerald:hover { background: rgba(52,211,153,0.2); }

.btn-red {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.2);
}
.btn-red:hover { background: rgba(248,113,113,0.2); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-med);
  color: var(--sub-lt);
}
.btn-outline:hover { border-color: var(--violet); color: var(--violet); background: var(--violet-dim); }

.btn-ghost { color: var(--sub-lt); }
.btn-ghost:hover { color: var(--text); background: var(--card); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }
.btn-full { width: 100%; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ── 토글 스위치 ──────────────────────────────────────────── */
.toggle-wrap { position: relative; width: 44px; height: 24px; display: inline-block; flex-shrink: 0; }
.toggle-wrap input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  transition: 0.2s;
  cursor: pointer;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
input:checked + .toggle-slider { background: var(--violet); }
input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── 폼 ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--sub-lt);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.form-input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.form-input:focus {
  border-color: var(--violet);
  background: rgba(167,139,250,0.05);
}
.form-input::placeholder { color: var(--sub); }
.form-input[type="password"] { letter-spacing: 0.1em; }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
.form-hint { font-size: 11px; color: var(--sub); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.form-error { font-size: 12px; color: var(--red); margin-top: 5px; }

/* ── 테이블 ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px; font-weight: 600;
  color: var(--sub);
  text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }
.td-mono { font-family: "SF Mono", "Fira Code", monospace; }
.td-right { text-align: right; }
.td-center { text-align: center; }

/* ── 빈 상태 ─────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 64px 24px; gap: 12px;
  color: var(--sub); text-align: center;
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.25; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--sub-lt); }
.empty-text { font-size: 13px; }

/* ── 로딩 스피너 ─────────────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--violet);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 48px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex; align-items: center; justify-content: center;
  padding: 64px;
}

/* ── 토스트 ──────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 28px; right: 28px;
  background: var(--card);
  border: 1px solid var(--border-med);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 200;
  transform: translateY(80px);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  max-width: 340px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0; background: var(--emerald);
}
.toast-dot.err { background: var(--red); }

/* ── 상태 점 ─────────────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.ok { background: var(--emerald); box-shadow: 0 0 6px var(--emerald); }
.status-dot.err { background: var(--red); }
.status-dot.idle { background: var(--sub); }

/* ══════════════════════════════════════════════════════════
   대시보드 페이지
   ══════════════════════════════════════════════════════════ */

/* 메트릭 그리드 (4열) */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

/* 에쿼티 차트 */
.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  position: relative;
}
.chart-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.chart-title { font-size: 13px; font-weight: 600; color: var(--sub); text-transform: uppercase; letter-spacing: 0.06em; }
.chart-value { font-size: 28px; font-weight: 700; font-family: monospace; letter-spacing: -0.02em; }
.chart-pct {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 600;
  padding: 3px 8px; border-radius: 6px; margin-top: 4px;
}
.chart-canvas-wrap { position: relative; height: 200px; }
canvas#equity-canvas { width: 100%; height: 100%; }

/* 차트 툴팁 */
#chart-tooltip {
  position: absolute;
  pointer-events: none;
  display: none;
  background: var(--card);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
#chart-tooltip .tt-date { color: var(--sub); font-size: 11px; }
#chart-tooltip .tt-val { font-weight: 700; font-family: monospace; margin-top: 2px; }

/* 하단 통계 카드들 */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

/* 자동매매 토글 카드 */
.auto-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 24px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
  transition: border-color 0.2s;
}
.auto-card.on { border-color: rgba(167,139,250,0.3); background: rgba(167,139,250,0.05); }
.auto-label { font-size: 14px; font-weight: 600; }
.auto-sub { font-size: 12px; color: var(--sub); margin-top: 2px; }
.auto-status {
  display: flex; align-items: center; gap: 8px;
}
.auto-badge {
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px;
}
.auto-badge.on { background: var(--violet-dim); color: var(--violet); }
.auto-badge.off { background: rgba(255,255,255,0.06); color: var(--sub); }

/* 시스템 상태 */
.sys-list { display: flex; flex-direction: column; gap: 10px; }
.sys-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px;
}
.sys-left { display: flex; align-items: center; gap: 8px; }
.sys-val { font-size: 12px; font-weight: 600; }
.sys-val.ok { color: var(--emerald); }
.sys-val.err { color: var(--red); }
.sys-val.idle { color: var(--sub); }

/* 매수/청산 통계 */
.trade-counts {
  display: flex; gap: 0; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border);
  margin-top: 12px;
}
.trade-count-item {
  flex: 1; text-align: center; padding: 12px 8px;
  border-right: 1px solid var(--border);
}
.trade-count-item:last-child { border-right: none; }
.tc-num {
  font-size: 20px; font-weight: 700;
  font-family: monospace; line-height: 1;
}
.tc-label { font-size: 10px; color: var(--sub); margin-top: 4px; }

/* ══════════════════════════════════════════════════════════
   포지션 페이지
   ══════════════════════════════════════════════════════════ */
.pos-table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* 포지션 요약 바 */
.pos-summary-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 16px;
  font-size: 13px;
}
.pos-summary-bar > div { color: var(--sub-lt); }

/* 포지션 카드 그리드 */
.pos-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
@media (max-width: 600px) {
  .pos-cards-grid { grid-template-columns: 1fr; }
}

/* 개별 포지션 카드 */
.pos-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
  transition: border-color 0.15s;
}
.pos-card:hover { border-color: var(--border-med); }
.pos-card.stage-triggered { border-left: 3px solid var(--sub); }
.pos-card.stage-tp         { border-left: 3px solid var(--emerald); }
.pos-card.stage-ts         { border-left: 3px solid var(--amber); }
.pos-card.stage-quick      { border-left: 3px solid var(--violet); }

/* 카드 헤더 */
.pos-card-header {
  display: flex; align-items: center; justify-content: space-between;
}
.pos-ticker {
  font-size: 16px; font-weight: 700; letter-spacing: 0.5px;
}
.pos-days {
  font-size: 11px; color: var(--sub); background: rgba(255,255,255,0.05);
  padding: 2px 8px; border-radius: 10px;
}

/* 존구간 */
.pos-zone {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  padding: 10px 14px;
}
.pos-zone-label {
  font-size: 11px; color: var(--sub); font-weight: 500;
}
.pos-zone-val {
  font-size: 13px; font-weight: 700; font-family: monospace;
  color: var(--blue);
}

/* 가격 행 */
.pos-prices {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
}
.pos-price-item {
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px; padding: 8px 10px;
}
.pos-price-label {
  font-size: 10px; color: var(--sub); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px;
}
.pos-price-val {
  font-size: 13px; font-weight: 700; font-family: monospace;
}

/* 핵심 가격 태그들 */
.pos-key-prices {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.pos-kp {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px; padding: 6px 10px;
}
.pos-kp-label {
  font-size: 11px; color: var(--sub); white-space: nowrap;
}
.pos-kp-val {
  font-size: 12px; font-weight: 700; font-family: monospace;
}

/* 카드 푸터 */
.pos-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.pos-qty-info {
  font-size: 12px; color: var(--sub);
}

/* 새로고침 버튼/상태 */
.pos-refresh-bar {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  margin-bottom: 14px; font-size: 12px; color: var(--sub);
}
.pos-refresh-time { font-variant-numeric: tabular-nums; }

/* 기존 stage-pill 유지 (하위 호환) */
.stage-progress {
  display: flex; align-items: center; gap: 0;
}
.stage-pill {
  font-size: 10px; font-weight: 600;
  padding: 2px 8px;
  background: rgba(255,255,255,0.05);
  color: var(--sub);
  white-space: nowrap;
}
.stage-pill.done { background: var(--emerald-dim); color: var(--emerald); }
.stage-pill.curr { background: var(--violet-dim); color: var(--violet); }
.stage-arrow { color: var(--sub); font-size: 10px; padding: 0 2px; }

/* ══════════════════════════════════════════════════════════
   매매내역 페이지
   ══════════════════════════════════════════════════════════ */
.history-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.history-filters {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.filter-chip {
  font-size: 12px; font-weight: 500;
  padding: 4px 12px; border-radius: 20px;
  border: 1px solid var(--border-med);
  color: var(--sub-lt);
  cursor: pointer; transition: all 0.15s;
}
.filter-chip.active, .filter-chip:hover {
  background: var(--violet-dim); color: var(--violet);
  border-color: rgba(167,139,250,0.3);
}
/* 스캔 필터 칩 — 동일 스타일 */
.scan-filter-chip {
  font-size: 12px; font-weight: 500;
  padding: 5px 14px; border-radius: 20px;
  border: 1px solid var(--border-med);
  color: var(--sub-lt);
  cursor: pointer; transition: all 0.15s;
  background: transparent;
}
.scan-filter-chip.active, .scan-filter-chip:hover {
  background: var(--violet-dim); color: var(--violet);
  border-color: rgba(167,139,250,0.3);
}
.scan-filter-chip b { font-weight: 700; }

/* ══════════════════════════════════════════════════════════
   백테스트 페이지
   ══════════════════════════════════════════════════════════ */
.backtest-form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.backtest-status-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04);
  font-size: 13px;
  margin-top: 12px;
}
.bt-running-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--amber);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ══════════════════════════════════════════════════════════
   설정 페이지
   ══════════════════════════════════════════════════════════ */
.settings-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: start;
}
.settings-nav {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: sticky;
  top: 0;
}
.settings-nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px;
  font-size: 13px; font-weight: 500;
  color: var(--sub-lt);
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: all 0.15s;
}
.settings-nav-item:last-child { border-bottom: none; }
.settings-nav-item:hover { background: var(--card-hover); color: var(--text); }
.settings-nav-item.active { color: var(--violet); background: var(--violet-dim); }
.settings-nav-item svg { width: 14px; height: 14px; }

.settings-section { display: none; }
.settings-section.active { display: block; }

.settings-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.settings-card-title {
  font-size: 14px; font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* ══════════════════════════════════════════════════════════
   인증 페이지 (login / register)
   ══════════════════════════════════════════════════════════ */
.auth-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-container { width: 100%; max-width: 400px; }
.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--violet), var(--violet-dark));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  box-shadow: 0 0 32px rgba(124,58,237,0.4);
}
.auth-logo-icon svg { width: 26px; height: 26px; }
.auth-logo-title {
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
}
.auth-logo-sub { font-size: 13px; color: var(--sub); margin-top: 4px; }

.auth-card {
  background: var(--card);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-lg);
  padding: 32px;
  position: relative;
  overflow: hidden;
}
.auth-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--violet), var(--violet-dark));
}
.auth-card-title {
  font-size: 18px; font-weight: 700;
  margin-bottom: 6px;
}
.auth-card-sub {
  font-size: 13px; color: var(--sub);
  margin-bottom: 28px;
}

.auth-form-group { margin-bottom: 16px; }
.auth-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--sub-lt); margin-bottom: 6px;
}
.auth-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text); font-size: 14px; outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.auth-input:focus {
  border-color: var(--violet);
  background: rgba(167,139,250,0.06);
}
.auth-input::placeholder { color: var(--sub); }

.auth-btn {
  width: 100%; padding: 12px;
  background: linear-gradient(135deg, var(--violet), var(--violet-dark));
  color: #fff; border: none;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 700;
  cursor: pointer; margin-top: 8px;
  transition: all 0.2s;
  box-shadow: 0 0 24px rgba(124,58,237,0.3);
}
.auth-btn:hover { filter: brightness(1.1); box-shadow: 0 0 32px rgba(124,58,237,0.5); }
.auth-btn:active { transform: scale(0.98); }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-error {
  background: var(--red-dim); border: 1px solid rgba(248,113,113,0.2);
  color: var(--red); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px;
  margin-bottom: 16px; display: none;
}
.auth-error.show { display: block; }

.auth-success {
  background: var(--emerald-dim); border: 1px solid rgba(52,211,153,0.2);
  color: var(--emerald); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px;
  margin-bottom: 16px; display: none;
}
.auth-success.show { display: block; }

.auth-footer {
  text-align: center; margin-top: 20px;
  font-size: 13px; color: var(--sub);
}
.auth-footer a { color: var(--violet); font-weight: 600; }
.auth-footer a:hover { text-decoration: underline; }

.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0; color: var(--sub); font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

/* ══════════════════════════════════════════════════════════
   어드민 페이지
   ══════════════════════════════════════════════════════════ */
.admin-stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 24px;
}
.admin-stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.admin-stat-num {
  font-size: 28px; font-weight: 700;
  font-family: monospace; color: var(--violet);
}
.admin-stat-label { font-size: 12px; color: var(--sub); margin-top: 4px; }

.user-table-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.user-table-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.user-table-title { font-size: 14px; font-weight: 600; }

.role-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.role-admin { background: var(--violet-dim); color: var(--violet); }
.role-user { background: var(--emerald-dim); color: var(--emerald); }
.role-pending { background: var(--amber-dim); color: var(--amber); }
.role-rejected { background: var(--red-dim); color: var(--red); }

/* ══════════════════════════════════════════════════════════
   반응형 (모바일)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .admin-stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .mobile-topbar { display: flex; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 20;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }

  #app { flex-direction: column; }
  .main-content { overflow-y: auto; }

  .page-header { padding: 16px 16px 0; }
  .page-body { padding: 16px; }
  .page-title { font-size: 18px; }

  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .metric-value { font-size: 20px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr; }
  .admin-stats-row { grid-template-columns: 1fr 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; display: flex; overflow-x: auto; }
  .settings-nav-item { border-bottom: none; border-right: 1px solid var(--border); flex-shrink: 0; }

  .page-body { padding: 12px; }
  .card { padding: 16px; }
  .metric-card { padding: 14px 16px; }
  .chart-canvas-wrap { height: 150px; }

  .toast { bottom: 16px; right: 16px; left: 16px; max-width: none; }
}

@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .admin-stats-row { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 20px; }
}
