/* Modern Minimalist Dashboard */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Loading spinner animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

:root {
    /* Legacy variables for backward compatibility */
    --bg-color: var(--bg);
    --text-color: var(--text);
    --card-bg: var(--card);
    --border-color: var(--border);
    --shadow-light: var(--shadow-sm);
    --shadow-medium: var(--shadow-md);
    --shadow-heavy: var(--shadow-md);
    --ap-red: #E11926;
    --krf-yellow: #FDED34;
    --h-blue: #87add7;
    --axis-color: var(--text-muted);
    --grid-color: var(--grid);
    --chart-line-color: var(--accent);
    --button-bg: var(--bg-elev);
    --button-hover: var(--border);
    --header-bg: color-mix(in oklab, var(--bg), transparent 20%);
    --progress-bg: color-mix(in oklab, var(--accent), transparent 90%);
    --progress-fill: var(--accent);
    
    /* Sidebar variables */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 40px;
    --header-height: 60px;
}

/* Dark theme is now handled by theme.css with [data-theme="dark"] */

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

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    font-size: var(--step-0);
    line-height: 1.5;
    transition: background-color var(--t) var(--ease), color var(--t) var(--ease);
}

body.loaded {
    overflow-y: auto;
}

/* New Header Layout */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-elev);
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.left-section, .right-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Header Search Styling */
.header-search {
    position: relative;
    display: flex;
    align-items: center;
}

.header-search-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 8px);
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text);
    width: 200px;
    transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}

.header-search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent), transparent 80%);
}

.header-search-input::placeholder {
    color: var(--text-muted);
}

.header-search-icon {
    position: absolute;
    right: 0.5rem;
    color: var(--text-muted);
    pointer-events: none;
}

/* Responsive header search */
@media (max-width: 768px) {
    .header-search-input {
        width: 150px;
    }
}

@media (max-width: 480px) {
    .header-search-input {
        width: 120px;
    }
}

.app-title {
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--text);
    cursor: pointer;
    transition: color var(--t) var(--ease);
}

.app-title:hover {
    color: var(--text);
}

/* MODERNIZED ICON BUTTONS - Removed animations and borders */
.icon-btn {
    background: transparent;
    border: none;
    border-radius: calc(var(--radius) - 6px);
    padding: 8px;
    cursor: pointer;
    transition: background-color var(--t) var(--ease);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
}

.icon-btn:hover {
    background: var(--bg-elev);
}

/* Lucide icon styling within icon buttons */
.icon-btn svg {
    display: block;
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Toggle icon animation - KEEPING sidebar panel animation */
.toggle-icon {
    transition: transform 0.2s ease;
}

body.sidebar-expanded .toggle-icon {
    transform: rotate(180deg);
}

/* MODERNIZED BUTTONS - Removed zoom/move animations */
.btn {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 8px);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: background-color var(--t) var(--ease);
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.btn:hover {
    background: var(--border);
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    overflow: hidden;
    transition: width 0.2s ease;
    box-shadow: var(--shadow-sm);
    z-index: 90;
}

.sidebar.collapsed {
    width: 0;
}

.sidebar.collapsed .sidebar-content {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sidebar.expanded {
    width: var(--sidebar-width);
}

.sidebar.expanded .sidebar-content {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sidebar-content {
    padding: 0.75rem;
    padding-top: calc(var(--header-height) + 0.75rem);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    overflow-x: hidden;
}

/* Table Wrapper */
.table-wrapper {
    position: relative;
}

/* Political Table Layout - OPTIMIZED 2-LINE DESIGN */
.political-table {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.65rem;
    line-height: 1.1;
    max-width: 100%;
    overflow: hidden;
}

/* Header Row */
.political-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.2rem 0.4rem;
    padding: 0.4rem;
    border-radius: 3px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    font-weight: 600;
    color: var(--text);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-height: 2.2rem;
    align-items: center;
}

.political-header .header-party {
    grid-column: 1;
    margin-left: 1.3rem;
    justify-self: start;
}

.political-header .header-pm {
    grid-column: 2;
    justify-self: center;
}

.political-header .header-coalition {
    grid-column: 3;
    justify-self: end;
    margin-right: 0.5rem;
}

.political-row {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 0.2rem 0.4rem;
    padding: 0.4rem;
    border-radius: 3px;
    border: 1px solid var(--border);
    background: var(--card);
    transition: background var(--t) var(--ease);
    min-height: 2.2rem;
}

.political-row:hover {
    background: var(--bg-elev);
}

/* Main party section (left side, spans 2 rows) */
.political-row .party-color {
    grid-row: 1 / 3;
    grid-column: 1;
    width: 10px;
    height: 100%;
    border-radius: 2px;
    display: block;
    margin-right: 0.3rem;
    align-self: stretch;
}

.political-row .party-short {
    grid-row: 1 / 3;
    grid-column: 1;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    transition: color var(--t) var(--ease);
    font-size: 0.65rem;
    margin-left: 1.3rem;
    align-self: center;
    white-space: nowrap;
}

.political-row .party-short:hover {
    color: var(--accent);
}

/* Government info (center column, top row) */
.political-row .regjering-name {
    grid-row: 1;
    grid-column: 2;
    color: var(--text);
    text-decoration: none;
    transition: color var(--t) var(--ease);
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    justify-self: center;
}

.political-row .regjering-name:hover {
    color: var(--accent);
}

/* Years (center column, bottom row) */
.political-row .years {
    grid-row: 2;
    grid-column: 2;
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    justify-self: center;
}

/* Coalition parties (right column, spans 2 rows) */
.political-row .coalition-parties {
    grid-row: 1 / 3;
    grid-column: 3;
    font-size: 0.6rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.2rem;
    flex-wrap: wrap;
    justify-self: end;
    max-width: 100%;
    margin-right: 0.5rem;
}

.political-row .coalition-parties .party-short {
    font-size: 0.6rem;
    margin: 0;
    padding: 0;
}

/* Party Colors - Consistent with chart colors */
.party-color.ap { background: #E11926; } /* Arbeiderpartiet red */
.party-color.h { background: #87add7; } /* Høyre light blue */
.party-color.sp { background: #4CAF50; } /* Senterpartiet green */
.party-color.v { background: #006666; } /* Venstre teal */
.party-color.krf { background: #FDED34; } /* Kristelig Folkeparti yellow */
.party-color.sv { background: #B5317C; } /* Sosialistisk Venstreparti pink */
.party-color.frp { background: #004F80; } /* Fremskrittspartiet dark blue */

/* Main Content */
.main-content {
    margin-left: 0;
    margin-top: var(--header-height);
    transition: margin-left 0.2s ease;
    min-height: calc(100vh - var(--header-height));
}

body.sidebar-expanded .main-content {
    margin-left: var(--sidebar-width);
}

/* Modern Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
    transition: background var(--t) var(--ease);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg);
}

/* Mobile-first responsive design */
html {
    scroll-behavior: smooth;
}

/* Responsive chart grid */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: 2rem;
}

/* Chart card layout: give containers a sane height and a fixed aspect on mobile */
.chart-card .chart-container {
    position: relative;
    /* Prefer aspect ratio for mobile; browsers that support it will ignore height */
    aspect-ratio: 16 / 9;
    /* Fallback height for older browsers + clamp for larger screens */
    height: clamp(220px, 38vh, 460px);
    max-width: 100%;
    overflow: hidden;
}

/* Let the canvas fill the container WITHOUT imposing its own height */
.chart-card .chart-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important; /* important ONLY because Chart.js may inline a height */
}

/* On wider screens, relax the aspect a bit and lower the max height */
@media (min-width: 900px) {
    .chart-card .chart-container {
        aspect-ratio: 2 / 1;
        height: clamp(260px, 32vh, 420px);
    }
}

/* If you use CSS Grid with equal-height rows, prevent "1fr" rows from stretching cards */
.chart-grid {
    grid-auto-rows: auto; /* not 1fr */
    align-items: start;   /* avoid children stretching grid tracks vertically */
}

/* Mobile optimizations - COMPLETELY OVERHAULED */
@media (max-width: 768px) {
    /* Thinner, more modern header */
    header {
        padding: 0.375rem 0.75rem;
        height: 44px;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    
    /* Responsive tweaks for tight viewports */
    .source-link {
        max-width: 18ch;          /* a bit tighter on phones */
    }
    .chart-actions {
        transform: scale(0.7);
        margin-right: 0.25rem;
    }
    
    header h1 {
        font-size: 1.125rem;
        font-weight: 600;
        letter-spacing: -0.02em;
    }
    
    /* Improved mobile menu */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--text);
        cursor: pointer;
        padding: 0.375rem;
        border-radius: 6px;
        transition: background-color var(--t) var(--ease);
        width: 32px;
        height: 32px;
    }
    
    .mobile-menu-toggle:hover {
        background: var(--border);
    }
    
    .hamburger-icon {
        width: 18px;
        height: 18px;
        transition: transform 0.3s ease;
    }
    
    .mobile-menu-toggle.active .hamburger-icon {
        transform: rotate(90deg);
    }
    
    /* Enhanced mobile menu dropdown */
    .header-controls {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--card);
        border: 1px solid var(--border);
        border-top: none;
        flex-direction: column;
        padding: 0.75rem;
        gap: 0.5rem;
        z-index: 1000;
        box-shadow: var(--shadow-md);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    
    .header-controls.mobile-open {
        display: flex;
        animation: slideDown 0.3s ease-out;
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .control-btn {
        padding: 0.625rem;
        font-size: 0.875rem;
        width: 100%;
        justify-content: center;
        border-radius: var(--radius);
        font-weight: 500;
        transition: background-color var(--t) var(--ease);
    }
    
    .control-btn:hover {
        background: var(--border);
    }
    
    /* Improved chart grid for mobile */
    .chart-grid {
        grid-template-columns: 1fr;
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .chart-card {
        width: 100%;
        margin-bottom: 0;
        border-radius: var(--radius);
        padding: 0.875rem;
        box-shadow: none; /* Turn off shadows on mobile for performance */
        transition: all var(--t) var(--ease);
    }
    
    .chart-card:hover {
        box-shadow: none; /* Keep shadows off on mobile */
    }


    
    .chart-container {
        border-radius: 8px;
        overflow: hidden;
    }
    
    /* Better typography for mobile */
    .chart-header h3 {
        font-size: 0.875rem;
        font-weight: 600;
        line-height: 1.3;
        margin-bottom: 0.25rem;
    }
    
    .chart-subtitle {
        font-size: 0.75rem;
        opacity: 0.7;
        font-weight: 400;
    }
    
    /* Improved skeleton loading */
    .skeleton-chart {
        height: 120px !important;
        border-radius: 8px;
        margin: 0;
    }
    
    /* Better progress bar */
    .progress-bar {
        height: 2px !important;
    }
    
    /* Enhanced filter panel for mobile */
    .slim-header {
        width: 280px;
        padding: 0.5rem 0.75rem;
        border-left: 1px solid var(--border);
    }
    
    .filter-container {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .search-box {
        width: 100%;
        max-width: none;
    }
    
    .search-input {
        font-size: 0.875rem;
        padding: 0.625rem 0.75rem 0.625rem 2.5rem;
        border-radius: var(--radius);
        border: 1px solid var(--border);
        background: var(--card);
    }
    
    .search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent), transparent 90%);
    outline: none;
}

.search-input:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent), transparent 90%);
    outline: none;
}
    
    .source-filters {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }
    
    .filter-btn, .sort-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        border-radius: var(--radius);
        font-weight: 500;
        text-align: center;
        transition: background-color var(--t) var(--ease);
    }
    
    .filter-btn:hover, .sort-btn:hover {
        background: var(--border);
    }
    
    /* Main content improvements */
    main {
        padding: 0.5rem;
        padding-bottom: 2rem;
        min-height: calc(100vh - 44px);
    }
    
    /* Increase tap targets for better UX */
    a, button {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Better source link positioning */
    .source-link {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
        border-radius: calc(var(--radius) - 8px);
        top: 0.5rem;
        right: 0.5rem;
    }
}

/* Hide mobile menu on desktop */
@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none;
    }
    
    .header-controls {
        display: flex !important;
    }
}

/* Wrap long chart titles */
.chart-header h3 {
    word-break: break-word;
    hyphens: auto;
}

/* Smooth transitions for theme switching */
body, .chart-card, .header-content, .slim-header {
    transition: background-color var(--t) var(--ease), color var(--t) var(--ease), border-color var(--t) var(--ease);
}

/* Theme Toggle Icon - now handled by theme.js */

/* Filter Toggle Icon */
.filter-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

#filterToggle.active .filter-icon {
    transform: rotate(180deg);
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--ap-red) 0%, var(--h-blue) 50%, var(--krf-yellow) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
    /* CSS-based timeout: hide after 30 seconds as a fallback */
    animation: loading-timeout 30s forwards;
}

@keyframes loading-timeout {
    0%, 90% {
        opacity: 1;
        visibility: visible;
    }
    100% {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
    animation: none; /* Disable timeout animation when manually hidden */
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
}

.loading-content p {
    font-size: 0.875rem;
    opacity: 0.8;
    font-weight: 400;
}

/* Loading dots animation */
.loading-dots {
    display: inline-block;
    animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
    0%, 20% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* Skeleton Loading */
.skeleton-chart {
    background: linear-gradient(90deg, 
        color-mix(in oklab, var(--card) 94%, var(--bg) 6%) 25%, 
        color-mix(in oklab, var(--card) 86%, var(--bg) 14%) 50%, 
        color-mix(in oklab, var(--card) 94%, var(--bg) 6%) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    height: 100%;
    display: none; /* Hidden by default */
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Legacy header styles - removed in favor of new sidebar layout */

/* Slim Header with Filters */
.slim-header {
    background: var(--card);
    border-left: 1px solid var(--border);
    padding: 0.5rem 1rem;
    box-shadow: var(--shadow-sm);
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: 300px;
    height: calc(100vh - var(--header-height));
    z-index: 95;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.slim-header.show {
    transform: translateX(0);
}

.filter-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 8px);
    background: var(--card);
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
    transition: all var(--t) var(--ease);
}

.search-input:focus {
    outline: none;
    border-color: var(--ap-red);
    box-shadow: 0 0 0 3px rgba(225, 25, 38, 0.1);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.source-filters {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* MODERNIZED FILTER BUTTONS - Removed zoom/move animations */
.filter-btn {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 8px);
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: background-color var(--t) var(--ease);
    font-family: inherit;
}

.filter-btn:hover {
    background: var(--border);
}

.filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.filter-btn.active:hover {
    background: color-mix(in oklab, var(--accent), black 10%);
}

/* Standalone sort button */
.sort-btn {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 8px);
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: background-color var(--t) var(--ease);
    font-family: inherit;
    margin-left: 0.5rem;
}

.sort-btn:hover {
    background: var(--border);
}

.sort-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.sort-btn.active:hover {
    background: color-mix(in oklab, var(--accent), black 10%);
}

/* Main Grid */
main {
    min-height: calc(100vh - 60px);
    padding: 1rem;
    padding-bottom: 6rem;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    max-width: 100vw;
    width: 100%;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    padding-bottom: 2rem;
    width: 100%;
    box-sizing: border-box;
}

/* Chart Cards */
.chart-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all var(--t) var(--ease);
    min-height: 200px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;           /* keep children from spilling out */
}

.chart-card:hover {
    box-shadow: var(--shadow-md);
}

/* Chart Actions - Download, Copy, and Fullscreen buttons */
.chart-header {
    display: flex;
    flex-direction: column;
    gap: 0.0625rem; /* Further reduced gap between header and subtitle */
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.chart-header h3 {
    font-size: var(--step-0);
    font-weight: 600;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.025em;
    /* make it the flexible child */
    flex: 1 1 auto;
    min-width: 0;               /* CRUCIAL for ellipsis in flex */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-header-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    flex-wrap: nowrap;
    /* IMPORTANT to allow children to actually shrink */
    min-width: 0;
    overflow: hidden; /* guardrail to avoid horizontal bleed */
}

.chart-subtitle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.5rem;
}

.chart-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.chart-actions {
    margin-left: auto;          /* keep it on the right */
    display: inline-flex;
    gap: 4px;
    transform: scale(0.75);
    transform-origin: right center;
    margin-right: 0.5rem;
    flex: 0 0 auto;             /* don't grow, don't shrink too small */
}

.subtitle-actions {
    display: inline-flex;
    gap: 4px;
    transform: scale(0.75);
    transform-origin: right center;
    flex: 0 0 auto;
}

/* MODERNIZED CHART ICON BUTTONS - Removed borders, blue lines, and zoom animations */
.chart-actions .icon-btn,
.subtitle-actions .icon-btn {
    appearance: none;
    border: none;
    background: transparent;
    border-radius: 8px;
    padding: 4px;
    line-height: 0;
    cursor: pointer;
    transition: background-color 120ms ease;
}

.chart-actions .icon-btn:hover,
.subtitle-actions .icon-btn:hover {
    background: color-mix(in oklab, var(--card), transparent 10%);
}

.chart-actions .icon-btn:focus-visible,
.subtitle-actions .icon-btn:focus-visible {
    outline: none;
}

.chart-actions .icon-btn svg,
.subtitle-actions .icon-btn svg {
    display: block;
    color: var(--text);
}

.chart-body {
    overflow: hidden;
}

.chart-meta {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 6px;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fullscreen Modal */
.fullscreen-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    overflow: hidden;
    animation: fadeIn 0.3s ease-out;
}

.fullscreen-card {
    background: var(--card);
    border-radius: 0;
    box-shadow: none;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.fullscreen-card .chart-header {
    padding: 2rem 3rem;
    border-bottom: 1px solid var(--border);
    background: var(--card);
    flex-shrink: 0;
}

.fullscreen-card .chart-header h3 {
    font-size: 2rem;
    margin: 0 0 0.75rem 0;
    color: var(--text);
}

.fullscreen-card .chart-subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin: 0;
}

.fullscreen-card .chart-actions {
    gap: 1rem;
}

.fullscreen-card .chart-actions .icon-btn {
    width: 3rem;
    height: 3rem;
    padding: 0.75rem;
}

.fullscreen-card .chart-actions .icon-btn svg {
    width: 24px;
    height: 24px;
}

.fullscreen-card .chart-container {
    flex: 1;
    padding: 3rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
    background: var(--card);
}

.fullscreen-card canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.fullscreen-card .source-link {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.fullscreen-card .source-link:hover {
    color: var(--primary);
}

/* Source Links */
.source-link {
    font-size: 0.75rem;
    color: var(--text);
    text-decoration: none;
    background: color-mix(in oklab, var(--card), transparent 10%);
    padding: 0.25rem 0.5rem;
    border-radius: calc(var(--radius) - 10px);
    transition: all var(--t) var(--ease);
    opacity: 0.6;
    font-weight: 500;
    white-space: nowrap;        /* stays a single run */
    max-width: 30ch;            /* keep it reasonable */
    overflow: hidden;           /* allow truncation */
    text-overflow: ellipsis;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.source-link:hover {
    opacity: 1;
    background: var(--card);
    box-shadow: var(--shadow-sm);
}

/* Removed duplicate chart-header and chart-subtitle styles */

.chart-container {
    flex: 1;
    position: relative;
    min-height: 150px;
    height: 180px; /* Fixed height to maintain consistent aspect ratio */
    display: block;
    visibility: visible;
    max-width: 100%;
    overflow: hidden;           /* keep children from spilling out */
}

/* Improve canvas rendering quality for better text clarity */
.chart-container canvas {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: block;
    max-width: 100%;
    width: 100% !important;     /* Chart.js respects this */
    height: 100% !important;    /* Fixed height to maintain aspect ratio */
}

/* Static Tooltip Area */
.static-tooltip {
    position: absolute;
    top: 2.5rem; /* Position below the source link button */
    right: 0;
    background: color-mix(in oklab, var(--card), transparent 5%);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 10px);
    padding: 0.5rem;
    font-size: 0.75rem;
    color: var(--text);
    max-width: 200px;
    z-index: 5;
    opacity: 0;
    transition: opacity var(--t) var(--ease);
    pointer-events: none;
}

.static-tooltip.visible {
    opacity: 1;
}

/* Enhanced Tooltip Content */
.tooltip-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.tooltip-title {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text);
}

.tooltip-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

.tooltip-date {
    font-size: 0.7rem;
    opacity: 0.8;
    color: var(--text-muted);
}

.tooltip-political {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.65rem;
    opacity: 0.9;
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.dark-mode .tooltip-political {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.tooltip-party {
    width: 8px;
    height: 8px;
    border-radius: 1px;
    flex-shrink: 0;
}

/* Footer - Modernized with CSS Grid and Lucide Icons */
:root {
    --footer-bg: var(--card);
    --footer-text: var(--text-color);
    --footer-accent: var(--ap-red);
    --footer-border: var(--border);
    --icon-size: 1.2rem;
    --external-icon-size: 0.8rem;
    --success-color: #10b981;
}

footer {
    background: color-mix(in oklab, var(--footer-bg), black 3%);
    border-top: 1px solid var(--footer-border);
    padding: 3rem 2rem;
    height: auto;
    min-height: 400px;
    box-shadow: var(--shadow-sm);
    width: 100%;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem;
    max-width: 1200px;
    margin: 0 auto;
    border-top: 3px solid var(--footer-accent);
    padding-top: 2rem;
    align-items: start;
    position: relative;
}

.footer-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
}

.footer-section h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--footer-text);
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    display: inline-block;
}

.footer-section p {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-muted);
    margin: 0;
}

.data-sources {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
}

.source-link, .social-link, .contact-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--footer-text);
    transition: color 0.2s ease, transform 0.2s ease;
    font-size: 0.875rem;
    padding: 0.25rem 0;
}

.source-link:hover, .social-link:hover, .contact-link:hover {
    color: var(--footer-accent);
}

.source-icon, .social-icon, .contact-icon {
    width: var(--icon-size);
    height: var(--icon-size);
    flex-shrink: 0;
    color: var(--footer-accent);
}

.external-icon {
    width: var(--external-icon-size);
    height: var(--external-icon-size);
    flex-shrink: 0;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

/* Legacy footer styles removed - now using CSS Grid layout */

.contact-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.about-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.disclaimer-text {
    max-width: 300px;
}

.disclaimer-text p {
    font-size: 0.7rem !important;
    line-height: 1.4;
    color: var(--text-muted);
    opacity: 0.8;
    margin: 0;
}

.footer-copyright {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
}
}

.social-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
}

.social-text {
    font-weight: 500;
}

.back-to-top {
    color: var(--footer-accent);
    text-decoration: none;
    font-size: 0.75rem;
    margin-left: 1rem;
    transition: color 0.2s ease;
}

.back-to-top:hover {
    color: var(--footer-text);
    text-decoration: underline;
}

/* Button Success Feedback Animation - No background color change */
.icon-btn.success-feedback {
    transition: all 0.3s ease;
}

/* Mood Rating Buttons */
.mood-section {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 0;
    margin-top: 1rem;
}

.mood-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.mood-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    color: var(--text-muted);
    opacity: 0.7;
}

        .mood-btn:hover {
            opacity: 1;
        }
        
        .mood-btn.success-feedback[data-mood="happy"] {
            color: #10b981;
        }
        
        .mood-btn.success-feedback[data-mood="neutral"] {
            color: #f59e0b;
        }
        
        .mood-btn.success-feedback[data-mood="sad"] {
            color: #ef4444;
        }

/* Dark theme adjustments for mood buttons */
[data-theme="dark"] .mood-btn {
    color: var(--text-muted);
}

/* Responsive footer adjustments */
@media (max-width: 768px) {
    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .mood-section {
        justify-content: center;
        margin-top: 1.5rem;
    }
}

[data-theme="dark"] .mood-btn:hover {
    background: var(--card-hover);
}

[data-theme="dark"] .mood-btn.success-feedback[data-mood="happy"] {
    color: #34d399;
}

[data-theme="dark"] .mood-btn.success-feedback[data-mood="neutral"] {
    color: #fbbf24;
}

[data-theme="dark"] .mood-btn.success-feedback[data-mood="sad"] {
    color: #f87171;
}

/* Success color for dark theme */
[data-theme="dark"] {
    --success-color: #34d399;
}

.footer-text {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
}

.footer-text p {
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
}

.footer-text a {
    color: var(--ap-red);
    text-decoration: none;
    transition: opacity var(--t) var(--ease);
}

.footer-text a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* COMPLETELY OVERHAULED MOBILE FOOTER */
@media (max-width: 768px) {
    /* Slim header positioning for mobile */
    .slim-header {
        top: 44px;
    }
    
    main {
        padding: 0.5rem;
        padding-bottom: 2rem;
        min-height: calc(100vh - 44px);
    }
    
    .chart-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding-bottom: 1.5rem;
    }
    
    .chart-card {
        min-height: 160px;
        padding: 0.75rem;
        border-radius: 12px;
    }
    
    .chart-header h3 {
        font-size: 0.875rem;
        line-height: 1.3;
    }
    
    .chart-subtitle {
        font-size: 0.75rem;
    }
    
    .chart-container {
        min-height: 120px;
        height: 130px; /* Fixed height for mobile to maintain aspect ratio */
        max-height: 130px;
        overflow: hidden;
    }
    
    /* COMPLETELY REDESIGNED MOBILE FOOTER */
    footer {
        padding: 2rem 1rem;
        min-height: auto;
    }
    
    /* Old flexbox footer styles removed - now using CSS Grid */
    
    .footer-section h4 {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
        border-bottom: none;
    }
    
    .footer-section p {
        font-size: 0.7rem;
    }
    
    .disclaimer-text {
        max-width: none;
    }
    
    .disclaimer-text p {
        font-size: 0.6rem !important;
        text-align: left;
    }
    
    /* Mobile mood buttons */
    .mood-section {
        padding: 0.5rem 0;
    }
    
    .mood-container {
        gap: 0.25rem;
    }
    
    .mood-btn {
        width: 2rem;
        height: 2rem;
        padding: 0.25rem;
    }
    
    /* Old footer-right styles removed - now using CSS Grid */
    
    .footer-copyright {
        text-align: center;
        width: 100%;
        margin-top: 2rem;
        padding-top: 1.5rem;
    }
    
    .footer-copyright p {
        font-size: 0.65rem;
    }
    
    /* Modernized Footer Responsive Design */
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 1.5rem;
    }
    
    .footer-section {
        height: auto;
        justify-content: flex-start;
        gap: 1rem;
    }
    
    .footer-section:last-child {
        align-items: center;
    }
    
    .source-link, .social-link {
        font-size: 0.8rem;
        gap: 0.4rem;
        justify-content: center;
    }
    
    .source-icon, .social-icon {
        width: 1rem;
        height: 1rem;
    }
    
    .external-icon {
        width: 0.7rem;
        height: 0.7rem;
    }
}

@media (max-width: 480px) {
    .footer-section h4 {
        font-size: 1.1rem;
    }
    
    .disclaimer-text p {
        font-size: 0.9rem;
    }
    
    .footer-copyright p {
        font-size: 0.7rem;
    }
    
    .back-to-top {
        display: block;
        margin: 0.5rem 0 0 0;
        text-align: center;
    }
}
        gap: 1.5rem;
    }
    
    .political-periods h4 {
        font-size: 1rem;
        margin-bottom: 1rem;
        text-align: center;
    }
    
    /* COMPLETELY REDESIGNED POLITICAL PERIODS FOR MOBILE */
    .political-text {
        gap: 0.75rem;
    }
    
    .political-period {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 1rem;
        background: var(--bg);
        border-radius: var(--radius);
        border: 1px solid var(--border);
        box-shadow: var(--shadow-sm);
        transition: all var(--t) var(--ease);
    }
    
    .political-period:hover {
        box-shadow: var(--shadow-md);
    }
    
    /* Header row for each political period */
    .political-period-header {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    .main-party {
        display: flex;
        align-items: center;
        gap: 0.25rem;
        min-width: 50px;
    }
    
    .regjering-info {
        display: flex;
        flex-direction: column;
        gap: 0.1rem;
        flex: 1;
    }
    
    .pm-name {
        font-size: 0.875rem;
        font-weight: 600;
        min-width: auto;
        line-height: 1.1;
    }
    
    .period-dates {
        font-size: 0.75rem;
        font-weight: 500;
        margin-left: 0;
        color: var(--text-muted);
        opacity: 0.8;
    }
    
    /* Party information row */
    .political-parties {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        align-items: center;
    }
    
    .party-square {
        width: 16px;
        height: 16px;
        border-radius: 3px;
    }
    
    .party-name {
        font-size: 0.8rem;
        font-weight: 600;
        min-width: auto;
    }
    
    /* Removed .other-parties styles as they're no longer used */
    
    /* Party colors grid for mobile */
    .party-colors {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .party-color-item {
        font-size: 0.8rem;
        padding: 0.5rem;
        background: var(--bg);
        border-radius: var(--radius);
        border: 1px solid var(--border);
    }
    
    .party-color {
        width: 16px;
        height: 16px;
        border-radius: 3px;
    }
    
    /* Footer right section for mobile */
    .footer-right {
        align-items: center;
        gap: 1.5rem;
        width: 100%;
    }
    
    .social-links {
        gap: 1rem;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .social-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        transition: all var(--t) var(--ease);
    }
    
    .social-link:hover {
        box-shadow: var(--shadow-md);
    }
    
    .footer-text {
        text-align: center;
        font-size: 0.75rem;
        width: 100%;
        line-height: 1.4;
    }
    
    .footer-text p {
        margin-bottom: 0.75rem;
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .chart-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1200px) {
    .chart-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Loading & Error States */
.loading, .error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 0.875rem;
    color: var(--text);
}

.error {
    color: var(--ap-red);
}

/* Progress Bars */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    z-index: 9999;
    transition: width 0.3s ease;
}

/* Loading Progress Bar */
.load-progress-bar {
    background: linear-gradient(90deg, #ef4444, #3b82f6, #eab308);
    opacity: 0;
}

.load-progress-bar.active {
    opacity: 1;
}

/* Scroll Progress Bar */
.scroll-progress-bar {
    background: linear-gradient(90deg, #3b82f6, #eab308);
    opacity: 0;
}

.scroll-progress-bar.active {
    opacity: 1;
}

/* Back to top button */
.back-to-top-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--border);
    color: var(--text);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all var(--t) var(--ease);
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.back-to-top-btn:hover {
    background: var(--border);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.back-to-top-btn svg {
    transition: color 0.3s ease;
}

/* Legacy drawer styles - removed in favor of new sidebar layout */

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Header controls */
.header-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* MODERNIZED CONTROL BUTTONS - Removed zoom/move animations */
.control-btn {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 8px);
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: background-color var(--t) var(--ease);
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: var(--border);
}

/* Mobile backdrop for sidebar overlay */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: saturate(120%) blur(2px);
    z-index: 85;
    opacity: 0;
    transition: opacity 150ms ease;
    display: none;
}

.sidebar-backdrop.show {
    opacity: 1;
}

/* Mobile backdrop for filter panel overlay */
.filter-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: saturate(120%) blur(2px);
    z-index: 90;
    opacity: 0;
    transition: opacity 150ms ease;
    display: none;
}

.filter-backdrop.show {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Mobile sidebar behavior */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        width: 280px;
    }
    
    .sidebar.expanded {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
    }
    
    /* Main content on mobile */
    .main-content {
        margin-left: 0;
        margin-top: var(--header-height);
    }
    
    body.sidebar-expanded .main-content {
        margin-left: 0;
    }
    
    /* Header adjustments for mobile */
    .app-header {
        padding: 0.5rem;
    }
    
    .app-title {
        font-size: 1rem;
    }
    
    .right-section {
        gap: 0.25rem;
    }
    
    .btn {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    /* Political table adjustments for mobile */
    .political-header {
        gap: 0.15rem 0.3rem;
        padding: 0.35rem;
        font-size: 0.55rem;
        min-height: 2rem;
    }
    
    .political-row {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        gap: 0.15rem 0.3rem;
        padding: 0.35rem;
        font-size: 0.6rem;
        min-height: 2rem;
    }
    
    .political-row .party-color {
        width: 8px;
        margin-right: 0.25rem;
    }
    
    .political-row .party-short {
        font-size: 0.6rem;
        margin-left: 1.1rem;
    }
    
    .political-row .regjering-name {
        font-size: 0.6rem;
    }
    
    .political-row .years,
    .political-row .coalition-parties {
        font-size: 0.55rem;
    }
    
    .political-row .coalition-parties {
        max-width: 55%;
    }
    

}

@media (max-width: 480px) {
    /* Very small screens */
    .footer-content {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .footer-left,
    .footer-center,
    .footer-right {
        min-width: auto;
        width: 100%;
    }
    
    .political-header {
        gap: 0.15rem 0.25rem;
        padding: 0.3rem;
        font-size: 0.5rem;
        min-height: 1.8rem;
    }
    
    .political-row {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        font-size: 0.55rem;
        padding: 0.3rem;
        min-height: 1.8rem;
    }
    
    .political-row .party-color {
        width: 7px;
        margin-right: 0.2rem;
    }
    
    .political-row .party-short {
        font-size: 0.55rem;
        margin-left: 0.9rem;
    }
    
    .political-row .regjering-name,
    .political-row .years,
    .political-row .coalition-parties {
        font-size: 0.55rem;
    }
    
    .political-row .coalition-parties {
        max-width: 50%;
    }
    

    
    .sidebar-content {
        padding: 0.5rem;
        padding-top: calc(var(--header-height) + 0.5rem);
    }
}

/* Ensure sidebar is always visible on desktop */
@media (min-width: 769px) {
    .sidebar {
        transform: none !important;
    }
    
    .sidebar.collapsed {
        transform: none !important;
        width: 0 !important;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Typography Fix - Match subtitle and source-link styling */
.chart-header .chart-subtitle {
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.01em;
  font-family: inherit;
  color: var(--text-muted);
}

/* Source link styling - matches subtitle exactly with underline */
.chart-header .source-link {
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.01em;
  font-family: inherit;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  opacity: 0.7;
  transition: opacity var(--t) var(--ease);
}

.chart-header .source-link:hover,
.chart-header .source-link:focus {
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  opacity: 1;
}

/* Icon button styling (shared) - MODERNIZED */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: background-color var(--t) var(--ease);
}
.icon-btn:hover { 
  background: var(--border, rgba(0,0,0,0.04)); 
}
.icon-btn:focus { 
  outline: none; 
}
.icon-btn .icon svg { 
  display: block; 
}
