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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #10b981;
    --accent-color: #8b5cf6;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

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

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

main {
    flex: 1;
}

.input-section {
    background: var(--surface);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.input-group input,
.input-group select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--surface);
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.calculate-btn {
    grid-column: 1 / -1;
    padding: 1rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.calculate-btn:hover {
    background: var(--primary-hover);
}

.calculate-btn:active {
    transform: scale(0.98);
}

.results-section {
    background: var(--surface);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow);
    display: none;
}

.results-section.visible {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

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

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.card {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border-radius: 12px;
    padding: 1.5rem;
    color: white;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.card:nth-child(2) {
    background: linear-gradient(135deg, var(--secondary-color), #059669);
}

.card:nth-child(3) {
    background: linear-gradient(135deg, var(--accent-color), #7c3aed);
}

.card-label {
    font-size: 0.85rem;
    opacity: 0.9;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 700;
}

.chart-container {
    background: var(--background);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    height: 400px;
}

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

.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead {
    background: var(--background);
}

th, td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

th:first-child,
td:first-child {
    text-align: left;
}

th {
    font-weight: 600;
    color: var(--text-secondary);
}

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

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

footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
}

footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .input-section {
        padding: 1.5rem;
        gap: 1rem;
    }

    .results-section {
        padding: 1.5rem;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .card-value {
        font-size: 1.5rem;
    }

    .chart-container {
        height: 300px;
        padding: 1rem;
    }

    table {
        font-size: 0.8rem;
    }

    th, td {
        padding: 0.75rem 0.5rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    .input-section {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 250px;
    }
}
