:root {
    /* Liquid Glass Theme Palette */
    --primary: #0ea5e9;
    /* Liquid Blue */
    --primary-dark: #0284c7;
    --secondary: #64748b;
    --background-gradient: linear-gradient(135deg, #e0f2fe 0%, #f0f9ff 100%);
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --text-main: #0f172a;
    --text-muted: #475569;
    --radius: 1rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--background-gradient);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    padding-bottom: 2rem;
    position: relative;
    overflow-x: hidden;
}

/* Background Mesh Effect */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    right: -50%;
    bottom: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(14, 165, 233, 0.08) 0%, transparent 50%);
    z-index: -1;
    animation: pulse 15s ease-in-out infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.8);
    }

    50% {
        transform: scale(1);
    }

    100% {
        transform: scale(0.8);
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Glass Card Style */
.card,
header,
.best-result-card,
details,
.chart-card {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--glass-shadow);
}

/* Header */
header {
    margin: 1.5rem 0 3rem 0;
    padding: 2rem;
    text-align: center;
    border-radius: 2rem;
    /* Pill shape */
}

header h1 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
}

/* Dataset Section */
.dataset-section {
    margin-top: 3rem;
}

.dataset-details {
    overflow: hidden;
}

.dataset-details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background 0.2s;
}

.dataset-details summary:hover {
    background: rgba(14, 165, 233, 0.1);
}

/* Viewer Section */
.viewer-controls {
    margin-bottom: 2rem;
}

.glass-select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 0.75rem;
    font-size: 0.95rem;
    color: var(--text-main);
    backdrop-filter: blur(5px);
    transition: all 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23334155' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
}

.glass-select:focus {
    background-color: white;
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.viewer-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: 0 20px 40px rgba(14, 165, 233, 0.1);
    animation: fadeIn 0.3s ease-out;
}

.viewer-card.hidden {
    display: none;
}

/* Input Section */
.input-section {
    margin-bottom: 2rem;
    /* Reduced from 3rem */
}

.card {
    padding: 1.5rem;
    /* Reduced from 2.5rem */
    transition: var(--transition);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    /* Reduced */
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
    padding: 0.35rem 0.75rem;
    /* Reduced padding */
    border-radius: 2rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.secondary-btn:hover {
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    color: var(--primary);
}

/* Form Grid */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    /* Reduced gap from 1.5rem */
}

@media (min-width: 768px) {
    .grid-2 {
        grid-template-columns: 1fr 1fr;
    }
}

.input-group {
    margin-bottom: 1.5rem;
    /* Reduced from 2.5rem */
}

.input-group h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.form-control label {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(14, 165, 233, 0.1);
    color: var(--primary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    /* For tooltip positioning context if needed */
}

.info-icon:hover,
.info-icon.active {
    background: var(--primary);
    color: white;
}

/* Tooltip (Custom Popover) */
.tooltip-popover {
    display: none;
    margin-top: 0.25rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(14, 165, 233, 0.2);
    border-radius: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    width: 100%;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tooltip-popover.visible {
    display: block;
}

/* Glass Inputs */
input[type="number"] {
    width: 100%;
    padding: 0.6rem 0.8rem;
    /* Reduced padding */
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 0.75rem;
    font-size: 1rem;
    color: var(--text-main);
    transition: var(--transition);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

input[type="number"]:focus {
    outline: none;
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

/* Custom Selectors */
/* Sliding Segmented Control for Material */
.glass-segment-control {
    display: flex;
    background: rgba(0, 0, 0, 0.03);
    padding: 0.25rem;
    border-radius: 0.75rem;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.segment-option {
    flex: 1;
    text-align: center;
    padding: 0.6rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: 0.5rem;
    transition: var(--transition);
    position: relative;
    z-index: 1;
}

.segment-option.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

/* Glass Chips for Subclass */
.glass-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.chip-option {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 2rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.chip-option:hover {
    background: rgba(255, 255, 255, 0.8);
}

.chip-option.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

/* Checkbox */
.glass-checkbox label {
    cursor: pointer;
    user-select: none;
}

.glass-checkbox input {
    accent-color: var(--primary);
    width: 1.2rem;
    height: 1.2rem;
}

/* Best Result Card - COMPACT V2 */
.best-result-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius);
    padding: 1.5rem;
    /* Reduced from 2.5rem */
    position: relative;
    margin-bottom: 2rem;
    box-shadow: 0 20px 50px rgba(14, 165, 233, 0.15);
}

.best-result-card .badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
}

.result-header h3 {
    font-size: 1.75rem;
    /* Reduced from 2.5rem */
    font-weight: 800;
    margin-bottom: 0.1rem;
    background: linear-gradient(135deg, #0F172A, #334155);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.result-header span {
    font-size: 0.9rem;
    /* Reduced from 1.1rem */
    color: var(--text-muted);
    font-weight: 500;
}

.result-main-stat {
    margin: 1rem 0;
    /* Reduced from 2rem */
    padding: 1rem;
    /* Reduced from 1.5rem */
    background: rgba(255, 255, 255, 0.5);
    border-radius: 0.75rem;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.result-main-stat .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.1rem;
}

.result-main-stat .value {
    font-size: 2rem;
    /* Reduced from 3rem */
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

/* Polished Highlight Stats - Compact Grid */
.result-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    /* Reduced from 1.5rem */
    margin-bottom: 1rem;
    /* Reduced from 2rem */
    border: none;
    padding: 0;
}

@media (max-width: 640px) {
    .result-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    /* On mobile, make the stats 2 columns instead of 1 long column for compactness? 
       Actually user wants ONE instance. Let's try to keep it grid if possible or very tight stack.
       Let's stick to 1fr but tight padding. */
    .stat-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem !important;
    }

    .stat-item .label {
        margin-bottom: 0 !important;
    }
}

.stat-item {
    background: rgba(255, 255, 255, 0.5);
    padding: 0.8rem;
    /* Reduced */
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: transform 0.2s;
}

.stat-item:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.8);
}

.stat-item .label {
    display: block;
    font-size: 0.7rem;
    opacity: 0.8;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-muted);
}

.stat-item .value {
    font-size: 1.1rem;
    /* Reduced from 1.4rem */
    font-weight: 700;
}

/* Highlight Colors - Same */
.highlight-total .value {
    color: #10B981;
}

.highlight-total {
    border-left: 3px solid #10B981;
}

.highlight-capital .value {
    color: #0EA5E9;
}

.highlight-capital {
    border-left: 3px solid #0EA5E9;
}

.highlight-energy .value {
    color: #F59E0B;
}

.highlight-energy {
    border-left: 3px solid #F59E0B;
}

.stage-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    background: rgba(15, 23, 42, 0.03);
    padding: 1rem;
    border-radius: 0.75rem;
}

@media (max-width: 640px) {
    .stage-details {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

.stage h4 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.stage p {
    font-size: 0.55rem;
    /* Reduced */
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.2rem;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-bottom: 4rem;
}

@media (min-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.chart-card {
    padding: 1.5rem;
    transition: transform 0.3s ease;
}

.chart-wrapper {
    position: relative;
    height: 350px;
    width: 100%;
}

.chart-card:hover {
    transform: translateY(-5px);
}

.chart-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Dataset Table */
details {
    overflow: hidden;
    /* For radius */
}

summary {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.3);
}

summary:hover {
    background: rgba(255, 255, 255, 0.5);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: rgba(0, 0, 0, 0.02);
    font-weight: 600;
    color: var(--text-muted);
    padding: 1rem;
    text-align: left;
}

td {
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--text-main);
}

tr:last-child td {
    border-bottom: none;
}

.table-wrapper {
    max-height: 500px;
    overflow-y: auto;
}