* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    padding-top: 40px;
}

.container {
    width: 100%;
    max-width: 900px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

h1 {
    background: linear-gradient(135deg, #4a90d9 0%, #357abd 100%);
    color: white;
    text-align: center;
    padding: 24px;
    font-size: 24px;
    font-weight: 600;
}

.calculator-wrapper {
    padding: 24px;
    display: flex;
    gap: 24px;
}

.left-section,
.right-section {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.right-section.result-section {
    display: flex !important;
    flex-direction: column;
}

.result-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: #999;
    overflow: hidden;
    max-width: 100%;
}

.result-section:not(.has-result) .result-content::before {
    content: '点击"开始计算"查看结果';
    font-size: 16px;
}

.result-section.has-result .result-content {
    justify-content: flex-start;
    align-items: stretch;
    text-align: left;
    overflow: visible;
}

.result-section.has-result .result-content::before {
    display: none;
}

.schedule-section {
    background: white;
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: 0 2px 12px rgba(74, 144, 217, 0.08);
    margin: 0 24px 24px 24px;
}

.schedule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e8eef3;
}

.schedule-header h2 {
    color: #333;
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    padding: 0;
    border: none;
}

.export-btn {
    background: #4a90d9;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.export-btn:hover {
    background: #357abd;
}

h2 {
    color: #333;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e8eef3;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    color: #555;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-group.inline-group label {
    font-size: 12px;
    margin-bottom: 6px;
}

.form-group.small-group input {
    padding: 10px 12px;
    font-size: 14px;
}

.radio-options {
    display: flex;
    gap: 8px;
}

.radio-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    border: 2px solid #e0e4e8;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    background: #fafbfc;
    position: relative;
}

.radio-option:hover {
    border-color: #4a90d9;
    background: #f0f6fc;
}

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

.radio-option input[type="radio"]:checked + span {
    color: #4a90d9;
    font-weight: 600;
}

.radio-option.selected {
    border-color: #4a90d9;
    background: #f0f6fc;
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.1);
}

.radio-option span {
    color: #555;
    font-size: 13px;
    transition: all 0.3s;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e4e8;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s;
    background: #fafbfc;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #4a90d9;
    background: white;
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.1);
}

.form-group input[readonly] {
    background: #f0f2f5;
    color: #666;
    cursor: not-allowed;
}

.small-group input,
.small-group select {
    padding: 10px 12px;
    font-size: 14px;
}

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

.component-item {
    display: flex;
    flex-direction: column;
}

.component-item label {
    display: block;
    color: #666;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 6px;
}

.component-item input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e4e8;
    border-radius: 6px;
    font-size: 14px;
    background: #fafbfc;
    transition: all 0.3s;
}

.component-item input:focus {
    outline: none;
    border-color: #4a90d9;
    background: white;
}

.calculate-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #4a90d9 0%, #357abd 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 8px;
}

.calculate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 217, 0.35);
}

.calculate-btn:active {
    transform: translateY(0);
}

.result-content {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
}

.donut-chart {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 16px;
    margin: 12px 0;
    padding: 12px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.donut-chart-svg {
    width: 130px;
    height: 130px;
    flex-shrink: 0;
}

.donut-center-percent {
    font-size: 12px;
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.donut-chart-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-width: 120px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-label {
    color: #666;
    font-size: 13px;
    flex-shrink: 0;
}

.legend-value {
    color: #333;
    font-size: 13px;
    font-weight: 600;
    flex: 1;
    min-width: 70px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #e8eef3;
}

.result-item:last-child {
    border-bottom: none;
}

.result-label {
    color: #666;
    font-size: 14px;
}

.result-value {
    color: #333;
    font-size: 18px;
    font-weight: 600;
    color: #4a90d9;
}

.result-value.highlight {
    color: #2c5aa0;
    font-size: 20px;
}

.details-table {
    width: 100%;
    min-width: 450px;
    border-collapse: collapse;
    table-layout: auto;
}

.details-table thead {
    display: table-header-group;
    position: sticky;
    top: 0;
    z-index: 10;
}

.details-table tbody {
    display: table-row-group;
}

.details-table tr {
    display: table-row;
}

.details-table th {
    background: #f5f7fa;
    color: #555;
    padding: 10px 8px;
    text-align: center;
    vertical-align: middle;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    border-bottom: 2px solid #e8eef3;
}

.details-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #f0f2f5;
    font-size: 13px;
    color: #555;
    white-space: nowrap;
    text-align: center;
    vertical-align: middle;
}

.details-table th.col-period,
.details-table td.col-period {
    width: 50px;
    min-width: 50px;
    text-align: center;
}

.details-table tr:hover {
    background: #fafbfc;
}

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

.table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 350px;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    position: relative;
}

.error-message {
    background: #fff5f5;
    color: #d33939;
    padding: 10px 14px;
    border-radius: 6px;
    border-left: 3px solid #d33939;
    font-size: 13px;
}

@media (max-width: 768px) {
    body {
        padding: 12px;
        padding-top: 20px;
    }

    .container {
        border-radius: 12px;
    }

    h1 {
        font-size: 20px;
        padding: 18px;
    }

    .calculator-wrapper {
        padding: 18px;
        gap: 18px;
        flex-direction: column;
    }

    .schedule-section {
        margin: 0 18px 18px 18px;
        padding: 16px 18px;
    }

    .schedule-section h2 {
        font-size: 18px;
        margin-bottom: 15px;
        padding-bottom: 8px;
    }

    h2 {
        font-size: 18px;
        margin-bottom: 15px;
        padding-bottom: 8px;
    }

    .form-group {
        margin-bottom: 14px;
    }

    .form-group label {
        font-size: 13px;
    }

    .form-group input,
    .form-group select {
        padding: 10px 14px;
        font-size: 14px;
    }

    .form-row {
        flex-direction: column;
        gap: 12px;
    }

    .payment-components-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .component-item input {
        padding: 8px 10px;
        font-size: 13px;
    }

    .donut-chart {
        flex-direction: column;
        gap: 12px;
        padding: 10px;
    }

    .donut-chart-svg {
        width: 120px;
        height: 120px;
    }

    .result-content {
        padding: 15px;
    }

    .result-item {
        padding: 12px 0;
    }

    .result-label {
        font-size: 13px;
    }

    .result-value {
        font-size: 16px;
    }

    .result-value.highlight {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 8px;
        padding-top: 15px;
    }

    h1 {
        font-size: 18px;
        padding: 14px;
    }

    h2 {
        font-size: 16px;
        margin-bottom: 12px;
        padding-bottom: 6px;
    }

    .calculator-wrapper {
        padding: 14px;
        gap: 14px;
    }

    .schedule-section {
        margin: 0 14px 14px 14px;
        padding: 12px 14px;
    }

    .form-group label {
        font-size: 12px;
    }

    .form-group input,
    .form-group select {
        padding: 8px 12px;
        font-size: 13px;
    }

    .loan-type-options,
    .calc-type-options {
        flex-direction: column;
        gap: 8px;
    }

    .type-option,
    .calc-option {
        padding: 10px;
    }

    .payment-components-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .component-item label {
        font-size: 12px;
    }

    .calculate-btn {
        padding: 12px;
        font-size: 15px;
    }

    .details-table {
        font-size: 11px;
        min-width: 320px;
    }

    .details-table th,
    .details-table td {
        padding: 6px 4px;
        font-size: 11px;
    }

    .table-container {
        max-height: 250px;
    }
}