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

:root {
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --secondary-color: #10b981;
    --background: #f9fafb;
    --card-background: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --pretax-color: #3b82f6;
    --roth-color: #8b5cf6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem 1rem;
}

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

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

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

.calculator-wrapper {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 2rem;
    align-items: start;
}

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

.input-section {
    background: var(--card-background);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    position: sticky;
    top: 2rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
}

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

.input-section h3 {
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border-color);
}

.input-group {
    margin-bottom: 1.25rem;
}

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

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

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

.input-group select {
    cursor: pointer;
}

.helper-text {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-style: italic;
}

.tax-info-box {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(79, 70, 229, 0.05));
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 1rem;
    margin: 1.5rem 0;
}

.tax-info-box h4 {
    color: var(--primary-color);
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.tax-rate-display {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.tax-rate-item {
    background: white;
    padding: 0.75rem;
    border-radius: 8px;
    text-align: center;
}

.tax-rate-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.tax-rate-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.tax-explainer {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.4;
    margin: 0;
    padding: 0.5rem;
    background: white;
    border-radius: 6px;
}

.calculate-btn {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.3);
}

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

/* Tiered Match Styling */
.match-section {
    animation: fadeIn 0.3s ease;
}

.tiered-info {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
    border-left: 4px solid var(--success-color);
    padding: 0.75rem;
    margin-bottom: 1rem;
    border-radius: 6px;
}

.tiered-info p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.tier-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.tier-group {
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}

.tier-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.tier-header strong {
    color: var(--primary-color);
    font-size: 0.95rem;
}

.remove-tier-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

.remove-tier-btn:hover {
    transform: scale(1.1);
    background: #dc2626;
}

.tier-inputs {
    display: flex;
    gap: 1rem;
}

.input-group-inline {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.input-group-inline label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.input-group-inline input {
    padding: 0.6rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.input-group-inline input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.add-tier-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
}

.add-tier-btn:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

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

/* Split Strategy Styling */
.split-strategy-box {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(139, 92, 246, 0.05));
    border: 2px solid var(--roth-color);
    border-radius: 12px;
    padding: 1rem;
    margin: 1.5rem 0;
}

.split-strategy-box h4 {
    color: var(--roth-color);
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.split-slider-container {
    margin-top: 1rem;
}

.split-slider-container label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

#rothPercent {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, var(--pretax-color), var(--roth-color));
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

#rothPercent::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--roth-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#rothPercent::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--roth-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.split-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.split-labels span {
    text-align: center;
    flex: 1;
}

.split-labels span:first-child {
    text-align: left;
}

.split-labels span:last-child {
    text-align: right;
}

.split-explanation {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.4;
    margin-top: 1rem;
    padding: 0.75rem;
    background: white;
    border-radius: 6px;
}

.results-section {
    background: var(--card-background);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.results-tabs {
    display: flex;
    background: var(--background);
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: rgba(79, 70, 229, 0.05);
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: white;
}

.tab-content {
    display: none;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

.tab-content h2 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    font-size: 1.75rem;
}

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

.comparison-grid.three-column {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.comparison-card {
    padding: 1.5rem;
    border-radius: 12px;
    border: 3px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.comparison-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.pretax-card {
    border-color: var(--pretax-color);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(59, 130, 246, 0.02));
}

.roth-card {
    border-color: var(--roth-color);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05), rgba(139, 92, 246, 0.02));
}

.split-card {
    border-color: var(--success-color);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(16, 185, 129, 0.02));
}

.comparison-card h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
}

.pretax-card h3 {
    color: var(--pretax-color);
}

.roth-card h3 {
    color: var(--roth-color);
}

.split-card h3 {
    color: var(--success-color);
}

.split-card h3 span {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-secondary);
}

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

.metric:last-child {
    border-bottom: none;
}

.metric-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.metric-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.metric-value.highlight {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.metric-value.tax-positive {
    color: var(--success-color);
}

.metric-value.tax-negative {
    color: var(--danger-color);
}

.winner-banner {
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 1rem;
}

.winner-banner.pretax-wins {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.05));
    color: var(--pretax-color);
    border: 2px solid var(--pretax-color);
}

.winner-banner.roth-wins {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(139, 92, 246, 0.05));
    color: var(--roth-color);
    border: 2px solid var(--roth-color);
}

.winner-banner.tie {
    background: linear-gradient(135deg, rgba(107, 114, 128, 0.15), rgba(107, 114, 128, 0.05));
    color: var(--text-secondary);
    border: 2px solid var(--text-secondary);
}

.winner-banner.split-wins {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05));
    color: var(--success-color);
    border: 2px solid var(--success-color);
}

.details-grid {
    display: grid;
    gap: 1rem;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
    border-left: 4px solid var(--border-color);
}

.detail-item.highlight-detail {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(79, 70, 229, 0.05));
    border-left-color: var(--primary-color);
    font-size: 1.1rem;
}

.detail-item strong {
    color: var(--text-primary);
}

.detail-item span {
    color: var(--primary-color);
    font-weight: 600;
}

.tax-explanation {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.tax-card {
    padding: 1.5rem;
    background: var(--background);
    border-radius: 12px;
    border: 2px solid var(--border-color);
}

.tax-card h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
}

.tax-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: 8px;
    transition: transform 0.2s ease;
}

.tax-item:hover {
    transform: translateX(5px);
}

.tax-item.taxed {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
    border-left: 4px solid var(--danger-color);
}

.tax-item.tax-free {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
    border-left: 4px solid var(--success-color);
}

.tax-icon {
    font-size: 1.5rem;
}

.tax-item strong {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.tax-item p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.tax-summary {
    margin-top: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    border: 2px solid var(--border-color);
}

.tax-summary p {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.tax-summary p:last-child {
    margin-bottom: 0;
}

.key-insights {
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(79, 70, 229, 0.05));
    border-radius: 12px;
    border: 2px solid var(--primary-color);
}

.key-insights h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.insight-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: white;
    border-radius: 6px;
    border-left: 3px solid var(--primary-color);
}

.insight-item:last-child {
    margin-bottom: 0;
}

/* Scrollbar styling */
.input-section::-webkit-scrollbar {
    width: 8px;
}

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

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

.input-section::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Disclaimer Section */
.disclaimer-section {
    margin-top: 3rem;
    padding: 2rem 1rem;
    background: rgba(255, 255, 255, 0.1);
}

.disclaimer-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    background: white;
    border-radius: 12px;
    border: 2px solid var(--warning-color);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.disclaimer-container h3 {
    color: var(--warning-color);
    font-size: 1.3rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.disclaimer-container p {
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.disclaimer-container ul {
    margin: 1.5rem 0;
    padding-left: 1.75rem;
}

.disclaimer-container ul li {
    margin-bottom: 0.75rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.disclaimer-container p:last-child {
    margin-bottom: 0;
}

.disclaimer-icon {
    font-size: 1.5rem;
}

.disclaimer-footer {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

