.guest-flow-banner {
    margin-bottom: 0.75rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-sub);
    font-size: 0.84rem;
    line-height: 1.55;
}

.guest-flow-banner strong {
    margin-right: 0.35rem;
    color: var(--text-main);
    font-weight: 850;
}

.portfolio-title-container {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.portfolio-title {
    min-width: 0;
    margin: 0;
    padding: 0.12rem 0.25rem;
    border-radius: var(--radius);
    color: var(--text-main);
    font-size: clamp(1.35rem, 2vw, 1.7rem);
    font-weight: 800;
    line-height: 1.25;
    cursor: pointer;
}

.portfolio-title:hover {
    background: var(--surface-muted);
}

.portfolio-title:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.portfolio-title::after {
    content: '수정';
    margin-left: 0.45rem;
    color: var(--text-sub);
    font-size: 0.72rem;
    font-weight: 800;
    opacity: 0;
}

.portfolio-title:hover::after,
.portfolio-title:focus-visible::after {
    opacity: 1;
}

.portfolio-title-input {
    display: none;
    min-width: min(320px, 60vw);
    padding: 0.24rem 0.45rem;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-main);
    font-size: clamp(1.35rem, 2vw, 1.7rem);
    font-weight: 800;
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.control-card,
.execution-summary-card {
    margin-bottom: 0;
    padding: 1rem;
}

.control-card {
    background: var(--surface);
}

.execution-summary-card {
    border-color: var(--border-strong);
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
}

.control-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 0.9rem;
}

.input-item {
    min-width: 210px;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.input-item label {
    min-width: 76px;
    color: var(--text-sub);
    font-size: 0.84rem;
    font-weight: 800;
    white-space: nowrap;
}

.new-investment-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-auto-investment {
    min-height: 36px;
    padding: 0.4rem 0.6rem;
}

.input-split-days {
    width: 74px;
}

.input-item .styled-input {
    height: 34px;
    min-height: 34px;
    padding: 0.34rem 0.58rem;
    font-size: 0.9rem;
}

.advanced-settings {
    flex: 1 1 100%;
    border: 0;
    background: transparent;
}

.advanced-settings summary {
    width: fit-content;
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-sub);
    font-size: 0.84rem;
    font-weight: 850;
    cursor: pointer;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
    list-style: none;
}

.advanced-settings summary::-webkit-details-marker {
    display: none;
}

.advanced-settings summary::before {
    content: "+";
    width: 1rem;
    color: var(--primary);
    font-weight: 900;
    text-align: center;
}

.advanced-settings[open] {
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
}

.advanced-settings[open] summary {
    margin-bottom: 0.65rem;
    color: var(--text-main);
}

.advanced-settings[open] summary::before {
    content: "-";
}

.advanced-settings summary:hover {
    border-color: var(--border-strong);
    background: var(--primary-soft);
    color: var(--primary);
}

.advanced-settings summary:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.advanced-settings-body {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 0.9rem;
    padding: 0;
}

.advanced-settings-note {
    flex: 1 1 100%;
    margin: 0;
    color: var(--text-sub);
    font-size: 0.78rem;
    line-height: 1.45;
}

.strategy-hint {
    margin: 0;
    color: var(--text-sub);
    font-size: 0.76rem;
    line-height: 1.35;
}

.control-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 0.5rem;
}

.stat-item {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.72rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
}

.stat-label {
    color: var(--text-sub);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.stat-value {
    color: var(--text-main);
    font-size: 1.06rem;
    font-weight: 850;
    letter-spacing: 0;
    white-space: nowrap;
}

.stat-value.highlight,
.stat-primary .stat-value {
    color: var(--positive);
}

.stat-danger .stat-value {
    color: var(--negative);
}

.stat-unit {
    font-size: 0.8em;
    font-weight: 600;
}

.chart-card {
    margin-bottom: 0.9rem;
    padding: 1.05rem;
}

.chart-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.75rem;
}

.chart-column {
    min-width: 0;
}

.chart-title {
    margin: 0 0 0.6rem;
    color: var(--text-sub);
    font-size: 0.92rem;
    text-align: center;
}

.chart-canvas-wrap {
    position: relative;
    height: 280px;
}

.table-actions {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.table-actions-spread {
    justify-content: space-between;
}

.table-action-buttons,
.table-action-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.table-action-buttons {
    justify-content: flex-start;
}

.table-action-group {
    padding-right: 0.55rem;
    border-right: 1px solid var(--border);
}

.table-action-group:last-child {
    padding-right: 0;
    border-right: 0;
}

.mobile-only-action {
    display: none;
}

.table-card {
    overflow: hidden;
    padding: 0;
}

.table-container {
    max-width: 100%;
    overflow-x: auto;
    border-radius: var(--radius);
    background: var(--surface);
}

table {
    width: 100%;
    min-width: 1080px;
    border-collapse: collapse;
    font-size: 0.88rem;
}

th {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 0.66rem 0.55rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text-sub);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0;
    text-align: center;
    white-space: nowrap;
}

td {
    height: 34px;
    padding: 0.2rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tr:last-child td {
    border-bottom: 0;
}

.col-number,
.col-delete {
    width: 48px;
}

table th:nth-child(2),
table td:nth-of-type(2) {
    text-align: left;
}

table td:nth-of-type(2) .cell-input {
    text-align: left;
}

.cell-input {
    width: 100%;
    height: 100%;
    padding: 0.32rem 0.45rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-main);
    font-size: 0.88rem;
    font-weight: 600;
    text-align: right;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.cell-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
}

.cell-input[readonly] {
    color: var(--text-sub);
}

.cell-input.text-center,
.text-center {
    text-align: center;
}

.cell-input.required-field {
    background: #fffbeb;
}

.cell-input.required-field:focus {
    background: var(--surface);
}

.td-recommended-buy {
    background: #f0fdf4;
}

.td-daily-purchase {
    background: var(--primary-soft);
}

.td-recommended-sell {
    background: #fff1f2;
}

.td-sum-daily-purchase {
    background: var(--positive-soft);
}

.daily-purchase {
    font-weight: 800;
}

tfoot tr,
tfoot td {
    background: var(--surface-muted);
}

tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 10;
    border-top: 2px solid var(--border);
    font-weight: 800;
}

tfoot .cell-input {
    color: var(--text-main);
    font-weight: 800;
}

.tfoot-total-label {
    color: var(--text-sub);
    text-align: center;
}

.position-status {
    min-width: 62px;
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.16rem 0.4rem;
    border-radius: var(--radius);
    background: var(--surface-strong);
    color: var(--text-sub);
    font-size: 0.74rem;
    font-weight: 800;
    white-space: nowrap;
}

.position-status.status-buy {
    background: var(--positive-soft);
    color: var(--positive);
}

.position-status.status-sell {
    background: var(--negative-soft);
    color: var(--negative);
}

.position-status.status-hold,
.position-status.status-target {
    background: var(--surface-strong);
    color: var(--text-sub);
}

.position-status.status-min {
    background: var(--warning-soft);
    color: var(--warning);
}

.position-status.status-data-check {
    background: var(--negative-soft);
    color: var(--negative);
}

.btn-add {
    width: 100%;
    border-color: var(--border);
    background: var(--surface);
    color: var(--text-main);
}

.btn-add:hover {
    border-color: var(--border-strong);
    background: var(--surface-muted);
}

.btn-delete-row {
    width: 34px;
    height: 34px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-sub);
    cursor: pointer;
    font-size: 1.08rem;
    line-height: 1;
}

.btn-delete-row:hover {
    border-color: var(--negative-soft);
    background: #fff7f7;
    color: var(--negative);
}

.row-actions-cell {
    min-width: 86px;
    text-align: center;
}

.btn-row-details {
    display: none;
    min-height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-main);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 850;
    padding: 0.3rem 0.55rem;
}

.btn-row-details:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.data-table-section.show-mobile-details .btn-row-details {
    display: none;
}

.portfolio-mobile-sticky {
    display: none;
}

.is-hidden,
.hidden-file-input {
    display: none;
}

.login-modal-message {
    margin-bottom: 0.85rem;
    color: var(--text-sub);
    font-size: 0.9rem;
    line-height: 1.55;
    white-space: pre-line;
}

.portfolio-modal .modal-content.login-form-modal-content {
    max-width: 360px;
}

.portfolio-modal .modal-content.excel-modal-content {
    width: min(100%, 520px);
    max-width: 520px;
}

.excel-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.45rem;
}

.excel-modal-head h3 {
    margin: 0;
}

.excel-modal-close {
    flex: 0 0 auto;
}

.excel-modal-description {
    margin: 0 0 0.85rem;
    color: var(--text-sub);
    font-size: 0.9rem;
    line-height: 1.55;
}

.excel-modal-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
}

.modal-field-group {
    margin-bottom: 0.75rem;
    text-align: left;
}

.modal-field-group-last {
    margin-bottom: 1rem;
}

.modal-field-label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--text-main);
    font-size: 0.88rem;
    font-weight: 800;
}

.modal-field-input {
    width: 100%;
}

.btn-full-width {
    width: 100%;
}

.modal-inline-links {
    margin-top: 0.85rem;
    font-size: 0.88rem;
    text-align: center;
}

.primary-link {
    color: var(--primary);
    font-weight: 800;
    text-decoration: none;
}

.drop-zone {
    padding: 1.2rem;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-muted);
    color: var(--text-sub);
    text-align: center;
    cursor: pointer;
}

.excel-drop-zone {
    min-height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 1.3rem;
}

.excel-drop-zone p:first-child {
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 800;
}

.drop-zone:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

.drop-zone.is-dragover,
.drop-zone.is-loading {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

.drop-zone.is-loading {
    pointer-events: none;
    opacity: 0.72;
}

.excel-template-button {
    width: 100%;
}

.muted {
    margin-top: 0.25rem;
    color: var(--text-sub);
    font-size: 0.82rem;
}

@media (min-width: 640px) {
    .table-actions {
        flex-direction: row;
        align-items: flex-start;
    }

    .table-action-buttons {
        flex: 1;
        justify-content: flex-end;
    }

    .btn-add {
        width: auto;
    }
}

@media (max-width: 767px) {
    body {
        padding-bottom: calc(74px + env(safe-area-inset-bottom));
    }

    .portfolio-title-container {
        align-items: flex-start;
    }

    .portfolio-title {
        word-break: keep-all;
    }

    .portfolio-title-input {
        min-width: 160px;
    }

    .control-inputs,
    .input-item {
        width: 100%;
    }

    .input-item {
        min-width: 0;
        align-items: flex-start;
        flex-direction: column;
        gap: 0.35rem;
    }

    .input-item label {
        min-width: 0;
    }

    .new-investment-input-wrap {
        width: 100%;
        flex: 1;
    }

    .new-investment-input-wrap .styled-input {
        min-width: 0;
        flex: 1;
    }

    .btn-auto-investment,
    .advanced-settings summary,
    .input-item .styled-input {
        min-height: 44px;
    }

    .advanced-settings-body {
        flex-direction: column;
    }

    .table-action-group {
        width: 100%;
        padding-right: 0;
        border-right: 0;
    }

    .table-action-group .btn,
    .table-action-group .btn-add {
        flex: 1 1 120px;
    }

    .mobile-only-action {
        display: inline-flex;
        justify-content: center;
    }

    .data-table-section:not(.show-mobile-details) .table-container {
        overflow: visible;
        background: transparent;
    }

    .data-table-section:not(.show-mobile-details) table,
    .data-table-section:not(.show-mobile-details) tbody {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .data-table-section:not(.show-mobile-details) thead,
    .data-table-section:not(.show-mobile-details) tfoot {
        display: none;
    }

    .data-table-section:not(.show-mobile-details) tbody tr:not(#rowTemplate) {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.55rem;
        margin-bottom: 0.75rem;
        padding: 0.75rem;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: var(--surface);
        box-shadow: var(--shadow-sm);
    }

    .data-table-section:not(.show-mobile-details) th:nth-child(1),
    .data-table-section:not(.show-mobile-details) th:nth-child(3),
    .data-table-section:not(.show-mobile-details) th:nth-child(5),
    .data-table-section:not(.show-mobile-details) th:nth-child(7),
    .data-table-section:not(.show-mobile-details) th:nth-child(8),
    .data-table-section:not(.show-mobile-details) th:nth-child(9),
    .data-table-section:not(.show-mobile-details) th:nth-child(10),
    .data-table-section:not(.show-mobile-details) th:nth-child(12),
    .data-table-section:not(.show-mobile-details) td:nth-of-type(1),
    .data-table-section:not(.show-mobile-details) tbody tr:not(.mobile-row-expanded) td:nth-of-type(3),
    .data-table-section:not(.show-mobile-details) tbody tr:not(.mobile-row-expanded) td:nth-of-type(5),
    .data-table-section:not(.show-mobile-details) tbody tr:not(.mobile-row-expanded) td:nth-of-type(7),
    .data-table-section:not(.show-mobile-details) tbody tr:not(.mobile-row-expanded) td:nth-of-type(8),
    .data-table-section:not(.show-mobile-details) tbody tr:not(.mobile-row-expanded) td:nth-of-type(9),
    .data-table-section:not(.show-mobile-details) tbody tr:not(.mobile-row-expanded) td:nth-of-type(10),
    .data-table-section:not(.show-mobile-details) tbody tr:not(.mobile-row-expanded) td:nth-of-type(12) {
        display: none;
    }

    .data-table-section:not(.show-mobile-details) .mobile-row-expanded td:nth-of-type(3),
    .data-table-section:not(.show-mobile-details) .mobile-row-expanded td:nth-of-type(5),
    .data-table-section:not(.show-mobile-details) .mobile-row-expanded td:nth-of-type(7),
    .data-table-section:not(.show-mobile-details) .mobile-row-expanded td:nth-of-type(8),
    .data-table-section:not(.show-mobile-details) .mobile-row-expanded td:nth-of-type(9),
    .data-table-section:not(.show-mobile-details) .mobile-row-expanded td:nth-of-type(10),
    .data-table-section:not(.show-mobile-details) .mobile-row-expanded td:nth-of-type(12) {
        display: flex;
    }

    .data-table-section:not(.show-mobile-details) td {
        height: auto;
        min-height: 54px;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        gap: 0.24rem;
        padding: 0;
        border-bottom: 0;
        background: transparent;
        white-space: normal;
    }

    .data-table-section:not(.show-mobile-details) td::before {
        color: var(--text-sub);
        font-size: 0.72rem;
        font-weight: 800;
        line-height: 1.2;
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(2)::before {
        content: '티커';
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(3)::before {
        content: '현재비중';
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(4)::before {
        content: '목표비중';
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(5)::before {
        content: '차이';
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(6)::before {
        content: '평가금액';
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(7)::before {
        content: '수익률';
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(8)::before {
        content: '추정원금';
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(9)::before {
        content: '기간 매수';
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(10)::before {
        content: '기간 매도';
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(11)::before {
        content: '오늘 금액';
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(12)::before {
        content: '상태';
    }

    .data-table-section:not(.show-mobile-details) th:nth-child(2),
    .data-table-section:not(.show-mobile-details) td:nth-of-type(2) {
        position: static;
        min-width: 0;
        background: var(--surface);
        box-shadow: none;
    }

    .data-table-section:not(.show-mobile-details) th:nth-child(2) {
        background: var(--surface-muted);
        z-index: 14;
    }

    .data-table-section:not(.show-mobile-details) th:nth-child(11),
    .data-table-section:not(.show-mobile-details) td:nth-of-type(11) {
        grid-column: 1 / -1;
        position: static;
        min-width: 0;
        padding: 0.55rem;
        border-radius: var(--radius);
        background: #f0fdf4;
        box-shadow: none;
    }

    .data-table-section:not(.show-mobile-details) th:nth-child(11) {
        background: var(--surface-muted);
        z-index: 14;
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(12) {
        grid-column: 1 / -1;
        min-height: auto;
        align-items: flex-start;
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(13) {
        grid-column: 1 / -1;
        min-height: 44px;
        flex-direction: row;
        justify-content: flex-end;
        align-items: center;
    }

    .data-table-section:not(.show-mobile-details) .cell-input {
        min-height: 44px;
        border-color: var(--border);
        background: var(--surface-muted);
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(2) .cell-input {
        text-align: left;
    }

    .data-table-section.show-mobile-details table {
        min-width: 1080px;
    }

    .btn-row-details {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
    }

    .btn-delete-row {
        width: 44px;
        height: 44px;
        flex: 0 0 44px;
    }

    .portfolio-mobile-sticky {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 90;
        display: block;
        padding: 0.65rem 1rem calc(0.65rem + env(safe-area-inset-bottom));
        border-top: 1px solid var(--border);
        background: rgba(255, 255, 255, 0.96);
        box-shadow: 0 -10px 28px rgba(16, 24, 40, 0.12);
        backdrop-filter: blur(12px);
    }

    .portfolio-mobile-sticky .btn {
        width: 100%;
        min-height: 48px;
    }
}

/* Rebalancing-first calculator layout */
.portfolio-calculator-page {
    padding-block: 1.4rem 2.5rem;
}

.dashboard-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: .9rem;
}

.calculator-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: .35rem .1rem .2rem;
}

.calculator-page-header > div {
    min-width: 0;
}

.calculator-kicker,
.summary-heading p,
.section-title-row > div > p {
    margin: 0 0 .3rem;
    color: var(--primary);
    font-size: .76rem;
    font-weight: 850;
    letter-spacing: .035em;
}

.calculator-page-header h1 {
    margin: 0;
    color: var(--text-main);
    font-size: clamp(1.8rem, 4vw, 2.65rem);
    font-weight: 900;
    letter-spacing: -.04em;
    line-height: 1.18;
    text-wrap: balance;
    word-break: keep-all;
}

.calculator-page-header p:last-child {
    max-width: 720px;
    margin: .65rem 0 0;
    color: var(--text-sub);
    font-size: .94rem;
    line-height: 1.65;
}

.execution-summary-card {
    padding: 1.1rem;
    border: 1px solid rgba(36, 99, 235, .28);
    border-radius: 12px;
    background: linear-gradient(145deg, #fff 0%, #f4f8ff 100%);
    box-shadow: 0 12px 30px rgba(36, 99, 235, .08);
}

.portfolio-result-section {
    display: grid;
    gap: .9rem;
}

.portfolio-result-section .chart-card {
    margin-bottom: 0;
}

.summary-heading,
.section-title-row,
.target-weight-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
}

.summary-heading {
    margin-bottom: .8rem;
}

.summary-actions {
    display: flex;
    align-items: center;
    gap: .45rem;
}

.summary-heading h2,
.section-title-row h2,
.calculator-faq h2 {
    margin: 0;
    color: var(--text-main);
    font-size: 1.08rem;
    font-weight: 900;
    line-height: 1.35;
}

.summary-live-badge {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    padding: .25rem .55rem;
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--text-sub);
    font-size: .74rem;
    font-weight: 850;
    white-space: nowrap;
}

.summary-live-badge.is-ready {
    background: var(--positive-soft);
    color: var(--positive);
}

.summary-live-badge.is-error {
    background: var(--negative-soft);
    color: var(--negative);
}

.execution-stats {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.execution-stats .stat-item {
    min-height: 78px;
    justify-content: center;
    background: rgba(255, 255, 255, .88);
}

.execution-stats .stat-primary {
    border-color: rgba(22, 128, 60, .25);
    background: #f0fbf4;
}

.execution-stats .stat-total {
    border-color: rgba(36, 99, 235, .25);
    background: var(--primary-soft);
}

.execution-stats .stat-total .stat-value {
    color: var(--primary);
}

.execution-stats .stat-danger {
    border-color: rgba(217, 45, 69, .22);
    background: #fff5f6;
}

.secondary-summary {
    margin-top: .75rem;
    border-top: 1px solid var(--border);
}

.secondary-summary summary {
    width: fit-content;
    padding-top: .7rem;
    color: var(--text-sub);
    cursor: pointer;
    font-size: .78rem;
    font-weight: 800;
}

.secondary-summary-note {
    margin: .6rem 0 0;
    color: var(--text-sub);
    font-size: .74rem;
    line-height: 1.5;
}

.secondary-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .5rem;
    margin-top: .6rem;
}

.secondary-summary-grid > div {
    display: grid;
    gap: .18rem;
    padding: .6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.secondary-summary-grid span {
    color: var(--text-sub);
    font-size: .72rem;
    font-weight: 700;
}

.secondary-summary-grid strong {
    color: var(--text-main);
    font-size: .84rem;
    font-weight: 850;
}

.calculation-trust-box {
    overflow: hidden;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.calculation-trust-box summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .7rem .85rem;
    color: var(--text-main);
    cursor: pointer;
    list-style: none;
}

.calculation-trust-box summary::-webkit-details-marker {
    display: none;
}

.calculation-trust-box summary::after {
    content: '+';
    margin-left: auto;
    color: var(--primary);
    font-size: 1rem;
    font-weight: 900;
}

.calculation-trust-box[open] summary::after {
    content: '−';
}

.calculation-trust-box summary:focus-visible {
    outline: none;
    box-shadow: inset var(--focus-ring);
}

.calculation-trust-box summary > span {
    flex: 0 0 auto;
    color: var(--primary);
    font-size: .78rem;
    font-weight: 900;
}

.calculation-trust-box summary > strong {
    min-width: 0;
    overflow: hidden;
    color: var(--text-sub);
    font-size: .77rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calculation-trust-body {
    padding: .75rem .9rem .85rem;
    border-top: 1px solid var(--border);
    background: var(--surface-muted);
}

.calculation-trust-box ul {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .32rem 1.2rem;
    margin-top: .55rem;
}

.calculation-trust-box li {
    position: relative;
    padding-left: .85rem;
    color: var(--text-sub);
    font-size: .77rem;
    line-height: 1.5;
}

.calculation-trust-box li::before {
    content: '';
    position: absolute;
    top: .55em;
    left: 0;
    width: 4px;
    height: 4px;
    border-radius: 999px;
    background: var(--primary);
}

.calculation-trust-body a {
    display: inline-flex;
    margin-top: .65rem;
    color: var(--primary);
    font-size: .76rem;
    font-weight: 850;
    text-decoration: none;
}

.calculation-trust-body a:hover {
    text-decoration: underline;
}

.investment-settings-card {
    padding: 1.05rem;
}

.section-title-row {
    align-items: flex-start;
    margin-bottom: .9rem;
}

.portfolio-title-container {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .35rem;
}

.portfolio-name-label {
    color: var(--text-muted);
    font-size: .7rem;
    font-weight: 750;
}

.portfolio-title {
    margin: 0;
    padding: .26rem .42rem;
    font-size: .82rem;
    font-weight: 800;
}

.portfolio-title-input {
    min-width: min(260px, 58vw);
    padding: .33rem .48rem;
    font-size: .82rem;
    font-weight: 750;
}

.control-inputs {
    display: grid;
    grid-template-columns: minmax(240px, .7fr) minmax(320px, 1.3fr);
    gap: .8rem;
}

.control-inputs > .input-item {
    min-width: 0;
    align-items: flex-start;
    flex-direction: column;
    padding: .85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-muted);
}

.control-inputs > .input-item label {
    min-width: 0;
}

.new-investment-input-wrap {
    width: 100%;
}

.new-investment-input-wrap > input {
    min-width: 0;
    flex: 1;
}

.target-weight-panel {
    min-width: 0;
    padding: .85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-muted);
}

.target-weight-heading > div {
    display: flex;
    align-items: baseline;
    gap: .42rem;
}

.target-weight-heading span {
    color: var(--text-sub);
    font-size: .74rem;
    font-weight: 750;
}

.target-weight-heading strong,
.target-weight-heading strong span {
    color: var(--text-main);
    font-size: .9rem;
    font-weight: 900;
}

.target-weight-progress {
    height: 11px;
    margin-top: .72rem;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-strong);
    box-shadow: inset 0 1px 2px rgba(16, 24, 40, .08);
}

.target-weight-progress > span {
    width: 0;
    height: 100%;
    display: block;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), #6990f4);
    transition: width .2s ease, background-color .2s ease;
}

.target-weight-panel.is-under .target-weight-progress > span {
    background: linear-gradient(90deg, #d99a2b, #f6c75f);
}

.target-weight-panel.is-invalid {
    border-color: rgba(217, 45, 69, .38);
    background: #fff7f8;
}

.target-weight-panel.is-invalid .target-weight-progress > span {
    background: var(--negative);
}

.target-weight-message {
    margin: .5rem 0 0;
    color: var(--text-sub);
    font-size: .74rem;
    line-height: 1.45;
}

.target-weight-panel.is-invalid .target-weight-message {
    color: var(--negative);
    font-weight: 750;
}

.strategy-fieldset {
    grid-column: 1 / -1;
    min-width: 0;
    padding: 0;
}

.strategy-fieldset legend {
    margin-bottom: .55rem;
    color: var(--text-main);
    font-size: .86rem;
    font-weight: 850;
}

.strategy-fieldset legend span {
    color: var(--primary);
    font-size: .72rem;
}

.strategy-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .65rem;
}

.strategy-option-card {
    position: relative;
    min-width: 0;
    display: block;
    cursor: pointer;
}

.strategy-option-card input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
}

.strategy-card-content {
    min-height: 102px;
    display: grid;
    align-content: start;
    gap: .5rem;
    padding: .9rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    transition: border-color .16s ease, background-color .16s ease, box-shadow .16s ease;
}

.strategy-card-content strong {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    color: var(--text-main);
    font-size: .9rem;
    font-weight: 900;
}

.strategy-card-content em {
    padding: .18rem .4rem;
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--text-sub);
    font-size: .66rem;
    font-style: normal;
    font-weight: 750;
}

.strategy-card-content > span {
    color: var(--text-sub);
    font-size: .79rem;
    line-height: 1.5;
}

.strategy-option-card input:checked + .strategy-card-content {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 2px rgba(36, 99, 235, .1);
}

.strategy-option-card input:checked + .strategy-card-content em {
    background: #fff;
    color: var(--primary);
}

.strategy-option-card input:focus-visible + .strategy-card-content {
    outline: none;
    box-shadow: var(--focus-ring);
}

.strategy-hint {
    margin: .5rem 0 0;
    font-size: .73rem;
    line-height: 1.45;
}

.strategy-hint { color: var(--text-sub); }

.advanced-settings {
    grid-column: 1 / -1;
}

.table-section-title {
    margin: .2rem 0 .7rem;
}

.calculation-empty-state {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: .9rem;
    padding: 1rem 1.05rem;
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    background: var(--surface-muted);
}

.calculation-empty-state.is-hidden,
.portfolio-result-section.is-hidden {
    display: none;
}

.calculation-empty-state.is-error {
    border-color: rgba(217, 45, 69, .42);
    background: #fff7f8;
}

.calculation-empty-mark {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 1.05rem;
    font-weight: 900;
}

.calculation-empty-state.is-error .calculation-empty-mark {
    background: var(--negative-soft);
    color: var(--negative);
}

.calculation-empty-copy {
    min-width: 0;
}

.calculation-empty-copy p {
    margin: 0 0 .2rem;
    color: var(--primary);
    font-size: .72rem;
    font-weight: 850;
}

.calculation-empty-copy h2 {
    margin: 0;
    color: var(--text-main);
    font-size: .94rem;
    font-weight: 900;
    line-height: 1.4;
}

.calculation-empty-copy > span {
    display: block;
    margin-top: .25rem;
    color: var(--text-sub);
    font-size: .76rem;
    line-height: 1.45;
}

.calculation-empty-actions {
    display: flex;
    flex: 0 0 auto;
    gap: .4rem;
}

.desktop-detail-action {
    display: inline-flex;
}

.calculator-faq {
    padding: 1.05rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.calculator-faq-list {
    display: grid;
    gap: .5rem;
}

.calculator-faq-list details {
    padding: .78rem .85rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-muted);
}

.calculator-faq-list summary {
    color: var(--text-main);
    cursor: pointer;
    font-size: .82rem;
    font-weight: 850;
}

.calculator-faq-list p {
    margin: .55rem 0 0;
    color: var(--text-sub);
    font-size: .78rem;
    line-height: 1.55;
}

@media (min-width: 768px) {
    .data-table-section:not(.show-desktop-details) table {
        min-width: 820px;
    }

    .data-table-section:not(.show-desktop-details) thead th:nth-child(1),
    .data-table-section:not(.show-desktop-details) thead th:nth-child(7),
    .data-table-section:not(.show-desktop-details) thead th:nth-child(8),
    .data-table-section:not(.show-desktop-details) thead th:nth-child(9),
    .data-table-section:not(.show-desktop-details) thead th:nth-child(10),
    .data-table-section:not(.show-desktop-details) tbody td:nth-of-type(1),
    .data-table-section:not(.show-desktop-details) tbody td:nth-of-type(7),
    .data-table-section:not(.show-desktop-details) tbody td:nth-of-type(8),
    .data-table-section:not(.show-desktop-details) tbody td:nth-of-type(9),
    .data-table-section:not(.show-desktop-details) tbody td:nth-of-type(10),
    .data-table-section:not(.show-desktop-details) tfoot {
        display: none;
    }

    .data-table-section:not(.show-desktop-details) .btn-row-details {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .data-table-section:not(.show-desktop-details) .row-actions-cell {
        min-width: 132px;
    }

    .data-table-section:not(.show-desktop-details) .row-actions-cell .btn-delete-row {
        display: inline-flex;
        margin: 0 0 0 .25rem;
        vertical-align: middle;
    }

    .data-table-section:not(.show-desktop-details) tbody tr.mobile-row-expanded td:nth-of-type(7),
    .data-table-section:not(.show-desktop-details) tbody tr.mobile-row-expanded td:nth-of-type(8),
    .data-table-section:not(.show-desktop-details) tbody tr.mobile-row-expanded td:nth-of-type(9),
    .data-table-section:not(.show-desktop-details) tbody tr.mobile-row-expanded td:nth-of-type(10) {
        display: table-cell;
    }

    .data-table-section:not(.show-desktop-details) tbody tr.mobile-row-expanded td:nth-of-type(7)::before,
    .data-table-section:not(.show-desktop-details) tbody tr.mobile-row-expanded td:nth-of-type(8)::before,
    .data-table-section:not(.show-desktop-details) tbody tr.mobile-row-expanded td:nth-of-type(9)::before,
    .data-table-section:not(.show-desktop-details) tbody tr.mobile-row-expanded td:nth-of-type(10)::before {
        display: block;
        margin-bottom: .14rem;
        color: var(--text-sub);
        font-size: .66rem;
        font-weight: 800;
        text-align: center;
    }

    .data-table-section:not(.show-desktop-details) tbody tr.mobile-row-expanded td:nth-of-type(7)::before { content: '수익률'; }
    .data-table-section:not(.show-desktop-details) tbody tr.mobile-row-expanded td:nth-of-type(8)::before { content: '추정원금'; }
    .data-table-section:not(.show-desktop-details) tbody tr.mobile-row-expanded td:nth-of-type(9)::before { content: '기간 매수'; }
    .data-table-section:not(.show-desktop-details) tbody tr.mobile-row-expanded td:nth-of-type(10)::before { content: '기간 매도'; }

    .data-table-section:not(.show-desktop-details):has(tbody tr.mobile-row-expanded) table {
        min-width: 1080px;
    }

    .data-table-section.is-awaiting-calculation:not(.show-desktop-details) table {
        min-width: 560px;
    }
}

@media (max-width: 1050px) {
    .execution-stats {
        grid-template-columns: repeat(3, minmax(130px, 1fr));
    }
}

@media (max-width: 767px) {
    .portfolio-calculator-page {
        padding: 1rem;
    }

    .calculator-page-header {
        flex-direction: column;
    }

    .calculator-page-header .btn {
        width: 100%;
    }

    .execution-stats,
    .secondary-summary-grid,
    .control-inputs,
    .strategy-card-grid,
    .calculation-trust-box ul {
        grid-template-columns: 1fr;
    }

    .execution-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .execution-stats .stat-total { grid-column: 1 / -1; }

    .section-title-row {
        align-items: stretch;
        flex-direction: column;
    }

    .portfolio-title-container {
        justify-content: flex-start;
    }

    .calculation-empty-state {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .calculation-empty-actions {
        grid-column: 1 / -1;
    }

    .calculation-empty-actions .btn {
        flex: 1 1 0;
    }

    .calculation-trust-box summary {
        align-items: flex-start;
    }

    .calculation-trust-box summary > strong {
        overflow: visible;
        text-overflow: clip;
        white-space: normal;
    }

    .strategy-fieldset,
    .advanced-settings {
        grid-column: auto;
    }

    .strategy-card-content {
        min-height: 0;
    }

    .desktop-detail-action {
        display: none;
    }

    .data-table-section:not(.show-mobile-details) tbody tr:not(.mobile-row-expanded) td:nth-of-type(3),
    .data-table-section:not(.show-mobile-details) tbody tr:not(.mobile-row-expanded) td:nth-of-type(5),
    .data-table-section:not(.show-mobile-details) tbody tr:not(.mobile-row-expanded) td:nth-of-type(6),
    .data-table-section:not(.show-mobile-details) tbody tr:not(.mobile-row-expanded) td:nth-of-type(12) {
        display: flex;
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(3),
    .data-table-section:not(.show-mobile-details) td:nth-of-type(4),
    .data-table-section:not(.show-mobile-details) td:nth-of-type(5) {
        min-height: 50px;
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(6) {
        grid-column: 1 / -1;
    }

    .data-table-section:not(.show-mobile-details) td:nth-of-type(12) {
        grid-column: 1 / -1;
        display: flex;
        align-items: flex-start;
    }

}

@media (max-width: 460px) {
    .summary-heading,
    .target-weight-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .summary-actions {
        width: 100%;
        justify-content: space-between;
    }

    .execution-stats {
        grid-template-columns: 1fr;
    }

    .calculation-empty-state {
        grid-template-columns: 1fr;
    }

    .calculation-empty-mark {
        display: none;
    }

    .calculation-empty-actions {
        grid-column: auto;
        flex-direction: column;
    }
}

/* Calculation output stays out of the input table until the required row values are ready. */
#portfolioRowsSection.is-awaiting-calculation thead th:nth-child(1),
#portfolioRowsSection.is-awaiting-calculation thead th:nth-child(3),
#portfolioRowsSection.is-awaiting-calculation thead th:nth-child(5),
#portfolioRowsSection.is-awaiting-calculation thead th:nth-child(8),
#portfolioRowsSection.is-awaiting-calculation thead th:nth-child(9),
#portfolioRowsSection.is-awaiting-calculation thead th:nth-child(10),
#portfolioRowsSection.is-awaiting-calculation thead th:nth-child(11),
#portfolioRowsSection.is-awaiting-calculation thead th:nth-child(12),
#portfolioRowsSection.is-awaiting-calculation tbody td:nth-of-type(1),
#portfolioRowsSection.is-awaiting-calculation tbody td:nth-of-type(3),
#portfolioRowsSection.is-awaiting-calculation tbody td:nth-of-type(5),
#portfolioRowsSection.is-awaiting-calculation tbody td:nth-of-type(8),
#portfolioRowsSection.is-awaiting-calculation tbody td:nth-of-type(9),
#portfolioRowsSection.is-awaiting-calculation tbody td:nth-of-type(10),
#portfolioRowsSection.is-awaiting-calculation tbody td:nth-of-type(11),
#portfolioRowsSection.is-awaiting-calculation tbody td:nth-of-type(12),
#portfolioRowsSection.is-awaiting-calculation tfoot {
    display: none;
}

#portfolioRowsSection.is-awaiting-calculation .btn-row-details {
    display: none;
}

#portfolioRowsSection.is-awaiting-calculation .row-actions-cell {
    min-width: 48px;
}
