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

/* ── Backtest ── */
.bt-settings {
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); margin: 12px; border-radius: var(--radius);
  border: 1px solid var(--border);
}
.bt-row { display: flex; gap: 10px; align-items: flex-start; }
.bt-row .form-group { flex: 1; }
.bt-summary {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 12px; margin: 0 12px;
}
.bt-stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; text-align: center;
}
.bt-stat .bt-stat-label { font-size: 11px; color: var(--text2); margin-bottom: 4px; }
.bt-stat .bt-stat-value { font-size: 20px; font-weight: 700; }
.bt-chart-wrap { margin: 12px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.bt-trades-title { padding: 12px 12px 6px; font-size: 13px; font-weight: 600; color: var(--text2); }
#bt-trades-wrap { margin: 0 12px 80px; border-radius: var(--radius); overflow: auto; border: 1px solid var(--border); }
#bt-trades-wrap table { min-width: 700px; }
#bt-trades-wrap th, #bt-trades-wrap td { white-space: nowrap; }

/* ── Login Screen ── */
.login-screen {
  position: fixed; inset: 0; background: #0a0e1a;
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.login-screen.hidden { display: none; }
.login-box {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 40px 32px; width: 100%; max-width: 320px;
}
.login-title {
  font-size: 28px; font-weight: 800; letter-spacing: 0.1em;
  background: linear-gradient(120deg, #00ff88, #00d4ff 50%, #6c63ff);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-sub { font-size: 12px; color: #4a5568; letter-spacing: 0.2em; margin-top: -8px; }
.btn-google {
  display: flex; align-items: center; gap: 10px;
  background: #fff; color: #1f1f1f; border: none; border-radius: 8px;
  padding: 12px 20px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; margin-top: 8px;
  width: 100%; justify-content: center;
  transition: opacity 0.15s;
}
.btn-google:active { opacity: 0.85; }
.login-error {
  color: #ef4444; font-size: 13px; text-align: center;
}
.login-error.hidden { display: none; }

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #263349;
  --border: #334155;
  --text: #f1f5f9;
  --text2: #94a3b8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --blue: #3b82f6;
  --purple: #a855f7;
  --accent: #38bdf8;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; }

#app { max-width: 480px; margin: 0 auto; padding-bottom: calc(80px + var(--safe-bottom)); }

/* ── Header ── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; position: sticky; top: 0; z-index: 10;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.header-title { display: flex; align-items: center; gap: 8px; }
.logo { font-size: 20px; }
.header h1 { font-size: 18px; font-weight: 700; }
.header-actions { display: flex; gap: 8px; }
.btn-icon {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; width: 36px; height: 36px;
  font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.btn-icon:active { opacity: 0.7; }

/* 헤더 계정 아바타 버튼 */
.account-avatar-btn { overflow: hidden; border-radius: 50%; padding: 0; }
.account-avatar-btn.has-avatar { border-color: var(--accent); }
.header-avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.btn-outline {
  background: transparent; border: 1px solid var(--accent); color: var(--accent);
  border-radius: 10px; padding: 13px; font-size: 15px; font-weight: 700;
  cursor: pointer;
}
.btn-outline:active { opacity: 0.8; }

/* ── Signal Card ── */
.signal-card {
  margin: 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  padding: 16px; min-height: 100px;
}
.signal-loading { color: var(--text2); text-align: center; padding: 24px 0; }

.signal-inner { display: flex; flex-direction: column; gap: 8px; }
.signal-top { display: flex; justify-content: space-between; align-items: flex-start; }
.signal-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 700;
}
.badge-buy { background: rgba(34,197,94,0.15); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.badge-sell { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.badge-hold { background: rgba(148,163,184,0.1); color: var(--text2); border: 1px solid var(--border); }
.badge-warn { background: rgba(234,179,8,0.15); color: var(--yellow); border: 1px solid rgba(234,179,8,0.3); }
.badge-kill { background: rgba(239,68,68,0.25); color: var(--red); border: 1px solid var(--red); }

.signal-time { font-size: 11px; color: var(--text2); }
.signal-detail { font-size: 13px; color: var(--text2); line-height: 1.5; }
.signal-weight { font-size: 22px; font-weight: 800; color: var(--text); }
.signal-weight span { font-size: 14px; font-weight: 400; color: var(--text2); margin-left: 4px; }

/* ── Metrics Grid ── */
.metrics-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin: 0 12px 12px;
}
.metric-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 10px;
}
.metric-label { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.metric-value { font-size: 16px; font-weight: 700; }
.metric-sub { font-size: 10px; color: var(--text2); margin-top: 2px; }
.val-up { color: var(--green); }
.val-down { color: var(--red); }
.val-warn { color: var(--yellow); }
.val-neutral { color: var(--text); }
.val-realtime { color: var(--accent); }

/* ── Tabs ── */
.tab-bar {
  display: flex; align-items: center; border-bottom: 1px solid var(--border);
  margin: 0 12px; gap: 2px; flex-wrap: nowrap;
}
.tab {
  background: none; border: none; color: var(--text2);
  padding: 10px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; flex-shrink: 0;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-action-btn {
  margin-left: auto;
  padding: 6px 10px;
  background: linear-gradient(120deg, #00ff88, #00d4ff);
  color: #0f172a; border: none; border-radius: 8px;
  font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: opacity 0.15s, transform 0.05s;
}
.tab-action-btn:hover { opacity: 0.9; }
.tab-action-btn:active { transform: scale(0.96); }
.tab-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.tab-content { display: none; margin: 12px; }
.tab-content.active { display: block; }

/* ── Chart ── */
.chart-controls {
  display: flex; gap: 12px; margin-bottom: 8px;
  align-items: center; flex-wrap: wrap;
}
.period-toggle {
  display: inline-flex; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden;
}
.period-btn {
  background: none; border: none; color: var(--text2);
  padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.period-btn + .period-btn { border-left: 1px solid var(--border); }
.period-btn.active { background: var(--accent); color: #0f172a; }
.toggle-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text2); cursor: pointer;
}
.toggle-label input { accent-color: var(--accent); }

.chart-container {
  border-radius: var(--radius); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  height: 280px;
}
.chart-container.rsi { height: 120px; margin-top: 8px; }

/* ── History Table ── */
.history-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.history-table th {
  background: var(--surface2); color: var(--text2);
  padding: 8px 6px; text-align: left; font-weight: 600;
  font-size: 11px; text-transform: uppercase;
}
.history-table td {
  padding: 10px 6px; border-bottom: 1px solid var(--border);
  color: var(--text);
}
.history-table tr:last-child td { border-bottom: none; }
.signal-text { font-size: 11px; font-weight: 600; }

/* ── FAB ── */
.fab-wrap {
  position: fixed; bottom: calc(16px + var(--safe-bottom));
  left: 50%; transform: translateX(-50%);
  z-index: 100;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.fab-exec {
  background: #22c55e; box-shadow: 0 4px 20px rgba(34,197,94,0.4);
}
.fab-exec:active { box-shadow: 0 2px 10px rgba(34,197,94,0.3); }
.fab {
  display: flex; align-items: center; gap: 8px;
  background: var(--accent); color: #0f172a;
  border: none; border-radius: 28px;
  padding: 14px 24px; font-size: 15px; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 20px rgba(56,189,248,0.4);
  transition: transform 0.1s, box-shadow 0.1s;
}
.fab:active { transform: scale(0.96); box-shadow: 0 2px 10px rgba(56,189,248,0.3); }
.fab.loading { opacity: 0.7; pointer-events: none; }
.fab-icon { font-size: 18px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: calc(90px + var(--safe-bottom));
  left: 50%; transform: translateX(-50%);
  background: var(--surface2); color: var(--text);
  padding: 10px 20px; border-radius: 20px;
  font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
  white-space: nowrap; z-index: 200;
}
.toast.show { opacity: 1; }

/* ── Conditions ── */
.cond-group { margin-bottom: 12px; }
.cond-group-title {
  font-size: 11px; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.8px;
  padding: 0 4px 6px; border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
.cond-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 8px; border-radius: 8px; margin-bottom: 4px;
}
.cond-item.hit   { background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.2); }
.cond-item.safe  { background: rgba(34,197,94,0.06); border: 1px solid rgba(34,197,94,0.15); }
.cond-item.unknown { background: rgba(234,179,8,0.07); border: 1px solid rgba(234,179,8,0.2); }
.cond-item.skip  { background: transparent; border: 1px solid var(--border); opacity: 0.45; }

.cond-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.cond-text { flex: 1; min-width: 0; }
.cond-name { font-size: 13px; font-weight: 600; color: var(--text); }
.cond-desc { font-size: 11px; color: var(--text2); margin-top: 2px; line-height: 1.4; }

/* ── Flags ── */
.flags-list {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px;
}
.flag-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font: inherit; text-align: left; width: 100%;
}
.flag-toggle { cursor: pointer; }
.flag-toggle:active { opacity: 0.8; }
.flag-toggle:disabled { opacity: 0.5; cursor: wait; }
.flag-label { font-size: 11px; color: var(--text2); }
.flag-value { font-size: 12px; font-weight: 600; color: var(--text); }
.force-body { padding: 12px 16px 16px; }
.force-note {
  margin: -2px 0 8px;
}
.header-hint {
  color: var(--text2); font-size: 11px; font-weight: 500;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 300; padding-bottom: var(--safe-bottom);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto;
  border: 1px solid var(--border);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface);
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 12px 16px; border-top: 1px solid var(--border); }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; color: var(--text2); font-weight: 600; }
.form-group input {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 10px 12px;
  font-size: 15px; width: 100%;
}
.form-group input:focus { outline: none; border-color: var(--accent); }
.form-hint { font-size: 11px; color: var(--text2); }
.secret-input {
  -webkit-text-security: disc;
  text-security: disc;
}

.btn-primary {
  width: 100%; background: var(--accent); color: #0f172a;
  border: none; border-radius: 10px; padding: 13px;
  font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-primary:active { opacity: 0.8; }

.position-bar {
  margin: 12px 12px 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text2);
}
.position-bar .pos-weight { font-size: 15px; font-weight: 700; color: var(--text); }
.position-bar .pos-entry { color: var(--text2); }

/* ── Resizable columns ── */
.col-resize-handle {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 5px; cursor: col-resize; z-index: 1;
  background: transparent;
}
.col-resize-handle:hover, .col-resize-handle.dragging {
  background: var(--accent);
}
.history-table th { position: relative; user-select: none; }

/* ── Backtest marker tooltip ── */
#bt-marker-tooltip {
  position: fixed; z-index: 500; display: none;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
  font-size: 12px; color: var(--text);
  max-width: 240px; min-width: 160px;
  box-shadow: 0 4px 20px rgba(0,0,0,.6);
  pointer-events: auto;
}
.bt-chart-label {
  padding: 10px 12px 4px;
  font-size: 11px; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.8px;
}

/* ── Account Drawer ── */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 400; transition: opacity 0.3s;
}
.drawer-backdrop.hidden { display: none; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 320px; max-width: 85vw;
  background: var(--bg); border-left: 1px solid var(--border);
  z-index: 410; overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}
.drawer.open { transform: translateX(0); }
.drawer.hidden { display: none; }

.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 1;
}
.drawer-title { font-size: 16px; font-weight: 700; }

.drawer-section {
  padding: 16px; border-bottom: 1px solid var(--border);
}
.drawer-section:last-child { border-bottom: none; }

.drawer-user-info {
  display: flex; align-items: center; gap: 12px;
}
.drawer-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.drawer-user-detail { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.drawer-user-name { font-size: 14px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-user-email { font-size: 12px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 자동매매 상태 */
.drawer-status-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; font-weight: 600;
}
.drawer-at-badge {
  font-size: 12px; font-weight: 700; padding: 3px 10px;
  border-radius: 12px;
}
.drawer-at-badge.on { background: rgba(34,197,94,0.15); color: var(--green); }
.drawer-at-badge.off { background: rgba(148,163,184,0.1); color: var(--text2); }

/* 아코디언 */
.drawer-accordion-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: none; border: none; color: var(--text); font-size: 14px;
  font-weight: 600; cursor: pointer; padding: 0;
}
.accordion-arrow {
  font-size: 12px; color: var(--text2);
  transition: transform 0.2s;
}
.accordion-arrow.open { transform: rotate(90deg); }
.drawer-accordion-body {
  margin-top: 14px; display: flex; flex-direction: column; gap: 10px;
}
.drawer-accordion-body.hidden { display: none; }

/* 로그아웃 */
.drawer-bottom { margin-top: auto; }
.drawer-logout-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: none; border: 1px solid var(--border); color: var(--red);
  border-radius: 10px; padding: 12px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.drawer-logout-btn:hover { background: rgba(239,68,68,0.1); }

/* KIS 미설정 안내 */
.kis-setup-guide {
  margin: 0 12px 80px; padding: 30px 20px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); text-align: center;
}
.kis-guide-icon { font-size: 32px; margin-bottom: 10px; }
.kis-guide-text { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.kis-guide-sub { font-size: 12px; color: var(--text2); line-height: 1.5; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── 하단 네비게이션 ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 40;
  max-width: 480px; margin: 0 auto;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 6px; border: none; background: none;
  color: var(--text2); cursor: pointer; transition: color 0.15s;
}
.nav-btn .nav-icon { font-size: 20px; }
.nav-btn .nav-label { font-size: 10px; font-weight: 600; }
.nav-btn.active { color: var(--accent); }
body { padding-bottom: 64px; }

/* ── 자동매매 화면 ── */
.at-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 12px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.at-status { display: flex; flex-direction: column; gap: 2px; }
.at-mode-label { font-size: 14px; font-weight: 700; color: var(--text); }
.at-mode-sub { font-size: 11px; color: var(--text2); }
.at-mode-label.mock { color: #fbbf24; }
.at-mode-label.real { color: #ef4444; }
.at-mode-label.disabled { color: var(--text2); }

/* 토글 스위치 */
.toggle-switch {
  position: relative; display: inline-block;
  width: 48px; height: 26px; flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #475569; border-radius: 13px; transition: 0.2s;
}
.toggle-slider::before {
  content: ""; position: absolute;
  width: 20px; height: 20px; left: 3px; top: 3px;
  background: white; border-radius: 50%; transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(120deg, #00ff88, #00d4ff);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}
.toggle-switch input:disabled + .toggle-slider { opacity: 0.5; cursor: not-allowed; }

/* 매매 시점 라디오 */
.trade-mode-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 12px 8px; padding: 8px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px;
}
.trade-mode-label { color: var(--text2); font-weight: 600; }
.trade-mode-options { display: flex; gap: 12px; }
.trade-mode-opt {
  display: flex; align-items: center; gap: 4px;
  color: var(--text); cursor: pointer; font-size: 12px;
}
.trade-mode-opt input[type="radio"] {
  accent-color: #00d4ff; margin: 0; cursor: pointer;
}

/* 잔고 카드 */
.balance-card {
  margin: 0 12px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.balance-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text2);
}
.balance-body { padding: 12px 14px; }
.balance-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; font-size: 14px;
}
.balance-row + .balance-row { border-top: 1px dashed var(--border); }
.balance-row .b-label { color: var(--text2); font-size: 13px; }
.balance-row .b-value { color: var(--text); font-weight: 600; }
.balance-row.total { padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--border); }
.balance-row.total .b-label { font-size: 14px; font-weight: 600; color: var(--text); }
.balance-row.total .b-value { font-size: 18px; color: var(--accent); }

.btn-icon-sm {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text2); width: 26px; height: 26px;
  border-radius: 6px; cursor: pointer;
}
.btn-secondary-sm {
  font-size: 11px; padding: 4px 10px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text2); border-radius: 6px; cursor: pointer;
}

/* (KIS 설정은 계정 드로어로 이동) */

/* ─────────────────────────────────────
   PC 반응형 (768px 이상)
   ───────────────────────────────────── */
@media (min-width: 768px) {
  #app { max-width: 900px; padding-bottom: calc(80px + var(--safe-bottom)); }
  .header { max-width: 900px; margin: 0 auto; padding: 18px 24px; }
  .bottom-nav { max-width: 480px; }

  /* 시그널 화면: 상단 카드들 grid */
  #view-signal .position-bar { margin: 16px 24px; }
  #view-signal .signal-card { margin: 16px 24px; padding: 24px; min-height: 120px; }
  #view-signal .metrics-grid { margin: 0 24px 16px; gap: 12px; grid-template-columns: repeat(4, 1fr); }
  #view-signal #my-metrics-grid { grid-template-columns: repeat(2, 1fr); }
  #view-signal .metric-card { padding: 16px; }
  #view-signal .metric-value { font-size: 22px; }
  #view-signal .tab-bar { margin: 0 24px; }
  #view-signal .tab-content { margin: 16px 24px; }
  #view-signal .chart-container { height: 380px; }
  #view-signal .chart-container.rsi { height: 160px; }

  /* 시그널 카드 내부 weight 강조 */
  .signal-weight { font-size: 28px; }

  /* 자동매매 화면 */
  .at-header { margin: 16px 24px; padding: 18px 24px; }
  .at-mode-label { font-size: 16px; }
  .balance-card { margin: 0 24px 16px; }
  .balance-body { padding: 16px 20px; }
  .balance-row { padding: 8px 0; font-size: 15px; }
  .balance-row.total .b-value { font-size: 22px; }
  #view-autotrade .signal-card { margin: 0 24px 16px; padding: 24px; }
  .kis-setup-guide { margin: 0 24px 100px; padding: 40px 30px; }

  /* 백테스트 */
  .bt-settings { padding: 20px; gap: 12px; }
  .bt-summary { padding: 20px; grid-template-columns: repeat(4, 1fr); }
  .bt-chart-wrap { margin: 16px 24px; }
  #bt-trades-wrap { margin: 0 24px 80px; }

  /* 모달 */
  .modal { max-width: 540px; }

  /* 매매완료 FAB - 우하단 고정 */
  .fab-wrap { right: 24px; bottom: calc(90px + var(--safe-bottom)); left: auto; }
  .fab { width: auto; padding: 12px 24px; border-radius: 100px; }

  /* 폼 입력 */
  .form-group input, .form-group select { padding: 10px 14px; font-size: 14px; }

  /* 헤더 액션 버튼 더 크게 */
  .btn-icon { width: 40px; height: 40px; font-size: 18px; }
}

/* 더 큰 화면 (1024px+) — 자동매매를 2단 그리드로 */
@media (min-width: 1024px) {
  #view-autotrade {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
    padding: 0 24px;
  }
  #view-autotrade.hidden-grid { display: none; }
  #view-autotrade .at-header { grid-column: 1 / -1; margin: 16px 0; }
  #view-autotrade .balance-card,
  #view-autotrade .signal-card,
  #view-autotrade .kis-setup-guide { margin: 0 0 16px; }
}
