.portfolio-header {
    margin-bottom: 0.75rem;
}

.portfolio-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

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

.tooltip-inline-offset {
    flex: 0 0 auto;
}

.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::after {
    content: '수정';
    margin-left: 0.45rem;
    color: var(--text-sub);
    font-size: 0.72rem;
    font-weight: 800;
    opacity: 0;
}

.portfolio-title:hover::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-panel {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

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

.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,
.strategy-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: 34px;
    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;
}

.input-item-strategy {
    flex: 1 1 430px;
    align-items: flex-start;
}

.strategy-control-wrap {
    width: min(100%, 430px);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.radio-group {
    width: 100%;
    display: flex;
    gap: 0.2rem;
    padding: 0.2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
}

.radio-group label {
    flex: 1 1 0;
    min-width: 0;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.34rem 0.65rem;
    border-radius: 6px;
    color: var(--text-sub);
    font-size: 0.84rem;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
}

.radio-group label span {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.radio-group label:has(input:checked) {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.radio-group input[type="radio"] {
    display: none;
}

.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.62rem 0.65rem;
    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: 1rem;
    font-weight: 800;
    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: 1rem;
}

.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;
}

.calculation-basis-banner {
    margin-bottom: 0.6rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--primary-light);
    border-radius: var(--radius);
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1.45;
}

.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: 42px;
    padding: 0.34rem;
    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-daily-purchase,
.td-recommended-buy {
    background: #f0fdf4;
}

.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(--primary);
}

.btn-add:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.btn-delete-row {
    width: 30px;
    height: 30px;
    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);
}

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

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

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

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

.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);
}

.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) {
    .portfolio-header-row {
        align-items: flex-start;
    }

    .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 {
        align-items: flex-start;
    }

    .new-investment-input-wrap,
    .strategy-control-wrap {
        flex: 1;
    }

    .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 {
        min-width: 760px;
    }

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

    .data-table-section:not(.show-mobile-details) th:nth-child(1),
    .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) th:nth-child(13),
    .data-table-section:not(.show-mobile-details) td:nth-of-type(1),
    .data-table-section:not(.show-mobile-details) td:nth-of-type(7),
    .data-table-section:not(.show-mobile-details) td:nth-of-type(8),
    .data-table-section:not(.show-mobile-details) td:nth-of-type(9),
    .data-table-section:not(.show-mobile-details) td:nth-of-type(10),
    .data-table-section:not(.show-mobile-details) td:nth-of-type(12),
    .data-table-section:not(.show-mobile-details) td:nth-of-type(13) {
        display: none;
    }

    .data-table-section:not(.show-mobile-details) th:nth-child(2),
    .data-table-section:not(.show-mobile-details) td:nth-of-type(2) {
        position: sticky;
        left: 0;
        z-index: 12;
        min-width: 118px;
        background: var(--surface);
        box-shadow: 8px 0 12px -12px rgba(15, 23, 42, 0.5);
    }

    .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) {
        position: sticky;
        right: 0;
        z-index: 12;
        min-width: 112px;
        background: #f0fdf4;
        box-shadow: -8px 0 12px -12px rgba(15, 23, 42, 0.5);
    }

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

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