.stock {
    display: grid;
    gap: 28px;
    /* Prevent overflow on small screens */
    width: 100%;
}

.stock-header {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 24px;
    align-items: center;
}

.stock-kicker {
    text-transform: uppercase;
    letter-spacing: 0.3em;
    font-size: 12px;
    color: var(--accent-stock);
    margin: 0 0 10px;
}

.stock-header h1 {
    margin: 0 0 12px;
    font-family: var(--font-display);
    font-size: clamp(30px, 4vw, 40px);
}

.stock-sub {
    margin: 0;
    color: var(--muted);
}

.stock-actions {
    display: flex;
    gap: 12px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.stock-card {
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 20px;
    background: var(--surface);
    display: grid;
    gap: 14px;
}

.stock-ideas {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    font-size: 13px;
    display: grid;
    gap: 6px;
}

.stock-card__title {
    margin: 0;
    font-weight: 600;
}

.stock-status {
    display: grid;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}

.stock-status>div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.stock-status strong {
    color: var(--text);
}

.stock-status__note {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.stock-pill {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    border: 1px solid var(--line);
}

.stock-pill.is-ok {
    border-color: rgba(106, 220, 187, 0.6);
    color: #b5f0dd;
}

.stock-pill.is-warn {
    border-color: rgba(245, 200, 115, 0.6);
    color: #f5d28a;
}

.stock-pill.is-unknown {
    color: var(--muted);
}

.stock-error {
    margin: 0;
    color: #f9b6b1;
    border: 1px solid rgba(249, 182, 177, 0.4);
    border-radius: 14px;
    padding: 12px;
    background: rgba(249, 182, 177, 0.1);
}

.stock-success {
    margin: 0;
    color: #b5f0dd;
    border: 1px solid rgba(106, 220, 187, 0.4);
    border-radius: 14px;
    padding: 12px;
    background: rgba(106, 220, 187, 0.12);
}

.stock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.stock-panel {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: grid;
    gap: 16px;
    box-shadow: var(--shadow-sm), var(--shadow-inset);
}

.stock-panel--wide {
    grid-column: 1 / -1;
}

.stock-filter-row {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    align-items: stretch;
}

.stock-filter-row .stock-panel {
    width: 100%;
    max-width: none;
}

.stock-panel__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.stock-panel__eyebrow {
    margin: 0 0 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--accent-stock);
}

.stock-panel__sub {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.stock-panel__actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.stock-chip {
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.stock-snapshot {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.stock-snapshot__card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    display: grid;
    gap: 6px;
    background: rgba(0, 0, 0, 0.2);
    min-height: 94px;
}

.stock-snapshot__card.is-highlight {
    border-color: rgba(96, 165, 250, 0.4);
    background: rgba(96, 165, 250, 0.06);
    box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.1), var(--shadow-inset);
}

.stock-snapshot__card p {
    margin: 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.stock-snapshot__card strong {
    font-size: 20px;
}

.stock-snapshot__card span {
    color: var(--muted);
    font-size: 12px;
}

.stock-snapshot__change {
    font-size: 12px;
    color: var(--muted);
}

.stock-snapshot__change.is-up {
    color: #f04452;
}

.stock-snapshot__change.is-down {
    color: #3b82f6;
}

.stock-schedule {
    display: grid;
    gap: 12px;
    font-size: 13px;
    color: var(--muted);
}

.stock-schedule strong {
    color: var(--text);
}

.stock-filter {
    display: grid;
    gap: 12px;
    color: var(--muted);
    font-size: 13px;
}

.stock-filter label {
    display: grid;
    gap: 8px;
}

.stock-filter select {
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    border-radius: 12px;
    padding: 10px 12px;
}

.stock-filter__note {
    margin: 0;
    font-size: 12px;
}

.stock-news {
    display: grid;
    gap: 14px;
}

.stock-tabs {
    display: flex;
    gap: 8px;
}

.stock-tab {
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.2);
    color: var(--muted);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.stock-tab.is-active {
    border-color: rgba(96, 165, 250, 0.5);
    color: var(--text);
    background: rgba(96, 165, 250, 0.1);
}

.stock-news__item {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    display: grid;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
}

.stock-news__title {
    margin: 0;
    font-weight: 600;
    font-size: 16px;
}

.stock-news__summary {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.stock-news__meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--muted);
    align-items: center;
}

.stock-news__meta a {
    color: var(--accent-stock);
    text-decoration: none;
    transition: opacity 0.15s;
}

.stock-news__meta a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.stock-empty {
    margin: 0;
    color: var(--muted);
}

.stock-trade {
    display: grid;
    gap: 16px;
}

.stock-balance {
    display: grid;
    gap: 12px;
}

.stock-balance__summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.stock-balance__card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(0, 0, 0, 0.2);
    font-size: 12px;
    color: var(--muted);
    flex: 1 1 120px;
    min-width: 100px;
}

.stock-balance__card strong {
    font-size: 16px;
    color: var(--text);
}

.stock-holdings {
    display: grid;
    gap: 8px;
}

.stock-holdings__item {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    font-size: 13px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.02);
    align-items: center;
}

/* 종목명 영역: 데스크톱에서는 넓게, 모바일에서 full width */
.stock-holdings__item>div:first-child {
    flex: 1 1 140px;
    min-width: 100px;
}

.stock-holdings__name {
    margin: 0;
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
}

.stock-holdings__code {
    font-size: 12px;
}

.stock-holdings__metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 70px;
    flex: 0 1 auto;
}

.stock-holdings__metric span {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.stock-holdings__metric strong {
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
}

.stock-profit {
    color: var(--text);
}

.stock-profit.is-up {
    color: #f04452;
}

.stock-profit.is-down {
    color: #3b82f6;
}

.stock-profit.is-flat {
    color: var(--muted);
}

.stock-profit.is-negative {
    color: #3b82f6;
}

.stock-result {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    margin-top: 10px;
}

.stock-result__title {
    margin: 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.stock-result pre {
    margin: 8px 0 0;
    white-space: pre-wrap;
    font-size: 12px;
    color: var(--muted);
}

.stock-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
}

.stock-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.stock-modal__card {
    position: relative;
    width: min(520px, 90vw);
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    padding: 16px;
    display: grid;
    gap: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.stock-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stock-modal__head h4 {
    margin: 0;
    font-size: 16px;
}

.stock-modal pre {
    margin: 0;
    white-space: pre-wrap;
    font-size: 12px;
    color: var(--muted);
}

.stock-order {
    display: grid;
    gap: 10px;
}

.stock-order label {
    display: grid;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}

.stock-order input,
.stock-order select {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    outline: none;
}

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

@media (max-width: 768px) {
    .stock {
        gap: 16px;
    }

    .stock-panel {
        padding: 14px;
        gap: 10px;
        border-radius: 16px;
    }

    .stock-filter-row {
        gap: 12px;
        grid-template-columns: 1fr;
    }

    .stock-header h1 {
        font-size: 26px;
    }

    .stock-actions {
        width: 100%;
    }

    .stock-actions .button {
        flex: 1;
        text-align: center;
        justify-content: center;
    }

    .stock-card {
        padding: 14px;
    }

    .stock-status>div {
        gap: 8px;
    }

    .stock-status strong {
        font-size: 14px;
        word-break: break-word;
    }

    /* 종목명: 모바일에서 full width로 한 줄 차지 */
    .stock-holdings__item>div:first-child {
        flex: 1 1 100%;
    }

    /* Metric 칩: 인라인으로 나란히, 공간 부족 시 줄바꿈 */
    .stock-holdings__metric {
        flex-direction: row;
        align-items: baseline;
        gap: 4px;
        min-width: 0;
        flex: 0 0 auto;
        padding: 4px 10px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.05);
    }

    .stock-holdings__metric span {
        font-size: 10px;
    }

    .stock-holdings__metric strong {
        font-size: 13px;
        word-break: keep-all;
    }

    .stock-holdings__name {
        font-size: 14px;
    }
}

@media (max-width: 420px) {
    .stock-panel {
        padding: 10px;
        border-radius: 12px;
    }

    .stock-holdings__item {
        padding: 10px;
        gap: 6px 8px;
    }

    .stock-holdings__metric {
        padding: 3px 8px;
    }

    .stock-holdings__metric span {
        font-size: 9px;
    }

    .stock-holdings__metric strong {
        font-size: 12px;
    }
}

/* ── Main Tabs ─────────────────────────────────────────────────────── */

.stock-main-tabs {
    display: flex;
    gap: 4px;
    margin: 0 0 20px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0;
}

.stock-main-tab {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.25s, background 0.25s;
    border-radius: 12px 12px 0 0;
}

.stock-main-tab:hover {
    color: var(--fg);
    background: rgba(255, 255, 255, 0.04);
}

.stock-main-tab.is-active {
    color: var(--fg);
    background: rgba(255, 255, 255, 0.06);
}

.stock-main-tab.is-active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 12px;
    right: 12px;
    height: 2px;
    background: linear-gradient(90deg, #818cf8, #a78bfa);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(129, 140, 248, 0.5);
}

.stock-main-tab__icon {
    font-size: 18px;
}

.stock-main-tab__label {
    font-weight: 600;
}

.stock-main-tab__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: linear-gradient(135deg, #818cf8, #a78bfa);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

.stock-main-tab__sub {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 8px;
    background: rgba(251, 191, 36, 0.15);
    color: rgba(251, 191, 36, 0.9);
    font-weight: 600;
}

@media (max-width: 520px) {
    .stock-main-tab {
        padding: 10px 14px;
        font-size: 13px;
        gap: 4px;
    }

    .stock-main-tab__icon {
        font-size: 15px;
    }

    .stock-main-tab__label {
        font-size: 13px;
    }
}

/* ── Portfolio ────────────────────────────────────────────────────── */

.pf-section {
    position: relative;
}

.pf-broker-section {
    transition: border-color 0.3s ease, background 0.3s ease;
}

.pf-add-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    padding: 16px;
    border: 1px dashed var(--line);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.15);
    animation: pf-slide-in 0.25s ease;
}

@keyframes pf-slide-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pf-add-form label {
    display: grid;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}

.pf-add-form input {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease;
}

.pf-add-form input:focus {
    border-color: var(--accent);
}

.pf-total-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.pf-total-summary__card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(0, 0, 0, 0.2);
    font-size: 12px;
    color: var(--muted);
    flex: 1 1 110px;
    min-width: 90px;
}

.pf-total-summary__card strong {
    font-size: 16px;
    color: var(--text);
    white-space: nowrap;
}

.pf-total-summary__card strong.is-fit-sm {
    font-size: 13px;
    letter-spacing: -0.01em;
}

.pf-total-summary__card strong.is-fit-xs {
    font-size: 11px;
    letter-spacing: -0.02em;
}

.pf-item-actions {
    margin-left: auto;
}

.pf-item-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: flex-end;
}

.pf-item-actions .button {
    padding: 4px 8px;
    min-height: 0;
    font-size: 14px;
    line-height: 1;
}

.pf-btn-danger {
    color: #f3a7a7 !important;
    border-color: rgba(243, 167, 167, 0.5) !important;
}

.pf-btn-sell {
    color: #fbbf24 !important;
    border-color: rgba(251, 191, 36, 0.5) !important;
}

.pf-sell-confirm {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pf-sell-confirm__msg {
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pf-sell-confirm__warn {
    color: #fbbf24;
    font-size: 11px;
}

.pf-null-price {
    color: var(--muted) !important;
    font-size: 12px !important;
    opacity: 0.7;
    font-style: italic;
}

.pf-nxt-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid rgba(139, 92, 246, 0.45);
    background: rgba(139, 92, 246, 0.12);
    color: #c4b5fd;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    vertical-align: middle;
    cursor: help;
    white-space: nowrap;
}

.pf-edit-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: end;
}

.pf-edit-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.pf-edit-fields label {
    display: grid;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}

.pf-edit-fields input {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    outline: none;
}

.pf-edit-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

@media (max-width: 768px) {
    .pf-add-form {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    .pf-edit-row {
        grid-template-columns: 1fr;
    }

    .pf-item-actions {
        flex: 0 0 auto;
        margin-left: 0;
    }
}

@media (max-width: 420px) {
    .pf-add-form {
        grid-template-columns: 1fr 1fr;
    }

    .pf-total-summary__card {
        padding: 8px 10px;
        flex: 1 1 80px;
        min-width: 70px;
    }

    .pf-total-summary__card strong {
        font-size: 14px;
    }

    .pf-total-summary__card strong.is-fit-sm {
        font-size: 12px;
    }

    .pf-total-summary__card strong.is-fit-xs {
        font-size: 10px;
    }
}

/* ── Cash Panel (예수금) ─────────────────────────────────────────── */

.pf-cash-table {
    display: grid;
    gap: 8px;
}

.pf-cash-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.15);
    font-size: 13px;
}

.pf-cash-broker {
    flex: 1;
    font-weight: 600;
    color: var(--text);
}

.pf-cash-amount {
    font-size: 15px;
    color: #93c5fd;
}

.pf-cash-date {
    color: var(--muted);
    font-size: 11px;
    min-width: 80px;
    text-align: right;
}

.pf-cash-edit-input {
    border: 1px solid var(--neon-cyan);
    border-radius: 8px;
    padding: 6px 10px;
    background: rgba(0, 212, 255, 0.05);
    color: var(--text-bright);
    font-size: 14px;
    font-weight: 600;
    width: 140px;
    outline: none;
}

.pf-cash-edit-input:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.15);
}

.pf-cash-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: end;
    padding: 14px;
    border: 1px dashed var(--line);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.12);
}

.pf-cash-form label {
    display: grid;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}

.pf-cash-form input {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease;
}

.pf-cash-form input:focus {
    border-color: var(--accent);
}

.pf-cash-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 8px;
    background: rgba(147, 197, 253, 0.15);
    border: 1px solid rgba(147, 197, 253, 0.3);
    color: #93c5fd;
    margin-left: 8px;
    vertical-align: middle;
    white-space: nowrap;
}

.pf-total-summary__card.is-cash {
    border-color: rgba(147, 197, 253, 0.4);
}

.pf-total-summary__card.is-cash strong {
    color: #93c5fd;
}

.pf-total-summary__card.is-assets {
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.04);
}

.pf-total-summary__card.is-assets strong {
    font-size: 17px;
}

/* ── 자산 추이 차트 ─────────────────────────────────────────────────────── */

.pf-asset-history {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--line-subtle);
}

.pf-asset-history__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.pf-asset-history__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.03em;
}

.pf-asset-history__controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pf-asset-period-btn {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.pf-asset-period-btn:hover {
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
}

.pf-asset-period-btn.is-active {
    background: rgba(56, 189, 248, 0.12);
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
}

.pf-asset-history__empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 80px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

@media (max-width: 768px) {
    .pf-asset-history__head {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 768px) {
    .pf-cash-form {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 420px) {
    .pf-cash-form {
        grid-template-columns: 1fr;
    }

    .pf-cash-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .pf-cash-date {
        display: none;
    }
}

/* ══════════════════════════════════════════════════════════════════
   Fear & Greed Index Panel
   ══════════════════════════════════════════════════════════════════ */

.fg-panel {
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 16px 0 8px;
    flex-wrap: wrap;
}

.fg-gauge {
    flex: 1;
    min-width: 200px;
}

.fg-gauge__track {
    position: relative;
    height: 14px;
    border-radius: 7px;
    background: linear-gradient(to right, #ef4444 0%, #f97316 25%, #eab308 50%, #84cc16 75%, #22c55e 100%);
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.fg-gauge__needle {
    position: absolute;
    top: -5px;
    transform: translateX(-50%);
    width: 5px;
    height: 24px;
    background: #fff;
    border-radius: 3px;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
    transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.fg-gauge__labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--muted);
    margin-top: 2px;
}

.fg-score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 90px;
    text-align: center;
}

.fg-score-number {
    font-size: 48px;
    font-weight: 800;
    line-height: 1;
    transition: color 0.4s ease;
}

.fg-score-label {
    font-size: 14px;
    font-weight: 700;
    transition: color 0.4s ease;
}

.fg-score-date {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

/* ── F&G Level 설명 ─────────────────────────────────────────────── */

.fg-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.fg-levels {
    display: grid;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.fg-level {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.2s ease, border-color 0.2s ease;
}

.fg-level.is-current {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.fg-level__head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.fg-level__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.fg-level__label {
    font-size: 12px;
    font-weight: 700;
}

.fg-level__range {
    font-size: 11px;
    color: var(--muted);
    margin-left: auto;
}

.fg-level__desc {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
    padding-left: 16px;
}

/* ── 뉴스 툴바 (탭 + 인라인 필터) ─────────────────────────────── */

.stock-news-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.stock-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: rgba(96, 165, 250, 0.15);
    font-size: 10px;
    font-weight: 700;
    margin-left: 4px;
    vertical-align: middle;
}

.stock-tab.is-active .stock-tab-count {
    background: rgba(96, 165, 250, 0.3);
}

.stock-news-limit {
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease;
}

.stock-news-limit:hover,
.stock-news-limit:focus {
    border-color: rgba(96, 165, 250, 0.4);
}

/* ══════════════════════════════════════════════════════════════════
   Report Charts Row
   ══════════════════════════════════════════════════════════════════ */

.report-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 12px;
}

.report-chart-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
}

.report-chart-title {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

@media (max-width: 640px) {
    .report-charts-row {
        grid-template-columns: 1fr;
    }
}

/* ══════════════════════════════════════════════════════════════════
   Report Table (Sortable)
   ══════════════════════════════════════════════════════════════════ */

.report-table-wrapper {
    overflow-x: auto;
    margin-top: 8px;
    border-radius: 12px;
    border: 1px solid var(--line);
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.report-table thead {
    background: rgba(0, 0, 0, 0.2);
}

.report-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: color 0.2s;
}

.report-table th:hover {
    color: var(--text);
}

.report-sort-icon {
    font-size: 10px;
    opacity: 0.7;
}

.report-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text);
    vertical-align: middle;
}

.report-table tbody tr:last-child td {
    border-bottom: none;
}

.report-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.report-td-muted {
    color: var(--muted) !important;
    font-size: 12px !important;
}

.report-table-name {
    margin: 0;
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

.report-table-code {
    font-size: 11px;
    color: var(--muted);
}

.report-rate-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 80px;
}

.report-rate-bar {
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    width: 80px;
}

.report-rate-bar__fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.4s ease;
}

.report-rate-bar__fill.is-up {
    background: #34d399;
}

.report-rate-bar__fill.is-down {
    background: #f87171;
}

/* ══════════════════════════════════════════════════════════════════
   AI 투자 코치 패널
   ══════════════════════════════════════════════════════════════════ */

.ai-market-ctx {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(0, 212, 255, 0.04);
    border: 1px solid rgba(0, 212, 255, 0.15);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
}

.ai-market-ctx__label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--neon-cyan);
    white-space: nowrap;
    padding-top: 2px;
}

.ai-market-ctx__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ai-market-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 100px;
    font-size: 11px;
    color: var(--text-dim);
}

.ai-market-chip strong {
    color: var(--text-bright);
    font-weight: 700;
}

.ai-market-chip em {
    font-style: normal;
    font-size: 10px;
    color: var(--text-muted);
}

.ai-coach-settings {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    border-radius: 14px;
    margin-bottom: 16px;
    align-items: end;
}

.ai-coach-settings label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}

.ai-coach-settings input,
.ai-coach-settings select {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 12px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.ai-coach-settings input:focus,
.ai-coach-settings select:focus {
    border-color: var(--accent);
}

.ai-coach-key-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ai-coach-key-input {
    flex: 1;
    min-width: 0;
}

.ai-coach-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.ai-coach-note {
    font-size: 11px;
    color: var(--muted);
}

/* Result */
.ai-coach-result {
    border-top: 1px solid var(--line);
    padding-top: 20px;
    margin-top: 4px;
}

.ai-coach-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.ai-grade-badge {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: 800;
    flex-shrink: 0;
    letter-spacing: -1px;
}

.ai-grade-badge.grade-s { background: linear-gradient(135deg, #7c3aed, #4f46e5); color: #fff; }
.ai-grade-badge.grade-a { background: linear-gradient(135deg, #059669, #10b981); color: #fff; }
.ai-grade-badge.grade-b { background: linear-gradient(135deg, #0284c7, #38bdf8); color: #fff; }
.ai-grade-badge.grade-c { background: linear-gradient(135deg, #d97706, #fbbf24); color: #fff; }
.ai-grade-badge.grade-d { background: linear-gradient(135deg, #dc2626, #f87171); color: #fff; }

.ai-score-wrap {
    display: flex;
    align-items: baseline;
    gap: 3px;
}

.ai-score-num {
    font-size: 36px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.ai-score-unit {
    font-size: 14px;
    color: var(--muted);
}

.ai-summary-text {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    min-width: 140px;
}

.ai-evaluation-text {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.7;
    margin: 0 0 20px;
}

.ai-advice-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.ai-advice-card {
    background: rgba(129, 140, 248, 0.07);
    border: 1px solid rgba(129, 140, 248, 0.2);
    border-radius: 14px;
    padding: 14px 16px;
    transition: background 0.2s;
}

.ai-advice-card:hover {
    background: rgba(129, 140, 248, 0.12);
}

.ai-advice-title {
    font-size: 13px;
    font-weight: 700;
    color: #a5b4fc;
    margin: 0 0 6px;
}

.ai-advice-body {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
    margin: 0;
}

@media (max-width: 700px) {
    .ai-coach-settings {
        grid-template-columns: 1fr;
    }

    .ai-advice-list {
        grid-template-columns: 1fr;
    }

    .ai-grade-badge {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }

    .ai-score-num {
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .fg-gauge__labels span:nth-child(2),
    .fg-gauge__labels span:nth-child(4) {
        display: none;
    }
}

/* ══════════════════════════════════════════════════════════════════
   VIX Panel
   ══════════════════════════════════════════════════════════════════ */

.stock-vix {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 0 8px;
    text-align: center;
    width: 100%;
}

.stock-vix__top {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
}

.stock-vix__score {
    font-size: 52px;
    font-weight: 800;
    line-height: 1;
    transition: color 0.4s ease;
}

.stock-vix__label {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    transition: color 0.4s ease;
}

.stock-vix__change {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--muted);
}

.stock-vix__change.is-up { color: #f04452; }
.stock-vix__change.is-down { color: #3b82f6; }

/* VIX 구간별 설명 목록 */
.stock-vix__levels {
    display: grid;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    width: 100%;
    text-align: left;
}

.stock-vix__level {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.2s ease, border-color 0.2s ease;
}

.stock-vix__level.is-current {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.stock-vix__level-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.stock-vix__level-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.stock-vix__level-label {
    font-size: 12px;
    font-weight: 700;
}

.stock-vix__level-range {
    font-size: 11px;
    color: var(--muted);
    margin-left: auto;
}

.stock-vix__level-desc {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
    padding-left: 16px;
}

/* ══════════════════════════════════════════════════════════════════
   News Card Grid
   ══════════════════════════════════════════════════════════════════ */

.stock-news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}

.stock-news-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.stock-news-card:hover {
    border-color: rgba(96, 165, 250, 0.3);
    background: rgba(96, 165, 250, 0.04);
    transform: translateY(-2px);
}

.stock-news-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.stock-news-card__date {
    font-size: 11px;
    color: var(--muted);
}

.stock-news-card__title {
    margin: 0;
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    line-height: 1.4;
}

.stock-news-card__summary {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.stock-news-card__link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--accent-stock);
    text-decoration: none;
    margin-top: auto;
    transition: opacity 0.15s;
    font-weight: 500;
}

.stock-news-card__link:hover {
    opacity: 0.75;
    text-decoration: underline;
}

@media (max-width: 640px) {
    .stock-news-grid {
        grid-template-columns: 1fr;
    }
}

/* ══════════════════════════════════════════════════════════════════
   매크로 지표 카드
   ══════════════════════════════════════════════════════════════════ */

.stock-macro-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

.stock-macro-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    display: grid;
    gap: 6px;
}

.stock-macro-card__title {
    margin: 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.stock-macro-card__value {
    font-size: 32px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.stock-macro-card__change {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

.stock-macro-card__change.is-up { color: #f04452; }
.stock-macro-card__change.is-down { color: #3b82f6; }

.stock-macro-card__desc {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
    border-top: 1px solid var(--line);
    padding-top: 8px;
}

/* ══════════════════════════════════════════════════════════════════
   시장 건강 지표 (Placeholder)
   ══════════════════════════════════════════════════════════════════ */

.stock-health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}

.stock-placeholder-card {
    border: 1px dashed var(--line);
    border-radius: 14px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.1);
    display: grid;
    gap: 8px;
    opacity: 0.75;
}

.stock-placeholder-card__title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.stock-placeholder-card__status {
    font-size: 13px;
    color: var(--muted);
}

.stock-placeholder-card__desc {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
}

.stock-placeholder-card__api {
    font-size: 11px;
    color: var(--muted);
    opacity: 0.7;
    font-family: monospace;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--line);
    display: inline-block;
}

@media (max-width: 768px) {
    .stock-macro-grid,
    .stock-health-grid {
        grid-template-columns: 1fr;
    }

    .stock-macro-card__value {
        font-size: 26px;
    }
}

/* ══════════════════════════════════════════════════════════════════
   리스크 분산 분석
   ══════════════════════════════════════════════════════════════════ */

.risk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}

.risk-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    display: grid;
    gap: 10px;
}

.risk-card__title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.risk-item {
    display: grid;
    gap: 4px;
}

.risk-item__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.risk-item__name {
    color: var(--text);
    font-weight: 500;
}

.risk-item__ratio {
    font-weight: 700;
    font-size: 13px;
}

.risk-item__ratio.is-ok { color: #34d399; }
.risk-item__ratio.is-warn { color: #f97316; }
.risk-item__ratio.is-danger { color: #ef4444; }

.risk-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
}

.risk-bar__fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.4s ease;
}

.risk-bar__fill.is-ok { background: #34d399; }
.risk-bar__fill.is-warn { background: #f97316; }
.risk-bar__fill.is-danger { background: #ef4444; }

.risk-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.3);
    font-size: 12px;
    color: #fdba74;
}

@media (max-width: 640px) {
    .risk-grid {
        grid-template-columns: 1fr;
    }
}
/* ══════════════════════════════════════════════════════════════════
   실현손익 내역
   ══════════════════════════════════════════════════════════════════ */

.sell-history__filters {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.sell-history__filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.sell-history__filter-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    min-width: 36px;
}

.sell-history__filter-btn {
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.sell-history__filter-btn:hover {
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text);
}

.sell-history__filter-btn.is-active {
    border-color: var(--accent-stock);
    color: var(--accent-stock);
    background: rgba(99, 179, 237, 0.08);
}

.sell-history__summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.sell-history__summary-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}

.sell-history__summary-card strong {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.sell-history__table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--line);
}

.sell-history__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sell-history__table thead th {
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.sell-history__table thead th.is-num {
    text-align: right;
}

.sell-history__table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
    white-space: nowrap;
    color: var(--text);
}

.sell-history__table tbody tr:last-child td {
    border-bottom: none;
}

.sell-history__table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.sell-history__table td.is-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.sell-history__name {
    font-weight: 500;
    display: block;
}

.sell-history__ticker {
    font-size: 11px;
    color: var(--muted);
    font-family: monospace;
}

.sell-history__broker {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
}

.sell-history__date {
    font-size: 12px;
    color: var(--muted);
}

@media (max-width: 768px) {
    .sell-history__summary {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ══════════════════════════════════════════════════════════════════
   매도 내역 수동 추가/수정 폼
   ══════════════════════════════════════════════════════════════════ */

.sh-form {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.25);
    margin-bottom: 20px;
    display: grid;
    gap: 16px;
}

.sh-form__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.sh-form__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.sh-form__grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}

.sh-form__grid label input {
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text);
    font-size: 13px;
    width: 100%;
    box-sizing: border-box;
}

.sh-form__grid label input:focus {
    outline: none;
    border-color: var(--accent-stock);
}

.sh-form__datetime {
    grid-column: span 2;
}

.sh-form__preview {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    font-size: 13px;
    color: var(--muted);
}

.sh-form__preview strong {
    margin-left: 6px;
}

.sh-form__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.sh-row-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

@media (max-width: 640px) {
    .sh-form__grid {
        grid-template-columns: 1fr 1fr;
    }

    .sh-form__datetime {
        grid-column: span 2;
    }
}

/* ══════════════════════════════════════════════════════════════════
   실현손익 floating 토글 버튼 (우측 고정)
   ══════════════════════════════════════════════════════════════════ */

.sh-floating-toggle {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 190;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 10px;
    border-radius: 12px 0 0 12px;
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-right: none;
    background: rgba(7, 11, 25, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fbbf24;
    cursor: pointer;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(251, 191, 36, 0.08) inset;
    transition: background 0.2s, box-shadow 0.2s, border-color 0.2s, padding 0.2s;
    white-space: nowrap;
}

.sh-floating-toggle:hover {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.65);
    box-shadow: -4px 0 32px rgba(251, 191, 36, 0.15);
    padding-right: 14px;
}

.sh-floating-toggle__icon {
    font-size: 20px;
    line-height: 1;
}

.sh-floating-toggle__label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.sh-floating-toggle__badge {
    background: #fbbf24;
    color: #000;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 5px;
    line-height: 1.3;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* ══════════════════════════════════════════════════════════════════
   실현손익 드로어 (slide-in from right)
   ══════════════════════════════════════════════════════════════════ */

.sh-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 200;
    animation: sh-backdrop-in 0.2s ease;
}

@keyframes sh-backdrop-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.sh-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100dvh;
    width: min(520px, 100vw);
    background: var(--bg, #070b19);
    border-left: 1px solid var(--line);
    z-index: 201;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* 스크롤바 */
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}

.sh-drawer.is-open {
    transform: translateX(0);
}

.sh-drawer__header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 20px 16px;
    background: var(--bg, #070b19);
    border-bottom: 1px solid var(--line);
}

.sh-drawer__eyebrow {
    margin: 0 0 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: #fbbf24;
}

.sh-drawer__title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.sh-drawer__header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.sh-drawer__close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.sh-drawer__close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

/* 드로어 내 섹션들 패딩 */
.sh-drawer .sell-history__filters,
.sh-drawer .sell-history__summary,
.sh-drawer .sh-drawer__list,
.sh-drawer .sh-form,
.sh-drawer .sh-drawer__empty {
    margin: 0;
    padding: 16px 20px;
}

.sh-drawer .sell-history__filters {
    border-bottom: 1px solid var(--line);
    padding-bottom: 14px;
}

.sh-drawer .sell-history__summary {
    grid-template-columns: repeat(2, 1fr);
    border-bottom: 1px solid var(--line);
}

.sh-drawer .sh-form {
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.3);
}

.sh-drawer .sh-form__grid {
    grid-template-columns: 1fr 1fr;
}

/* 드로어 카드형 목록 */
.sh-drawer__list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 16px;
    padding-bottom: 24px;
}

.sh-drawer__item {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: background 0.15s;
}

.sh-drawer__item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.sh-drawer__item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sh-drawer__item-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

.sh-drawer__item-name code {
    font-size: 11px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

.sh-drawer__item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.sh-drawer__item-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.sh-drawer__item-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.sh-drawer__item-metrics > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
}

.sh-drawer__item-metrics > div span {
    color: var(--muted);
    font-size: 11px;
}

.sh-drawer__item-metrics > div strong {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.sh-drawer__empty {
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    padding-top: 40px !important;
}

@media (max-width: 480px) {
    .sh-drawer {
        width: 100vw;
    }

    .sh-drawer__item-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .sh-drawer .sh-form__grid {
        grid-template-columns: 1fr;
    }

    .sh-drawer .sh-form__datetime {
        grid-column: span 1;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   AI Advisor Tab (TAB_ADVISOR)
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Tab button ──────────────────────────────────────────────────────── */

.stock-main-tab--advisor {
    position: relative;
}

.stock-main-tab--advisor::after {
    content: 'AI';
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.05em;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-radius: 4px;
    padding: 1px 4px;
    line-height: 1.4;
}

/* ── Panel layout ────────────────────────────────────────────────────── */

.advisor-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.advisor-panel__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.advisor-panel__title-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.advisor-panel__badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #818cf8;
    background: rgba(129, 140, 248, 0.12);
    border: 1px solid rgba(129, 140, 248, 0.3);
    border-radius: 6px;
    padding: 2px 8px;
    width: fit-content;
}

.advisor-panel__title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-bright);
}

.advisor-panel__sub {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    max-width: 480px;
}

.advisor-panel__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.advisor-prompt__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.advisor-prompt__info {
    font-size: 12px;
    color: var(--text-muted);
}

.button.primary.small.is-copied {
    background: #34d399;
    color: #0f172a;
}

.advisor-prompt__preview {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    line-height: 1.7;
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 20px;
    max-height: 520px;
    overflow-y: auto;
}

.advisor-panel__timestamp {
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px 10px;
}

/* ── Loading state ───────────────────────────────────────────────────── */

.advisor-panel__loading {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 32px 0;
}

.advisor-loading-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid rgba(129, 140, 248, 0.15);
    border-top-color: #818cf8;
    animation: spin 0.9s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.advisor-loading-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.advisor-loading-text p {
    margin: 0;
    font-size: 14px;
    color: var(--text-bright);
}

.advisor-loading-sub {
    font-size: 12px !important;
    color: var(--text-muted) !important;
}

/* ── Error state ─────────────────────────────────────────────────────── */

.advisor-panel__error {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(249, 182, 177, 0.08);
    border: 1px solid rgba(249, 182, 177, 0.3);
    color: #f9b6b1;
    font-size: 13px;
}

/* ── Empty state ─────────────────────────────────────────────────────── */

.advisor-panel__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 60px 0;
    color: var(--text-muted);
}

.advisor-panel__empty-icon {
    font-size: 40px;
    opacity: 0.4;
}

/* ── Analysis body ───────────────────────────────────────────────────── */

.advisor-panel__body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.advisor-panel__disclaimer {
    margin: 0;
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.6;
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

/* ── Markdown renderer ───────────────────────────────────────────────── */

.adv-md {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.75;
}

.adv-md-h2 {
    margin: 20px 0 6px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-bright);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
}

.adv-md-h3 {
    margin: 14px 0 4px;
    font-size: 14px;
    font-weight: 700;
    color: #818cf8;
}

.adv-md-p {
    margin: 0;
    font-size: 13px;
    color: var(--text);
    line-height: 1.75;
}

.adv-md-p strong {
    color: var(--text-bright);
    font-weight: 700;
}

.adv-md-p em {
    color: #fbbf24;
    font-style: normal;
}

.adv-md-p code {
    font-family: monospace;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 1px 5px;
    color: #34d399;
}

.adv-md-hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 12px 0;
}

.adv-md-gap {
    height: 6px;
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .advisor-panel__head {
        flex-direction: column;
    }

    .advisor-panel__actions {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 768px) {
    /* 필터 가로 스크롤 */
    .stock-filter-row {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }

    .stock-filter-row > * {
        flex-shrink: 0;
    }

    /* 지표 카드 가로 스크롤 캐러셀 */
    .stock-snapshot {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 12px;
        padding-bottom: 8px;
        scroll-snap-type: x mandatory;
    }

    .stock-snapshot > * {
        flex: 0 0 200px;
        scroll-snap-align: start;
    }

    /* 뉴스 1컬럼 */
    .stock-news-grid {
        grid-template-columns: 1fr;
    }

    /* 매크로 지표 1컬럼 */
    .stock-macro-grid {
        grid-template-columns: 1fr;
    }
}
