/* ============================================================
   주식 초보자용 모바일 분석 웹앱 - 스타일
   ============================================================ */

:root {
  --bg: #0f1320;
  --surface: #1a1f2e;
  --surface-2: #242a3d;
  --text: #e8ecf4;
  --text-muted: #9aa3b5;
  --primary: #4f8cff;
  --primary-dim: #2f5fb3;
  --positive: #3ddc97;
  --negative: #ff6b6b;
  --warning: #ffb84d;
  --border: #2c3347;
  --radius: 16px;
  --nav-h: 64px;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
}

#app-shell {
  padding-bottom: calc(var(--nav-h) + 16px);
}

/* ---------- 공통 상단 ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 19, 32, 0.92);
  backdrop-filter: blur(12px);
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.app-brand { font-weight: 700; font-size: 18px; }
.header-user { display: flex; align-items: center; gap: 8px; }
.current-user-name { font-size: 12px; color: var(--text-muted); }
.header-meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge--muted { opacity: 0.8; }
.badge--positive { background: rgba(61, 220, 151, 0.15); color: var(--positive); border-color: transparent; }
.badge--negative { background: rgba(255, 107, 107, 0.15); color: var(--negative); border-color: transparent; }
.badge--warning { background: rgba(255, 184, 77, 0.15); color: var(--warning); border-color: transparent; }

.logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}
.logout-btn:hover { color: var(--text); border-color: var(--text-muted); }

/* ---------- 화면 전환 ---------- */
.screen { display: none; padding: 12px 16px; }
.screen--active { display: block; }

/* ---------- 카드 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.section-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.subsection-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }

.label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.label input, .label select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  font-size: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  appearance: none;
}
.label input:focus, .label select:focus { outline: 2px solid var(--primary); border-color: transparent; }

/* ---------- 검색 ---------- */
.search-row { display: flex; gap: 8px; }
.search-row input {
  flex: 1;
  padding: 14px;
  font-size: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

/* ---------- 버튼 ---------- */
.btn {
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.8; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:disabled { background: var(--primary-dim); opacity: 0.6; cursor: not-allowed; }
.btn--block { width: 100%; margin-top: 8px; }

/* ---------- 시세 카드 ---------- */
.quote-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.stock-name { font-size: 20px; font-weight: 700; }
.stock-ticker { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.quote-price-wrap { text-align: right; }
.current-price { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.change-rate { font-size: 14px; font-weight: 600; }
.change-rate.positive { color: var(--positive); }
.change-rate.negative { color: var(--negative); }
.quote-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-top: 10px; }

/* ---------- 분석 결과 ---------- */
.analysis-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }
.recommendation-badge {
  font-size: 18px;
  font-weight: 800;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--surface-2);
}
.recommendation-badge--buy { background: rgba(61, 220, 151, 0.18); color: var(--positive); }
.recommendation-badge--sell { background: rgba(255, 107, 107, 0.18); color: var(--negative); }
.recommendation-badge--hold { background: rgba(255, 184, 77, 0.18); color: var(--warning); }
.recommendation-badge--pending { background: var(--surface-2); color: var(--text-muted); }
.analysis-timestamp { font-size: 11px; color: var(--text-muted); }
.overall-summary { font-size: 15px; line-height: 1.65; margin-bottom: 14px; }
.scenario-box { background: var(--surface-2); border-radius: 12px; padding: 12px; margin-bottom: 14px; }
.body-text { font-size: 14px; color: var(--text); line-height: 1.65; }
.note-text { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.risk-note { font-size: 11px; color: var(--text-muted); margin-top: 16px; line-height: 1.5; }
.error-text { color: var(--negative); font-size: 13px; margin-top: 8px; }

/* ---------- 아코디언 ---------- */
.accordion { border-top: 1px solid var(--border); }
.accordion-trigger {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 4px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.accordion-icon { transition: transform 0.2s; color: var(--text-muted); }
.accordion-trigger[aria-expanded="true"] .accordion-icon { transform: rotate(180deg); }
.accordion-panel { display: none; padding: 0 4px 16px; }
.accordion-trigger[aria-expanded="true"] + .accordion-panel { display: block; }

.tip-box {
  margin-top: 12px;
  padding: 12px;
  background: rgba(79, 140, 255, 0.08);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  font-size: 13px;
}
.tip-box strong { display: block; margin-bottom: 4px; color: var(--primary); font-size: 12px; }

/* ---------- 뉴스 ---------- */
.news-list { list-style: none; margin-top: 10px; }
.news-list li { padding: 10px 0; border-top: 1px solid var(--border); }
.news-list li:first-child { border-top: none; }
.news-title { font-size: 14px; font-weight: 600; color: var(--text); text-decoration: none; display: block; }
.news-title:hover { color: var(--primary); }
.news-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.news-impact { font-size: 11px; font-weight: 600; margin-top: 4px; display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); }
.news-impact--pos { color: var(--positive); }
.news-impact--neg { color: var(--negative); }

/* ---------- 보유 요약 ---------- */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary-item { background: var(--surface-2); border-radius: 12px; padding: 12px; }
.summary-label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.summary-value { font-size: 16px; font-weight: 700; }
.holdings-list { display: flex; flex-direction: column; gap: 10px; }
.holding-card {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 14px;
}
.holding-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.holding-name { font-size: 16px; font-weight: 700; }
.holding-ticker { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.holding-qty { font-size: 16px; font-weight: 700; white-space: nowrap; }
.holding-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.holding-meta dt { color: var(--text-muted); font-size: 11px; }
.holding-meta dd { font-weight: 600; margin: 0; }
.empty-text { color: var(--text-muted); font-size: 14px; text-align: center; padding: 20px 0; }

/* ---------- 거래 내역 토글 / 리스트 ---------- */
.tx-toggle {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
}
.tx-toggle:hover { color: var(--text); border-color: var(--text-muted); }
.tx-list { margin-top: 12px; padding-top: 4px; border-top: 1px solid var(--border); }
.tx-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.tx-row:last-child { border-bottom: none; }
.tx-main { font-size: 13px; line-height: 1.5; }
.tx-type-buy { color: var(--positive); font-weight: 700; }
.tx-type-sell { color: var(--negative); font-weight: 700; }
.tx-date { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.tx-actions { display: flex; gap: 4px; }
.tx-action-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
}
.tx-action-btn:hover { color: var(--text); }
.tx-action-btn--danger:hover { color: var(--negative); border-color: var(--negative); }

/* ---------- 거래 폼 ---------- */
.tx-form .label { margin-bottom: 8px; }

/* ---------- 하단 네비게이션 ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-h);
  display: flex;
  background: rgba(26, 31, 46, 0.96);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 30;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px;
}
.nav-btn--active { color: var(--primary); }
.nav-icon { font-size: 20px; line-height: 1; }

/* ---------- 로그인 화면 ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}
.login-wrap { width: 100%; max-width: 400px; }
.login-header { text-align: center; margin-bottom: 24px; }
.login-logo { font-size: 48px; margin-bottom: 8px; line-height: 1; }
.login-title { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.login-subtitle { font-size: 14px; color: var(--text-muted); }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.login-buttons { display: flex; flex-direction: column; gap: 10px; }
.login-name-btn {
  font-size: 17px;
  padding: 18px;
  font-weight: 700;
}
.login-loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 12px;
}
.login-footer-note {
  margin-top: 20px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* ---------- 유틸 ---------- */
[hidden] { display: none !important; }