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

.portfolio-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.portfolio-title-container {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    position: relative;
}

.tooltip-inline-offset {
    position: relative;
    margin-left: 5px;
}

.portfolio-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    cursor: pointer;
    border-radius: var(--radius);
    padding: 0.2rem 0.5rem;
    transition: all 0.2s;
    margin: 0;
}

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

.portfolio-title::after {
    content: '✎';
    font-size: 1rem;
    color: var(--text-sub);
    margin-left: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
    vertical-align: middle;
}

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

.portfolio-title-input {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    outline: none;
    background: var(--surface);
    padding: 0.2rem 0.5rem;
    width: auto;
    min-width: 200px;
    display: none;
    font-family: inherit;
    box-shadow: 0 0 0 3px var(--primary-light);
}

.control-card {
    padding: 1.1rem 1.25rem;
    margin-bottom: 2rem;
}

.control-bar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.control-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.input-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
}

.new-investment-input-wrap {
    display: flex;
    gap: 5px;
}

.btn-auto-investment {
    padding: 0.5rem;
    cursor: pointer;
}

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

.strategy-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-sub);
    margin-right: 0.75rem;
}

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

.input-item .styled-input {
    height: 36px;
    padding: 0.35rem 0.65rem;
    font-size: 0.95rem;
}

.control-divider {
    display: none;
}

.control-stats {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1.5rem;
    width: 100%;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.stat-item {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    width: 100%;
}

.sell-execution-hint {
    margin-top: 0.7rem;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid #f6d7a8;
    background: #fff8ec;
    color: #8a5a00;
    border-radius: 8px;
    font-size: 0.86rem;
    line-height: 1.45;
}

@media (min-width: 768px) {
    .control-bar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .control-inputs {
        flex-direction: row;
        align-items: center;
        width: auto;
        flex-wrap: wrap;
        gap: 0.75rem 1.25rem;
    }

    .input-item {
        width: auto;
        min-width: 220px;
    }

    .input-item:nth-child(1) {
        min-width: 340px;
    }

    .input-item:nth-child(2) {
        min-width: 200px;
    }

    .input-item:nth-child(3) {
        min-width: 240px;
    }

    .input-item:nth-child(4) {
        min-width: 260px;
    }

    .control-divider {
        display: none;
    }

    .control-stats {
        flex-direction: row;
        width: auto;
        padding-top: 0;
        border-top: none;
        gap: 1.5rem 2.5rem;
        justify-content: flex-end;
        margin-left: auto;
    }

    .stat-item {
        flex-direction: row;
        align-items: baseline;
        width: auto;
        gap: 0.6rem;
    }

    .sell-execution-hint {
        margin-top: 0.55rem;
    }
}

.radio-group {
    display: flex;
    gap: 0.25rem;
    background-color: var(--background);
    padding: 0.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.radio-group label {
    flex: 1;
    text-transform: none;
    color: var(--text-sub);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    white-space: nowrap;
}

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

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

.stat-label {
    font-size: 0.85rem;
    color: var(--text-sub);
    font-weight: 500;
    min-width: 110px;
    white-space: nowrap;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
    white-space: nowrap;
}

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

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

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

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

.table-action-buttons {
    display: flex;
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .table-actions {
        flex-direction: row;
        justify-content: flex-end;
    }
}

.table-container {
    overflow-x: auto;
    border-radius: 1.5rem;
    background-color: var(--surface);
    box-shadow: var(--shadow-sm);
    padding: 0;
    max-width: 100%;
}

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

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

th {
    background-color: #f8fafc;
    color: var(--text-sub);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

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

table th:nth-child(2),
table th:nth-child(3) {
    text-align: left;
    padding-left: 1.2rem;
}

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

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

table td:nth-child(2) .cell-input,
table td:nth-child(3) .cell-input {
    text-align: left;
}

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

.cell-input {
    width: 100%;
    height: 100%;
    border: 1px solid transparent;
    padding: 0.4rem 0.6rem;
    font-family: inherit;
    font-size: 0.95rem;
    background: transparent;
    text-align: right;
    color: var(--text-main);
    transition: all 0.2s;
    border-radius: 0.5rem;
    font-weight: 500;
}

.cell-input:focus {
    outline: none;
    background-color: var(--surface);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 700;
    box-shadow: 0 0 0 2px var(--primary-light);
}

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

.text-center {
    text-align: center;
}

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

.td-daily-purchase {
    background-color: #f0fdf4;
}

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

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

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

tfoot tr {
    background-color: #f8fafc;
}

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

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

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

.td-sum-daily-purchase {
    background-color: #dcfce7;
}

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

.chart-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.chart-column {
    flex: 1;
    min-width: 300px;
    max-width: 100%;
}

.chart-title {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--text-sub);
    font-size: 1.1rem;
}

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

.is-hidden {
    display: none;
}

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

.login-modal-message {
    margin-bottom: 1.5rem;
    color: var(--text-sub);
}

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

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

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

.modal-field-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-main);
}

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

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

.modal-inline-links {
    margin-top: 1rem;
    font-size: 0.9rem;
}

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

.share-modal-content {
    max-width: 520px;
}

.share-modal-status {
    margin-bottom: 0.8rem;
    color: var(--text-sub);
}

.btn-add {
    background-color: var(--surface);
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.7rem 1.2rem;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    width: 100%;
}

@media (min-width: 640px) {
    .btn-add {
        width: auto;
    }
}

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

.btn-delete-row {
    background: transparent;
    border: none;
    color: var(--text-sub);
    cursor: pointer;
    font-size: 0.9rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin: 0 auto;
}

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

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 1rem;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.2s;
    background-color: var(--background);
}

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