:root {
    --primary-bg: #1a1b26;
    --secondary-bg: #16161e;
    --border-color: #292e42;
    --text-primary: #c0caf5;
    --text-secondary: #b1bfff;
    --accent-color: #7aa2f7;
    --env-bg: #1f2335;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.25);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --sidebar-width: 240px;
}

/* OS-based theme detection */
@media (prefers-color-scheme: light) {
    :root {
        --primary-bg: #ffffff;
        --secondary-bg: #f7f7f7;
        --border-color: #d1d1d1;
        --text-primary: #111827;
        --text-secondary: #6b7280;
        --accent-color: #394662;
        --env-bg: #e5e7eb;
        --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
        --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
        --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    }
}

/* Manual theme overrides (these take precedence over OS settings) */
:root[data-theme="light"] {
    --primary-bg: #ffffff;
    --secondary-bg: #f7f7f7;
    --border-color: #d1d1d1;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --accent-color: #394662;
    --env-bg: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

:root[data-theme="dark"] {
    --primary-bg: #1a1b26;
    --secondary-bg: #16161e;
    --border-color: #292e42;
    --text-primary: #c0caf5;
    --text-secondary: #b1bfff;
    --accent-color: #7aa2f7;
    --env-bg: #1f2335;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.25);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--secondary-bg);
    color: var(--text-primary);
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: calc(100vh - 4rem);
}

.breadcrumbs {
    margin-bottom: 2rem;
}

.breadcrumb ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.breadcrumb li {
    display: flex;
    align-items: center;
    color: var(--text-secondary);
}

.breadcrumb li:not(:last-child)::after {
    content: "/";
    margin-left: 0.5rem;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--accent-color);
}

.breadcrumb span {
    color: var(--text-primary);
}

.title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    padding: 0;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.item-card {
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    transition: all 0.2s;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
}

.item-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

a {
    text-decoration: none;
    color: inherit;
}

a:hover {
    color: var(--accent-color);
}

.item-title {
    font-size: 1.125rem;
    font-weight: 500;
    margin: 0;
    color: var(--text-primary);
}

.item-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0.25rem 0 0;
}

.item-metadata {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    font-size: 0.75rem;
}

.metadata-item {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.metadata-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.metadata-value {
    color: var(--text-primary);
}

.theme-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    background: var(--env-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--border-color);
}

.theme-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: currentColor;
}

/* Layout CSS */
.page-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-bg);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 1rem;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    overflow-y: auto;
    box-shadow: var(--shadow-sm);
    z-index: 100;
    transition: transform 0.3s ease-in-out;
}

.main-content {
    flex-grow: 1;
    padding: 2rem;
    margin-left: var(--sidebar-width);
    max-width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease-in-out;
}

/* Sidebar CSS needed */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-group-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-group-title-link {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.15s ease-in-out;
}

.sidebar-group-title-link:hover {
    color: var(--accent-color);
}

.sidebar-group-title-link.active {
    color: var(--accent-color);
}

.sidebar-subsection {
    margin-bottom: 1rem;
}

.sidebar-subsection-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0.5rem;
    padding-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

.sidebar-subgroup-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-link {
    display: block;
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out;
}

.sidebar-link:hover {
    background-color: var(--env-bg);
    color: var(--text-primary);
}

.sidebar-link.active {
    background-color: var(--accent-color);
    color: white;
    font-weight: 500;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 110;
    padding: 0.5rem;
    background-color: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
}

.sidebar-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--text-primary);
    margin: 4px 0;
    transition: transform 0.3s ease;
}


/* Landing page list styling */
.landing-subgroup-list {
    list-style: disc;
    padding-left: 20px;
    margin-top: 0.5rem;
}

.landing-subgroup-list li {
    margin-bottom: 0.25rem;
}

.landing-subgroup-list a {
    font-size: 0.9rem;
    color: var(--accent-color);
    text-decoration: none;
}

.landing-subgroup-list a:hover {
    text-decoration: underline;
}

/* Readme Content Styling */
.readme-content {
    font-size: 0.875rem;
}

.readme-content h1, 
.readme-content h2, 
.readme-content h3, 
.readme-content h4, 
.readme-content h5, 
.readme-content h6 {
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.readme-content h1 {
    font-size: 1.75rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.readme-content h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.readme-content h3 {
    font-size: 1.25rem;
}

.readme-content h4 {
    font-size: 1.1rem;
}

.readme-content p {
    margin: 0.75rem 0;
}

.readme-content ul, 
.readme-content ol {
    padding-left: 1.5rem;
    margin: 0.75rem 0;
}

.readme-content li {
    margin-bottom: 0.25rem;
}

.readme-content a {
    color: var(--accent-color);
    text-decoration: none;
}

.readme-content a:hover {
    text-decoration: underline;
}

.readme-content code {
    font-family: monospace;
    background: var(--env-bg);
    padding: 0.1rem 0.3rem;
    border-radius: 0.25rem;
    font-size: 0.9em;
}

.readme-content pre {
    background: var(--env-bg);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.readme-content pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
}

.readme-content blockquote {
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    border-left: 0.25rem solid var(--accent-color);
    background: var(--env-bg);
    color: var(--text-secondary);
}

.readme-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin: 1rem 0;
}

.readme-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
}

.readme-content table th,
.readme-content table td {
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    text-align: left;
}

.readme-content table th {
    background: var(--env-bg);
    font-weight: 600;
}

/* Styles needed for Chart Page Horizontal Navigation */
.header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.title-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chart-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.metric-description {
    margin: 0.75rem 0;
    padding: 1rem;
}

.metric-description p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.chart-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
    padding: 0;
}

.metadata-line {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    margin: 8px 0;
}

.metadata-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0 8px;
    align-items: center;
}

.metadata-list li {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.875rem;
}

.metadata-list li:not(:last-child)::after {
    content: "|";
    margin-left: 8px;
    color: var(--border-color);
}

.metadata-list li .key {
    color: var(--accent-color);
    font-weight: 500;
}

.metadata-list li .value {
    color: var(--text-primary);
}

.env-section {
    margin-top: 8px;
    font-size: 0.875rem;
    line-height: 1.5;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
}

.env-title {
    color: var(--accent-color);
    font-weight: 500;
    grid-column: 1;
    text-transform: uppercase;
}

.env-list {
    list-style: none;
    padding: 0;
    margin: 0;
    grid-column: 2;
    display: grid;
    gap: 4px;
}

.env-list li {
    display: flex;
    gap: 4px;
}

.env-list li .env-key {
    color: var(--text-secondary);
}

.env-list li .env-value {
    color: var(--text-primary);
}

.nav {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 0.5rem 0;
    margin-top: 1rem;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-start;
    width: 100%;
}

.nav-group-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    text-align: left;
}

.nav-group-links {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-left: 1rem;
    width: 100%;
}

.nav-link {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s;
    border-radius: 4px;
    font-weight: 400;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    width: calc(100% / 15);
    min-width: 5rem;
    height: 4rem;
    text-align: left;
    background: var(--env-bg);
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--primary-bg);
}

.nav-link.active {
    color: var(--accent-color);
    font-weight: 500;
    background: var(--primary-bg);
}

.nav-separator {
    width: 1px;
    height: 2rem;
    background-color: var(--border-color);
    margin: 0 0.5rem;
}

.chart-container {
    flex: 1;
    margin-top: 1rem;
    min-height: 900px;
    background: var(--primary-bg);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
    padding: 1rem;
    border: 1px solid var(--border-color);
}

/* Specific styling for chart containers */
#chart_bar {
    margin-bottom: 0rem;
}

/* Additional styling for the time-series chart container */
#chart_time {
    margin-top: 0rem;
}

/* Single consolidated media query for mobile */
@media (max-width: 768px) {

    /* Container and basic layout */
    .container {
        margin: 1rem auto;
        padding: 0 0.75rem;
        gap: 0.5rem;
    }

    .title {
        font-size: 1.25rem;
    }

    .items-grid {
        grid-template-columns: 1fr;
    }

    /* Sidebar handling */
    .sidebar {
        transform: translateX(-100%);
        /* Start hidden */
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
        /* Slide in */
    }

    .main-content {
        margin-left: 0;
        /* Remove margin on mobile */
        padding: 0.1rem;
        /* Reduce padding */
        max-width: 100%;
        padding-top: 3.5rem;
        /* Adjust padding for fixed toggle */
    }

    .sidebar-toggle {
        display: block;
        /* Show hamburger */
    }

    /* Chart title area */
    .header {
        gap: 0.25rem;
    }

    .title-section {
        gap: 0.125rem;
    }

    .chart-title {
        font-size: 1.125rem;
    }

    .chart-subtitle {
        font-size: 0.75rem;
    }

    /* Metadata display */
    .metadata-list {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
        width: 100%;
    }

    .metadata-list li:not(:last-child)::after {
        content: none;
        /* Hide pipe separators */
    }

    /* Navigation */
    .theme-toggle {
        top: 1rem;
        right: 1rem;
    }

    .nav {
        align-items: stretch;
    }

    .nav-group {
        width: 100%;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 0.5rem;
    }

    .nav-group-links {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        justify-content: flex-start;
    }

    .nav-separator {
        display: none;
    }

    .nav-link {
        padding: 0.4rem 0.2rem;
        border: 0;
        width: 100%;
        height: auto;
        background: none;
        margin-left: 0rem;
    }

    /* Chart container */
    .chart-container {
        min-height: 650px;
        /* Use the larger value from the media queries */
        padding: 0.5rem;
        overflow-x: auto;
        /* Horizontal scroll for wide charts */
    }

    .env-section {
        display: block;
    }
    
}

/* Summary Page Styles */
/* Description styles for individual metric pages */
.description {
    color: var(--text-secondary);
    margin: 0.5rem 0 1rem 0;
    font-style: italic;
    line-height: 1.4;
}

.summary-description {
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--env-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    text-align: center;
}

.summary-description p {
    margin: 0;
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.summary-charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
    /* Inherit the chart-container styles */
    flex: 1;
    margin-top: 1rem;
    min-height: 900px;
}

.summary-chart-item {
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.summary-chart-footer {
    padding: 1rem;
    background: var(--primary-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}


.summary-chart-link {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s;
    margin: 0 1rem 0 auto;
}

.summary-chart-link:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.summary-chart {
    height: 600px;
    width: 100%;
}

/* Mobile styles for summary */
@media (max-width: 768px) {
    .summary-charts-grid {
        gap: 1rem;
        padding: 1rem;
    }
    
    .summary-chart-item {
        margin: 0;
    }
    
    .summary-chart {
        height: 400px;
    }
}