:root {
  --bg: #080b10;
  --surface: #0d1117;
  --surface2: #131920;
  --border: #1e2a38;
  --accent: #00e5a0;
  --accent2: #0088ff;
  --danger: #ff3b5c;
  --warn: #ffb800;
  --text: #e8edf3;
  --muted: #5a6a7e;
  --light-slate: #707070;
  --green: #00d68f;
  --red: #ff3b5c;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Scanline overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,229,160,0.015) 2px,
    rgba(0,229,160,0.015) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* Layout */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  max-width: 1320px;
  margin: 0 auto;
  box-shadow: 0 0 0 1px var(--border);
}

/* Header */
header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 20px;
}

.logo {
  font-family: 'Syne', sans-serif;
  font-size:20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(0,229,160,0.4);
}

.logo span { color: var(--text); }

.version-badge {
  font-family: 'DM Mono', monospace;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0 5px;
  line-height: 1.4;
  white-space: nowrap;
  margin-left: -16px;
  transform: translateY(-10px);
  box-shadow: 0 0 6px rgba(0,229,160,0.25);
}

.app-tagline {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  margin-left: 4px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--muted);
}

.pulse {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: pulse 2s ease infinite;
}
.pulse.inactive { background: var(--muted); box-shadow: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.header-time {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--accent);
  padding: 4px 12px;
  border: 1px solid rgba(0,229,160,0.2);
  border-radius: 4px;
  background: rgba(0,229,160,0.05);
}

/* Sidebar */
nav {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-label {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
  padding: 8px 12px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav-item.active {
  background: rgba(0,229,160,0.08);
  color: var(--accent);
  border-color: rgba(0,229,160,0.15);
}

.nav-item svg { flex-shrink: 0; }

.nav-item span { font-size: 13px; font-weight: 500; }

/* Main content */
main {
  overflow-y: auto;
  background: var(--bg);
}

/* Pages */
.page { display: none; padding: 24px; }
.page.active { display: block; }

/* Page title */
.page-title {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.page-desc {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 24px;
}

/* Market Closed Banner */
.market-closed-banner {
  display: none;
  align-items: center;
  gap: 14px;
  background: rgba(255, 184, 0, 0.07);
  border: 1px solid rgba(255, 184, 0, 0.28);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 20px;
  color: var(--warn);
}
.market-closed-banner svg { flex-shrink: 0; opacity: 0.9; }
.market-closed-banner-title {
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}
.market-closed-banner-sub {
  font-size: 11px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

/* Backtest data notice */
.bt-notice {
  border-radius: 8px;
  padding: 13px 18px;
  margin-bottom: 16px;
  font-size: 12px;
  line-height: 1.6;
}
.bt-notice-warn {
  background: rgba(255, 59, 92, 0.07);
  border: 1px solid rgba(255, 59, 92, 0.3);
  color: var(--red);
}
.bt-notice-info {
  background: rgba(0, 136, 255, 0.07);
  border: 1px solid rgba(0, 136, 255, 0.28);
  color: var(--accent2);
}
.bt-notice strong { font-weight: 600; }
.bt-notice-sub {
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  margin-top: 2px;
  display: block;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

/* Grid layouts */
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 16px; }
.grid-1 { display: grid; grid-template-columns: repeat(1, 1fr); gap: 16px; margin-bottom: 16px; }

/* Stat cards */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.6;
}

.stat-card.red::before { background: var(--red); }
.stat-card.blue::before { background: var(--accent2); }
.stat-card.warn::before { background: var(--warn); }

.stat-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.blue { color: var(--accent2); }
.stat-value.warn { color: var(--warn); }
.stat-sub.red { color: var(--red); }
.stat-sub.blue { color: var(--accent2); }

.stat-sub {
  font-size: 11px;
  color: var(--muted);
}

/* Table */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-weight: 400;
}

td {
  padding: 12px 12px;
  border-bottom: 1px solid rgba(30,42,56,0.5);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: rgba(255,255,255,0.02); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-family: 'DM Mono', monospace;
  font-weight: 500;
  white-space: nowrap;
}

.badge-green { background: rgba(0,214,143,0.1); color: var(--green); border: 1px solid rgba(0,214,143,0.2); }
.badge-red { background: rgba(255,59,92,0.1); color: var(--red); border: 1px solid rgba(255,59,92,0.2); }
.badge-profit { background: rgba(255,59,92,0.1); color: var(--red); border: 1px solid rgba(255,59,92,0.2); }
.badge-loss { background: rgba(0,136,255,0.1); color: var(--accent2); border: 1px solid rgba(0,136,255,0.2); }
.badge-blue { background: rgba(0,136,255,0.1); color: var(--accent2); border: 1px solid rgba(0,136,255,0.2); }
.badge-warn { background: rgba(255,184,0,0.1); color: var(--warn); border: 1px solid rgba(255,184,0,0.2); }
.badge-gray { background: rgba(255,255,255,0.05); color: var(--muted); border: 1px solid rgba(255,255,255,0.1); }
.badge-muted { background: rgba(90,106,126,0.1); color: var(--muted); border: 1px solid rgba(90,106,126,0.2); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  font-family: 'Noto Sans KR', sans-serif;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover { background: #00ffb5; transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(255,59,92,0.3);
}
.btn-danger:hover { background: rgba(255,59,92,0.1); }
.btn-danger:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-sm { padding: 5px 10px; font-size: 11px; }
.vb-run-tab { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.vb-run-tab.active { background: rgba(0,255,163,0.12); color: var(--accent); border-color: var(--accent); }
.btn-xs { padding: 3px 8px; font-size: 10px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.5px;
}

.form-input, .form-select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Noto Sans KR', sans-serif;
  outline: none;
  transition: border-color 0.15s;
  color-scheme: dark;
}

.form-input:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,229,160,0.08);
}

.form-select option { background: var(--surface); }

/* Progress bar */
.progress-wrap {
  background: var(--bg);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 1s ease;
}

.progress-bar.red { background: var(--red); }
.progress-bar.warn { background: var(--warn); }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 600px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal-close {
  position: absolute;
  top: 20px; right: 20px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== Wizard Steps ===== */
.wizard-steps { display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.wizard-step { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-family: 'DM Mono', monospace; font-weight: 500; background: var(--surface); border: 1px solid var(--border); color: var(--muted); transition: all 0.2s; flex-shrink: 0; }
.wizard-step.active { background: var(--accent); color: #0a1628; border-color: var(--accent); }
.wizard-step.done { background: rgba(0,229,160,0.15); color: var(--accent); border-color: rgba(0,229,160,0.4); }
.wizard-step-line { flex: 1; height: 1px; background: var(--border); max-width: 56px; margin: 0 6px; }
.wizard-step-labels { display: flex; justify-content: space-around; margin-bottom: 20px; }
.wizard-step-label { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--muted); flex: 1; text-align: center; }
.wizard-step-label.active { color: var(--text); }

/* ===== Strategy Cards ===== */
.strategy-card-grid { display: flex; flex-direction: column; gap: 10px; }
.strategy-card { border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; cursor: pointer; transition: border-color 0.15s, background 0.15s; display: flex; gap: 14px; align-items: flex-start; }
.strategy-card:hover { border-color: rgba(0,229,160,0.4); background: rgba(0,229,160,0.03); }
.strategy-card.selected { border-color: var(--accent); background: rgba(0,229,160,0.07); }
.strategy-card-icon { font-size: 26px; line-height: 1; flex-shrink: 0; margin-top: 1px; }
.strategy-card-name { font-family: 'Syne', sans-serif; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.strategy-card-desc { font-size: 11px; color: var(--muted); line-height: 1.55; margin-bottom: 10px; }
.strategy-card-metrics { display: flex; flex-wrap: wrap; gap: 6px; }
.strategy-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 9px;
  min-width: 64px;
}
.strategy-metric-label {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.strategy-metric-value {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 600;
}
/* Setup 탭 (실시간 모니터 / 거래 이력) */
.tab-bar { display: flex; gap: 6px; flex-wrap: wrap; }
.tab-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.tab-btn:hover { border-color: var(--accent); color: var(--text); }
.tab-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(0,229,160,0.07); }

.strategy-metric-value.metric-good   { color: var(--green); }
.strategy-metric-value.metric-warn   { color: var(--warn); }
.strategy-metric-value.metric-muted  { color: var(--muted); }
.strategy-metric-value.metric-accent { color: var(--accent); }
.strategy-metric-value.metric-blue   { color: var(--blue); }
.strategy-metric-value.metric-red    { color: var(--red); }

/* ===== Account Cards ===== */
.account-card-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.account-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; cursor: pointer; transition: border-color 0.15s, background 0.15s; display: flex; justify-content: space-between; align-items: center; }
.account-card:hover { border-color: rgba(0,229,160,0.4); }
.account-card.selected { border-color: var(--accent); background: rgba(0,229,160,0.07); }

/* ===== Account Dropdown ===== */
.acc-dd { position: relative; }
.acc-dd-trigger { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; cursor: pointer; transition: border-color 0.15s, background 0.15s; background: var(--card-bg); }
.acc-dd-trigger:hover { border-color: rgba(0,229,160,0.4); }
.acc-dd.open .acc-dd-trigger { border-color: var(--accent); }
.acc-dd-trigger > .acc-dd-content { flex: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-width: 0; }
.acc-dd-trigger > .acc-dd-placeholder { flex: 1; color: var(--muted); font-size: 13px; }
.acc-dd-caret { flex-shrink: 0; color: var(--muted); transition: transform 0.15s; }
.acc-dd.open .acc-dd-caret { transform: rotate(180deg); }
/* 패널은 absolute 오버레이가 아니라 in-flow 로 펼친다. absolute + 모달 overflow-y:auto
   조합에서 패널 하단이 잘리는 문제를 근본 차단 — 열리면 아래 내용을 밀어내고 모달이
   자연히 늘어나 overflow-y 스크롤로 모달/뷰포트 크기와 무관하게 항상 전체가 보인다. */
.acc-dd-panel { position: static; margin-top: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px; display: none; }
.acc-dd.open .acc-dd-panel { display: block; }
.acc-dd-panel .account-card { margin-bottom: 6px; }
.acc-dd-panel .account-card:last-child { margin-bottom: 0; }
/* 전략 선택 드롭다운 (acc-dd 인프라 재사용, 카드 모양 유지) */
.acc-dd-panel .strategy-card { margin-bottom: 6px; }
.acc-dd-panel .strategy-card:last-child { margin-bottom: 0; }
.acc-dd-trigger > .strategy-card-trigger { flex: 1; display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.acc-dd-trigger > .strategy-card-trigger .strategy-card-desc { margin-bottom: 8px; }

/* ===== Field Tooltip ===== */
.field-label-wrap { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.field-label-wrap .form-label { margin-bottom: 0; }
.tip-btn { background: none; border: 1px solid var(--border); border-radius: 50%; width: 16px; height: 16px; font-size: 9px; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; transition: border-color 0.15s, color 0.15s; padding: 0; line-height: 1; }
.tip-btn:hover { border-color: var(--accent); color: var(--accent); }
#field-tip { position: fixed; z-index: 9999; max-width: 260px; background: var(--surface); border: 1px solid rgba(0,229,160,0.3); border-radius: 8px; padding: 10px 12px; font-size: 12px; color: var(--text); line-height: 1.55; box-shadow: 0 4px 20px rgba(0,0,0,0.35); display: none; }
#field-tip.visible { display: block; }

/* Ticker animation */
.ticker-wrap {
  background: rgba(0,229,160,0.04);
  border: 1px solid rgba(0,229,160,0.1);
  border-radius: 8px;
  padding: 10px 16px;
  overflow: hidden;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ticker-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px;
  flex-shrink: 0;
  border-right: 1px solid rgba(0,229,160,0.2);
  padding-right: 12px;
}

.ticker-scroll {
  display: flex;
  width: max-content;
  gap: 32px;
  animation: ticker 30s linear infinite;
  white-space: nowrap;
}

@keyframes ticker {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
}
.ticker-item.holding {
  background: rgba(0,229,160,0.1);
  padding: 2px 8px;
  border-radius: 4px;
}
.t-badge {
  font-size: 9px;
  padding: 1px 4px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 3px;
  font-weight: 700;
}

.ticker-item .t-name { color: var(--text); }
.ticker-item .t-price { color: var(--muted); }
.ticker-item .t-change.up { color: var(--red); }
.ticker-item .t-change.dn { color: var(--accent2); }

/* Chart placeholder */
.chart-area {
  height: 160px;
  position: relative;
  overflow: hidden;
}

.chart-svg { width: 100%; height: 100%; }

/* Monitor positions */
.position-row {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}

.position-row::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 3px;
  background: var(--accent);
}

.position-row.loss::before { background: var(--accent2); }

.pos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.pos-name {
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 600;
}

.pos-code {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--muted);
}

.pos-rate {
  font-family: 'Syne', sans-serif;
  font-size: 20px;
  font-weight: 700;
}

.pos-rate.up { color: var(--red); }
.pos-rate.dn { color: var(--accent2); }

.pos-range {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--muted);
}

.range-bar-wrap {
  flex: 1;
  height: 4px;
  background: var(--bg);
  border-radius: 4px;
  position: relative;
  overflow: visible;
}

.range-bar-fill {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 4px;
}

.range-sl { left: 0; width: 20%; background: rgba(255,59,92,0.3); }
.range-tp { right: 0; width: 20%; background: rgba(0,214,143,0.3); }

.range-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

/* Toggle */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle {
  width: 40px; height: 22px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 11px;
  position: relative;
  transition: all 0.2s;
}

.toggle.on {
  background: rgba(0,229,160,0.15);
  border-color: var(--accent);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: all 0.2s;
}

.toggle.on::after {
  left: 21px;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

/* Notification */
.notif {
  position: fixed;
  bottom: 24px;
  right: max(24px, calc((100vw - 1320px) / 2 + 24px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 2000;
  max-width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.notif.show {
  transform: translateY(0);
  opacity: 1;
}

.notif-icon { font-size: 18px; }

/* Data view table */
.data-rank {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

.data-rank.top { color: var(--warn); }

.change-pill {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
}
.change-pill.up { background: rgba(255,59,92,0.1); color: var(--red); }
.change-pill.dn { background: rgba(0,136,255,0.1); color: var(--accent2); }

/* Credential card */
.cred-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 12px;
  position: relative;
}

.cred-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cred-id {
  font-family: 'DM Mono', monospace;
  font-size: 16px;
  color: var(--accent);
}

.cred-actions { display: flex; gap: 8px; }

.cred-fields {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.cred-field-label {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 3px;
}

.cred-field-value {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--text);
}

.secret-mask {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 2px;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  width: fit-content;
}

.tab {
  padding: 7px 16px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.15s;
  border: none;
  background: none;
  font-family: 'Noto Sans KR', sans-serif;
}

.tab.active {
  background: var(--surface2);
  color: var(--accent);
  border: 1px solid rgba(0,229,160,0.15);
}

/* Empty state */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-title { font-family: 'Syne', sans-serif; font-size: 16px; margin-bottom: 8px; color: var(--text); }

/* Log entries */
.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(30,42,56,0.5);
  font-size: 11px;
}

.log-time {
  font-family: 'DM Mono', monospace;
  color: var(--muted);
  flex-shrink: 0;
  width: 75px;
}

.log-type {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-top: 1px;
}

.log-type.buy { background: var(--accent2); }
.log-type.sell-profit { background: var(--red); }
.log-type.sell-loss { background: var(--accent2); }
.log-type.info { background: var(--muted); }
.log-type.warn { background: var(--warn); }

/* 전역 스크롤바 숨김 (스크롤 기능은 유지) */
* {
  scrollbar-width: none;       /* Firefox */
  -ms-overflow-style: none;    /* IE / Edge legacy */
}
*::-webkit-scrollbar { display: none; }  /* Chrome / Safari */

.scrollable { max-height: 280px; overflow-y: auto; }

/* Section header divider */
.section-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 28px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}

.section-desc {
  font-size: 11px;
  color: var(--muted);
}

/* Setup status cards */
#setup-status-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 12px; }

/* Setup pagination */
#setup-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 24px;
}

.setup-page-btn {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.setup-page-btn:hover { background: var(--surface2); }
.setup-page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.setup-page-btn:disabled { opacity: 0.35; cursor: default; }

.setup-status-card { padding: 16px 20px; }

.setup-status-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.setup-status-name {
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 700;
  flex: 1;
}

/* 주요 지표 3개 */
.setup-status-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.setup-stat {
  padding: 0 16px;
  border-right: 1px solid var(--border);
}
.setup-stat:first-child { padding-left: 0; }
.setup-stat:last-child  { padding-right: 0; border-right: none; }

.setup-stat-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.setup-stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.setup-stat-sub {
  font-size: 11px;
  color: var(--muted);
}

/* 설정값 요약 줄 */
.setup-status-config {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

/* System status panel */
.sys-panel {
  margin: 16px 12px 0;
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.sys-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--muted);
}

.sys-row:last-child { margin-bottom: 0; }

.sys-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

.sys-dot.ok { background: var(--green); box-shadow: 0 0 4px var(--green); }
.sys-dot.err { background: var(--red); }

/* ── Setup Wizard ── */
.setup-step {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.setup-step:last-of-type { border-bottom: none; }
.setup-step-indicator {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  transition: all .2s;
}
.setup-step-indicator.done {
  background: rgba(0,229,160,.15);
  border-color: rgba(0,229,160,.4);
  color: var(--accent);
}
.setup-step-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.setup-step-desc  { font-size: 12px; color: var(--muted); }

/* ===== RESPONSIVE — Bootstrap 5.3 breakpoints ===== */

/* 모바일 전용 요소 - 데스크톱에서 숨김 */
.mobile-nav { display: none; }
.nav-toggle { display: none; }
.nav-overlay { display: none; }
/* 테이블 모바일 전용 변형(등락률만/구분배지/손익 2번째줄/헤더 라벨) — 데스크톱 숨김 */
.td-day-mobile, .td-exit-mobile, .td-pnl-mobile, .th-m { display: none; }

/* ── lg 미만 (< 992px): 태블릿 — 아이콘 전용 사이드바 ── */
@media (max-width: 991.98px) {
  .app { grid-template-columns: 60px 1fr; }

  nav {
    width: 60px;
    overflow: visible;
  }

  .nav-label { display: none; }
  .nav-section { padding: 0 6px; }

  .nav-item {
    padding: 10px;
    justify-content: center;
    gap: 0;
    position: relative;
  }

  .nav-item span { display: none; }

  /* 아이콘 hover 툴팁 */
  .nav-item::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 11px;
    color: var(--text);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 900;
  }

  .nav-item:hover::after { opacity: 1; }

  /* 시스템 패널 숨김 (공간 부족) */
  .sys-panel { display: none; }

  /* 그리드 조정 */
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  /* 전략카드 통계(계좌잔고·누적수익률·오늘실현손익)는 태블릿에서도 한 줄 3열 유지 */
  .grid-3.setup-stats { grid-template-columns: repeat(3, 1fr); }

  /* app-tagline 은 데스크톱(≥992px)에서만 표시 */
  .app-tagline { display: none; }
}

/* ── md 미만 (< 768px): 모바일 — 오프캔버스 사이드바 ── */
@media (max-width: 767.98px) {
  /* 레이아웃: 사이드바 제거, 하단 네비 추가 */
  /* minmax(0,1fr): 트랙이 헤더 등 자식의 min-content 폭으로 확장되는 것을 막아
     콘텐츠가 뷰포트(device-width)보다 넓어져 모바일 브라우저가 줌아웃되는 현상 방지 */
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 52px 1fr;
  }

  /* grid item 들이 내부 콘텐츠 때문에 트랙을 넘어 늘어나지 않도록 */
  header, main, .app > nav { min-width: 0; }

  /* 사이드바 - 오프캔버스 드로어 */
  .app > nav {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    width: 220px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 800;
    overflow-y: auto;
    overflow-x: visible;
  }

  .app > nav.nav-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  /* lg에서 숨겼던 nav 요소 복원 */
  .nav-label { display: block; }
  .nav-section { padding: 0 12px; }
  .nav-item { padding: 10px 12px; justify-content: flex-start; gap: 10px; }
  .nav-item span { display: inline; }
  .nav-item::after { display: none; }

  /* 오버레이 */
  .nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 799;
  }

  .nav-overlay.nav-open { display: block; }

  /* 햄버거 버튼 */
  .nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    padding: 6px;
    cursor: pointer;
    flex-shrink: 0;
  }

  /* sys-status 텍스트 숨김 */
  #sys-status { display: none; }

  /* 하단 네비 */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 56px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 500;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    color: var(--muted);
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    transition: color 0.15s;
  }

  .mobile-nav-item.active { color: var(--accent); }
  .mobile-nav-item svg { width: 18px; height: 18px; }

  /* 헤더 간소화 — nowrap 콘텐츠가 헤더 폭을 device-width 너머로 밀어내지 않도록 정리 */
  header { padding: 0 10px; gap: 7px; overflow: hidden; }
  /* 로그아웃 버튼 패딩 축소 */
  header > div:last-child > button:last-of-type { padding: 4px 7px; }
  /* (app-tagline 숨김은 ≤991.98px 태블릿 블록에서 처리 — 데스크톱 전용 표시) */
  /* 로고 축소로 우측 공간 확보 */
  .logo { font-size: 17px; }
  /* 우측 상태블록: 간격 축소 + 사용자명 텍스트 숨김(아이콘만) */
  header > div:last-child { gap: 8px !important; margin-left: auto; min-width: 0; }
  /* 연결 상태 표시(펄스+CONNECTING) — sys-status 텍스트는 이미 숨김, 모바일선 점도 생략 */
  header > div:last-child > div:first-child { display: none !important; }
  #header-username { display: none; }
  /* 시계 표시는 모바일에서 숨김 */
  .header-time { display: none; }

  /* 페이지 패딩 (하단 네비 높이만큼 여백) */
  .page { padding: 14px 14px 70px; }

  /* 그리드 조정 */
  .grid-5 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-3 { grid-template-columns: 1fr; gap: 10px; }
  .grid-2 { grid-template-columns: 1fr; gap: 10px; }

  /* Stat 값 크기 축소 */
  .stat-value { font-size: 22px; }

  /* Credential 카드 — 모바일은 주요정보만(예수금·총평가금액·주문가능금액 한 줄).
     계좌번호(cano)·HTS ID 배지·부가필드·APP Key/Secret 행은 숨김 */
  .cred-fields { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .cred-field-sec { display: none !important; }  /* 상품코드·신청일·만료일·순자산·계좌번호(cano) */
  .cred-hts-badge { display: none !important; }  /* HTS ID 배지 */
  .cred-secret-row { display: none !important; }
  /* 헤더: ID·배지·액션버튼을 한 줄로 */
  .cred-header { flex-wrap: nowrap; gap: 8px; align-items: center; }
  .cred-actions { flex-wrap: nowrap; gap: 6px; }
  .cred-id { font-size: 13px; }

  /* 휴장 배너 — 모바일은 제목만, 보조설명("자동 거래가 중지됩니다 …") 숨김 */
  .market-closed-banner-sub { display: none; }

  /* 대시보드 지수 — 모바일은 KOSDAQ 박스 숨김(KOSPI만 표시). 인라인 display 덮어쓰기 */
  .dash-index-kosdaq { display: none !important; }

  /* Setup(전략) 카드 — 모바일은 주요정보만. 파라미터 요약 줄 숨김 */
  .setup-params-summary { display: none !important; }
  /* 통계 3박스(계좌잔고·누적수익률·오늘실현손익)를 한 줄로 */
  .grid-3.setup-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .setup-stats .setup-box { padding: 8px 8px; }
  /* 각 박스는 라벨(1줄)+값(2줄)까지만, 이하 서브라인 숨김 */
  .setup-stats .setup-box > div:nth-child(2) { font-size: 13px !important; }
  .setup-stats .setup-box > div:nth-child(n+3) { display: none !important; }

  /* Setup 카드 1열 */
  #setup-status-list { grid-template-columns: 1fr; }

  /* 탭 가로 스크롤 */
  .tabs { overflow-x: auto; width: 100%; }

  /* 테이블(거래이력·실시간 모니터): 모바일은 2열 — 종목 / 수익률·손익(2줄).
     날짜·매수가·매도가·수량·손익·구분 열은 col-mobile-hide 로 숨기고,
     구분(익절/손절)은 종목 셀로, 손익은 수익률 셀 2번째 줄로 합침 */
  /* table-layout:auto + 종목 col width:100% — 빈 행(colspan) 시 유령 컬럼이 생겨도
     종목 열이 남은 폭을 모두 차지해 좌측 쏠림 없이 항상 동일 폭 유지 */
  .table-wrap table { min-width: 0; width: 100%; }
  .col-mobile-hide { display: none !important; }
  .table-wrap th, .table-wrap td { padding: 8px 8px; vertical-align: top; }
  /* 종목 열: 남은 폭 모두 차지(greedy) + 줄바꿈 허용 */
  .col-stock { width: 100%; white-space: normal; word-break: keep-all; }
  /* 종목 셀 변형: 시가/종가 숨김·당일 등락률만, 구분(익절/손절) 배지 인라인 */
  .td-day-full { display: none !important; }  /* 인라인 display:block 덮어쓰기 */
  .td-day-mobile { display: block; }
  .td-exit-mobile { display: inline-flex; vertical-align: middle; }
  /* 수익률+손익 합친 열: 고정폭·우측정렬·2줄(수익률/손익) */
  .th-d { display: none; }
  .th-m { display: inline; }
  .td-ratepnl { width: 96px; white-space: nowrap; text-align: right; }
  /* 손익(위)·수익률(아래) 모두 우측 끝 정렬로 일치 — 수익률은 배지 배경/패딩 제거한 plain 텍스트 */
  .td-pnl-mobile { display: block; font-weight: 700; }
  .td-ratepnl .change-pill { display: block; background: none; padding: 0; margin-top: 2px; font-size: 11px; }

  /* 버튼 라벨이 좁은 폭에서 글자 단위로 줄바꿈되지 않도록 */
  .btn { white-space: nowrap; }
  /* 거래 날짜 필터: 고정 160px input 을 유연하게 — 버튼이 밀려 줄바꿈되는 것 방지 */
  #trades-date-filter { width: auto !important; flex: 1 1 80px; min-width: 0; }

  /* 모달 */
  .modal {
    width: 100%;
    max-width: 98vw;
    max-height: 92vh;
    padding: 20px 16px;
    border-radius: 12px;
  }

  /* 섹션 헤더 간격 */
  .section-header { margin: 20px 0 12px; }

  /* secret mask 축소 */
  .secret-mask { letter-spacing: 0; max-width: 72px; }

  /* 알림 토스트 */
  .notif { right: 12px; bottom: 68px; max-width: 90vw; }
}

/* ── sm 미만 (< 576px): 소형 폰 ── */
@media (max-width: 575.98px) {
  .page { padding: 12px 10px 70px; }

  .stat-card { padding: 14px; }
  .stat-value { font-size: 20px; }
  .page-title { font-size: 18px; }

  /* Credential 카드 필드 — 소형폰도 예수금·총평가금액·주문가능금액 한 줄(3열) 유지 */
  .cred-fields { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .cred-field-value { font-size: 11px; }
  .cred-field-label { font-size: 8px; letter-spacing: 0.5px; }

  /* 모달 패딩 최소화 */
  .modal { padding: 16px 12px; }

  /* 알림 토스트 전체 너비 */
  .notif { right: 8px; left: 8px; max-width: 100%; }
}

.sys-dot.warn { background: var(--warn); }
