/* ===== Reset & Base ===== */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
:root {
  --bg: #0A1628;
  --card: #111B2E;
  --border: #1E2D45;
  --gold: #F0B429;
  --profit: #FF4444;
  --loss: #4488FF;
  --text: #E8E8E8;
  --text-dim: #8899AA;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
html { font-size: 14px; }
body {
  font-family: 'Apple SD Gothic Neo', -apple-system, 'Pretendard', sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-user-select: none;
  user-select: none;
  padding-top: var(--safe-t);
}

/* ===== Header ===== */
.app-header {
  padding: 16px 20px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.app-header h1 {
  font-size: 1.25rem;
  color: var(--gold);
  font-weight: 700;
}
.app-header .date {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ===== Tab Content ===== */
.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 120px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.tab-content::-webkit-scrollbar { display: none; }
.tab-page { display: none; }
.tab-page.active { display: block; }

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: #0D1829;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + var(--safe-b));
  z-index: 100;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.7rem;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.nav-item i { font-size: 1.25rem; }
.nav-item.active { color: var(--gold); }

/* ===== Cards ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
}
.card.card-port {
  padding: 2px 10px;
  margin-bottom: 4px;
}
.card-title {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 4px;
  font-weight: 600;
}

/* ===== Portfolio Header ===== */
.port-header {
  text-align: center;
  padding: 6px 0 4px;
}
.port-total {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.port-return {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 1px;
}
.port-return.profit { color: var(--profit); }
.port-return.loss { color: var(--loss); }

/* ===== Donut Chart ===== */
.chart-wrapper {
  position: relative;
  max-width: 160px;
  margin: 0 auto 4px;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  justify-content: center;
  margin-bottom: 4px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--text-dim);
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== Category Section ===== */
.category-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gold);
  padding: 6px 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

/* ===== Stock Card ===== */
.stock-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.stock-card:last-child { border-bottom: none; }
.stock-left { flex: 1; }
.stock-ticker {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}
.stock-name {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 2px;
}
.stock-status {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 3px;
}
.status-holding { background: #1a3a2a; color: #44cc88; }
.status-new { background: #3a2a1a; color: #F0B429; }
.status-ftd { background: #1a2a3a; color: #4488FF; }
.stock-right { text-align: right; }
.stock-price {
  font-weight: 700;
  font-size: 1.1rem;
}
.stock-return {
  font-size: 0.9rem;
  margin-top: 2px;
}
.stock-value {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 2px;
}
.stock-weight {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 1px;
}

/* ===== Rebalance Alert ===== */
.rebalance-alert {
  background: #1a1a2e;
  border: 1px solid #F0B429;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 6px;
}
.rebalance-alert .title {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 4px;
}
.rebalance-item {
  font-size: 0.75rem;
  color: var(--text);
  padding: 2px 0;
}

/* ===== Placeholder ===== */
.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--text-dim);
  gap: 12px;
}
.placeholder i { font-size: 3rem; color: var(--border); }
.placeholder p { font-size: 0.9rem; }

/* ===== Disclaimer ===== */
.disclaimer {
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-dim);
  padding: 20px 16px 8px;
  line-height: 1.4;
}

/* ===== Skeleton ===== */
.skeleton {
  background: linear-gradient(90deg, var(--card) 25%, #1a2a40 50%, var(--card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
  height: 20px;
  margin: 8px 0;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Market Timing ===== */
.section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0 4px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gold);
}
.section-header i { font-size: 0.9rem; }

/* Signal Badge */
.signal-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}
.signal-bullish { background: #1a3a2a; color: #44CC88; border: 1px solid #44CC88; }
.signal-neutral { background: #2a2a1a; color: #F0B429; border: 1px solid #F0B429; }
.signal-bearish { background: #3a1a1a; color: #FF4444; border: 1px solid #FF4444; }

/* Gauge */
.gauge-container {
  margin: 6px 0;
}
.gauge-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.gauge-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.gauge-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.gauge-marker {
  position: absolute;
  top: -4px;
  width: 3px;
  height: 16px;
  background: var(--text);
  border-radius: 2px;
  transform: translateX(-50%);
}
.gauge-value {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 800;
  margin-top: 4px;
}

/* Input Row */
.input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
}
.input-row label {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.input-row select,
.input-row input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 8px;
  font-size: 0.8rem;
  outline: none;
  -webkit-appearance: none;
}
.input-row select { min-width: 130px; }
.input-row input[type="number"] { width: 80px; text-align: center; }
.input-row input[type="date"] { width: 140px; }

/* Stat Grid */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0;
}
.stat-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.stat-box .val {
  font-size: 1.1rem;
  font-weight: 700;
}
.stat-box .lbl {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Monthly Win Rate Bar */
.month-bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0;
  font-size: 0.75rem;
}
.month-bar-row .mon { width: 28px; color: var(--text-dim); text-align: right; }
.month-bar-row .bar-track {
  flex: 1;
  height: 14px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.month-bar-row .bar-fill {
  height: 100%;
  border-radius: 3px;
}
.month-bar-row .pct { width: 36px; text-align: right; }

/* Integrated Box */
.integrated-box {
  background: linear-gradient(135deg, #111B2E 0%, #1a2540 100%);
  border: 2px solid var(--gold);
  border-radius: 16px;
  padding: 20px;
  margin: 16px 0;
  text-align: center;
}
.integrated-box .main-signal {
  font-size: 1.3rem;
  font-weight: 800;
  margin: 8px 0;
}
.integrated-box .advice {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.5;
  margin-top: 8px;
  text-align: left;
}

/* Exposure Gauge (big) */
.exposure-gauge {
  margin: 16px auto;
  text-align: center;
}
.exposure-gauge canvas { max-width: 220px; }
.exposure-gauge-compact {
  text-align: center;
  margin: 4px auto;
  position: relative;
}
.exposure-gauge-compact canvas { max-width: 150px; max-height: 80px; }
.exposure-pct {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--gold);
  margin-top: -8px;
}
.exposure-gauge-compact .exposure-pct {
  font-size: 1.8rem;
  margin-top: -4px;
}
.exposure-label {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Timeline chart container */
.timeline-chart { margin: 8px 0; }
.timeline-chart canvas { max-height: 180px; }

/* Save button */
.btn-save {
  display: block;
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: var(--gold);
  color: #000;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  -webkit-tap-highlight-color: transparent;
}
.btn-save:active { opacity: 0.8; }

/* Subsection divider */
.sub-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* ===== Watchlist Tab ===== */
.watch-subtabs {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--border);
  overflow: hidden;
}
.watch-subtab {
  flex: 1;
  padding: 10px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  -webkit-tap-highlight-color: transparent;
}
.watch-subtab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.watch-subpage { display: none; }
.watch-subpage.active { display: block; }

/* Search bar */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.search-bar input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.9rem;
  outline: none;
}
.search-bar input::placeholder { color: var(--text-dim); }
.search-bar button {
  background: var(--gold);
  color: #000;
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.search-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 48px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  z-index: 100;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.search-dropdown.open { display: block; }
.search-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.search-dropdown-item:last-child { border-bottom: none; }
.search-dropdown-item:hover { background: rgba(255,255,255,0.05); }
.sd-ticker { font-weight: 700; font-size: 0.9rem; min-width: 60px; }
.sd-name { font-size: 0.78rem; color: var(--text-dim); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-type { font-size: 0.7rem; color: var(--gold); }
.search-results { margin-bottom: 12px; }
.search-result-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}
.sr-left { flex: 1; }
.sr-ticker { font-weight: 700; font-size: 1rem; }
.sr-name { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }
.sr-sector { font-size: 0.7rem; color: var(--text-dim); }
.sr-right { text-align: right; }
.sr-price { font-weight: 700; }
.sr-change { font-size: 0.8rem; margin-top: 2px; }
.sr-actions { display: flex; gap: 6px; margin-top: 6px; }
.sr-actions button {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
}
.btn-add-watch { background: var(--gold); color: #000; }
.btn-detail { background: var(--border); color: var(--text); }

/* Watchlist table-like cards */
.wl-header {
  display: grid;
  grid-template-columns: 80px 1fr 50px 50px 50px 50px;
  gap: 4px;
  padding: 8px 10px;
  font-size: 0.65rem;
  color: var(--text-dim);
  font-weight: 600;
}
.wl-row {
  display: grid;
  grid-template-columns: 80px 1fr 50px 50px 50px 50px;
  gap: 4px;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  align-items: center;
  font-size: 0.8rem;
}
.wl-row .ticker { font-weight: 700; }
.wl-row .name { font-size: 0.7rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-status-icon { font-size: 1rem; text-align: center; }
.wl-edit-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.7rem;
  cursor: pointer;
}

/* Event cards */
.event-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 8px;
  position: relative;
}
.event-card .ev-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.ev-ticker {
  font-weight: 700;
  font-size: 1rem;
}
.ev-type {
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 10px;
  font-weight: 600;
}
.ev-type-임상발표 { background: #2a1a3a; color: #AA66FF; }
.ev-type-FDA결정 { background: #1a3a2a; color: #44CC88; }
.ev-type-리밸런싱 { background: #2a2a1a; color: #F0B429; }
.ev-type-실적발표 { background: #1a2a3a; color: #4488FF; }
.ev-type-피벗돌파 { background: #3a1a1a; color: #FF4444; }
.ev-type-지지이탈 { background: #3a2a1a; color: #FF8844; }
.ev-dday {
  font-size: 1.3rem;
  font-weight: 800;
  margin: 4px 0;
}
.ev-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.4;
}
.ev-impact {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 8px;
  background: #1a1a2e;
  color: var(--gold);
  margin-top: 4px;
}
.ev-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.ev-actions button {
  flex: 1;
  padding: 6px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
}
.btn-edit-ev { background: var(--border); color: var(--text); }
.btn-del-ev { background: #3a1a1a; color: #FF4444; }

/* Modal / form overlay */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  justify-content: center;
  align-items: center;
}
.modal-overlay.show { display: flex; }
.modal-sheet {
  background: var(--card);
  border-radius: 16px;
  padding: 16px 14px;
  width: 88%;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.modal-sheet::-webkit-scrollbar { display: none; }
.modal-sheet h3 {
  font-size: 1rem;
  color: var(--gold);
  margin-bottom: 16px;
}
.form-group {
  margin-bottom: 8px;
}
.form-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px;
  font-size: 0.85rem;
  outline: none;
}
.form-group textarea { resize: vertical; min-height: 60px; }
.form-buttons {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.form-buttons button {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
}
.btn-confirm { background: var(--gold); color: #000; }
.btn-cancel { background: var(--border); color: var(--text); }

/* Detail page */
.detail-page {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  z-index: 150;
  overflow-y: auto;
  padding: 0 16px var(--safe-b);
  max-width: 480px;
  margin: 0 auto;
}
.detail-page.show { display: block; }
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.detail-header .back-btn {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
}
.detail-ticker {
  font-size: 1.5rem;
  font-weight: 800;
}
.detail-name {
  font-size: 0.85rem;
  color: var(--text-dim);
}
.detail-price-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}
.detail-price {
  font-size: 2rem;
  font-weight: 800;
}
.detail-change {
  font-size: 1rem;
  font-weight: 600;
}
.guru-rating {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}
.guru-rating .tag {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
}

/* ===== 해자/장기 분석 스타일 ===== */
.moat-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.moat-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.track-badge-a {
  display: inline-block;
  background: #0d2818;
  color: #44CC88;
  border: 1px solid #44CC88;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.8rem;
}
.track-badge-b {
  display: inline-block;
  background: #0d1a2a;
  color: #4488FF;
  border: 1px solid #4488FF;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.8rem;
}
.score-grade-a { color: #44CC88; }
.score-grade-b { color: #F0B429; }
.score-grade-c { color: #FF8844; }
.score-grade-d { color: #FF4444; }

/* ===== Home Dashboard ===== */
.market-status-banner {
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.msb-uptrend { background: linear-gradient(135deg, #0d2818, #1a3a2a); border: 1px solid #44CC88; }
.msb-pressure { background: linear-gradient(135deg, #2a2200, #3a2a1a); border: 1px solid #F0B429; }
.msb-correction { background: linear-gradient(135deg, #2a0d0d, #3a1a1a); border: 1px solid #FF4444; }
.msb-icon { font-size: 1.5rem; }
.msb-text { flex: 1; }
.msb-title { font-size: 0.9rem; font-weight: 700; }
.msb-sub { font-size: 0.7rem; color: var(--text-dim); margin-top: 2px; }

.guru-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 5px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.guru-card .gc-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gc-oneil { background: #1a2a1a; color: #44CC88; }
.gc-minervini { background: #2a1a1a; color: #FF4444; }
.gc-macro { background: #1a1a2a; color: #4488FF; }
.guru-card .gc-body { flex: 1; }
.guru-card .gc-name { font-size: 0.65rem; color: var(--text-dim); font-weight: 600; }
.guru-card .gc-msg { font-size: 0.78rem; margin-top: 2px; line-height: 1.35; }

.alert-banner {
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
}
.alert-urgent {
  background: #2a0d0d;
  border: 1px solid #FF4444;
  color: #FF6666;
}
.alert-warning {
  background: #2a2200;
  border: 1px solid #F0B429;
  color: #F0B429;
}
.alert-info {
  background: #0d1a2a;
  border: 1px solid #4488FF;
  color: #6699FF;
}
.alert-banner i { font-size: 1rem; flex-shrink: 0; }

.home-port-summary {
  background: linear-gradient(135deg, #111B2E, #1a2540);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  text-align: center;
}
.hps-value { font-size: 1.8rem; font-weight: 800; }
.hps-return { font-size: 1rem; font-weight: 600; margin-top: 4px; }
.hps-label { font-size: 0.7rem; color: var(--text-dim); margin-top: 4px; }
.hps-row {
  display: flex;
  justify-content: space-around;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.hps-item { text-align: center; }
.hps-item .v { font-size: 1rem; font-weight: 700; }
.hps-item .l { font-size: 0.65rem; color: var(--text-dim); margin-top: 2px; }

/* ===== Pull to Refresh ===== */
.ptr-indicator {
  text-align: center;
  padding: 0;
  height: 0;
  overflow: hidden;
  transition: height 0.2s, padding 0.2s;
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 600;
}
.ptr-indicator.pulling { height: 40px; padding: 10px 0; }
.ptr-indicator.refreshing { height: 40px; padding: 10px 0; }
.ptr-indicator .spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Exchange Rate Bar ===== */
.fx-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 0.75rem;
  color: var(--text-dim);
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.fx-bar .rate { color: var(--gold); font-weight: 700; }

/* ===== Sparkline ===== */
.sparkline-container {
  display: none;
}
.sparkline-container canvas {
  width: 100%;
  height: 100%;
}

/* ===== KRW toggle ===== */
.krw-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 0.75rem;
  color: var(--text-dim);
}
.krw-toggle button {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  cursor: pointer;
  background: none;
  color: var(--text-dim);
}
.krw-toggle button.active {
  background: var(--gold);
  color: #000;
  border-color: var(--gold);
}

/* ===== Watchlist V2 Rows ===== */
.wl-row-v2 {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.wl-row-v2 .wl-main { flex: 1; min-width: 0; }
.wl-row-v2 .ticker { font-weight: 700; font-size: 0.95rem; }
.wl-row-v2 .name { font-size: 0.7rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-row-v2 .wl-metrics {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 0.65rem;
  font-weight: 600;
  text-align: right;
}
.wl-entry-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 48px;
  padding: 4px 6px;
  border-radius: 8px;
  text-align: center;
}
.entry-ok { background: #0d2818; color: #44CC88; border: 1px solid #44CC88; }
.entry-denied { background: #2a0d0d; color: #FF4444; border: 1px solid #FF4444; }
.entry-wait { background: #2a2200; color: #F0B429; border: 1px solid #F0B429; }
.entry-none { background: var(--card); color: var(--text-dim); border: 1px solid var(--border); }

/* ===== Settings Tab ===== */
.settings-section {
  margin-bottom: 12px;
}
.settings-section-title {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 600;
  padding: 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  margin-bottom: -1px;
}
.setting-row:first-of-type { border-radius: 12px 12px 0 0; }
.setting-row:last-of-type { border-radius: 0 0 12px 12px; margin-bottom: 0; }
.setting-row:only-of-type { border-radius: 12px; }
.setting-label {
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.setting-label i { color: var(--text-dim); width: 20px; text-align: center; }
.setting-value {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 24px;
  transition: 0.3s;
}
.toggle .slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: var(--text);
  border-radius: 50%;
  transition: 0.3s;
}
.toggle input:checked + .slider { background: var(--gold); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

/* Portfolio edit table */
.port-edit-row {
  display: grid;
  grid-template-columns: 60px 1fr 60px 50px;
  gap: 6px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.port-edit-row input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px;
  font-size: 0.8rem;
  text-align: center;
  width: 100%;
}
.target-pct-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 4px;
}
.target-pct-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
}
.pct-total {
  text-align: center;
  padding: 10px;
  font-size: 0.9rem;
  font-weight: 700;
}
.pct-total.valid { color: #44CC88; }
.pct-total.invalid { color: #FF4444; }

/* Danger zone */
.btn-danger {
  display: block;
  width: 100%;
  padding: 14px;
  border: 1px solid #FF4444;
  border-radius: 12px;
  background: transparent;
  color: #FF4444;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}
.btn-danger:active { background: #3a1a1a; }

/* Style selector */
.style-options {
  display: flex;
  gap: 8px;
}
.style-option {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}
.style-option.selected {
  border-color: var(--gold);
  color: var(--gold);
}
.style-option .style-icon { font-size: 1.2rem; margin-bottom: 4px; }

/* App info */
.app-info {
  text-align: center;
  padding: 20px 0;
  color: var(--text-dim);
  font-size: 0.75rem;
  line-height: 1.6;
}
.app-info .version { color: var(--gold); font-weight: 700; font-size: 0.85rem; }

/* ===== System Guide ===== */
.sys-guide-wrap {
  display: none;
  padding: 0 2px;
}
.sys-guide-wrap.show {
  display: block;
}
.guide-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
}
.guide-section summary {
  padding: 12px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
}
.guide-section summary::-webkit-details-marker { display: none; }
.guide-section summary::after {
  content: '▸';
  margin-left: auto;
  color: var(--text-dim);
  font-size: 0.7rem;
  transition: transform 0.2s;
}
.guide-section[open] summary::after {
  transform: rotate(90deg);
}
.guide-section summary i {
  color: var(--gold);
  width: 18px;
  text-align: center;
}
.guide-body {
  padding: 0 14px 14px;
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.6;
}
.guide-body p {
  margin-bottom: 8px;
}
.guide-body ul {
  padding-left: 16px;
  margin-bottom: 8px;
}
.guide-body ul li {
  margin-bottom: 3px;
}
.guide-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.guide-card-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 6px;
}
.guide-quote {
  font-style: italic;
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 6px 10px;
  border-left: 3px solid var(--gold);
  margin-bottom: 8px;
  background: rgba(240,180,41,0.05);
  border-radius: 0 6px 6px 0;
}
.guide-note {
  font-size: 0.72rem;
  color: var(--gold);
  background: rgba(240,180,41,0.08);
  border: 1px solid rgba(240,180,41,0.2);
  border-radius: 6px;
  padding: 8px 10px;
  margin-top: 8px;
}
.guide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  margin-bottom: 6px;
}
.guide-table th {
  background: var(--bg);
  color: var(--gold);
  font-weight: 700;
  padding: 6px 8px;
  text-align: left;
  border-bottom: 2px solid var(--border);
}
.guide-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.guide-table tr:last-child td { border-bottom: none; }
.guide-checklist {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.75rem;
  padding: 6px 0;
}
.guide-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
}
.flow-step {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  width: 90%;
}
.flow-q {
  background: rgba(136,153,170,0.15);
  border: 1px solid var(--border);
  color: var(--text);
}
.flow-ok {
  background: rgba(68,204,136,0.15);
  border: 1px solid #44CC88;
  color: #44CC88;
}
.flow-arrow {
  font-size: 0.7rem;
  color: var(--text-dim);
}
.flow-branch {
  font-size: 0.7rem;
  align-self: flex-end;
  margin-right: 5%;
}
.flow-no { color: #FF4444; }
.flow-wait { color: #F0B429; }
.guide-dl {
  margin: 0;
  padding: 0;
}
.guide-dl dt {
  font-weight: 700;
  color: var(--gold);
  font-size: 0.78rem;
  margin-top: 6px;
}
.guide-dl dt:first-child { margin-top: 0; }
.guide-dl dd {
  margin: 2px 0 0 0;
  padding-left: 12px;
  font-size: 0.73rem;
  color: var(--text-dim);
  border-left: 2px solid var(--border);
}
.guide-faq {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.guide-faq:last-child { border-bottom: none; }
.faq-q {
  font-weight: 700;
  color: var(--text);
  font-size: 0.78rem;
  margin-bottom: 4px;
}
.faq-a {
  font-size: 0.73rem;
  color: var(--text-dim);
  line-height: 1.5;
  padding-left: 8px;
}
