/* --- 1. Design System & Variables --- */
:root {
    /* Palette */
    --brand-primary: #3b82f6;
    --brand-secondary: #6366f1;
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    
    /* Semantic Colors */
    --color-profit: #10b981;
    --color-tax: #f59e0b;
    --color-expense: #ef4444;

    /* Spacing & Radius */
    --radius-md: 12px;
    --radius-lg: 24px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Transitions */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-body: #111827;
        --bg-card: #1f2937;
        --text-main: #f9fafb;
        --text-muted: #9ca3af;
        --border-color: #374151;
    }
}

/* --- 2. Global Resets --- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    line-height: 1.5;
}

/* --- 3. Layout Components --- */
.app-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    max-width: 1000px;
    width: 100%;
}

@media (min-width: 768px) {
    .app-container {
        grid-template-columns: 1.2fr 1fr; /* Inputs left, Results right */
        align-items: start;
    }
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

/* --- 4. Typography --- */
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; margin-bottom: 0.5rem; }
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 1.5rem; }
p.subtitle { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 2rem; }

/* --- 5. Form Elements --- */
.form-group { margin-bottom: 1.5rem; }

label {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

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

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    pointer-events: none;
}

input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem; /* Space for icon */
    background: var(--bg-body);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
}

input[type="number"]:focus {
    outline: none;
    background: var(--bg-card);
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

/* Range Slider Styling */
input[type="range"] {
    width: 100%;
    margin-top: 0.5rem;
    accent-color: var(--brand-primary);
    cursor: pointer;
}

.helper-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* --- 6. Results Section --- */
.results-sticky {
    position: sticky;
    top: 20px;
}

.rate-display {
    text-align: center;
    padding: 2rem 0;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%);
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
}

.rate-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--brand-primary);
}

.rate-value {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
    margin: 0.5rem 0;
}

.rate-period { color: var(--text-muted); font-size: 0.875rem; }

/* Breakdown Visualization */
.breakdown-bar {
    display: flex;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.bar-segment { height: 100%; transition: width 0.5s ease; }
.bg-profit { background: var(--color-profit); }
.bg-tax { background: var(--color-tax); }
.bg-expense { background: var(--color-expense); }

.legend {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    font-size: 0.75rem;
}

.legend-item { display: flex; align-items: center; gap: 0.5rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; }

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.stat-box h4 {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}
.stat-box p {
    font-size: 1.125rem;
    font-weight: 600;
    margin-top: 0.25rem;
}
