/* 대시보드. 토큰·헤더·버튼은 base.css */

:root {
    --chart-h:      300px;
    --chart-h-tall: 440px;
    --tabs-h:       48px;
}

/* ── 탭 ───────────────────────────────────────────── */
.tab-nav {
    position: sticky;
    top: var(--header-h);
    z-index: 99;
    padding: 0 24px;
    background: rgba(11, 13, 18, .92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.tab-nav-inner {
    max-width: 1440px;
    height: var(--tabs-h);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}
/* 탭 줄이 가로로 넘치면 오른쪽 끝을 --bg로 흐리게(.has-more, 끝까지 스크롤하면 사라짐) */
.tab-scroll {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 100%;
}
.tab-scroll::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 36px;
    background: linear-gradient(to right, transparent, var(--bg));
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
}
.tab-scroll.has-more::after { opacity: 1; }
.tab-list {
    position: relative; /* 탭의 offsetLeft 기준 */
    flex: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
}
.tab-list::-webkit-scrollbar { display: none; }

.tab {
    position: relative;
    height: 100%;
    flex-shrink: 0;
    padding: 0 13px;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: .92rem;
    font-weight: 500;
    white-space: nowrap;
    transition: color .15s;
}
.tab:hover  { color: var(--text); }
.tab.active { color: var(--text); font-weight: 700; }
.tab.active::after {
    content: '';
    position: absolute;
    left: 13px;
    right: 13px;
    bottom: 0;
    height: 2px;
    border-radius: 2px;
    background: var(--accent);
}
/* 경보가 있는 지표 탭 */
.tab.has-alert::before {
    content: '';
    position: absolute;
    top: 12px;
    right: 5px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.tab.alert-amber::before { background: var(--warn); }
.tab.alert-red::before   { background: var(--bad); }

.tab-sep { width: 1px; height: 18px; margin: 0 8px; flex-shrink: 0; background: var(--border-strong); }
.tab-group-label { flex-shrink: 0; margin-right: 2px; color: var(--muted); font-size: .74rem; opacity: .8; white-space: nowrap; }

.updated-at {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 999px;
    color: var(--muted);
    font-size: .78rem;
    white-space: nowrap;
}
.updated-at.stale {
    color: var(--warn);
    background: var(--warn-soft);
    border: 1px solid rgba(251, 191, 36, .35);
}

/* ── 차트 컨트롤 (차트 탭에서만) ─────────────────────── */
.controls-bar {
    position: sticky;
    top: calc(var(--header-h) + var(--tabs-h));
    z-index: 98;
    padding: 8px 24px;
    background: rgba(11, 13, 18, .92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.controls-main, .controls-adv {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 14px;
}
.controls-adv { padding-top: 8px; margin-top: 8px; border-top: 1px dashed var(--border); }
.adv-toggle { margin-left: auto; }

.range-group { display: flex; gap: 4px; align-items: center; }
.range-label { margin-right: 4px; color: var(--muted); font-size: .74rem; font-weight: 600; }

.date-range-group { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.date-input {
    padding: 4px 8px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: .78rem;
    color-scheme: dark;
}
.date-input:focus { outline: none; border-color: var(--accent); }
.date-sep { color: var(--muted); font-size: .8rem; }

.range-btn {
    padding: 5px 12px;
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    cursor: pointer;
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.range-btn:hover  { color: var(--text); border-color: var(--accent-line); }
.range-btn.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.zoom-hint, .recession-note { color: var(--muted); font-size: .75rem; }

.adv-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-2);
    cursor: pointer;
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
}
.adv-check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.recession-swatch {
    display: inline-block;
    width: 14px;
    height: 9px;
    vertical-align: middle;
    background: rgba(148, 163, 184, .35);
    border-radius: 2px;
}

/* ── 레이아웃 ─────────────────────────────────────── */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tab-content { display: flex; flex-direction: column; gap: 16px; }
.tab-content.hidden { display: none; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

/* ── 카드 (배경·테두리는 base.css .card) ──────────── */
.card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.card-title {
    color: var(--text);
    font-size: .98rem;
    font-weight: 700;
    letter-spacing: -.01em;
}

.card-desc {
    margin-top: -4px;
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.55;
}

.card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.card-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ── 지표 배지 ────────────────────────────────────── */
.stat-badge {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 28px;
    font-variant-numeric: tabular-nums;
}
.stat-badge .val  { color: var(--text); font-size: 1.55rem; font-weight: 700; line-height: 1; letter-spacing: -.01em; }
.stat-badge .unit { color: var(--muted); font-size: .74rem; }
.stat-badge .date { margin-left: 2px; color: var(--muted); font-size: .72rem; opacity: .8; }
.stat-badge .stale-tag { color: var(--warn); font-size: .72rem; font-weight: 600; }
.stat-badge .trend-wrap {
    margin-left: auto;
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 2px 5px;
}
.stat-badge .trend { font-size: .8rem; font-weight: 700; white-space: nowrap; }
.stat-badge .trend-ref { color: var(--muted); font-size: .7rem; white-space: nowrap; }
/* 좋고 나쁨의 방향이 정해지지 않은 지표는 회색 */
.trend-up   { color: var(--muted); }
.trend-down { color: var(--muted); }
.trend-good { color: var(--good); }
.trend-bad  { color: var(--bad); }
.trend-neu  { color: var(--muted); }

/* ── 차트 ─────────────────────────────────────────── */
.chart-wrap { position: relative; width: 100%; height: var(--chart-h); }
.chart-wrap--tall { height: var(--chart-h-tall); }
.chart-wrap--fill { flex: 1; min-height: 320px; }

/* 터치 기기: 차트 위에서도 세로 스크롤(확대·이동은 JS에서 끈다) */
@media (pointer: coarse) {
    .chart-wrap canvas { touch-action: pan-y !important; }
    #resetZoom, .zoom-hint { display: none; }
}

/* 딥링크(#탭/지표)로 찾아간 카드: 테두리를 잠깐 강조하고 서서히 지운다 */
.tab-content .card {
    scroll-margin-top: calc(var(--header-h) + var(--tabs-h) + 12px);
    transition: border-color .8s ease, box-shadow .8s ease;
}
.tab-content .card.is-target {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), var(--shadow);
    transition: none;
}

/* ── 시장 심리 ────────────────────────────────────── */
.sentiment-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    align-items: stretch;
}
.gauge-card { align-items: center; }
.gauge-wrap { position: relative; width: 100%; max-width: 300px; margin: 0 auto; }
.gauge-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: -22px;
    line-height: 1.2;
}
.gauge-score  { font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.gauge-rating { color: var(--muted); font-size: .9rem; letter-spacing: .04em; }
.invest-alert {
    width: 100%;
    padding: 10px 16px;
    background: var(--surface2);
    border-radius: 10px;
    color: var(--text-2);
    font-size: .84rem;
    line-height: 1.6;
    text-align: center;
}

/* ── AI 예측 ──────────────────────────────────────── */
.forecast-ctrl-group { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.fc-label { color: var(--muted); font-size: .74rem; font-weight: 600; white-space: nowrap; }

.horizon-select {
    padding: 4px 8px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    font-size: .78rem;
    outline: none;
    transition: border-color .15s;
}
.horizon-select:focus { border-color: var(--accent); }

.btn-ai {
    flex-shrink: 0;
    padding: 2px 9px;
    background: transparent;
    border: 1px solid var(--accent-line);
    border-radius: 999px;
    color: var(--accent-hover);
    cursor: pointer;
    font-size: .7rem;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn-ai:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); color: #d9d4ff; }
.btn-ai.loading { color: var(--accent); border-color: var(--accent); animation: fc-blink 1s ease-in-out infinite; }
.btn-ai.done    { background: var(--accent-soft); border-color: var(--accent); color: #d9d4ff; }
.btn-ai:disabled { cursor: wait; opacity: .65; }

@keyframes fc-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: .45; }
}

.forecast-row { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: -4px; }
.forecast-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    padding: 2px 8px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: .72rem;
}
.forecast-chip::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 2px;
    background: repeating-linear-gradient(to right, var(--muted) 0, var(--muted) 5px, transparent 5px, transparent 8px);
}

/* ── 로딩·오류 ────────────────────────────────────── */
.loading-state, .error-state { padding: 80px 24px; color: var(--muted); font-size: 1rem; text-align: center; }
.error-state { color: var(--bad); }

/* ── 참고 지표 신호 ───────────────────────────────── */
.signal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px;
    margin-top: 4px;
}
.signal-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface2);
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: border-color .15s, background .15s;
}
.signal-pill:hover { background: var(--surface3); border-color: var(--accent-line); }
.signal-pill.level-amber { background: var(--warn-soft); }
.signal-pill.level-red   { background: var(--bad-soft); }

.signal-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.signal-pill.level-green .signal-dot { background: var(--good); }
.signal-pill.level-amber .signal-dot { background: var(--warn); box-shadow: 0 0 8px rgba(251, 191, 36, .5); }
.signal-pill.level-red   .signal-dot { background: var(--bad);  box-shadow: 0 0 8px rgba(248, 113, 113, .5); }

.signal-info  { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.signal-label { color: var(--muted); font-size: .74rem; }
.signal-value { color: var(--text); font-size: .86rem; font-weight: 600; white-space: nowrap; }

/* ── 근거 탭 ──────────────────────────────────────── */
.inline-link { color: var(--accent); font-weight: 600; text-decoration: none; white-space: nowrap; }
.inline-link:hover { color: var(--accent-hover); text-decoration: underline; }

.mgr-empty { padding: var(--sp-4) 0; color: var(--muted); font-size: var(--fs-sm); }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.card-title-row.wrap { flex-wrap: wrap; }
.card-title-group { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; min-width: 0; }

/* 상태 띠: 판정 한 줄 + 일지 쓰기·기준 바꾸기 */
.status-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2) var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.status-word {
    flex-shrink: 0;
    display: inline-block;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: var(--fs-sm);
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
}
.status-word.is-buy { background: var(--accent); color: var(--on-accent); }
.status-word.is-hold, .status-word.is-none { background: var(--surface3); color: var(--text); }
.status-text {
    flex: 1 1 280px;
    min-width: 0;
    color: var(--text);
    font-size: .94rem;
    font-weight: 600;
    line-height: 1.55;
    font-variant-numeric: tabular-nums;
}
.status-actions { display: flex; gap: var(--sp-2); margin-left: auto; flex-shrink: 0; }

/* 공포·탐욕과 내 기준 */
.mgr-toggle {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 6px;
    color: var(--text-2);
    cursor: pointer;
    font-size: .8rem;
    font-weight: 600;
}
.mgr-toggle input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.fg-rule-note { color: var(--text); font-size: .9rem; line-height: 1.6; font-variant-numeric: tabular-nums; }

/* 지금과 같은 상황의 과거 */
.past-lead { color: var(--text); font-size: .92rem; line-height: 1.6; font-variant-numeric: tabular-nums; }
.past-wrap { overflow-x: auto; }
.past-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.past-table th, .past-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    vertical-align: top;
}
.past-table thead th { color: var(--muted); font-size: .74rem; font-weight: 600; white-space: nowrap; }
.past-table tbody th { color: var(--text); font-size: .84rem; font-weight: 600; text-align: left; }
.past-table tr.is-now th, .past-table tr.is-now td { background: var(--accent-soft); }
.past-avg { display: block; color: var(--text); font-size: 1rem; font-weight: 700; }
.past-avg.good { color: var(--good); }
.past-avg.bad  { color: var(--bad); }
.past-sub { display: block; margin-top: 2px; color: var(--muted); font-size: .72rem; white-space: nowrap; }
.past-cell.is-thin { opacity: .45; }
.past-source { color: var(--muted); font-size: .74rem; line-height: 1.5; }

/* 참고 지표 요약 */
.basis-chip {
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface2);
    color: var(--muted);
    font-size: .7rem;
    font-weight: 600;
    white-space: nowrap;
}
.ref-alerts { display: flex; flex-direction: column; gap: 6px; list-style: none; }
.ref-alert {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface2);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: border-color .15s;
}
.ref-alert:hover { border-color: var(--accent-line); }
.ref-alert.level-amber { background: var(--warn-soft); }
.ref-alert.level-red   { background: var(--bad-soft); }
.ref-label { flex: 1; min-width: 0; font-size: .88rem; font-weight: 600; }
.ref-value { font-size: .88rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ref-go { color: var(--muted); }
.ref-ok { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; color: var(--text); font-size: .9rem; line-height: 1.6; }
.ref-details > summary {
    width: fit-content;
    padding: 6px 0;
    color: var(--text-2);
    cursor: pointer;
    font-size: .82rem;
    font-weight: 600;
}
.ref-details > summary:hover { color: var(--text); }
.ref-details[open] > summary { margin-bottom: 4px; }

/* ── 내 기준 탭: 저장된 기준 ──────────────────────── */
.my-rule-text { color: var(--text); font-size: 1.08rem; font-weight: 700; line-height: 1.5; font-variant-numeric: tabular-nums; }
.my-rule-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rule-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface2);
    color: var(--text-2);
    font-size: .76rem;
    font-weight: 600;
}
.rule-badge:empty { display: none; }
.rule-badge.is-server { border-color: transparent; background: var(--good-soft); color: var(--good); }
.rule-badge.is-device { border-color: transparent; background: var(--warn-soft); color: var(--warn); }
.rule-saved-at { color: var(--muted); font-size: .76rem; }

/* 감당 숫자 4개(2×2): 돈 2개·기다림 2개. 시험 중이면 저장값을 취소선으로 */
.budget { display: flex; flex-direction: column; gap: 6px; max-width: 880px; margin-top: 2px; }
.budget-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.budget-tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 12px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.budget-label { color: var(--text-2); font-size: .78rem; font-weight: 600; }
.budget-kind { margin-left: 5px; color: var(--muted); font-size: .68rem; font-weight: 500; }
.budget-value {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
    color: var(--text);
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
}
.budget-value .bad { color: var(--bad); }
.budget-was { color: var(--muted); font-size: .8rem; font-weight: 500; letter-spacing: 0; }
.budget-sub { color: var(--muted); font-size: .74rem; line-height: 1.45; overflow-wrap: anywhere; }
.budget-basis { color: var(--muted); font-size: .74rem; line-height: 1.5; }

/* 시험 값이 저장값과 다를 때: 저장 미리보기 띠. 데스크톱은 탭 줄 아래에 붙고, 폰은 하단 고정 바 */
.unsaved-bar {
    position: sticky;
    top: calc(var(--header-h) + var(--tabs-h) + 8px);
    z-index: 90;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding: 12px 16px;
    background: linear-gradient(var(--warn-soft), var(--warn-soft)), var(--surface);
    border: 1px solid var(--warn);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
}
.unsaved-text { flex: 0 0 auto; min-width: 0; color: var(--text); font-size: .9rem; font-weight: 700; line-height: 1.5; }
.unsaved-list {
    flex: 1 1 480px;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 2px 18px;
    list-style: none;
    color: var(--text-2);
    font-size: .82rem;
    line-height: 1.55;
    font-variant-numeric: tabular-nums;
}
.unsaved-list b { color: var(--text); font-weight: 700; }
.unsaved-where { color: var(--muted); }
.unsaved-text::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--warn);
    vertical-align: middle;
}
.unsaved-actions { display: flex; gap: 6px; margin-left: auto; }

/* 기준 후보 비교 */
.cand-lead { color: var(--text); font-size: .9rem; font-weight: 600; line-height: 1.55; }
.cand-wrap { overflow-x: auto; }
.cand-table { width: 100%; border-collapse: collapse; font-size: .84rem; font-variant-numeric: tabular-nums; }
.cand-table th, .cand-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    white-space: nowrap;
}
.cand-table thead th { color: var(--muted); font-size: .74rem; font-weight: 600; }
.cand-table th:first-child { text-align: left; }
.cand-table tbody th { font-weight: 600; }
.cand-table .good { color: var(--good); }
.cand-table .bad  { color: var(--bad); }
.cand-row, .cand-sub { cursor: pointer; }
.cand-row:hover > *, .cand-row:hover + .cand-sub > *, .cand-row:focus-visible > * { background: var(--surface2); }
.cand-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cand-row.is-saved > *, .cand-row.is-saved + .cand-sub > * { background: var(--accent-soft); }
.cand-row.is-trial > th:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.cand-t { color: var(--text); font-weight: 700; }
.cand-tag {
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: .66rem;
    font-weight: 700;
    vertical-align: 1px;
}
.cand-tag.is-saved { background: var(--accent); color: var(--on-accent); }
.cand-tag.is-trial { background: var(--warn-soft); color: var(--warn); }
.cand-err { color: var(--muted); text-align: left !important; }
.cand-m { display: none; } /* 폰 전용 칸 */
.cand-sub { display: none; }
.cand-sub td { padding: 0 6px 9px; color: var(--muted); font-size: .72rem; text-align: left; white-space: normal; }

/* ── 내 기준: 매수 시뮬레이터 ────────────────────── */
.bt-range { color: var(--muted); font-size: .76rem; }
.sim-question { margin: 2px 0 2px; color: var(--text); font-size: .98rem; line-height: 1.65; }
.sim-question strong { color: var(--accent-hover); font-weight: 700; }

/* 검증 조건(F&G 소스·기간): 접힌 한 줄 */
.sim-conditions > summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    width: fit-content;
    max-width: 100%;
    min-height: 32px;
    color: var(--muted);
    cursor: pointer;
    font-size: .8rem;
    list-style: none;
}
.sim-conditions > summary::-webkit-details-marker { display: none; }
.sim-cond-text { min-width: 0; overflow-wrap: anywhere; }
.sim-cond-change { color: var(--accent); font-weight: 600; white-space: nowrap; }
.sim-conditions > summary:hover .sim-cond-change { color: var(--accent-hover); text-decoration: underline; }
.sim-conditions[open] .sim-cond-change { color: var(--text-2); }
.sim-cond-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
    padding: 14px 16px;
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
}

.sim-controls {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 4px;
    padding: 16px;
    background: var(--surface2);
    border-radius: 12px;
}
.sim-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.sim-lead { color: var(--muted); font-size: .8rem; font-weight: 600; }
.sim-src-note { flex-basis: 100%; color: var(--muted); font-size: .74rem; line-height: 1.5; }

.chip-group { display: inline-flex; gap: 3px; padding: 3px; background: var(--bg); border-radius: 10px; }
.chip {
    padding: 6px 13px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background .12s, color .12s;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); color: var(--on-accent); }
.chip:disabled { opacity: .4; cursor: not-allowed; }
.chip-sm { padding: 5px 11px; font-size: .78rem; }

.sim-slider-row { gap: 14px; }
.sim-slider { flex: 1; min-width: 160px; max-width: 380px; height: 4px; cursor: pointer; accent-color: var(--accent); }
.sim-slider-label { min-width: 190px; color: var(--text); font-size: .86rem; font-weight: 600; }

.sim-amounts { display: flex; flex-wrap: wrap; gap: 20px 28px; }
.sim-amount-field { display: flex; flex-direction: column; gap: 8px; }
.sim-lead-hint { margin-left: 4px; color: var(--muted); font-size: .72rem; font-weight: 400; }
.sim-amount-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sim-amount-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 13px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
}
.sim-amount-wrap:focus-within { border-color: var(--accent); }
.sim-amount {
    width: 120px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 700;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.sim-amount-unit { color: var(--muted); font-size: .82rem; }

/* 같은 돈 비교 한 줄 + 작은 수치 */
.sim-takeaway { display: flex; flex-direction: column; gap: 6px; }
.sim-line {
    padding: 12px 14px;
    background: var(--surface2);
    border-radius: 10px;
    color: var(--text);
    font-size: .92rem;
    line-height: 1.7;
    font-variant-numeric: tabular-nums;
}
.sim-line .good { color: var(--good); }
.sim-line .bad  { color: var(--bad); }
.sim-line .pill-gray { margin-left: 8px; vertical-align: 1px; }
.pill-gray {
    display: inline-block;
    padding: 1px 9px;
    border-radius: 999px;
    background: var(--surface3);
    color: var(--text-2);
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
}
.sim-figures { padding: 0 2px; color: var(--muted); font-size: .76rem; line-height: 1.55; font-variant-numeric: tabular-nums; }
.sim-empty { padding: 10px 0; color: var(--muted); font-size: .86rem; }

/* 추이 보기(누적 평가액 차트): 기본 닫힘 */
.sim-trend > summary {
    width: fit-content;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    padding: 4px 0;
    color: var(--text-2);
    cursor: pointer;
    font-size: .82rem;
    font-weight: 600;
}
.sim-trend > summary:hover { color: var(--text); }
.sim-trend[open] > summary { margin-bottom: 6px; }

/* 근거 탭으로 옮긴 과거 통계 대신 남기는 한 줄 */
.stat-line { padding: 0 4px; color: var(--text-2); font-size: .84rem; line-height: 1.6; font-variant-numeric: tabular-nums; }
.stat-line strong { color: var(--text); font-weight: 700; }
.stat-line-sub { color: var(--muted); font-size: .76rem; }
.stat-line .inline-link { margin-left: 4px; }

/* 거시 탭 달러 인덱스 카드: 달러·환율 탭 링크 */
.card-side-link { font-size: .76rem; }

/* 구간별 통계 */
.stat-table-wrap { overflow-x: auto; }
.stat-table { width: 100%; margin-top: 6px; border-collapse: collapse; font-size: .84rem; font-variant-numeric: tabular-nums; }
.stat-table th, .stat-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    white-space: nowrap;
}
.stat-table th { color: var(--muted); font-size: .74rem; font-weight: 600; }
.stat-table td:first-child, .stat-table th:first-child { text-align: left; }
.stat-table td.good { color: var(--good); }
.stat-table td.bad  { color: var(--bad); }
.stat-table tr.current td { background: var(--accent-soft); }
.stat-range { margin-left: 4px; color: var(--muted); font-size: .72rem; }
.stat-now {
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: .66rem;
    font-weight: 700;
}
.stat-table td.stat-active-col { color: var(--text); font-weight: 700; }
.stat-table tr.stat-thin td { opacity: .5; }
.stat-mode-note { margin-top: 10px; color: var(--muted); font-size: .74rem; line-height: 1.5; }
.stat-more-btn {
    display: none;
    margin-top: 8px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    cursor: pointer;
    font-size: .78rem;
    font-weight: 600;
}
.stat-more-btn:hover { color: var(--text); border-color: var(--accent-line); }

.manager-disclaimer { margin: 4px 2px 20px; color: var(--muted); font-size: .74rem; line-height: 1.6; }

/* ── 반응형 ───────────────────────────────────────── */
@media (max-width: 1100px) {
    :root { --chart-h: 260px; --chart-h-tall: 380px; }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .sentiment-layout { grid-template-columns: 240px 1fr; }
}


@media (max-width: 640px) {
    :root { --chart-h: 220px; --chart-h-tall: 300px; --tabs-h: 44px; }
    .tab-nav, .controls-bar { padding-left: 12px; padding-right: 12px; }
    .controls-bar { position: static; } /* 좁은 화면에서는 차트 공간을 먼저 */
    .tab { padding: 0 10px; font-size: .88rem; }
    .tab.active::after { left: 10px; right: 10px; }
    .tab-group-label { display: none; }
    .tab-sep { margin: 0 4px; }
    .updated-at { display: none; }
    .updated-at.stale { display: inline-block; }
    .container { padding: 14px 12px; }
    .card { padding: 16px; }
    .grid-2, .grid-3, .sentiment-layout { grid-template-columns: 1fr; }
    .zoom-hint { display: none; }
    #resetZoom { display: none; }
    .fc-label { display: none; }
    .sim-slider-label { min-width: 0; }
    .sim-slider { min-width: 0; flex-basis: 100%; max-width: none; height: 24px; }
    .sim-amount { width: 90px; }
    .sim-cond-body { padding: 12px; }
    .sim-conditions > summary, .sim-trend > summary { min-height: 44px; }
    /* 칩 묶음(기간 5개 등)이 한 줄로 넘치지 않게 줄바꿈 — 375px에서 가로 스크롤 방지 */
    .sim-controls { padding: 12px; }
    .chip-group { flex-wrap: wrap; max-width: 100%; }

    /* 상태 띠: 판정 칩과 문장은 이어서 두 줄까지, 버튼은 다음 줄 */
    .status-strip { display: block; padding: var(--sp-3); }
    .status-word { margin-right: 6px; padding: 2px 9px; vertical-align: 1px; }
    .status-text { display: inline; font-size: var(--fs-sm); }
    .status-actions { display: flex; margin-top: var(--sp-3); }
    .status-actions .btn { flex: 1; height: 40px; }

    .past-table th, .past-table td { padding: 8px 6px; }
    .past-table tbody th { font-size: .78rem; }
    .past-avg { font-size: .92rem; }
    .past-sub { white-space: normal; }

    /* 감당 숫자: 폰에서도 2×2 */
    .budget-tiles { gap: 8px; }
    .budget-tile { padding: 10px 11px; }
    .budget-value { font-size: 1.2rem; }
    .budget-label { font-size: .74rem; }
    .budget-kind { display: none; }
    .budget-sub { font-size: .7rem; }

    /* 저장 미리보기: 화면 하단 고정 바(안전 영역 여백), 본문 아래에 바 높이만큼 여백 */
    .unsaved-bar {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 150;
        gap: 6px;
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
        border-width: 1px 0 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    .unsaved-text { font-size: .84rem; }
    .unsaved-list { flex-basis: 100%; flex-direction: column; gap: 0; font-size: .76rem; line-height: 1.5; }
    .unsaved-actions { width: 100%; }
    .unsaved-actions .btn { flex: 1; height: 44px; }
    body.has-unsaved #tab-strategy { padding-bottom: var(--unsaved-pad, 230px); }
    /* 하단 바가 보이는 동안 토스트는 바 위에 뜬다(바 버튼을 가리지 않게) */
    body.has-unsaved:has(#tab-strategy:not(.hidden)) .toast-stack { bottom: var(--unsaved-pad, 230px); }

    .sim-figures { font-size: .72rem; }

    /* 후보 비교: 기준·한 달 평균·같은 돈 대비 3열, 나머지는 행 아래 작은 글씨 */
    .cand-x { display: none; }
    .cand-sub { display: table-row; }
    .cand-row > th, .cand-row > td { border-bottom: 0; padding: 8px 6px 4px; }
    .cand-sub td { border-bottom: 1px solid var(--border); }
    .cand-m { display: table-cell; }
    .cand-row.is-err > th, .cand-row.is-err > td { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
    .cand-table thead th { padding: 8px 6px; white-space: normal; vertical-align: bottom; }

    /* 구간별 통계: 30일 열만 기본, 버튼으로 90·180일 */
    .stat-table-wrap:not(.show-all) .h-more { display: none; }
    .stat-more-btn { display: inline-flex; }
}

/* ─── 적립 도우미(내 기준 탭, saving.js) ─── */
.saving-card { display: flex; flex-direction: column; gap: 14px; }
.saving-grid { display: flex; flex-wrap: wrap; gap: 16px 28px; }
.saving-field { display: flex; flex-direction: column; gap: 8px; }
.saving-prefix { color: var(--muted); font-size: .82rem; }
.saving-th { width: 44px; }
.saving-alloc-box { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.saving-alloc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.saving-sum { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.saving-sum.is-bad { color: var(--bad); font-weight: 700; }
#savingAlloc { display: flex; flex-direction: column; gap: 6px; }
.saving-alloc-row { display: flex; align-items: center; gap: 6px; }
.saving-sym, .saving-pct {
    padding: 7px 10px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--text);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.saving-sym { width: 92px; text-transform: uppercase; }
.saving-pct { width: 56px; text-align: right; }
.saving-sym:focus, .saving-pct:focus { outline: none; border-color: var(--accent); }
.saving-unit { color: var(--muted); font-size: .82rem; }
.saving-alloc-empty { color: var(--muted); font-size: .8rem; }
.saving-lev {
    padding: 8px 12px;
    background: var(--warn-soft);
    border-radius: 8px;
    color: var(--text-2);
    font-size: .8rem;
    line-height: 1.5;
}
.saving-preview {
    padding: 12px 14px;
    background: var(--surface2);
    border-radius: 10px;
    color: var(--text);
    line-height: 1.6;
    font-variant-numeric: tabular-nums;
}
.saving-note { color: var(--muted); font-size: .76rem; line-height: 1.5; }
.saving-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 600px) {
    .saving-grid { flex-direction: column; }
}
