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

:root {
    --primary-color: #0052cc;
    --primary-hover: #0747a6;
    --secondary-color: #42526e;
    --success-color: #00875a;
    --danger-color: #de350b;
    --warning-color: #ff991f;
    --background: #f4f5f7;
    --surface: #ffffff;
    --text-primary: #172b4d;
    --text-secondary: #6b778c;
    --border-color: #dfe1e6;
    --shadow-sm: 0 1px 3px rgba(9, 30, 66, 0.13);
    --shadow-md: 0 4px 8px rgba(9, 30, 66, 0.13);
    --shadow-lg: 0 8px 16px rgba(9, 30, 66, 0.13);
    --radius-sm: 3px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.5;
    color: var(--text-primary);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px 32px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.main-title {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.title-icon {
    font-size: 32px;
}

.language-selector select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.language-selector select:hover {
    border-color: var(--primary-color);
}

.language-selector select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 82, 204, 0.2);
}

main {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.calculator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

@media (max-width: 968px) {
    .calculator-grid {
        grid-template-columns: 1fr;
    }
}

section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-md);
}

section h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-primary);
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-with-unit {
    display: flex;
    align-items: center;
    position: relative;
}

.input-with-unit input {
    flex: 1;
    padding: 10px 12px;
    padding-right: 50px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 16px;
    transition: all 0.2s;
}

.input-with-unit input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 82, 204, 0.2);
}

.input-with-unit .unit {
    position: absolute;
    right: 12px;
    color: var(--text-secondary);
    font-size: 14px;
    pointer-events: none;
}

select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 16px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 82, 204, 0.2);
}

.btn-primary,
.btn-secondary {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--background);
    color: var(--text-primary);
    margin-right: 12px;
}

.btn-secondary:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

.result-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 768px) {
    .result-cards {
        grid-template-columns: 1fr;
    }
}

.result-card {
    padding: 16px;
    background: var(--background);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
}

.result-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-value {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-container {
    height: 300px;
    margin-top: 24px;
}

.prepayment-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.prepayment-result {
    margin-top: 24px;
    padding: 24px;
    background: var(--background);
    border-radius: var(--radius-md);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .result-comparison {
        grid-template-columns: 1fr;
    }
}

.comparison-card {
    padding: 20px;
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
}

.comparison-card.highlight {
    border-color: var(--success-color);
    background: linear-gradient(135deg, rgba(0, 135, 90, 0.05) 0%, rgba(0, 135, 90, 0.02) 100%);
}

.comparison-card h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.comparison-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.comparison-item span:first-child {
    color: var(--text-secondary);
    font-size: 14px;
}

.comparison-item span:last-child {
    font-weight: 600;
    color: var(--text-primary);
}

.savings-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(0, 135, 90, 0.1) 0%, rgba(0, 135, 90, 0.05) 100%);
    border-radius: var(--radius-md);
    border: 2px solid var(--success-color);
}

.savings-display span:first-child {
    font-size: 16px;
    color: var(--text-primary);
}

.savings-amount {
    font-size: 28px;
    font-weight: 700;
    color: var(--success-color);
}

.schedule-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.schedule-table-container {
    overflow-x: auto;
    margin-top: 24px;
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
}

.schedule-table thead {
    background: var(--background);
}

.schedule-table th {
    padding: 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

.schedule-table tbody tr {
    border-bottom: 1px solid var(--border-color);
}

.schedule-table tbody tr:hover {
    background: var(--background);
}

.schedule-table td {
    padding: 12px;
    font-size: 14px;
    color: var(--text-primary);
}

.schedule-ellipsis {
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 20px;
}

footer {
    margin-top: 48px;
    padding: 24px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
}

footer p {
    color: var(--text-secondary);
    font-size: 14px;
}

.hidden {
    display: none;
}

/* レスポンシブデザイン */
@media (max-width: 640px) {
    .container {
        padding: 12px;
    }
    
    header {
        flex-direction: column;
        gap: 16px;
        padding: 20px;
    }
    
    .main-title {
        font-size: 24px;
    }
    
    section {
        padding: 20px;
    }
    
    .result-value {
        font-size: 20px;
    }
    
    .savings-amount {
        font-size: 24px;
    }
    
    .schedule-table {
        font-size: 12px;
    }
    
    .schedule-table th,
    .schedule-table td {
        padding: 8px;
    }
}

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.result-card,
.comparison-card {
    animation: fadeIn 0.5s ease;
}

/* スクロールバー */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}