:root {
    /* Ocean & Air Palette */
    --primary: #0ea5e9;
    /* Ocean Blue */
    --primary-light: #38bdf8;
    /* Lighter Sky Blue */
    --primary-hover: #0284c7;
    --background: #fcfbf9;
    /* Sand/Off-white */
    --surface: rgba(255, 255, 255, 0.7);
    /* Glassy surface */
    --surface-solid: #ffffff;
    --text-main: #334155;
    /* Slate */
    --text-muted: #64748b;
    --border: rgba(226, 232, 240, 0.6);
    --success: #22c55e;
    --danger: #ef4444;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-pill: 50px;
    --shadow-soft: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
}
h4 {
    margin-top: 0;
}

body {
    font-family: 'Quicksand', 'Outfit', sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
    /* Soft gradient background */
    background-image: linear-gradient(to bottom, #f0f9ff 0%, #fcfbf9 100%);
}

/* Background Scenic Elements */
.scenic-background {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    /* Cover full height for gradient/elements */
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.wave {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 120px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 88.7'%3E%3Cpath d='M800 56.9c-155.5 0-204.9-50-405.5-49.9-200 0-250 49.9-394.5 49.9v31.8h800v-.2-31.6z' fill='%230ea5e9' opacity='0.4'/%3E%3C/svg%3E");
    background-repeat: repeat-x;
    transform: translate3d(0, 0, 0);
    opacity: 0.8;
}

.wave:nth-of-type(1) {
    bottom: 0;
    animation: wave 10s cubic-bezier(0.36, 0.45, 0.63, 0.53) infinite;
    z-index: 1;
    opacity: 0.3;
}

.wave:nth-of-type(2) {
    bottom: 10px;
    animation: wave 12s cubic-bezier(0.36, 0.45, 0.63, 0.53) -.125s infinite, swell 10s ease -1.25s infinite;
    z-index: 2;
    opacity: 0.2;
}

.wave:nth-of-type(3) {
    bottom: 20px;
    animation: wave 15s cubic-bezier(0.36, 0.45, 0.63, 0.53) -.125s infinite, swell 8s ease -1.25s infinite;
    z-index: 3;
    opacity: 0.15;
}

@keyframes wave {
    0% {
        margin-left: 0;
    }

    100% {
        margin-left: -1600px;
    }
}

@keyframes swell {

    0%,
    100% {
        transform: translate3d(0, -25px, 0);
    }

    50% {
        transform: translate3d(0, 5px, 0);
    }
}

/* Navigation Sidebar */
.navbar {
    background-color: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 110px;
    overflow: hidden;
    transition: width 0.3s ease;
    z-index: 100;
}

.navbar:hover {
    width: 280px;
}

.logo {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    margin-bottom: 2rem;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
    width: 100%;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-pill);
    display: block;
    white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
    background: rgba(14, 165, 233, 0.1);
}

.nav-long {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    display: inline-block;
}

.navbar:hover .nav-long {
    opacity: 1;
    visibility: visible;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 1rem auto 3rem auto; /* reduced top margin */
    padding: 0 1.5rem 0 calc(110px + 2rem); /* padding left to clear collapsed navbar */
    position: relative;
    z-index: 10;
}


.card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-soft);
    margin-bottom: 2rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px -5px rgba(0, 0, 0, 0.1);
}

h1,
h2,
h3 {
    margin-top: 0;
    font-weight: 700;
    color: var(--text-main);
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--text-main) 0%, var(--primary) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1.5rem;
}

/* Dashboard Grid for Activities */
.dashboard-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
}

.controls-panel {
    background: var(--surface-solid);
    padding: 1.0rem;
    border-radius: var(--radius-lg);
    height: fit-content;
    box-shadow: var(--shadow-soft);
    position: sticky;
    top: 1.0rem;
}

.viz-panel {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    min-width: 0;
    /* Prevents indefinite growth in Grid/Flex layouts */
}

/* Inputs */
.input-group {
    margin-bottom: 0.8rem;
    padding: 0.2rem;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
    cursor: pointer;
}

.value-display {
    float: right;
    font-weight: 700;
    color: var(--primary);
    background: rgba(14, 165, 233, 0.1);
    padding: 0.1rem 0.5rem;
    border-radius: 8px;
    font-size: 0.85rem;
}

button.primary-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

button.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.4);
}

button.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn.active,
.metric-toggle .secondary-btn.active {
    background: rgba(14, 165, 233, 0.14);
    color: var(--primary-hover);
    border-color: var(--primary-light);
}

/* Charts */
.chart-container {
    position: relative;
    /* height: 350px; REMOVED FIXED HEIGHT */
    width: 100%;
    background: white;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.stats-row {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
    background: white;
    /* Clean white for stats */
    border-radius: var(--radius-lg);
    justify-content: space-around;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.03em;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    margin-top: 0.25rem;
}

/* Tables */
table.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.95rem;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: rgba(14, 165, 233, 0.05);
    /* Very light tint */
    font-weight: 700;
    color: var(--text-muted);
}

.data-table th:first-child {
    border-top-left-radius: 12px;
}

.data-table th:last-child {
    border-top-right-radius: 12px;
}

.data-table tr:hover td {
    background: #f8fafc;
}

#data-inspector-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

#data-inspector-table th {
    background: #ffffff;
    opacity: 1;
    z-index: 6;
}

.warning-box {
    border-left: 4px solid var(--danger);
    background: #fef2f2;
    padding: 1.0rem;
    border-radius: 0 12px 12px 0;
    margin-top: 1.0rem;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.1);
}

.success-box {
    border-left: 4px solid var(--success);
    background: #f0fdf4;
    padding: 1.0rem;
    border-radius: 0 12px 12px 0;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.1);
}

/* Fix for table overflow */
#fns-table-container,
#fps-table-container {
    overflow-x: auto;
    width: 100%;
    margin-top: 1rem;
}

/* Diagonal Headers for Inspector Tables */
#fns-table-container .data-table th,
#fps-table-container .data-table th {
    height: 140px;
    white-space: nowrap;
    vertical-align: bottom;
    padding: 0 1rem 1rem 1rem;
    line-height: 1;
}

#fns-table-container .data-table th>div,
#fps-table-container .data-table th>div {
    transform: translate(5px, 0) rotate(-45deg);
    transform-origin: bottom left;
    width: 30px;
}

/* Loading Animations */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.loading-icon {
    display: inline-block;
    animation: spin 2s linear infinite;
    transform-origin: center;
}

.loading-dots::after {
    content: ".";
    animation: dots 1.5s infinite steps(1);
}

@keyframes dots {

    0%,
    20% {
        content: ".";
    }

    40% {
        content: "..";
    }

    60% {
        content: "...";
    }

    80%,
    100% {
        content: "";
    }
}
