/* ============================================================
   Financial Planner · Toss-inspired design system
   ============================================================ */
:root {
  --primary: #6E1E2B;          /* 옥스블러드 — 브랜드 포인트색 */
  --primary-strong: #561620;
  --primary-soft: #F3E9E9;
  --bg: #FAF7F0;               /* 웜 아이보리 페이퍼 */
  --bg-card: #FFFFFF;
  --text: #1C1B19;             /* 웜 잉크 */
  --text-sub: #4A463F;
  --text-mute: #8A8478;        /* 웜 그레이 */
  --border: #ECE5D8;           /* 웜 괘선(hairline) */
  --border-strong: #DBD3C4;
  --red: #B23A2E;              /* 상승(한국 관습) — 웜 레드 */
  --red-soft: #F7ECEA;
  --green: #2F7D63;            /* 성장/긍정 — 딥 그린 */
  --green-soft: #E9F3EE;
  --amber: #B5821F;
  --shadow-sm: none;           /* 에디토리얼 = 평면, 괘선으로 구획 */
  --shadow-md: none;
  --shadow-lg: 0 12px 48px rgba(28, 27, 25, .12);
  --radius: 6px;
  --radius-lg: 10px;
  --font-serif: 'Noto Serif KR', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui,
               'Segoe UI', Roboto, 'Apple SD Gothic Neo', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum";
  letter-spacing: -.01em;
  max-width: 100%;
  overflow-x: hidden;   /* 어떤 요소도 페이지를 가로로 밀어내지 못하게 */
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input { font-family: inherit; }

/* -------- App Shell -------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 32px; height: 32px;
  filter: drop-shadow(0 4px 10px rgba(49,130,246,.35));
  flex-shrink: 0;
}
.brand-name { font-family: var(--font-serif); font-size: 19px; font-weight: 600; color: var(--text); letter-spacing: 0; }
.brand-sub { font-size: 11px; letter-spacing: .18em; color: var(--text-mute); padding-left: 10px; border-left: 1px solid var(--border-strong); align-self: center; }

.steps {
  display: flex;
  gap: 2px;
  margin-left: auto;
  background: var(--bg);
  padding: 4px;
  border-radius: 999px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 1;
  min-width: 0;
}
.steps::-webkit-scrollbar { display: none; }
.step {
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  transition: all .18s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.step:hover { color: var(--text-sub); }
.step.active { background: var(--text); color: white; }

.topbar-meta { margin-left: 8px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-mute  { background: var(--bg); color: var(--text-mute); }
.badge-live  { background: var(--green-soft); color: var(--green); }
.badge-local { background: var(--primary-soft); color: var(--primary-strong); }

/* -------- Content -------- */
.content {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 96px;
  width: 100%;
}
.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hero { padding: 24px 4px 28px; }
.hero-title {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 0 0 8px;
}
.hero-sub { color: var(--text-sub); font-size: 15px; margin: 0; }

/* -------- Card -------- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.card h2 {
  font-family: var(--font-serif);
  font-size: 18px;
  margin: 0 0 18px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h2 { margin-bottom: 0; }

/* 포지션 카드 액션 버튼 그룹 */
.position-actions {
  display: flex;
  gap: 6px;
  align-self: flex-start;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.position-actions .btn-ghost { white-space: nowrap; }

.muted { color: var(--text-mute); font-size: 13px; }

/* -------- Holdings list -------- */
.holdings { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.holding-row {
  display: grid;
  gap: 8px;
  align-items: center;
  /* 데스크톱 기본: 8컬럼 */
}
/* 데스크톱 컬럼 정의 — ticker/cash 동일한 8열 (비중고정 자물쇠는 3.최적화 탭으로 이동)
   del(36) | 증권유형(auto) | 증권명(1fr) | 증권ID(0.8fr) | 수량(64px) | 평가금액(minmax90,1.1fr) | 1년추세(minmax140,1.3fr) | 비중(auto) */
.holding-row--ticker,
.holding-row--cash { grid-template-columns: 36px auto 1fr 0.8fr 64px minmax(90px,1.1fr) minmax(140px,1.3fr) auto; }

.holding-row {
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 10px;
  transition: background .15s;
}
.holding-row:hover { background: #f1f3f5; }
.holding-row select,
.holding-row input[type=number] {
  width: 100%;
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border .15s;
}
.holding-row select:focus,
.holding-row input[type=number]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.lock-btn {
  font-size: 15px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--text-mute);
  background: white;
  border: 1px solid var(--border-strong);
  transition: all .15s ease;
  display: flex; align-items: center; justify-content: center;
}
.lock-btn:hover { background: var(--primary-soft); }
.lock-btn.locked {
  background: var(--primary); color: white; border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(49,130,246,.32);
}
.holding-row.is-locked {
  background: var(--primary-soft);
  outline: 1px solid #c9deff;
}

/* ── 포지션 비중 배지 (auto 너비) ── */
.pos-weight-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 8px;
  padding: 4px 8px;
  white-space: nowrap;
  letter-spacing: -.3px;
  min-height: 28px;
  min-width: 40px;
}

/* ── 스파크라인 아래 % 라벨 (HTML — 늘어나지 않음) ── */
.spark-pct-label {
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  line-height: 1;
  margin-top: 1px;
  letter-spacing: -.2px;
  white-space: nowrap;
}

/* ── 포지션 컬럼 헤더 행 ── */
.holding-row-header {
  pointer-events: none;  /* 헤더 전체는 클릭 차단, 기간 버튼은 아래에서 복원 */
  background: var(--bg) !important;
  border: none !important;
  box-shadow: none !important;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border-strong) !important;
  border-radius: 0 !important;
}
.holding-row-header:hover { background: var(--bg) !important; }
/* 헤더 내 버튼(가격/재무 토글·기간·연도)은 클릭 허용 */
.holding-row-header button { pointer-events: all; }
.spark-period-btn { pointer-events: all; }

/* 평가금액 읽기전용 표시 */
.notional-display {
  display: flex;
  align-items: center;
  gap: 1px;
  font-size: 12px;
  color: var(--text);
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  min-width: 0;
  overflow: hidden;
  cursor: default;
  white-space: nowrap;
}
.notional-sym {
  color: var(--text-mute);
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
}
.notional-num {
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notional-empty {
  color: var(--text-mute);
}

.col-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-mute);
  letter-spacing: .03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
}

/* ── 증권명 인라인 입력 (라벨처럼 보이다가 클릭하면 편집) ── */
.name-inline-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  padding: 4px 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  width: 100%;
  min-width: 0;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
  cursor: pointer;
}
.name-inline-input::placeholder {
  color: var(--text-mute);
  font-weight: 400;
}
.name-inline-input:hover {
  border-bottom-color: var(--border-strong);
  cursor: text;
}
.name-inline-input:focus {
  border-bottom-color: var(--primary);
  cursor: text;
}

/* ── 현금 이름 라벨 ── */
.cash-name-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  padding: 4px 2px;
}

/* ----- Weight breakdown donuts (Step 1) ----- */
.weights-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 12px;
}
@media (max-width: 720px) {
  .weights-grid { grid-template-columns: 1fr; }
}
.weight-tile {
  background: var(--bg);
  border-radius: 14px;
  padding: 14px;
}
.wt-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 8px;
}
.wt-chart {
  position: relative;
  height: 320px;
}
/* Stacked bars stay at the same height whether LT is on or off — the
   columns just split into two narrower bars. Legend lives to the right
   so categories with long names (e.g. "Information Technology /
   Systems Software") don't overflow the chart area. */
.weights-grid.lt-mode .wt-chart { height: 320px; }
#lookThroughBtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-sub);
  transition: all .15s ease;
}
#lookThroughBtn:hover {
  background: var(--primary-soft);
  color: var(--primary-strong);
}
#lookThroughBtn.on {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(49,130,246,.32);
}

/* ----- Black-Litterman view UI ----- */
.bl-presets {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 10px 0 14px;
}
.bl-presets .bl-preset { font-size: 12px; }

.bl-view-list {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px;
}
.bl-view-row {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 12px; align-items: center;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 12px;
  border-left: 3px solid var(--primary);
}
.bl-view-row.kind-rel { border-left-color: var(--amber); }
.bl-view-desc { font-size: 13px; font-weight: 600; }
.bl-kind-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  background: var(--primary-soft); color: var(--primary-strong);
  text-align: center;
}
.bl-view-row.kind-rel .bl-kind-pill {
  background: #fff5e0; color: #b8631a;
}

.bl-view-add {
  background: var(--bg);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}
.bl-add-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 1fr auto;
  gap: 14px; align-items: end;
}
.bl-add-grid select {
  width: 100%;
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}
.bl-add-grid input[type=number] {
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
}
.bl-params {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 6px;
}
.bl-params input[type=number] {
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
}

/* engine info grid */
.engine-info-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.positive { color: var(--green); }
.negative { color: var(--red); }
.remove-btn {
  font-size: 14px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--text-mute);
  background: white;
  border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
}
.remove-btn:hover { color: var(--red); background: var(--red-soft); border-color: var(--red); }

.summary-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 4px 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.summary-row .label { font-size: 13px; color: var(--text-mute); margin-bottom: 4px; }
.summary-row .big { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }

/* -------- Fields / inputs -------- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.field { padding: 8px 0; }
.field label {
  display: block; font-size: 13px; color: var(--text-sub);
  margin-bottom: 8px; font-weight: 600;
}

.seg {
  display: inline-flex;
  background: var(--bg);
  border-radius: 12px;
  padding: 4px;
  gap: 2px;
  flex-wrap: wrap;
}
.seg button {
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mute);
  transition: all .15s;
}
.seg button:hover { color: var(--text); }
.seg button.on {
  background: white;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.seg-lg button { padding: 12px 20px; font-size: 14px; }

.toggle { display: flex; align-items: center; gap: 12px; }
.toggle input[type=checkbox] { display: none; }
.toggle label {
  width: 44px; height: 26px; border-radius: 999px;
  background: var(--border-strong); position: relative;
  cursor: pointer; transition: background .2s; margin: 0;
}
.toggle label::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: white; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.toggle input:checked + label { background: var(--primary); }
.toggle input:checked + label::after { left: 21px; }
.toggle-hint { font-size: 12px; color: var(--text-mute); }

.input-row {
  display: flex;
  align-items: center;
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 4px 16px;
  max-width: 240px;
}
.input-row input {
  flex: 1; padding: 12px 0; border: none; outline: none;
  font-size: 16px; font-weight: 600;
}
.input-row .suffix { color: var(--text-mute); font-weight: 600; }

/* -------- Buttons -------- */
.btn-primary {
  background: var(--primary);
  color: white;
  font-size: 15px;
  font-weight: 700;
  padding: 16px 28px;
  border-radius: 14px;
  transition: all .15s;
  letter-spacing: -.01em;
  box-shadow: 0 4px 16px rgba(49,130,246,.22);
}
.btn-primary:hover { background: var(--primary-strong); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { background: #c6dcfb; cursor: not-allowed; box-shadow: none; transform: none; }

.btn-ghost {
  font-size: 14px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 12px;
  color: var(--text-sub);
  background: var(--bg);
  transition: all .15s;
}
.btn-ghost:hover { background: #f0f2f4; color: var(--text); }

.btn-excel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 10px;
  background: #1d6f42;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-excel:hover { background: #155534; transform: translateY(-1px); }
.btn-excel:active { transform: translateY(0); }

.footer-cta {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
  margin-top: 28px;
}
.footer-cta.inline { margin-top: 16px; justify-content: flex-end; }
.footer-cta .btn-primary { margin-left: auto; }

/* -------- Metric grid -------- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 720px) { .metric-grid { grid-template-columns: repeat(2, 1fr); } }

.metric-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 22px;
  border: 1px solid var(--border);
}
.metric-card.alert { background: linear-gradient(180deg, var(--red-soft), white 65%); }
.metric-label { font-size: 13px; color: var(--text-sub); font-weight: 600; margin-bottom: 6px; }
.metric-value { font-size: 26px; font-weight: 800; letter-spacing: -.025em; }
.metric-value.blue { color: var(--primary); }
.metric-value.red { color: var(--red); }
.metric-foot { font-size: 12px; color: var(--text-mute); margin-top: 4px; }
.metric-foot.positive { color: var(--green); }
.metric-foot.negative { color: var(--red); }

/* -------- Charts -------- */
.chart-wrap { position: relative; height: 320px; }
.chart-wrap.small { height: 260px; }

/* -------- Distribution bar -------- */
.dist-bar {
  display: flex; height: 28px; border-radius: 999px; overflow: hidden;
  margin: 18px 0 12px;
}
.dist-bar > div {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
}
.dist-legend {
  display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-sub);
}
.dist-legend > div { display: flex; align-items: center; gap: 6px; }
.dot {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block;
}
.dot.worst { background: var(--red); }
.dot.bad { background: #ff9500; }
.dot.med { background: var(--primary); }
.dot.good { background: var(--green); }
.dot.frontier { background: var(--primary); }
.dot.current { background: var(--amber); }
.dot.best { background: var(--green); }
.dot.min { background: var(--text); }

/* -------- Delta list (optimize) -------- */
.delta-list { display: flex; flex-direction: column; gap: 10px; }
.delta-row {
  display: grid;
  grid-template-columns: 1.4fr 80px 80px 80px;
  align-items: center;
  font-size: 13px;
}
.delta-row .name { font-weight: 600; }
.delta-row .from, .delta-row .to { color: var(--text-sub); text-align: right; }
.delta-row .arrow { color: var(--text-mute); text-align: center; }
.delta-row .delta { text-align: right; font-weight: 700; }
.delta-row .delta.up { color: var(--green); }
.delta-row .delta.down { color: var(--red); }
.delta-row .bar {
  grid-column: 1 / -1;
  height: 4px; border-radius: 2px;
  background: var(--bg);
  margin-top: 4px; overflow: hidden;
}
.delta-row .bar > span { display:block; height:100%; background: var(--primary); }

/* -------- Frontier -------- */
.frontier-legend {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-sub); margin-top: 10px;
}
.frontier-legend > div { display: flex; align-items: center; gap: 6px; }

/* -------- Preset chips -------- */
.preset-row {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center;
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.preset-chip {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all .15s;
}
.preset-chip:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-1px);
}

/* -------- History list -------- */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 12px;
  font-size: 13px;
  transition: background .12s;
}
.history-row:hover { background: #f1f3f5; }
.history-row input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.history-row .label { font-weight: 700; color: var(--text); }
.history-row .meta { color: var(--text-mute); font-size: 12px; }
.history-row .pill {
  display: inline-block; padding: 3px 8px; border-radius: 999px;
  background: white; font-size: 11px; font-weight: 700; color: var(--primary-strong);
  border: 1px solid var(--border-strong);
}
.history-row .pill.red { color: var(--red); }
.history-row button {
  font-size: 12px; padding: 6px 10px; border-radius: 8px;
  color: var(--text-mute); background: white;
}
.history-row button:hover { color: var(--red); background: var(--red-soft); }

#compareBar {
  position: sticky; bottom: 16px;
  display: none;
  align-items: center; justify-content: space-between;
  background: var(--text); color: white;
  padding: 10px 16px; border-radius: 12px;
  margin: 12px 0 0; box-shadow: var(--shadow-md);
}
#compareBar.show { display: flex; }
#compareBar button {
  background: var(--primary); color: white;
  padding: 8px 16px; border-radius: 8px; font-weight: 700; font-size: 13px;
}

/* -------- Compare grid (side-by-side metric cards) -------- */
.compare-col {
  display: flex; flex-direction: column; gap: 12px;
}
.compare-col h3 {
  font-size: 14px;
  margin: 0 0 6px;
  color: var(--text-sub);
}
.compare-row {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 13px;
}
.compare-row .name { font-weight: 600; }
.compare-row .val  { text-align: right; font-weight: 700; }
.compare-row.better .val { color: var(--green); }
.compare-row.worse  .val { color: var(--red); }

/* -------- WB drilldown table -------- */
.drill-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13px;
}
.drill-table th, .drill-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.drill-table th { color: var(--text-sub); font-weight: 600; white-space: nowrap; }
.drill-table td { white-space: nowrap; }
.drill-table td.num { text-align: right; font-weight: 600; font-feature-settings: "tnum"; }
.drill-table td.red { color: var(--red); }
/* 그룹 헤더 행 (그룹별 Component VaR) */
.drill-table tr.drill-grp td {
  background: var(--bg);
  border-top: 2px solid var(--border-strong);
  font-family: var(--font-serif);
  white-space: nowrap;
}
.drill-table tr.drill-grp td b { color: var(--text); }

/* -------- WB metadata grid -------- */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.meta-cell {
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
}
.meta-cell .k { color: var(--text-mute); font-size: 11px; font-weight: 600; }
.meta-cell .v { font-weight: 700; word-break: break-all; margin-top: 2px; }

/* -------- WB console (warnings/errors) -------- */
#wbConsole {
  background: #0e1525;
  color: #cbd5e1;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  border-radius: 12px;
  padding: 14px 16px;
  max-height: 220px;
  overflow: auto;
}
#wbConsole .warn { color: #ffb020; }
#wbConsole .err  { color: #ff6b7a; }

.position-kind-pill {
  font-size: 10px; padding: 2px 7px; border-radius: 999px;
  font-weight: 700;
}
.kind-ticker { background: #e8f3ff; color: var(--primary-strong); }
.kind-isin   { background: #fff4e0; color: #b8631a; }
.kind-cash   { background: #eafaf3; color: #138a5e; }
.kind-bond   { background: #f3f0ff; color: #5b3fd4; }

/* ── 종목 검색 자동완성 드롭다운 ── */
.name-search-wrap {
  position: relative;
  min-width: 0;
}
.security-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: auto;           /* right: 0 제거 → 부모 너비 종속 해제 */
  min-width: max(100%, 360px);  /* 최소 360px, 부모보다 넓으면 부모 따라감 */
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,23,51,.12);
  z-index: 200;
  overflow: hidden;
  max-height: 300px;
  overflow-y: auto;
}
.security-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.security-item:last-child { border-bottom: none; }
.security-item:hover { background: var(--bg); }
.security-item-ticker {
  font-weight: 700;
  color: var(--primary);
  min-width: 68px;
  font-size: 12px;
  flex-shrink: 0;
}
.security-item-name {
  flex: 1;
  min-width: 120px;     /* 이름이 120px 이상 확보 */
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.security-item-mkt {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
  margin-right: 2px;
}
.security-item-mkt.kr { background: #fff0f0; color: #e03131; }
.security-item-mkt.us { background: #e8f4fd; color: #1971c2; }
.security-item-type {
  font-size: 10px;
  color: var(--text-mute);
  background: var(--bg);
  padding: 1px 4px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-left: auto;
}
.security-item-cat {
  font-size: 11px;
  color: var(--text-mute);
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--bg);
  border-radius: 4px;
  padding: 2px 6px;
}
/* 채권 검색 결과 — 만기/쿠폰 메타 텍스트 */
.security-item-bond-meta {
  font-size: 10px;
  color: #0891b2;
  background: #ecfeff;
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}

/* legacy aliases */
.kind-equity { background: #e8f3ff; color: var(--primary-strong); }
.kind-et     { background: #fff4e0; color: #b8631a; }

/* -------- XML preview boxes (WB SOAP step) -------- */
.xml-box {
  background: #0e1525;
  color: #cbd5e1;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  padding: 16px 18px;
  border-radius: 12px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* -------- MyData (마이데이터 view) -------- */
.btn-mydata {
  background: linear-gradient(135deg, #20c997 0%, #138a5e 100%);
  color: white;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 10px;
  transition: transform .12s, box-shadow .12s;
  box-shadow: 0 2px 8px rgba(32, 201, 151, .25);
}
.btn-mydata:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(32, 201, 151, .35); }

.md-progress {
  display: flex;
  gap: 10px;
  margin: 12px 0 24px;
}
.md-step {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 12px;
  color: var(--text-mute);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  border: 2px solid transparent;
}
.md-step.active { background: var(--primary-soft); color: var(--primary-strong); border-color: var(--primary); }
.md-step.done   { background: #eafaf3; color: #138a5e; }

.persona-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.persona-card {
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 18px;
  cursor: pointer;
  transition: all .15s;
  text-align: left;
}
.persona-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  background: white;
  box-shadow: var(--shadow-md);
}
.persona-card .pname { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.persona-card .psum  { font-size: 12px; color: var(--text-sub); margin-bottom: 10px; line-height: 1.45; }
.persona-card .pstat { font-size: 11px; color: var(--text-mute); }

.consent-box {
  background: var(--bg);
  border-radius: 14px;
  padding: 22px;
}
.consent-org { display: flex; align-items: center; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.consent-list { padding-left: 18px; margin: 12px 0; }
.consent-list li { font-size: 14px; padding: 4px 0; color: var(--text-sub); }
.consent-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.md-account {
  background: var(--bg);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 10px;
}
.md-account-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.md-account-head .name { font-weight: 700; font-size: 14px; }
.md-account-head .num  { color: var(--text-mute); font-size: 12px; }
.md-product-row {
  display: grid;
  grid-template-columns: 50px 1fr 90px 130px 60px;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px dashed var(--border);
  font-size: 13px;
}
.md-product-row .type-pill { font-size: 10px; padding: 3px 6px; border-radius: 5px; text-align: center; font-weight: 700; align-self: center; }
.md-product-row .num { text-align: right; font-feature-settings: "tnum"; }
.md-product-row .ccy { color: var(--text-mute); font-size: 11px; align-self: center; }
.t-eq { background: #e8f3ff; color: var(--primary-strong); }
.t-etf { background: #fff4e0; color: #b8631a; }
.t-bond { background: #f0e8ff; color: #5e3edc; }
.t-cash { background: #eafaf3; color: #138a5e; }
.t-other { background: var(--border); color: var(--text-mute); }

.md-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  margin: 18px 0;
  padding: 14px;
  background: var(--primary-soft);
  border-radius: 12px;
}
.md-summary .sumcell { font-size: 12px; }
.md-summary .sumcell .k { color: var(--primary-strong); font-weight: 700; }
.md-summary .sumcell .v { font-weight: 700; font-size: 14px; margin-top: 2px; }

.md-cta-grid { margin-top: 12px; }
.md-cta {
  padding: 22px 20px !important;
  font-size: 15px;
  text-align: center;
  border-radius: 16px !important;
}

/* -------- Analyze side-by-side layout -------- */
.analyze-sidebyside {
  display: grid;
  grid-template-columns: 1fr;      /* 분석 설정을 전체 폭으로 (결과는 아래에 전체 폭 표시) */
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}
.analyze-col-left,
.analyze-col-right { display: flex; flex-direction: column; }

/* 우측 메트릭 고정 2×2 그리드 */
.metric-grid-2x2 {
  grid-template-columns: repeat(2, 1fr) !important;
}

@media (max-width: 900px) {
  .analyze-sidebyside { grid-template-columns: 1fr; }
}

/* -------- Macro Indicators -------- */
.macro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 12px;
  margin-top: 4px;
}

/* 매크로 지표 — 한 줄 티커(오른쪽 → 왼쪽 무한 이동) */
.macro-ticker {
  overflow: hidden;
  position: relative;
  width: 100%;
  margin-top: 4px;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 5%, #000 95%, transparent);
          mask-image: linear-gradient(to right, transparent, #000 5%, #000 95%, transparent);
}
.macro-ticker-track {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  will-change: transform;
  animation: macroTickerScroll 40s linear infinite;
}
.macro-ticker:hover .macro-ticker-track { animation-play-state: paused; }
@keyframes macroTickerScroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-33.333%); }   /* 3벌 중 1벌 이동 = seamless */
}
.macro-ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-right: 1px solid var(--border, #ececec);
  cursor: pointer;
  font-size: 13px;
  flex: 0 0 auto;
}
.macro-ticker-item:hover { background: var(--bg-soft, #f6f3ec); }
.mti-name { color: var(--text-mute); font-weight: 500; }
.mti-spark { width: 46px; height: 16px; display: inline-flex; align-items: center; }
.mti-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.mti-unit { font-weight: 500; font-size: 11px; color: var(--text-mute); margin-left: 2px; }
.mti-chg { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
  .macro-ticker-track { animation: none; }
}
.macro-tile {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--bg);
  cursor: pointer;
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.macro-tile:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
  transform: translateY(-2px);
  border-color: #c4cdd6;
}
.macro-tile-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}
.macro-tile-name { font-size: 12px; font-weight: 600; color: var(--text-mute); }
.macro-tile-chg  { font-size: 11px; font-weight: 700; white-space: nowrap; }
.macro-tile-val {
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
  margin: 5px 0 8px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.macro-tile-unit { font-size: 11px; font-weight: 500; color: var(--text-mute); }
.macro-spark { height: 44px; }
.macro-tile-foot { font-size: 10px; color: var(--text-mute); margin-top: 7px; }

/* 하이퍼스케일러 CapEx */
.cx-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.cx-headline { font-size: 14px; color: var(--text-sub); }
.cx-headline b { font-size: 24px; color: var(--text); font-weight: 800; }
.cx-per { font-size: 12px; color: var(--text-mute); }
.cx-yoybig { font-size: 14px; font-weight: 700; }
.cx-chart-wrap { position: relative; height: 230px; margin: 6px 0 12px; }
.cx-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.cx-table-wrap { overflow-x: auto; border-top: 1px solid var(--border); padding-top: 8px; }
.cx-matrix { width: 100%; border-collapse: collapse; min-width: 520px; font-size: 12px; }
.cx-th { text-align: right; font-weight: 600; color: var(--text-mute); padding: 6px 8px; white-space: nowrap; border-bottom: 1px solid var(--border-strong); }
.cx-th-name { text-align: left; }
.cx-td { text-align: right; padding: 6px 8px; white-space: nowrap; color: var(--text); font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--border); }
.cx-tdname { text-align: left; font-weight: 600; }
.cx-total td { border-top: 2px solid var(--border-strong); font-weight: 800; background: var(--bg); }
.cx-pending { margin-top: 10px; font-size: 11px; color: #9a6a00; background: #fff8e6; border: 1px solid #ffe8b3; border-radius: 8px; padding: 6px 9px; }
.cx-note { margin-top: 10px; font-size: 11px; color: var(--text-mute); padding-top: 9px; border-top: 1px dashed var(--border-strong); line-height: 1.5; }

/* 스트레스 경보 */
.sa-top { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.sa-gauge { flex: 0 0 auto; text-align: center; min-width: 120px; }
.sa-score { font-size: 40px; font-weight: 800; line-height: 1; }
.sa-score-max { font-size: 14px; font-weight: 600; color: var(--text-mute); }
.sa-level { display: inline-block; margin-top: 6px; padding: 3px 14px; border-radius: 14px; color: #fff; font-size: 13px; font-weight: 700; }
.sa-bar { margin-top: 8px; height: 7px; border-radius: 4px; background: var(--border-strong); overflow: hidden; }
.sa-fill { height: 100%; border-radius: 4px; transition: width .4s; }
.sa-advisory { flex: 1; min-width: 200px; }
.sa-adv { font-size: 14px; font-weight: 600; line-height: 1.5; }
.sa-updated { font-size: 11px; color: var(--text-mute); margin-top: 4px; }
.sa-signals { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); padding-top: 10px; }
.sa-row { display: grid; grid-template-columns: 14px 132px 66px 46px 1fr; align-items: center; gap: 8px; padding: 5px 2px; font-size: 12px; }
.sa-dot { width: 9px; height: 9px; border-radius: 50%; }
.sa-name { font-weight: 600; color: var(--text); }
.sa-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.sa-badge { text-align: center; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; border: 1px solid; }
.sa-note { color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sa-notify { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border-strong); }
.sa-notify-head { font-size: 13px; font-weight: 700; color: var(--text); }
.sa-notify-desc { font-size: 11px; color: var(--text-mute); margin: 4px 0 8px; line-height: 1.5; }
.sa-notify-row { display: flex; gap: 8px; flex-wrap: wrap; }
.sa-input { font-size: 13px; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; color: var(--text); }
.sa-save { font-size: 13px; font-weight: 600; padding: 7px 16px; border: none; border-radius: 8px; background: var(--primary, var(--primary)); color: #fff; cursor: pointer; }
.sa-save:hover { background: var(--primary-strong, var(--primary-strong)); }
.sa-ghost { font-size: 13px; font-weight: 600; padding: 7px 14px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; color: var(--text-sub); cursor: pointer; }
.sa-ghost:hover { background: var(--bg); }
.sa-kakao-ok { font-size: 13px; font-weight: 700; color: #12b886; display: inline-flex; align-items: center; }

/* 국장 예보 */
.fc-presslabel { font-size: 11px; color: var(--text-mute); margin-top: 6px; }
.fc-foreign { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.fc-foreign-h { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.fc-foreign-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.fc-foreign-lbl { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.fc-foreign-lbl.sell { color: #1971c2; background: #1971c215; }
.fc-foreign-lbl.buy { color: #e03131; background: #e0313115; }
.fc-chip { font-size: 12px; padding: 3px 9px; border-radius: 13px; background: var(--bg); border: 1px solid var(--border-strong); color: var(--text-sub); white-space: nowrap; }
.fc-chip.sell { border-color: #1971c233; }
.fc-chip.buy { border-color: #e0313133; }
.sa-disclaimer { margin-top: 12px; font-size: 11px; color: var(--text-mute); line-height: 1.5; padding-top: 10px; border-top: 1px dashed var(--border-strong); }
@media (max-width: 560px) { .sa-row { grid-template-columns: 12px 1fr 58px 42px; } .sa-note { display: none; } }

/* -------- Stress Test -------- */
.stress-scenario-desc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 4px;
}
.stress-scen-badge {
  background: color-mix(in srgb, var(--sc-color) 8%, white);
  border: 1.5px solid color-mix(in srgb, var(--sc-color) 25%, white);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stress-scen-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--sc-color);
  letter-spacing: -.01em;
}
.stress-scen-period {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-mute);
}
.stress-scen-desc {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 2px;
  line-height: 1.45;
}

/* 3 result cards in a row */
.stress-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.stress-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.stress-card-header {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--sc-color) 7%, white);
}
.stress-card-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--sc-color);
}
.stress-card-period {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 2px;
}
.stress-card-body {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stress-metric-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.stress-metric-label {
  font-size: 12px;
  color: var(--text-mute);
  font-weight: 600;
  white-space: nowrap;
}
.stress-metric-vals {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.stress-metric-before {
  font-size: 13px;
  color: var(--text-sub);
  text-decoration: line-through;
  text-decoration-color: var(--border-strong);
}
.stress-metric-after {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}
.stress-metric-after.loss { color: var(--red); }
.stress-metric-after.gain { color: var(--green); }
.stress-delta-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.stress-delta-pill.neg { background: var(--red-soft); color: var(--red); }
.stress-delta-pill.pos { background: var(--green-soft); color: var(--green); }
.stress-vol-mult {
  font-size: 11px;
  color: var(--text-mute);
  margin-left: 4px;
}

@media (max-width: 900px) {
  .stress-scenario-desc-grid { grid-template-columns: 1fr; }
  .stress-cards-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .stress-scenario-desc-grid { gap: 8px; }
  .stress-cards-grid { gap: 10px; }
}

/* -------- Table scroll wrapper -------- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.table-scroll::-webkit-scrollbar { height: 4px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

/* -------- Analyze loading card -------- */
.analyze-loading-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 28px 24px;
}
/* 분석 전 안내 placeholder */
.analyze-placeholder-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px;
  border: 1.5px dashed var(--border-strong);
  background: var(--bg);
  box-shadow: none;
}
.analyze-ph-icon { flex-shrink: 0; font-size: 30px; opacity: .55; filter: grayscale(1); }
.analyze-ph-text { display: flex; flex-direction: column; gap: 5px; }
.analyze-ph-text strong { font-size: 14px; color: var(--text); }
.analyze-ph-text span { font-size: 12.5px; color: var(--text-mute); line-height: 1.55; }
/* 스트레스 사용자 지정 기간 */
.stress-custom { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border-strong); }
.stress-custom-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.stress-custom-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.stress-custom-row label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--text-mute); }
.stress-custom-row input {
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 9px;
  font-size: 13px; color: var(--text); background: #fff; outline: none;
}
.stress-custom-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.analyze-spinner {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.analyze-loading-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.analyze-loading-text strong {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.analyze-loading-text span {
  font-size: 13px;
  color: var(--text-mute);
}

/* -------- Optimization Method Cards (새 가로 레이아웃) -------- */

/* 가로 4개 카드 행 */
.method-cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 12px 0 0;
}

/* 개별 방법론 카드 */
.method-card {
  background: #fff;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s, background .18s;
  user-select: none;
}
.method-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 10px rgba(49,130,246,.10);
}
.method-card.active {
  border-color: var(--primary);
  background: rgba(49,130,246,.04);
  box-shadow: 0 3px 16px rgba(49,130,246,.15);
}
.method-card-no {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 4px;
  padding: 1px 6px;
  display: inline-block;
  margin-bottom: 7px;
}
.method-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  line-height: 1.3;
}
.method-card-eng {
  font-size: 10.5px;
  color: var(--text-mute);
  margin-bottom: 8px;
}
.method-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.method-card-tags span {
  font-size: 10px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 4px;
  padding: 1px 6px;
}

/* 선택된 카드 아래 설정 패널 */
.method-panel {
  margin-top: 20px;
  padding: 20px;
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  animation: fadeSlideDown .18s ease;
}
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.method-panel-inner {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}
.method-panel-left  { flex: 1; min-width: 0; }
.method-panel-right { flex: 0 0 240px; }
.method-panel-desc {
  font-size: 12.5px;
  color: var(--text-mute);
  line-height: 1.65;
  margin-bottom: 12px;
}

.paper-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 6px;
  padding: 4px 10px;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.paper-download-btn:hover {
  background: var(--primary);
  color: #fff;
}

@media (max-width: 900px) {
  .method-cards-row { grid-template-columns: repeat(2, 1fr); }
  .method-panel-inner { flex-direction: column; }
  .method-panel-right { flex: none; width: 100%; }
}
@media (max-width: 540px) {
  .method-cards-row { grid-template-columns: 1fr 1fr; }
}

/* -------- Trading Tab -------- */
.broker-bar {
  display: flex;
  gap: 24px;
  align-items: center;
  padding: 14px 20px;
  flex-wrap: wrap;
}
.broker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-sub);
}
.broker-item strong { font-weight: 700; color: var(--text); }
.broker-item.active strong { color: var(--primary); }
.broker-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
}
.broker-dot.active {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.broker-label {
  font-size: 11px;
  color: var(--text-mute);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Order table inside trade section */
.trade-order-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.trade-order-table th,
.trade-order-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.trade-order-table th { color: var(--text-sub); font-weight: 600; }
.trade-order-table td.num { text-align: right; font-feature-settings: "tnum"; font-weight: 600; }
.trade-action-buy  { color: var(--primary); font-weight: 800; }
.trade-action-sell { color: var(--red);     font-weight: 800; }
.trade-action-hold { color: var(--text-mute); font-weight: 600; }

/* Summary bar above execute button */
.trade-summary-bar {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 12px;
  font-size: 13px;
}
.trade-summary-item { display: flex; flex-direction: column; gap: 2px; }
.trade-summary-item .k { font-size: 11px; color: var(--text-mute); font-weight: 600; }
.trade-summary-item .v { font-weight: 700; }
.trade-summary-item .v.buy  { color: var(--primary); }
.trade-summary-item .v.sell { color: var(--red); }

/* -------- KIS Config Panel -------- */
.broker-item.clickable {
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 8px;
  margin: -4px -8px;
  transition: background 0.15s;
}
.broker-item.clickable:hover { background: var(--bg); }

.badge-green {
  background: #d3f8e0;
  color: #0a6e35;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 600;
}

.kis-config-panel {
  padding: 20px 24px 24px;
  margin-top: 0;
  border-top: 3px solid var(--primary);
}
.kis-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}
.kis-input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
}
.kis-field { display: flex; flex-direction: column; gap: 5px; }
.kis-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kis-input {
  height: 36px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}
.kis-input:focus { border-color: var(--primary); }

.kis-mode-toggle {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-top: 4px;
}
.kis-mode-opt {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-sub);
}
.kis-mode-opt.real { color: var(--red); font-weight: 600; }

.kis-real-warning {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fff5f5;
  border: 1px solid #fcc;
  border-radius: 8px;
  font-size: 12px;
  color: var(--red);
  line-height: 1.5;
}

.kis-connected-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #f0faf4;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}

.kis-balance-section { margin-top: 4px; }
.kis-balance-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.kis-order-result {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.kis-result-header {
  padding: 8px 12px;
  background: var(--bg);
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.kis-result-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.kis-result-row:last-child { border-bottom: none; }
.kis-result-status { margin-left: auto; }

/* KIS execute button */
.btn-kis {
  height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: #1453c8;
  color: #fff;
  transition: background 0.15s, opacity 0.15s;
}
.btn-kis:hover:not(:disabled) { background: #0f3fa0; }
.btn-kis:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-kis.btn-kis-real {
  background: var(--red);
}
.btn-kis.btn-kis-real:hover:not(:disabled) { background: #c0392b; }

@media (max-width: 768px) {
  .broker-bar { gap: 14px; padding: 12px 14px; }
  .trade-summary-bar { gap: 14px; }
  .kis-input-grid { grid-template-columns: 1fr; }
}

/* -------- Footer -------- */
.foot {
  margin-top: auto;
  padding: 16px 24px 32px;
  text-align: center;
  color: var(--text-mute);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.foot-creed {
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--text);
  letter-spacing: .02em;
}

/* ═══════════ 투자 신조 (전 화면 상시) ═══════════ */
.manifesto {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg-soft, #f6f3ec);
  text-align: center;
  padding: 9px 16px;
}
.manifesto-line {
  font-family: var(--font-serif);
  font-size: 13.5px;
  letter-spacing: .04em;
  color: var(--text);
}
.manifesto-line em {
  font-style: normal;
  font-weight: 700;
  color: var(--primary, #7b2d3a);
  border-bottom: 2px solid currentColor;
  padding-bottom: 1px;
}
@media (max-width: 720px) {
  .manifesto { padding: 8px 12px; }
  .manifesto-line { font-size: 12px; letter-spacing: .02em; }
}

/* ═══════════ 투자 철학 분석 ═══════════ */

/* 탭 */
.philosophy-card { }
.phil-tabs {
  display: flex; gap: 4px;
  border-bottom: 2px solid var(--border);
  margin: 12px 0 20px;
}
.phil-tab {
  padding: 8px 16px; border-radius: 8px 8px 0 0;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; background: none; color: var(--text-sub);
  transition: color .15s, background .15s;
}
.phil-tab:hover { background: var(--bg); color: var(--text); }
.phil-tab.active {
  color: var(--primary); border-bottom: 2px solid var(--primary);
  margin-bottom: -2px;
}
.phil-pane { animation: fadeIn .2s ease; }

/* DNA 레이아웃 */
.phil-dna-layout {
  display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start;
}
.phil-radar-wrap { display: flex; justify-content: center; }

/* 스타일 배지 */
.phil-style-badge {
  display: inline-block; padding: 5px 12px;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 20px; font-size: 12px; font-weight: 700;
  margin-bottom: 14px;
}

/* 점수 바 */
.phil-score-bars { display: flex; flex-direction: column; gap: 7px; }
.phil-score-row { display: flex; align-items: center; gap: 8px; }
.phil-score-label { width: 46px; font-size: 12px; color: var(--text-sub); font-weight: 600; }
.phil-bar-bg { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.phil-bar-fill { height: 100%; border-radius: 4px; transition: width .5s ease; }
.phil-score-val { width: 28px; text-align: right; font-size: 12px; font-weight: 700; color: var(--text-sub); }

/* Gap 분석 */
.phil-gaps { margin-top: 14px; }
.phil-gap-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 7px 10px; border-radius: 8px; margin-bottom: 6px; font-size: 12px;
}
.phil-gap-warn { background: #fff7ed; border-left: 3px solid var(--amber); }
.phil-gap-info { background: var(--bg); border-left: 3px solid var(--border-strong); }
.phil-gap-fix { font-size: 11px; color: var(--text-mute); }
.phil-all-ok { margin-top: 12px; font-size: 13px; color: var(--green); font-weight: 600; }

/* 실제 보유 종목 (SEC 13F) */
.famous13f-section { margin-bottom: 4px; }
.famous13f-head, .famous-models-head {
  font-size: 15px; font-weight: 700; color: var(--text);
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 2px 0 12px;
}
.famous13f-head span, .famous-models-head span {
  font-size: 12px; font-weight: 500; color: var(--text-mute);
}
.famous-models-head { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border-strong); }
.famous13f-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px;
}
.f13-card {
  border: 1.5px solid var(--border); border-radius: 14px; padding: 14px; background: var(--bg-card);
}
.f13-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.f13-emoji { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex-shrink: 0; border: 1px solid var(--border-strong); border-radius: 50%; font-family: var(--font-serif); font-size: 13px; font-weight: 600; color: var(--text-sub); letter-spacing: .03em; }
.f13-id { flex: 1; min-width: 0; }
.f13-name { font-size: 15px; font-weight: 700; color: var(--text); }
.f13-fund { font-size: 12px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f13-date {
  font-size: 11px; color: var(--text-sub); background: var(--bg);
  padding: 2px 7px; border-radius: 6px; white-space: nowrap;
}
.f13-canvas-wrap { position: relative; height: 176px; margin: 8px 0 12px; }
.f13-legend { display: flex; flex-direction: column; gap: 4px; }
.f13-leg { font-size: 12px; color: var(--text-sub); display: flex; align-items: center; gap: 6px; }
.f13-leg strong { color: var(--text); font-weight: 700; margin-left: auto; }
.f13-dot { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.f13-meta { font-size: 11px; color: var(--text-mute); margin-top: 7px; padding-top: 7px; border-top: 1px dashed var(--border-strong); }
.f13-note {
  font-size: 11px; color: #9a6a00; background: #fff8e6; border: 1px solid #ffe8b3;
  border-radius: 8px; padding: 7px 9px; margin-top: 10px; line-height: 1.45;
}
.f13-hist-btn {
  width: 100%; margin-top: 10px; padding: 8px 10px; font-size: 12px; font-weight: 600;
  color: var(--text-sub); background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: 9px; cursor: pointer; transition: background .12s, border-color .12s;
}
.f13-hist-btn:hover { background: #eef2ff; border-color: var(--primary, var(--primary)); color: var(--primary, var(--primary)); }

/* 13F 5년 추이 모달 */
.f13-modal-close {
  position: absolute; top: 16px; right: 18px; background: none; border: none;
  font-size: 18px; cursor: pointer; color: var(--text-mute); line-height: 1;
}
.f13-hist-title { font-size: 16px; font-weight: 700; color: var(--text); padding-right: 24px; }
.f13-hist-sub { font-size: 12px; color: var(--text-mute); margin: 2px 0 12px; }
.f13-hist-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.f13-hist-chip {
  font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 8px; cursor: pointer;
  color: var(--text-sub); background: var(--bg); border: 1px solid var(--border-strong);
  transition: all .12s;
}
.f13-hist-chip:hover { border-color: var(--primary, var(--primary)); }
.f13-hist-chip.active {
  color: #fff; background: var(--primary, var(--primary)); border-color: var(--primary, var(--primary));
}
.f13-hist-meta { font-size: 12px; color: var(--text-sub); margin-bottom: 10px; text-align: center; }

/* ── 투자일지 노트 (옥스포드 노트) ───────────────────────────── */
.journal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(20,20,30,.5); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.journal-sheet {
  position: relative; width: min(560px, 96vw); max-height: 92vh; overflow-y: auto;
  background: #fbf7ec; border-radius: 14px; padding: 20px 22px 18px;
  box-shadow: 0 30px 70px rgba(0,0,0,.4);
}
.journal-close {
  position: absolute; top: 14px; right: 16px; background: none; border: none;
  font-size: 18px; cursor: pointer; color: #9b9384; line-height: 1; z-index: 2;
}
.journal-mute {
  position: absolute; top: 13px; right: 44px; background: none; border: none;
  font-size: 16px; cursor: pointer; line-height: 1; z-index: 2; opacity: .85;
}
.journal-mute:hover { opacity: 1; }
.journal-head { font-size: 16px; font-weight: 800; color: #2b2b3a; padding-right: 24px; }
.journal-sub  { font-size: 12px; color: #8b95a1; margin: 3px 0 4px; }

/* 템플릿 선택 카드 */
.journal-tpl-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 10px 0 14px; }
.journal-tpl-card {
  text-align: left; cursor: pointer; padding: 14px; border-radius: 12px;
  border: 1.5px solid #e6dfcb; background: #fffdf6;
  transition: transform .1s, border-color .1s, box-shadow .1s;
}
.journal-tpl-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.journal-tpl-icon { color: var(--text-sub); line-height: 0; display: inline-block; }
.journal-tpl-name { font-weight: 700; font-size: 14px; color: #2b2b3a; margin-top: 6px; }
.journal-tpl-desc { font-size: 11px; color: #8b95a1; margin-top: 2px; }

/* 지난 일지 목록 */
.journal-past { margin-top: 8px; border-top: 1px dashed #d9d2bd; padding-top: 10px; }
.journal-past-title { font-size: 12px; font-weight: 700; color: #6b6450; margin-bottom: 6px; }
.journal-past-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: transparent; border: none; border-radius: 8px; padding: 6px 8px; cursor: pointer; font-size: 12px;
}
.journal-past-item:hover { background: #f1ead6; }
.journal-past-date { font-weight: 600; color: #2b2b3a; white-space: nowrap; }
.journal-past-icon { font-size: 14px; }
.journal-past-prev { color: #8b95a1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 노트 작성 화면 */
.journal-paper-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 0; padding-right: 26px; }
.journal-tab {
  display: inline-block; font-weight: 700; font-size: 13px; color: #fff;
  background: var(--primary); padding: 6px 14px; border-radius: 8px 8px 0 0;
}
.journal-date { border: 1px solid #d9d2bd; border-radius: 8px; padding: 5px 8px; font-size: 12px; background: #fffdf6; color: #2b2b3a; }
.journal-book {
  position: relative; border-radius: 8px;
  box-shadow: inset 0 0 0 1px #ece6d3;
}
.journal-rings { display: none; }
.journal-paper {
  display: block; width: 100%; min-height: 340px; box-sizing: border-box;
  border: none; outline: none; resize: vertical;
  padding: 16px 18px;
  line-height: 1.7; font-size: 15px;
  font-family: 'Pretendard', system-ui, sans-serif; color: #2b2b3a;
  background-color: #fffdf5;
  border-radius: 8px;
}
.journal-paper::placeholder { color: #b9b29c; }
.journal-blocks { display: flex; flex-direction: column; gap: 8px; background: #f6f1e6; padding: 8px; border-radius: 8px; }
.journal-block { display: flex; gap: 8px; align-items: flex-start; background: #fffdf5; border: 1px solid #e7e0d0; border-radius: 8px; padding: 8px 10px; }
.journal-block.dragging { opacity: .45; border-style: dashed; }
.journal-block-handle { cursor: grab; color: #c0b9a6; padding: 5px 2px 0; line-height: 0; flex-shrink: 0; touch-action: none; }
.journal-block-handle:active { cursor: grabbing; }
.journal-block-main { flex: 1; min-width: 0; }
.journal-block-title { font-size: 12px; font-weight: 600; color: #6b6452; margin-bottom: 3px; }
.journal-block-text { width: 100%; border: none; outline: none; resize: vertical; background: transparent; font-family: 'Pretendard', system-ui, sans-serif; font-size: 14px; line-height: 1.6; color: #2b2b3a; min-height: 36px; }
.journal-block-text::placeholder { color: #c9c2b0; }
.journal-hint { font-size: 11px; color: #b9b29c; margin-top: 8px; display: flex; align-items: center; gap: 5px; }
.journal-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.journal-btn {
  font-size: 13px; padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 600;
  border: 1px solid #d9d2bd; background: #fffdf6; color: #5b5440;
}
.journal-btn:hover { background: #f1ead6; }
.journal-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.journal-btn.primary:hover { background: var(--primary-strong); }
.journal-del { color: #e03131; border-color: #f3c0c0; }
@media (max-width: 480px) { .journal-tpl-grid { grid-template-columns: 1fr; } }

/* 유명 투자자 */
.phil-famous-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.famous-card {
  border: 1.5px solid var(--border); border-radius: 14px;
  padding: 16px 18px; display: flex; flex-direction: column; gap: 10px;
}
.famous-head { display: flex; justify-content: space-between; align-items: flex-start; }
.famous-name { font-size: 15px; font-weight: 700; }
.famous-subtitle { font-size: 11px; color: var(--text-mute); margin-top: 2px; }

.sim-badge {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.sim-high { background: #d3f8e0; color: #0a6e35; }
.sim-mid  { background: #fff7ed; color: #8a4d00; }
.sim-low  { background: #fff1f3; color: #c0392b; }

.alloc-bar-wrap { }
.alloc-bar {
  display: flex; height: 10px; border-radius: 6px; overflow: hidden; gap: 1px;
}
.alloc-seg { height: 100%; min-width: 3px; }
.alloc-legend {
  display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px;
}
.alloc-leg-item { font-size: 10.5px; color: var(--text-sub); display: flex; align-items: center; gap: 4px; }
.alloc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.famous-desc { font-size: 12px; color: var(--text-sub); line-height: 1.55; margin: 0; }
.famous-sw { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sw-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.sw-item { font-size: 11px; color: var(--text-sub); line-height: 1.6; }
.famous-quote {
  font-size: 11px; color: var(--text-mute); font-style: italic;
  border-top: 1px solid var(--border); padding-top: 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* 연구 기반 뷰 */
.phil-research-grid { display: flex; flex-direction: column; gap: 12px; }
.research-card {
  border: 1.5px solid var(--border); border-radius: 14px; padding: 16px 18px;
  transition: border-color .2s, box-shadow .2s;
}
.research-card:hover { border-color: var(--primary-strong); }
.research-card-activated {
  border-color: var(--primary) !important;
  background: var(--primary-soft);
}
.research-head {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px;
}
.research-icon { font-size: 22px; flex-shrink: 0; margin-top: 1px; }
.research-title-group { flex: 1; }
.research-title { font-size: 14px; font-weight: 700; }
.research-source {
  display: inline-block; margin-top: 3px; padding: 2px 8px;
  background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: 20px; font-size: 10.5px; color: var(--text-sub);
}
.research-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.conf-dots { font-size: 11px; letter-spacing: 2px; }
.conf-high { color: var(--green); }
.conf-mid  { color: var(--amber); }
.conf-low  { color: var(--text-mute); }
.research-horizon {
  font-size: 10.5px; font-weight: 600; padding: 2px 8px;
  border-radius: 20px; white-space: nowrap;
}
.research-desc { font-size: 12.5px; color: var(--text-sub); line-height: 1.55; margin: 0 0 8px; }
.research-evidence {
  font-size: 11.5px; color: var(--text-mute); background: var(--bg);
  border-radius: 8px; padding: 7px 10px; margin-bottom: 8px;
}
.research-match {
  font-size: 12px; padding: 7px 10px; border-radius: 8px; margin-bottom: 8px; line-height: 1.6;
}
.research-match.ok   { background: #eafaf3; color: #0a6e35; }
.research-match.miss { background: var(--bg); color: var(--text-sub); }
.research-footer { display: flex; gap: 8px; flex-wrap: wrap; }
.research-action-btn { font-size: 12px; padding: 5px 14px; }

@media (max-width: 860px) {
  .phil-dna-layout { grid-template-columns: 1fr; }
  .phil-radar-wrap { margin: 0 auto; }
  .phil-famous-grid { grid-template-columns: 1fr; }
}

/* -------- Toast -------- */
.toast {
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--text); color: white;
  padding: 14px 22px; border-radius: 14px;
  font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: all .25s ease;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* -------- Loading button state -------- */
.btn-primary.loading {
  position: relative; color: transparent !important;
}
.btn-primary.loading::after {
  content: ''; position: absolute;
  top: 50%; left: 50%;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: translate(-50%,-50%) rotate(360deg); } }

/* ============================================================
   MOBILE RESPONSIVE
   768px : tablet  |  480px : phone
   ============================================================ */

/* ── Bottom nav bar (hidden on desktop) ── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: rgba(255,255,255,.96);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.mobile-nav-inner {
  display: flex;
  width: 100%;
  height: 56px;
  /* 5개 탭은 화면 폭에 균등 배치 (overflow-x:auto 가 flex:1 분배를 막아 제거) */
}
.mob-tab {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-mute);
  font-size: 10px;
  font-weight: 600;
  padding: 6px 4px;
  transition: color .15s;
  letter-spacing: 0;
}
.mob-tab svg { width: 20px; height: 20px; stroke-width: 1.8; }
.mob-tab.active { color: var(--primary); }
.mob-tab.active svg { stroke-width: 2.4; }

/* ── 768px: tablet adjustments ── */
@media (max-width: 768px) {
  /* show bottom nav, hide topbar steps */
  .mobile-nav { display: flex; }
  .steps { display: none; }

  /* topbar */
  .topbar-inner { padding: 10px 16px; gap: 10px; }
  .topbar-meta { margin-left: auto; }
  .topbar-meta .badge-local { display: none; }
  .btn-mydata { font-size: 12px !important; padding: 7px 11px !important; }

  /* page content — extra bottom padding for nav bar */
  .content { padding: 16px 14px 72px; }

  /* cards */
  .card { padding: 18px 16px; border-radius: 16px; }
  .card h2 { font-size: 15px; margin-bottom: 14px; }

  /* hero */
  .hero { padding: 14px 4px 20px; }
  .hero-title { font-size: 24px; }
  .hero-sub { font-size: 13px; }

  /* card header stacks on mobile */
  .card-header { flex-wrap: wrap; gap: 10px; }

  /* 포지션 액션 버튼 — 2×2 그리드 (한 줄에 두 개씩, 텍스트 안 깨짐) */
  .position-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
  }
  .position-actions .btn-ghost {
    width: 100%;
    justify-content: center;
    text-align: center;
    font-size: 12.5px;
    padding: 11px 8px;
    white-space: nowrap;
  }

  /* preset chip row — horizontal scroll */
  .preset-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 10px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .preset-row::-webkit-scrollbar { display: none; }

  /* seg control — horizontal scroll */
  .seg {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { white-space: nowrap; }

  /* 컬럼 헤더 — 모바일 카드 레이아웃에선 데스크탑 9열 그리드가 화면을 넘침.
     라벨은 숨기고 '추세' 기간 토글 버튼만 우측에 한 줄로 표시. */
  .holding-row-header {
    display: flex !important;
    justify-content: flex-end !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 6px 10px !important;
    flex-wrap: wrap;
  }
  .holding-row-header > span { display: none !important; }

  /* ── Holding rows: 모바일 컴팩트 (12컬럼, 이름+티커 한 줄) ──
     child order: ①del ②badge ③name ④id ⑤shares ⑥notional ⑦spark ⑧weight ⑨lock
     Row 1: [✕] [배지] [이름──────] [티커──] [🔓]
     Row 2: [수량] [평가금액] [비중] [📈 수익률버튼]
     Row 3: [그래프] (수익률버튼 탭 시 펼침)            */
  .holding-row--ticker,
  .holding-row--cash {
    grid-template-columns: repeat(12, 1fr) !important;
    grid-template-rows: auto auto auto !important;
    row-gap: 6px !important;
    column-gap: 4px !important;
    padding: 9px 8px !important;
  }
  /* ① del → r1 */
  .holding-row > :nth-child(1) { grid-column: 1/2;   grid-row:1; align-self:center; }
  /* ② badge → r1 */
  .holding-row > :nth-child(2) { grid-column: 2/4;   grid-row:1; align-self:center; }
  /* ③ name → r1 */
  .holding-row > :nth-child(3) { grid-column: 4/9;   grid-row:1; min-width:0; align-self:center; }
  /* ④ id(티커) → r1 (이름 옆, 자물쇠 삭제로 끝까지 확장) */
  .holding-row > :nth-child(4) { grid-column: 9/13;  grid-row:1; min-width:0; align-self:center; }
  /* ⑤ shares(수량) → r2 */
  .holding-row > :nth-child(5) { grid-column: 1/4;   grid-row:2; min-width:0; align-self:center; }
  /* ⑥ notional(평가금액) → r2 */
  .holding-row > :nth-child(6) { grid-column: 4/8;   grid-row:2; min-width:0; align-self:center; }
  /* ⑧ weight(비중) → r2 */
  .holding-row > :nth-child(8) {
    grid-column: 8/10; grid-row:2;
    font-size: 11px; padding: 4px 4px; min-height: auto;
    align-self: center; justify-self: center; white-space: nowrap;
  }
  /* del / lock 버튼은 1칸 셀에 맞게 작게 */
  .holding-row > :nth-child(1) button,
  .holding-row > :nth-child(9) button {
    width: 100% !important; min-width: 0 !important; padding: 5px 0 !important;
  }
  /* ⑦ sparkline(수익률버튼) → r2, 탭하면 r3로 펼침 */
  .holding-row > :nth-child(7) {
    grid-column: 10/13;
    grid-row: 2;
    min-width: 0 !important;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 30px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 3px;
    overflow: hidden;
  }
  /* 접힘 상태: 그래프(svg) 숨기고 "📈 +수익률%" 버튼 */
  .holding-row > :nth-child(7) svg { display: none !important; }
  .holding-row > :nth-child(7)::before { content: "📈"; font-size: 11px; flex: none; }
  .holding-row > :nth-child(7) .spark-pct-label { margin: 0; font-size: 11px; flex: none; }
  /* 펼침 상태(.spark-open): r4 전체폭에 그래프 표시 */
  .holding-row.spark-open > :nth-child(7) {
    grid-column: 1/13;
    grid-row: 3;
    flex-direction: column;
    align-items: stretch;
    background: transparent;
    border: none;
    padding: 4px 0;
    min-height: 46px;
  }
  .holding-row.spark-open > :nth-child(7) svg { display: block !important; height: 36px !important; width: 100% !important; }
  .holding-row.spark-open > :nth-child(7)::before { display: none; }
  .holding-row.spark-open > :nth-child(7) .spark-pct-label { text-align: center; margin-top: 1px; }

  /* 재무·배당 미니차트(.mini-chart)는 모바일에서도 막대 표시 — 가격 스파크라인만 접음 */
  .holding-row > :nth-child(7):has(.mini-chart)::before { display: none; }
  .holding-row > :nth-child(7) .mini-chart svg {
    display: block !important;
    height: 24px !important;
    flex: 1 1 auto;
    min-width: 0;
    width: auto !important;
  }

  /* 모달 사이드 패널(연간 배당표·QoQ표)은 모바일에서 차트 아래 전체폭 */
  .modal-side {
    flex: 1 1 100% !important;
    max-width: none !important;
    border-left: none !important;
    padding-left: 0 !important;
    align-self: stretch !important;
    margin-top: 6px;
  }

  /* inputs full-width */
  .holding-row input[type=number],
  .holding-row input[type=text]   { max-width:none !important; width:100% !important; font-size:12px; padding:5px 6px; }

  /* 평가금액 — 좁은 셀에 맞게 작은 폰트 */
  .holding-row .notional-display { font-size:10.5px !important; padding:5px 6px !important; gap:1px; }
  .holding-row .notional-num     { font-size:10.5px; }
  .holding-row .notional-sym     { font-size:10px; }
  .holding-row select              { max-width:none !important; width:100% !important; font-size:12px; padding:5px 6px; }

  /* name-search-wrap full width */
  .name-search-wrap { width:100%; }

  /* metric grid: 2×2 */
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-card { padding: 14px 16px; }
  .metric-value { font-size: 20px; }

  /* optimize results: single column */
  #optResult .grid-2 { grid-template-columns: 1fr; }

  /* weight delta list */
  .delta-row { grid-template-columns: 1.2fr 60px 60px; }
  .delta-row .arrow { display: none; }

  /* BL add grid → single column */
  .bl-add-grid { grid-template-columns: 1fr; }
  .bl-params { grid-template-columns: 1fr 1fr; }

  /* footer CTA */
  .footer-cta { flex-wrap: wrap; gap: 8px; }
  .footer-cta .btn-primary { margin-left: 0; flex: 1 0 100%; text-align: center; }
  .footer-cta .btn-ghost   { flex: 1; }
  .footer-cta .cta-stress  { flex: 1 0 100%; text-align: center; }  /* 스트레스 버튼은 모바일에서 한 줄 전체 */

  /* summary row */
  .summary-row .big { font-size: 20px; }

  /* history rows */
  .history-row {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto auto;
    gap: 6px 8px;
  }
  .history-row .label { grid-column: 2; grid-row: 1; }
  .history-row .meta  { grid-column: 2; grid-row: 2; }
  .history-row .pill  { grid-column: 1 / -1; grid-row: 3; }
  .history-row button { grid-column: 3; grid-row: 1; }

  /* chart heights */
  .chart-wrap       { height: 240px; }
  .chart-wrap.small { height: 200px; }
  .wt-chart         { height: 240px !important; }

  /* MyData persona grid */
  .persona-grid { grid-template-columns: 1fr; }

  /* MyData product rows */
  .md-product-row { grid-template-columns: 46px 1fr 70px; }
  .md-product-row .ccy { display: none; }

  /* MyData step pills */
  .md-step { font-size: 11px; padding: 10px 6px; }

  /* compare bar */
  #compareBar { bottom: 72px; }
}

/* ── 480px: phone adjustments ── */
@media (max-width: 480px) {
  .topbar-inner { padding: 10px 12px; }
  .brand-name { font-size: 15px; }

  .content { padding: 12px 10px 72px; }

  .hero-title { font-size: 20px; }
  .hero-sub   { font-size: 12px; }

  .card { padding: 14px 12px; }

  .seg button { padding: 8px 10px; font-size: 12px; }
  .seg-lg button { padding: 10px 14px; font-size: 13px; }

  .btn-primary { padding: 14px 20px; font-size: 14px; }
  .btn-ghost   { padding: 10px 14px; font-size: 13px; }

  .metric-value { font-size: 18px; }
  .metric-card  { padding: 12px 14px; }

  /* weights donuts: single column on phones */
  .weights-grid { grid-template-columns: 1fr; }

  /* frontier legend wrap */
  .frontier-legend { gap: 10px; }
}

/* ════════════════════════════════════════════════════════════════
   투자 성향 진단 + GAP 분석 — styles
   ════════════════════════════════════════════════════════════════ */

/* ── 투자자 유형 필 ─────────────────────────────────────────── */
.profile-type-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  vertical-align: middle;
}

/* ── 인트로 그리드 ───────────────────────────────────────────── */
.profile-intro {
  padding: 8px 0 4px;
}
.profile-intro-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}
@media (max-width: 540px) {
  .profile-intro-grid { grid-template-columns: 1fr; }
}
.profile-intro-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.profile-intro-icon {
  color: var(--text-sub);
  display: inline-flex;
  align-items: center;
  line-height: 0;
  flex-shrink: 0;
  margin-top: 1px;
}
.profile-intro-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.profile-intro-text strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}
.profile-intro-text span {
  font-size: 12px;
  color: var(--text-mute);
}

/* ── 퀴즈 ────────────────────────────────────────────────────── */
.profile-quiz {
  padding: 4px 0 8px;
}
.profile-quiz-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.profile-quiz-prog-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.profile-quiz-prog-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.3s ease;
}
.profile-quiz-prog-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  white-space: nowrap;
}
.profile-quiz-question {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.profile-q-emoji {
  font-size: 28px;
  flex-shrink: 0;
}
.profile-q-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  line-height: 1.4;
}
.profile-option-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 540px) {
  .profile-option-grid { grid-template-columns: 1fr; }
  .profile-q-text { font-size: 15px; }
}
.profile-option-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 16px;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  font-family: inherit;
}
.profile-option-btn:hover {
  border-color: var(--primary);
  background: rgba(49, 130, 246, 0.04);
  transform: translateY(-1px);
}
.profile-option-btn.selected {
  border-color: var(--primary);
  background: rgba(49, 130, 246, 0.08);
  box-shadow: 0 0 0 2px rgba(49, 130, 246, 0.15);
}
.profile-opt-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}
.profile-opt-sub {
  font-size: 12px;
  color: var(--text-mute);
}
.profile-quiz-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}
.profile-quiz-skip:hover { color: var(--text-main) !important; }

/* ── 결과 ────────────────────────────────────────────────────── */
.profile-result {
  padding: 4px 0 8px;
}
.profile-result-hero {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  border: 1.5px solid;
  border-radius: 14px;
  margin-bottom: 16px;
}
.profile-result-emoji {
  font-size: 32px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  flex-shrink: 0;
}
.profile-result-info { flex: 1; }

/* 강점·약점 그리드 */
.profile-sw-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 540px) {
  .profile-sw-grid { grid-template-columns: 1fr; }
}
.profile-sw-col { display: flex; flex-direction: column; gap: 6px; }
.profile-sw-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.profile-sw-item {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 7px;
  font-weight: 500;
}
.profile-sw-item.strength { background: rgba(32, 201, 151, 0.08); color: #157060; }
.profile-sw-item.weakness { background: rgba(240, 68, 82, 0.08);  color: #b52030; }

/* 섹션 */
.profile-section {
  margin-bottom: 18px;
}
.profile-section-sub {
  font-size: 12.5px;
  color: var(--text-mute);
  margin: 4px 0 12px;
  line-height: 1.55;
}

/* ── 투자 원칙 섹션 ── */
.profile-section-principles {
  background: #f8fafc;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--border-strong);
}
.principle-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.principle-metric {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  border: 1px solid var(--border-strong);
}
.principle-metric-val {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 4px;
}
.principle-metric-label {
  font-size: 10.5px;
  color: var(--text-mute);
  line-height: 1.3;
}
.principle-detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.principle-detail-row:last-of-type { border-bottom: none; }
.principle-detail-label {
  color: var(--text-mute);
  min-width: 90px;
  font-size: 12px;
}
.principle-detail-val {
  color: var(--text);
  font-weight: 600;
}
.principle-notes {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.principle-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.5;
}
.principle-note-num {
  min-width: 20px;
  height: 20px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── 최적화 가이드 섹션 ── */
.profile-section-optguide {
  background: #fffbf0;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #fde68a;
}
.opt-guide-recommend {
  background: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.opt-guide-method-label {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}
.opt-guide-reason {
  font-size: 12.5px;
  color: var(--text-mute);
  margin: 0;
  line-height: 1.6;
}
.opt-guide-steps-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.opt-guide-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.opt-guide-step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.5;
}
.opt-guide-step-num {
  min-width: 22px;
  height: 22px;
  background: #f59e0b;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.opt-guide-alt {
  font-size: 12px;
  color: var(--text-mute);
  background: #f9fafb;
  border-radius: 7px;
  padding: 8px 12px;
  line-height: 1.5;
}
.opt-guide-alt-label {
  font-size: 10px;
  font-weight: 700;
  color: #6b7280;
  background: #e5e7eb;
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 6px;
}
@media (max-width: 640px) {
  .principle-grid { grid-template-columns: repeat(2, 1fr); }
}

.profile-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 10px;
}

/* 추천 배분 바 */
.profile-rec-bar {
  display: flex;
  height: 18px;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 10px;
}
.profile-rec-seg { flex-shrink: 0; transition: width 0.3s; }
.profile-rec-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.profile-rec-leg-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-sub);
}
.profile-rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* GAP placeholder */
.profile-gap-placeholder {
  padding: 16px;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  text-align: center;
}

/* GAP 테이블 */
.gap-table-wrap {
  overflow-x: auto;
  margin-bottom: 10px;
}
.gap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.gap-table th {
  padding: 7px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  white-space: nowrap;
}
.gap-row td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.gap-row:last-child td { border-bottom: none; }
.gap-dim { font-size: 13px; min-width: 52px; }
.gap-bar-wrap {
  width: 80px;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}
.gap-bar-fill {
  height: 100%;
  border-radius: 99px;
}
.gap-bar-fill.current { background: var(--primary); }
.gap-bar-fill.ideal   { background: #20c997; }
.gap-val {
  font-size: 11px;
  color: var(--text-mute);
  vertical-align: middle;
}
.gap-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  white-space: nowrap;
}
.gap-status.gap-ok    { background: rgba(32,201,151,0.12); color: #157060; }
.gap-status.gap-over  { background: rgba(255,176,32,0.12);  color: #a06000; }
.gap-status.gap-under { background: rgba(49,130,246,0.12);  color: #1453c8; }
.gap-rec {
  font-size: 11.5px;
  max-width: 160px;
  line-height: 1.4;
}

/* GAP 요약 */
.profile-gap-summary { margin-top: 6px; }
.profile-gap-summary-text {
  font-size: 13px;
  color: var(--text-sub);
  padding: 10px 14px;
  background: rgba(255, 176, 32, 0.07);
  border-left: 3px solid #ffb020;
  border-radius: 0 8px 8px 0;
  line-height: 1.5;
}
.profile-gap-warn-icon {
  margin-right: 4px;
  color: #ffb020;
}
.profile-all-ok {
  font-size: 13px;
  color: #157060;
  padding: 10px 14px;
  background: rgba(32, 201, 151, 0.07);
  border-left: 3px solid #20c997;
  border-radius: 0 8px 8px 0;
}

/* 하단 CTA */
.profile-cta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

/* 연구 기반 뷰 — 투자자 유형 추천 배지 */
.research-card-relevant {
  border-color: rgba(49, 130, 246, 0.35) !important;
  box-shadow: 0 0 0 2px rgba(49, 130, 246, 0.10);
}
.research-profile-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(49, 130, 246, 0.12);
  color: #1453c8;
  white-space: nowrap;
}


/* ---- Sparkline (YoY mini chart) ---- */
.sparkline-wrap {
  width: 100%;
  height: auto;
  min-width: 80px;
  display: flex;
  flex-direction: column;
  overflow: visible;
}
.sparkline-wrap svg {
  display: block;
  flex-shrink: 0;
}

/* ── 증권 그룹 (드래그앤드롭 바스켓) ───────────────────────────── */
#groupsArea { margin-top: 14px; }
.groups-empty {
  margin-top: 6px; padding: 14px 16px; font-size: 12.5px; line-height: 1.6;
  color: var(--text-mute); border: 1px dashed var(--border-strong); border-radius: 8px;
  background: rgba(0,0,0,.012);
}
.groups-empty b { color: var(--text); }
.groups-head {
  display: flex; align-items: baseline; gap: 10px; margin: 4px 2px 8px;
}
.groups-title { font-family: var(--font-serif); font-size: 15px; color: var(--text); }
.groups-hint  { font-size: 11px; color: var(--text-mute); }

.grp-basket {
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px 10px;
  margin-bottom: 10px; background: #fff;
}
.grp-basket.grp-pool { background: rgba(0,0,0,.015); border-style: dashed; }
.grp-basket-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 7px;
}
.grp-basket-name { font-weight: 600; font-size: 13px; color: var(--text); }
.grp-name-input {
  font-family: var(--font-serif); font-size: 14px; font-weight: 600; color: var(--text);
  border: none; border-bottom: 1px solid transparent; background: transparent;
  padding: 1px 2px; flex: 0 1 auto; min-width: 60px; max-width: 220px; outline: none;
}
.grp-name-input:hover  { border-bottom-color: var(--border-strong); }
.grp-name-input:focus  { border-bottom-color: var(--primary); }
.grp-count {
  font-size: 10.5px; color: var(--text-mute); background: rgba(0,0,0,.05);
  border-radius: 10px; padding: 1px 7px; min-width: 16px; text-align: center;
}
.grp-del {
  margin-left: auto; border: none; background: transparent; color: var(--text-mute);
  font-size: 17px; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 4px;
}
.grp-del:hover { color: var(--primary); background: rgba(110,30,43,.08); }

.grp-dropzone {
  display: flex; flex-wrap: wrap; gap: 6px; min-height: 38px;
  padding: 6px; border-radius: 6px; transition: background .12s, box-shadow .12s;
  align-content: flex-start;
}
.grp-dropzone.drag-over {
  background: rgba(110,30,43,.06); box-shadow: inset 0 0 0 1.5px var(--primary);
}
.grp-placeholder { font-size: 11px; color: var(--text-mute); padding: 4px 4px; align-self: center; }

.grp-chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: grab;
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 4px 9px; font-size: 12px; color: var(--text); user-select: none;
  transition: border-color .12s, box-shadow .12s;
}
.grp-chip:hover { border-color: var(--primary); }
.grp-chip:active { cursor: grabbing; }
.grp-chip.dragging { opacity: .45; }
.grp-chip-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex-shrink: 0;
}
.grp-chip-grip {
  display: inline-flex; align-items: center; flex-shrink: 0;
  color: var(--text-mute); opacity: .65; cursor: grab; line-height: 0;
}
.grp-chip:hover .grp-chip-grip { color: var(--primary); opacity: 1; }
.grp-chip:active .grp-chip-grip { cursor: grabbing; }
.grp-chip-sub { font-size: 10px; color: var(--text-mute); margin-left: 2px; }

/* ── 포트폴리오 바: 모바일에서 생성/불러오기/저장 버튼 줄바꿈 ────────── */
.pf-bar-actions { flex-shrink: 0; }
@media (max-width: 640px) {
  #portfolioBar .pf-bar-actions {
    width: 100%;
    flex-wrap: wrap;
    flex-shrink: 1;
  }
  #portfolioBar .pf-bar-actions button {
    flex: 1 1 calc(50% - 4px);   /* 한 줄에 2개씩, 넘치면 줄바꿈 */
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 10px;
    padding-right: 10px;
    white-space: nowrap;
  }
  /* 생성 버튼은 한 줄 전체 (가장 중요) */
  #portfolioBar .pf-bar-actions #btnCreatePortfolio { flex-basis: 100%; }
}

/* ── 포스트잇 메모 위젯 (좌우 여백) ───────────────────────────── */
.sticky-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;   /* 레이어는 클릭 통과, 메모만 클릭 받음 */
  z-index: 45;
}
.sticky-note {
  position: fixed;
  display: flex;
  flex-direction: column;
  width: 152px;
  min-height: 108px;
  padding: 24px 13px 14px;
  box-sizing: border-box;
  font-family: 'Gaegu', 'Nanum Pen Script', system-ui, cursive;
  font-size: 17px;
  line-height: 1.42;
  color: #463c30;
  background: #fff7ae;
  border-radius: 2px;
  box-shadow: 1px 4px 12px rgba(0, 0, 0, .16), 0 1px 2px rgba(0, 0, 0, .08);
  pointer-events: auto;
  cursor: grab;            /* 본체를 잡으면 이동 */
  transition: box-shadow .15s ease;
}
.sticky-note:hover {
  box-shadow: 2px 7px 18px rgba(0, 0, 0, .22), 0 1px 2px rgba(0, 0, 0, .1);
  z-index: 2;
}
.sticky-note.dragging {
  cursor: grabbing;
  z-index: 200;
  user-select: none;
  transition: none;
  box-shadow: 3px 11px 26px rgba(0, 0, 0, .3);
}
/* 빨간 압정 핀 */
.sticky-pin {
  position: absolute;
  top: -9px;
  left: 50%;
  margin-left: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ff9c8f 0%, #e04338 45%, #b5281f 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .35), inset -1px -1px 2px rgba(0, 0, 0, .25);
}
.sticky-pin::after {        /* 핀 바늘 그림자 */
  content: '';
  position: absolute;
  top: 13px;
  left: 50%;
  width: 2px;
  height: 7px;
  margin-left: -1px;
  background: rgba(0, 0, 0, .18);
  transform: rotate(8deg);
  transform-origin: top center;
}
.sticky-text {
  flex: 1 1 auto;          /* 높이 고정 시 텍스트가 남은 공간 채움 */
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;        /* 내용이 넘치면 메모 안에서 스크롤 */
  min-height: 78px;
  cursor: text;
}
.sticky-text:empty::before {
  content: attr(data-ph);
  color: rgba(0, 0, 0, .3);
}
/* 우하단 크기조절 그립 */
.sticky-resize {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 15px;
  height: 15px;
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity .15s ease;
  background: linear-gradient(135deg,
    transparent 0 46%, rgba(0, 0, 0, .3) 46% 54%,
    transparent 54% 66%, rgba(0, 0, 0, .3) 66% 74%, transparent 74%);
}
.sticky-note:hover .sticky-resize { opacity: .7; }
/* 좌하단 회전 핸들 */
.sticky-rotate {
  position: absolute;
  left: 3px;
  bottom: 2px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(0, 0, 0, .42);
  cursor: grab;
  opacity: 0;
  transition: opacity .15s ease;
}
.sticky-note:hover .sticky-rotate { opacity: .7; }
.sticky-rotate:active { cursor: grabbing; }
.sticky-del {
  position: absolute;
  top: 0;
  right: 4px;
  border: none;
  background: transparent;
  font-size: 18px;
  line-height: 1.2;
  color: rgba(0, 0, 0, .32);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease;
}
.sticky-note:hover .sticky-del { opacity: 1; }
.sticky-del:hover { color: rgba(0, 0, 0, .6); }

.sticky-toolbar {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 46;
  display: flex;
  gap: 8px;
}
.sticky-add,
.sticky-save {
  display: inline-flex;
  align-items: center;
  border: none;
  border-radius: 22px;
  padding: 8px 15px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .2px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .22);
  transition: filter .15s ease, transform .1s ease;
}
.sticky-add { background: var(--primary, #7b2d3a); color: #fff; }
.sticky-save { background: #fff; color: var(--primary, #7b2d3a); border: 1px solid var(--primary, #7b2d3a); }
.sticky-add:hover, .sticky-save:hover { filter: brightness(1.05); }
.sticky-add:active, .sticky-save:active { transform: translateY(1px); }

/* 본문(1080px) 양옆 여백이 부족한 화면에선 여백 포스트잇 숨김 */
@media (max-width: 1365px) {
  .sticky-layer,
  .sticky-toolbar { display: none; }
}

/* 메모 리스트 버튼 (좌하단 고정) */
.sticky-mfab {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 46;
  display: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--primary, #7b2d3a);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .25);
}
@media (max-width: 1365px) {
  .sticky-mfab { display: flex; align-items: center; justify-content: center; }
}
/* 리스트 모드: 화면 크기와 무관하게 메모 버튼 표시 */
.sticky-mfab.force { display: flex !important; align-items: center; justify-content: center; }
/* 모바일: 하단 네비 위로 올림 */
@media (max-width: 768px) {
  .sticky-mfab { bottom: 78px; }
}

/* CODEF 증권사 아이콘 드롭다운 행 */
.cdf-brk-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  cursor: pointer;
  font-size: 14px;
}
.cdf-brk-row:hover { background: var(--bg-soft, #f4f1ea); }
