/* =========================================
   Design System & Variables
   ========================================= */
:root {
    /* Color Palette - Vibrant Dark Mode */
    --bg-primary: #0f172a;
    /* Slate 900 */
    --bg-secondary: #1e293b;
    /* Slate 800 */
    --bg-panel: rgba(30, 41, 59, 0.7);
    --border-subtle: rgba(255, 255, 255, 0.1);

    --text-primary: #f8fafc;
    /* Slate 50 */
    --text-secondary: #94a3b8;
    /* Slate 400 */
    --text-muted: #64748b;
    /* Slate 500 */

    /* Accents */
    --accent-blue: #3b82f6;
    /* Blue 500 */
    --accent-blue-hover: #2563eb;
    /* Blue 600 */
    --accent-indigo: #6366f1;
    /* Indigo 500 */
    --accent-teal: #14b8a6;
    /* Teal 500 */
    --accent-rose: #f43f5e;
    /* Rose 500 */
    --accent-green: #22c55e;

    /* Chart Colors */
    --chart-rrsp: #3b82f6;
    --chart-tfsa: #14b8a6;
    --chart-nonreg: #8b5cf6;
    --chart-tax: #f43f5e;
    --chart-income: #22c55e;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    --gradient-bg: radial-gradient(circle at top right, #1e1b4b, var(--bg-primary) 50%);

    /* Typography */
    --font-heading: 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Structure */
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-soft: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

/* =========================================
   Reset & Base Styles
   ========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    background-image: var(--gradient-bg);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.025em;
}

/* =========================================
   Layout
   ========================================= */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.app-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.header-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--accent-blue);
}

.logo h1 {
    font-size: 1.5rem;
    color: var(--text-primary);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   Panels & Glassmorphism
   ========================================= */
.panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-soft), var(--shadow-glow);
}

.input-panel h2 {
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 1.5rem 0;
}

/* =========================================
   Forms & Inputs
   ========================================= */
.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

input[type="number"],
input[type="text"] {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: all 0.2s ease;
}

input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    background: rgba(15, 23, 42, 0.9);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.currency-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
}

.input-with-icon input[type="text"] {
    padding-left: 2rem;
}

.percent-icon {
    position: absolute;
    right: 1rem;
    color: var(--text-muted);
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: -0.2rem;
}

.primary-btn {
    width: 100%;
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 0.875rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}

.primary-btn:active {
    transform: translateY(0);
}

.input-error {
    color: var(--accent-rose);
    font-size: 0.75rem;
    font-weight: 600;
}

.hidden {
    display: none !important;
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.secondary-btn {
    width: 100%;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 0.875rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-secondary);
}

/* =========================================
   Results & Charts
   ========================================= */
.results-panel {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.card-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-value {
    font-size: 2rem;
    color: var(--text-primary);
    font-weight: 700;
}

.chart-container {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.chart-container h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.canvas-wrapper {
    position: relative;
    height: 350px;
    width: 100%;
}

/* Dynamic Classes */
.status-good {
    border-color: var(--accent-green);
    background: rgba(34, 197, 94, 0.05);
}

.status-good .card-value {
    color: var(--accent-green);
}

.status-warning {
    border-color: var(--accent-rose);
    background: rgba(244, 63, 94, 0.05);
}

.status-warning .card-value {
    color: var(--accent-rose);
}

/* =========================================
   Data Table
   ========================================= */
.table-panel {
    margin-top: 2rem;
    overflow: hidden;
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: right;
}

table th {
    background: rgba(15, 23, 42, 0.8);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 1rem;
    border-bottom: 2px solid var(--border-subtle);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

table th:first-child,
table td:first-child {
    text-align: center;
}

table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    white-space: nowrap;
}

table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.row-retired td {
    background: rgba(34, 197, 94, 0.03);
    /* Subtle green tint for retirement years */
}

.row-retired:hover td {
    background: rgba(34, 197, 94, 0.08);
}