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

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --success-color: #10b981;
    --error-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.container {
    max-width: 600px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.sync-section {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sync-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    white-space: nowrap;
}

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

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

.sync-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.sync-icon {
    font-size: 1.2rem;
    display: inline-block;
    transition: transform 0.5s;
}

.sync-btn.syncing .sync-icon {
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.sync-status {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.sync-status.success {
    color: var(--success-color);
}

.sync-status.error {
    color: var(--error-color);
}

.currency-section {
    background: var(--card-bg);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.currency-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.currency-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.currency-toggle {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-color);
    padding: 0.25rem;
    border-radius: 8px;
}

.currency-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.currency-btn:hover {
    color: var(--text-primary);
}

.currency-btn.active {
    background: var(--primary-color);
    color: white;
}

.exchange-rate {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding-left: 0.5rem;
}

.card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}

select,
input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    color: var(--text-primary);
    transition: border-color 0.2s;
}

select:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.model-info {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: none;
}

.model-info.visible {
    display: block;
}

.model-info strong {
    color: var(--text-primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.model-section {
    margin-bottom: 1.5rem;
}

.model-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.model-2-section {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1rem;
    transition: all 0.3s;
}

.model-2-section.hidden {
    display: none;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 600;
}

.checkbox-label input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.checkbox-label span {
    user-select: none;
}

.recurring-options {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    transition: all 0.3s;
}

.recurring-options.hidden {
    display: none;
}

.recurring-options label {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.recurring-inputs {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 0.75rem;
}

.recurring-inputs input[type="number"],
.recurring-inputs select {
    margin-top: 0;
}

.recurring-breakdown {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.recurring-breakdown.hidden {
    display: none;
}

.recurring-breakdown h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.calculate-btn {
    width: 100%;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 1.5rem;
}

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

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

.calculate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.results {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    transition: all 0.3s;
}

.results.hidden {
    display: none;
}

.results h2 {
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.model-results {
    margin-bottom: 2rem;
}

.model-results.hidden {
    display: none;
}

.model-result-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-left: 0.5rem;
    border-left: 4px solid var(--primary-color);
}

.breakdown {
    margin-bottom: 1.5rem;
}

.breakdown-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.breakdown-row.subtotal {
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    font-weight: 600;
}

.breakdown-row.total {
    border-bottom: none;
    border-top: 2px solid var(--border-color);
    margin-top: 0.5rem;
    padding-top: 1rem;
    font-weight: 700;
    font-size: 1.2rem;
}

.breakdown-row .label {
    color: var(--text-secondary);
}

.breakdown-row.total .label,
.breakdown-row.total .value {
    color: var(--primary-color);
}

.total-breakdown {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

.calculation-details {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.last-update {
    margin-bottom: 0.5rem;
}

.footer-note {
    color: var(--text-secondary);
    opacity: 0.8;
}

@media (max-width: 640px) {
    body {
        padding: 1rem 0.5rem;
    }

    .container {
        padding: 0 0.5rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .sync-section {
        flex-direction: column;
        text-align: center;
    }

    .sync-btn {
        width: 100%;
        justify-content: center;
    }

    .currency-info {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .currency-toggle {
        width: 100%;
    }

    .currency-btn {
        flex: 1;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .recurring-inputs {
        grid-template-columns: 1fr;
    }

    .card,
    .results {
        padding: 1.5rem;
    }
}
