:root {
    --primary: #94a3b8;
    --primary-glow: rgba(148, 163, 184, 0.1);
    --bg-dark: #020617;
    --text-main: #f8fafc;
    --text-dim: #64748b;
    --glass: rgba(15, 23, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.04);
    --input-bg: rgba(2, 6, 23, 0.4);
    --accent: #f8fafc;
}

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

/* ==========================================================================
   Mobile-Only Persistent Layout
   ========================================================================== */

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    /* Mobile defaults: Scrollable, auto height */
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    display: block;
    padding: 0.5rem 0.5rem;
    /* Reduced top padding */
}

/* Dashboard: Stacked vertically by default */
.dashboard {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: auto;
    max-width: 100%;
    padding: 0;
    gap: 0.75rem;
    /* Reduced gap between sidebar and main panel */
    overflow: visible;
}

.sidebar,
.main-panel {
    width: 100%;
    height: auto;
    /* Allow content to determine height on mobile */
    flex: none;
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* Reduced gap between cards */
}

.glass-card {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.75rem;
    /* Reduced padding */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 100%;
    height: auto;
    flex: none;
    margin-bottom: 0.25rem;
    /* Reduced margin */
}

.glass-card.compact {
    padding: 1rem;
}

/* Specific card defaults for mobile */
.table-card-expanded,
.chart-card {
    min-height: 400px;
    height: auto;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.table-wrapper {
    max-height: 400px;
    /* Scrollable table on mobile */
    min-height: 300px;
    overflow-y: auto;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.chart-card {
    aspect-ratio: auto;
    min-height: 350px;
}

header .title {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    text-align: center;
    font-size: 1.15rem;
    /* Compact title */
    margin-bottom: 0.5rem;
    white-space: nowrap;
}

header .title span {
    color: inherit;
    font-weight: inherit;
    font-size: inherit;
    display: inline;
    /* Single line */
    margin-left: 0.25rem;
}

.fv-amount-sidebar {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    color: white;
    margin-top: 0.15rem;
    text-align: center;
    font-size: clamp(1.6rem, 8vw, 2.2rem);
    /* More compact */
}

.summary-item {
    text-align: center;
    margin: 0.4rem 0;
}

.summary-item label {
    font-size: 0.6rem;
}

.summary-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-items: center;
}

canvas {
    max-height: 300px;
    width: 100% !important;
}


/* ==========================================================================
   Desktop Enhancements (Large Screens Only)
   ========================================================================== */

@media (min-width: 1024px) {
    body {
        height: 100vh;
        overflow: hidden;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .dashboard {
        display: grid;
        grid-template-columns: 1fr 2.2fr;
        /* Sidebar 31%, Main 69% */
        gap: 1.25rem;
        width: 98vw;
        height: 98vh;
        max-width: 1800px;
        padding: 0.75rem;
        overflow: hidden;
    }

    /* Reset mobile flexible widths/heights to rigid desktop structure */
    .sidebar {
        height: 100%;
        overflow-y: auto;
        width: auto;
        /* let grid handle width */
        gap: 0.75rem;
    }

    .main-panel {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        height: 100%;
        min-width: 0;
        min-height: 0;
        overflow: hidden;
        width: auto;
    }

    /* Restore Desktop Card Sizing */
    .glass-card {
        margin-bottom: 0;
        /* Remove mobile margin */
        height: auto;
        /* Let flex/grid handle it */
    }

    .glass-card.compact {
        padding: 1rem;
    }

    .table-card-expanded {
        height: 60%;
        flex: 0 0 60%;
        min-height: 0;
        padding: 0.85rem;
        display: flex;
        flex-direction: column;
    }

    .chart-card {
        height: 38%;
        flex: 0 0 38%;
        min-height: 0;
        padding: 0.85rem;
        aspect-ratio: unset;
    }

    .table-wrapper {
        flex: 1;
        min-height: 0;
        max-height: none;
        /* Let container control height */
        overflow-y: auto;
    }

    /* Reset Typography Alignments */
    header .title {
        text-align: left;
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }

    .fv-amount-sidebar {
        text-align: left;
        font-size: 1.8rem;
    }

    .summary-item {
        text-align: left;
    }

    .summary-stats-grid {
        justify-items: start;
    }

    canvas {
        max-height: 100%;
        /* Fill container */
    }
}


/* ==========================================================================
   Shared Components
   ========================================================================== */

/* Background */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(120px);
}

.blob {
    position: absolute;
    border-radius: 50%;
    opacity: 0.2;
    animation: move 40s infinite alternate;
}

.blob-1 {
    width: 600px;
    height: 600px;
    background: #1e293b;
    top: -200px;
    left: -200px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: #0f172a;
    bottom: -150px;
    right: -150px;
}

@keyframes move {
    from {
        transform: translate(0, 0);
    }

    to {
        transform: translate(40px, 40px);
    }
}

/* Scrollbars */
.sidebar::-webkit-scrollbar,
.table-wrapper::-webkit-scrollbar {
    width: 3px;
}

.sidebar::-webkit-scrollbar-thumb,
.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar {
    width: 6px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    border-radius: 10px;
}

/* Form Styles */
.input-grid-vertical {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    /* Reduced gap */
}

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

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    /* Reduced gap */
}

label {
    font-size: 0.65rem;
    /* Smaller font */
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

input,
select {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    /* Reduced padding */
    color: white;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.2s;
}

.prefix,
.suffix {
    font-size: 0.75rem;
}

.prefix {
    left: 0.75rem;
}

.suffix {
    right: 0.75rem;
}

input[id="principal"],
input[id="addition"] {
    padding-left: 1.6rem;
}

input[id="interest"] {
    padding-right: 1.6rem;
}

input:focus,
select:focus {
    outline: none;
    border-color: #475569;
}

.cta-button {
    width: 100%;
    background: var(--text-main);
    border: none;
    border-radius: 8px;
    padding: 0.6rem;
    /* Reduced padding */
    color: var(--bg-dark);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    margin-top: 0.5rem;
    /* Reduced margin */
    font-family: 'Outfit', sans-serif;
}

/* Base Summary Styles */
.result-summary {
    margin-top: 0.5rem;
    /* Reduced margin */
}

.stat {
    text-align: center;
}

.stat span:first-child {
    font-size: 0.6rem;
    color: var(--text-dim);
    text-transform: uppercase;
    display: block;
    margin-bottom: 2px;
}

.stat span:last-child {
    font-size: 0.85rem;
}

.divider {
    height: 1px;
    background: var(--glass-border);
    margin: 0.5rem 0;
}

/* Table Styles */
.table-header h3 {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 1rem;
    text-align: left;
}

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

thead {
    position: sticky;
    top: 0;
    background: #1e293b;
    z-index: 10;
}

th {
    padding: 0.75rem 1rem;
    text-align: left;
    color: var(--text-dim);
    font-size: 0.65rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--glass-border);
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    color: #cbd5e1;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}