:root {
    /* Brand Colors (Netz Düsseldorf Inspired) */
    --primary-color: #005B82;    /* Deep Blue */
    --primary-dark: #004462;
    --secondary-color: #00B4E6;  /* Light Blue */
    --accent-color: #C6D423;     /* Green Accent */
    
    /* Background & Surface */
    --bg-color: #f4f7f6;
    --surface-color: #ffffff;
    --surface-hover: #f8fafc;
    
    /* Text */
    --text-main: #212529;
    --text-muted: #6c757d;
    --border-color: #e9ecef;
    
    /* Utility */
    --success-color: #10b981;    /* Green */
    --warning-color: #f59e0b;    /* Orange/Yellow */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius-md: 8px;
    --radius-lg: 12px;
}

[data-theme="dark"] {
    --primary-color: #38bdf8;
    --primary-dark: #0284c7;
    --secondary-color: #7dd3fc;
    --accent-color: #a3e635;
    --success-color: #34d399;
    --warning-color: #fbbf24;
    
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --surface-hover: #334155;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

.screen {
    min-height: 100vh;
    transition: opacity 0.3s ease;
}

/* ==========================================
   UPLOAD SCREEN
   ========================================== */
#upload-screen {
    display: block;
    overflow-y: auto;
    background:
        radial-gradient(circle at 85% 8%, rgba(56, 189, 248, 0.13), transparent 30rem),
        var(--bg-color);
    scroll-behavior: smooth;
}

.upload-container {
    background: var(--surface-color);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
    width: 100%;
    border: 1px solid var(--border-color);
}

.landing-header {
    width: min(1180px, calc(100% - 3rem));
    min-height: 72px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.landing-brand,
.landing-links a,
.landing-module-card a {
    color: inherit;
    text-decoration: none;
}

.landing-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 750;
    letter-spacing: -0.02em;
}

.landing-brand-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: var(--secondary-color);
    background: rgba(56, 189, 248, 0.12);
}

.landing-brand-icon svg {
    width: 21px;
    height: 21px;
}

.beta-badge,
.module-state {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.beta-badge {
    padding: 0.18rem 0.48rem;
    color: #082f49;
    background: #7dd3fc;
}

.landing-links {
    display: flex;
    align-items: center;
    gap: 1.4rem;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.landing-links a:hover,
.landing-links a:focus-visible,
.landing-module-card a:hover,
.landing-module-card a:focus-visible {
    color: var(--primary-color);
}

.landing-main {
    width: min(1180px, calc(100% - 3rem));
    margin: 0 auto;
    padding: 4rem 0 5rem;
}

.landing-hero {
    min-height: 500px;
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    align-items: center;
    gap: clamp(2rem, 7vw, 6rem);
}

.landing-kicker {
    display: inline-block;
    color: var(--secondary-color);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}

.landing-hero h1 {
    max-width: 780px;
    font-size: clamp(2.35rem, 5.6vw, 4.8rem);
    line-height: 1.02;
    letter-spacing: -0.055em;
    margin: 0;
}

.landing-hero > div > p {
    max-width: 700px;
    margin-top: 1.4rem;
    color: var(--text-muted);
    font-size: clamp(1rem, 1.7vw, 1.18rem);
}

.landing-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.8rem;
}

.landing-primary,
.landing-secondary {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    padding: 0.7rem 1rem;
    font-weight: 700;
    text-decoration: none;
}

.landing-primary {
    background: var(--primary-color);
    color: #082f49;
    border: 1px solid var(--primary-color);
}

.landing-secondary {
    color: var(--text-main);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
}

.trust-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem 1.2rem;
    list-style: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 1.4rem;
}

.trust-list li::before {
    content: "✓";
    color: var(--success-color);
    margin-right: 0.38rem;
    font-weight: 800;
}

.hero-preview {
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: linear-gradient(145deg, var(--surface-color), rgba(56, 189, 248, 0.05));
    box-shadow: var(--shadow-lg);
}

.preview-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.8rem;
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-dot {
    color: var(--success-color);
}

.status-dot::before {
    content: "";
    width: 7px;
    height: 7px;
    display: inline-block;
    margin-right: 0.35rem;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.1);
}

.hero-preview ol {
    list-style: none;
    display: grid;
    gap: 0.65rem;
}

.hero-preview li {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.85rem;
    border-radius: 12px;
    background: var(--surface-hover);
}

.hero-preview li > strong {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    flex: 0 0 34px;
    border-radius: 9px;
    color: var(--primary-color);
    background: rgba(56, 189, 248, 0.1);
}

.hero-preview li span,
.hero-preview li small {
    display: block;
}

.hero-preview li small {
    margin-top: 0.15rem;
    color: var(--text-muted);
}

.landing-section {
    scroll-margin-top: 1rem;
    margin-top: 5.5rem;
}

.section-heading {
    max-width: 750px;
    margin-bottom: 1.5rem;
}

.landing-section h2 {
    font-size: clamp(1.65rem, 3vw, 2.45rem);
    line-height: 1.12;
    letter-spacing: -0.035em;
}

.module-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.landing-module-card {
    min-height: 230px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
    padding: 1.4rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--surface-color);
}

.landing-module-card.featured {
    border-color: rgba(56, 189, 248, 0.55);
    box-shadow: inset 0 3px 0 var(--primary-color);
}

.landing-module-card.muted {
    opacity: 0.78;
}

.landing-module-card h3 {
    font-size: 1.12rem;
}

.landing-module-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.landing-module-card a {
    margin-top: auto;
    color: var(--primary-color);
    font-weight: 700;
    font-size: 0.86rem;
}

.module-state {
    padding: 0.28rem 0.55rem;
}

.module-state.ready {
    color: #064e3b;
    background: #6ee7b7;
}

.module-state.beta {
    color: #78350f;
    background: #fde68a;
}

.module-state.planned {
    color: var(--text-muted);
    background: var(--surface-hover);
}

.import-section {
    display: grid;
    grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.28fr);
    align-items: center;
    gap: clamp(1.5rem, 5vw, 4rem);
    padding: clamp(1.2rem, 4vw, 3rem);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: rgba(56, 189, 248, 0.04);
}

.import-copy > p,
.feedback-panel p {
    color: var(--text-muted);
    margin-top: 0.8rem;
}

.plain-check-list,
.plain-x-list {
    list-style: none;
    display: grid;
    gap: 0.5rem;
    margin-top: 1rem;
}

.plain-check-list li::before,
.plain-x-list li::before {
    display: inline-block;
    width: 1.35rem;
    font-weight: 800;
}

.plain-check-list li::before {
    content: "✓";
    color: var(--success-color);
}

.plain-x-list li::before {
    content: "–";
    color: var(--warning-color);
}

.empty-start-row {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.8rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.empty-start-row .btn {
    min-height: 40px;
}

.format-example {
    scroll-margin-top: 1rem;
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--surface-color);
    overflow: hidden;
}

.format-example summary {
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.85rem 1rem;
    cursor: pointer;
    color: var(--primary-color);
    font-weight: 700;
}

.format-example-body {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(230px, 0.8fr);
    gap: 1.2rem;
    padding: 0 1rem 1rem;
    color: var(--text-muted);
    font-size: 0.86rem;
}

.format-example pre {
    overflow-x: auto;
    margin-top: 0.7rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    background: #07111f;
    color: #bae6fd;
    border: 1px solid var(--border-color);
}

.format-example ul {
    padding-left: 1.2rem;
    align-self: center;
}

.transparency-panel {
    padding: clamp(1.2rem, 4vw, 2.5rem);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--surface-color);
}

.transparency-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2rem;
    margin-top: 1.5rem;
}

.transparency-columns h3 {
    font-size: 0.95rem;
}

.beta-disclaimer {
    margin-top: 1.5rem;
    padding: 1rem;
    border-left: 4px solid var(--warning-color);
    border-radius: var(--radius-md);
    background: rgba(245, 158, 11, 0.09);
    color: var(--text-muted);
    font-size: 0.84rem;
}

.feedback-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: clamp(1.2rem, 4vw, 2rem);
    border-radius: 20px;
    color: var(--text-main);
    background: linear-gradient(125deg, rgba(56, 189, 248, 0.14), rgba(163, 230, 53, 0.07));
    border: 1px solid rgba(56, 189, 248, 0.28);
}

.feedback-panel > div {
    max-width: 760px;
}

.feedback-panel .btn {
    flex: 0 0 auto;
}

.landing-footer {
    width: min(1180px, calc(100% - 3rem));
    min-height: 80px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
}

.drop-zone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    padding: 3rem 2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #f8fafc;
}

.privacy-note {
    margin-top: 1rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid rgba(45, 212, 191, 0.35);
    border-left: 3px solid var(--secondary-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    background: rgba(45, 212, 191, 0.06);
    font-size: 0.78rem;
    line-height: 1.5;
}

.privacy-note strong {
    color: var(--text-main);
}

[data-theme="dark"] .drop-zone {
    background-color: rgba(15, 23, 42, 0.48);
    border-color: #475569;
}

@media (max-width: 820px) {
    .landing-header,
    .landing-main,
    .landing-footer {
        width: min(100% - 1.5rem, 1180px);
    }

    .landing-header {
        min-height: 64px;
    }

    .landing-links {
        display: none;
    }

    .landing-main {
        padding-top: 2.2rem;
    }

    .landing-hero,
    .import-section,
    .format-example-body,
    .transparency-columns {
        grid-template-columns: 1fr;
    }

    .landing-hero {
        min-height: auto;
    }

    .hero-preview {
        margin-top: 0.5rem;
    }

    .module-card-grid {
        grid-template-columns: 1fr;
    }

    .landing-module-card {
        min-height: 190px;
    }

    .feedback-panel,
    .landing-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .feedback-panel .btn {
        width: 100%;
    }

    .landing-footer {
        justify-content: center;
        padding: 1.2rem 0;
    }
}

@media (max-width: 480px) {
    .landing-brand > span:nth-child(2) {
        font-size: 0.9rem;
    }

    .landing-hero h1 {
        font-size: 2.25rem;
    }

    .landing-actions,
    .landing-actions .btn {
        width: 100%;
    }

    .landing-section {
        margin-top: 3.5rem;
    }

    .import-section,
    .transparency-panel {
        padding: 1rem;
        border-radius: 14px;
    }

    .upload-container {
        padding: 0.75rem;
    }

    .drop-zone {
        padding: 2rem 1rem;
    }
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--secondary-color);
    background-color: rgba(0, 180, 230, 0.05);
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: #94a3b8;
    margin-bottom: 1rem;
    transition: color 0.2s ease;
}

.drop-zone:hover .upload-icon, .drop-zone.dragover .upload-icon {
    color: var(--secondary-color);
}

.drop-zone h2 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.drop-zone p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 91, 130, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 2rem auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#upload-status {
    font-weight: 500;
    color: var(--primary-color);
}

/* ==========================================
   DASHBOARD SCREEN
   ========================================== */
#dashboard-screen {
    display: flex;
    flex-direction: row;
    height: 100vh;
    overflow: hidden;
}

.dashboard-header {
    background-color: var(--surface-color);
    height: 70px;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--primary-color);
}

.brand svg {
    width: 28px;
    height: 28px;
    color: var(--secondary-color);
}

.header-center {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex: 1;
    justify-content: center;
}

.zoom-controls {
    display: flex;
    gap: 0;
    background-color: var(--bg-color);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    width: 100%;
    box-sizing: border-box;
}

[data-theme="dark"] .zoom-controls {
    background-color: rgba(0, 0, 0, 0.2);
}

.btn-zoom {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.4rem 0.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    position: relative;
}

.btn-zoom:hover {
    color: var(--primary-color);
}

.btn-zoom.active {
    background-color: var(--surface-color);
    color: var(--secondary-color);
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .btn-zoom.active {
    background-color: var(--surface-hover);
}

/* Subtle vertical dividers for segmented controls */
.btn-zoom:not(:first-child)::before,
.btn-comp:not(:first-child)::before {
    content: '';
    position: absolute;
    left: 0;
    top: 25%;
    height: 50%;
    width: 1px;
    background-color: var(--border-color);
    opacity: 0.55;
    transition: opacity 0.15s ease;
}

/* Hide divider if button itself is active or hovered */
.btn-zoom.active::before,
.btn-comp.active::before,
.btn-zoom:hover::before,
.btn-comp:hover::before {
    opacity: 0;
}

/* Hide divider on next sibling if current button is active or hovered */
.btn-zoom.active + .btn-zoom::before,
.btn-comp.active + .btn-comp::before,
.btn-zoom:hover + .btn-zoom::before,
.btn-comp:hover + .btn-comp::before {
    opacity: 0;
}



.date-nav-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-nav {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-nav:hover {
    background-color: var(--surface-hover);
    color: var(--primary-color);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.file-badge {
    background-color: rgba(0, 180, 230, 0.05);
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 600;
    border: 1px solid rgba(0, 180, 230, 0.25);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

[data-theme="dark"] .file-badge {
    background-color: rgba(0, 180, 230, 0.12);
    color: var(--primary-color);
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 0.9rem;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0 !important;
    border-radius: var(--radius-md);
    background-color: var(--surface-color);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background-color: var(--surface-hover);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

[data-theme="dark"] .btn-icon {
    background-color: var(--surface-color);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.btn-secondary {
    background-color: var(--surface-color);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--surface-hover);
    color: var(--text-color);
    border-color: var(--text-color);
}

[data-theme="dark"] .btn-secondary {
    background-color: var(--surface-color);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .btn-secondary:hover {
    background-color: var(--surface-hover);
    color: var(--text-color);
    border-color: var(--text-color);
}

.btn-primary {
    background-color: var(--primary-color);
    color: #ffffff !important;
    border: 1px solid var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #ffffff !important;
}

[data-theme="dark"] .btn-primary {
    background-color: var(--primary-color);
    color: #0f172a !important; /* Dark text on bright blue background in dark mode */
    border: 1px solid var(--primary-color);
}

[data-theme="dark"] .btn-primary:hover {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: #0f172a !important;
}

.dashboard-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 70px);
    position: relative;
}

/* Sidebar */
.sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 60px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    padding: 35px 0 0.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    white-space: nowrap;
    box-sizing: border-box;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
}

.sidebar:hover,
.sidebar.expanded {
    width: 300px;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.08);
    gap: 0.65rem;
}

[data-theme="dark"] .sidebar:hover,
[data-theme="dark"] .sidebar.expanded {
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
}

.filter-section {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.4rem;
    box-sizing: border-box;
    width: 100%;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar:hover .filter-section,
.sidebar.expanded .filter-section {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    margin: 0 0.5rem;
    width: calc(100% - 1.0rem);
}

.sidebar .section-content {
    padding: 0.25rem 0 0 0 !important;
}

.sidebar .checkbox-group {
    padding: 0.25rem 0 !important;
}

.section-header {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    width: 100%;
}

.sidebar-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-left: 12px;
    margin-right: 16px;
    color: var(--text-muted);
    transition: color 0.2s;
}

.tab-btn:hover .sidebar-icon,
.tab-btn.active .sidebar-icon {
    color: var(--primary-color);
}

.section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 700;
    color: var(--text-muted);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sidebar:hover .section-title,
.sidebar.expanded .section-title {
    opacity: 1;
    visibility: visible;
}

.section-content {
    opacity: 0;
    visibility: hidden;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.2s ease, max-height 0.3s ease, visibility 0.2s ease;
    padding: 0 0.75rem;
    width: 100%;
    box-sizing: border-box;
}

.sidebar:hover .section-content,
.sidebar.expanded .section-content {
    opacity: 1;
    visibility: visible;
    max-height: 400px;
}

.input-field {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    background-color: var(--surface-color);
    color: var(--text-main);
}

.input-field:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(0, 180, 230, 0.1);
}

[data-theme="dark"] .input-field {
    color-scheme: dark;
}

.date-inputs {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.date-inputs span {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.date-field {
    min-width: 140px;
    width: auto;
    padding: 0.4rem 0.6rem;
}

/* Sidebar Compact Date Nav Controls overrides */
.sidebar .date-inputs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.sidebar .date-inputs-row .date-field {
    min-width: 0 !important;
    width: calc(50% - 10px) !important;
    padding: 0.4rem 0.4rem !important;
    font-size: 0.8rem !important;
    text-align: center !important;
    height: 34px !important;
    box-sizing: border-box !important;
}

.sidebar .date-separator {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.sidebar .date-nav-row {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 0.5rem;
}

.sidebar .date-nav-row .btn-nav {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 38px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar .date-nav-row .btn-nav:hover {
    border-color: var(--secondary-color);
    color: var(--secondary-color);
    background-color: var(--surface-hover);
}

/* Header navigation tabs */
.header-tabs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 100%;
}

.header-tabs .tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem !important;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.85rem !important;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    height: 38px;
    box-sizing: border-box;
    margin: 0 !important;
    width: auto !important;
}

.header-tabs .tab-btn:hover {
    background-color: var(--surface-hover);
    color: var(--text-main);
}

.header-tabs .tab-btn.active {
    background-color: rgba(0, 180, 230, 0.08);
    color: var(--secondary-color);
    font-weight: 600;
}

.header-tabs .tab-btn.active::before {
    display: none !important; /* Hide sidebar active line indicator */
}

.header-tabs .tab-icon {
    width: 16px;
    height: 16px;
    color: inherit;
}

.tabs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
    width: 100%;
}

.tab-btn {
    display: flex;
    align-items: center;
    padding: 0.8rem 0;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: calc(100% - 1rem);
    margin: 0 0.5rem;
    box-sizing: border-box;
    position: relative;
}

.tab-btn:hover {
    background-color: var(--surface-hover);
    color: var(--primary-color);
}

.tab-btn.active {
    background-color: rgba(0, 180, 230, 0.06);
    color: var(--secondary-color);
}

[data-theme="dark"] .tab-btn.active {
    background-color: rgba(0, 180, 230, 0.12);
    color: var(--secondary-color);
}

.tab-btn.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 3px;
    background-color: var(--secondary-color);
    border-radius: 0 3px 3px 0;
}

.tab-text {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sidebar:hover .tab-text,
.sidebar.expanded .tab-text {
    opacity: 1;
    visibility: visible;
}

/* Sidebar Toggle Button */
.btn-sidebar-toggle {
    position: absolute;
    top: 8px;
    right: 18px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s, opacity 0.2s, visibility 0.2s;
    z-index: 110;
    opacity: 0;
    visibility: hidden;
}

.sidebar:hover .btn-sidebar-toggle,
.sidebar.expanded .btn-sidebar-toggle {
    opacity: 1;
    visibility: visible;
}

/* Sidebar Toggle Pin Icon Animation */
.btn-sidebar-toggle svg {
    transform: rotate(45deg);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.expanded .btn-sidebar-toggle svg {
    transform: rotate(0deg);
}

.btn-sidebar-toggle:hover {
    background-color: var(--border-color) !important;
    color: var(--text-color) !important;
}

/* Main Content */
.dashboard-content {
    flex: 1;
    margin-left: 60px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-color);
    min-height: 0;
}

.tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.tab-content.active {
    display: flex;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.kpi-card {
    background-color: var(--bg-color);
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--secondary-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.kpi-card:hover {
    background-color: var(--surface-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.chart-card .kpi-card {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--secondary-color);
}

.kpi-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.kpi-value .unit {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
}

.kpi-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.chart-card {
    background-color: var(--surface-color);
    padding: 1.2rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chart-title {
    font-size: 1.05rem;
    color: var(--primary-color);
    margin: 0;
    font-weight: 700;
    flex-shrink: 0;
    line-height: 1.25;
}

.chart-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
    gap: 0.75rem;
    flex-shrink: 0;
    width: 100%;
}

.chart-heading {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 0 1 auto;
    min-width: 220px;
}

.chart-context {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.aggregation-badge {
    background-color: var(--surface-hover);
    border: 1px solid var(--border-color);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--secondary-color);
    display: inline-flex;
    align-items: center;
}

.chart-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sub-text {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    width: 100%;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.5rem 1rem;
    background-color: var(--surface-hover);
    border-radius: var(--radius-md);
    width: fit-content;
}

[data-theme="dark"] .filter-row {
    background-color: rgba(255, 255, 255, 0.03);
}

.filter-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    min-width: 110px;
}

.filter-row label {
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.25rem 0.75rem;
    box-sizing: border-box;
}

.checkbox-group-row {
    flex-direction: row;
    justify-content: flex-start;
    gap: 1rem;
    flex-wrap: nowrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input {
    cursor: pointer;
    width: 15px;
    height: 15px;
    accent-color: var(--secondary-color);
}

.metric-swatch {
    display: inline-block;
    width: 16px;
    border-top: 2px solid currentColor;
    margin-right: 2px;
    flex-shrink: 0;
    opacity: 0.8;
}

.metric-swatch-dashed {
    border-top-style: dashed;
}

.metric-swatch-dotted {
    border-top-style: dotted;
}

/* Data Table */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    text-align: left;
    padding: 1rem;
    background-color: var(--surface-hover);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.data-table th:first-child,
.data-table td:first-child,
#pivot-table th:first-child,
#pivot-table td:first-child {
    max-width: 220px !important;
    min-width: 140px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* Rotated 45° Table Headers for Pivot Matrix */
.table-header-rotated {
    height: 75px;
    vertical-align: bottom;
}

.table-header-rotated th.th-rotated {
    height: 75px;
    position: relative;
    vertical-align: bottom;
    padding: 0 0.5rem 0.5rem 0.5rem;
    white-space: nowrap;
}

.table-header-rotated th.th-rotated > div {
    transform: translate(0px, 0px) rotate(-45deg);
    transform-origin: bottom left;
    width: 30px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-main);
    display: inline-block;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background-color: var(--surface-color);
    color: var(--text-main);
    border-left: 4px solid var(--secondary-color);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    font-weight: 500;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
    max-width: 400px;
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.3s ease;
    border: 1px solid var(--border-color);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-success {
    border-left-color: #22c55e;
}

.toast-error {
    border-left-color: #ef4444;
}

.toast-warning {
    border-left-color: #f59e0b;
}

.toast-info {
    border-left-color: var(--secondary-color);
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

.data-table tbody tr:hover {
    background-color: var(--surface-hover);
}

#peaks-table tbody tr:first-child td {
    font-weight: 600;
    color: #ef4444; /* Highlight top 1 */
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-layout {
        flex-direction: column;
        overflow: auto;
        height: auto;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
    }
    
    .tabs {
        flex-direction: row;
        overflow-x: auto;
        margin-top: 1rem;
    }
    
    .tab-btn {
        white-space: nowrap;
    }
    
    .tab-btn.active::before {
        left: 10%;
        top: auto;
        bottom: 0;
        height: 3px;
        width: 80%;
        border-radius: 3px 3px 0 0;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Custom Chart Header and Actions (Priority 2) */
.chart-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chart-header-row .chart-title {
    margin-bottom: 0;
}

.chart-heading {
    min-width: 0;
}

.chart-context {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.3rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.aggregation-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.45rem;
    padding: 0.08rem 0.5rem;
    border: 1px solid color-mix(in srgb, var(--primary-color) 55%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary-color) 12%, transparent);
    color: var(--primary-color);
    font-weight: 600;
    white-space: nowrap;
}

@media (max-width: 620px) {
    .chart-header-row {
        align-items: flex-start;
    }

    .chart-actions {
        width: 100%;
    }
}

.chart-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    height: 32px;
}

.btn-sm svg {
    flex-shrink: 0;
}

/* Clickable Table Rows (Priority 2) */
#peaks-table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

#peaks-table tbody tr:hover {
    background-color: var(--surface-hover);
}

[data-theme="dark"] #peaks-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Multi-Lastgang Checkbox List (Priority 3 - Multi-Comparison) */
.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 180px;
    overflow-y: auto;
    padding: 0.3rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--surface-color);
    width: 100%;
    flex-shrink: 0;
}

.checkbox-list-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease;
    white-space: normal;
    word-break: break-all;
}

.checkbox-list-item:hover {
    background-color: var(--surface-hover);
}

.checkbox-list-item input {
    cursor: pointer;
    flex-shrink: 0;
}

/* Dynamic Sidebar Controls (Priority 3) */
#sidebar-verlauf-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
#sidebar-verlauf-controls.hidden {
    display: none !important;
}

#sidebar-profil-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
#sidebar-profil-controls.hidden {
    display: none !important;
}

.hidden {
    display: none !important;
}

.btn-comp {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.4rem 0.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    position: relative;
}

.btn-comp:hover {
    color: var(--text-main);
}

.btn-comp.active {
    background-color: var(--surface-color);
    color: var(--secondary-color);
    box-shadow: var(--shadow-sm);
}

.btn-dataset-select {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--surface-color);
    color: var(--text-main);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    text-align: left;
    gap: 0.4rem;
    box-sizing: border-box;
}

.btn-dataset-select:hover {
    background-color: var(--surface-hover);
    border-color: var(--primary-color);
}

.btn-dataset-select.active {
    background-color: rgba(0, 180, 230, 0.05);
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 1px var(--secondary-color);
}

[data-theme="dark"] .btn-dataset-select.active {
    background-color: rgba(0, 180, 230, 0.12);
}

.btn-dataset-select .dataset-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Highlight primary comparison mode segmented controls */
.btn-comp-mode.active {
    background-color: var(--primary-color) !important;
    color: var(--bg-color) !important;
    font-weight: 600 !important;
    box-shadow: var(--shadow-sm), 0 2px 8px rgba(0, 180, 230, 0.15) !important;
}

/* Sidebar Inline Edit styles */
.btn-dataset-select {
    position: relative;
    padding-right: 2.2rem !important; /* Make room for pencil edit button */
}

.btn-edit-dataset-name {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    padding: 0;
}

.btn-dataset-select:hover .btn-edit-dataset-name {
    opacity: 1;
}

.btn-edit-dataset-name:hover {
    color: var(--primary-color);
    background-color: var(--surface-hover);
}

.btn-dataset-edit-input {
    background-color: var(--surface-color);
    color: var(--text-main);
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.8rem;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
    height: 24px;
}

/* Sidebar Display Unit Segmented Toggle button styling */
.btn-unit-toggle {
    background-color: transparent;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-unit-toggle:hover {
    color: var(--text-main);
    background-color: var(--surface-hover);
}

.btn-unit-toggle.active {
    background-color: var(--primary-color) !important;
    color: var(--bg-color) !important;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* Modal Overlay & Dialog Card */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.25s ease;
}
.modal-overlay.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}
.modal-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 90%;
    max-width: 460px;
    box-shadow: var(--shadow-xl), 0 10px 30px rgba(0,0,0,0.3);
    animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}
.modal-desc {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 500;
    margin-bottom: 1rem;
    background-color: rgba(0, 180, 230, 0.08);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    display: inline-block;
}
.modal-info {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
    line-height: 1.4;
}
.modal-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Spreadsheet Grid Styles */
.spreadsheet-grid {
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.spreadsheet-grid th, .spreadsheet-grid td {
    border: 1px solid var(--border-color) !important;
    padding: 4px 6px !important;
    height: 30px;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.spreadsheet-grid th {
    background-color: var(--surface-hover);
    color: var(--text-main);
    font-weight: 600;
    text-align: left;
    position: relative;
    font-size: 0.8rem;
}
.spreadsheet-grid td {
    background-color: var(--surface-color);
    color: var(--text-main);
    user-select: none;
    cursor: cell;
    font-size: 0.8rem;
}
.spreadsheet-grid td.cell-center {
    text-align: center;
}
.spreadsheet-grid td.cell-right {
    text-align: right;
}
.spreadsheet-grid td.cell-readonly {
    background-color: rgba(30, 41, 59, 0.15);
    color: var(--text-muted);
    cursor: default;
}

/* Table Column Resizing */
.resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    cursor: col-resize;
    user-select: none;
    height: 100%;
    z-index: 10;
}
.resizer:hover, .resizer.resizing {
    background-color: var(--primary-color);
    opacity: 0.8;
}
[data-theme="dark"] .spreadsheet-grid td.cell-readonly {
    background-color: rgba(15, 23, 42, 0.35);
}
.spreadsheet-grid td.cell-selected {
    background-color: rgba(0, 180, 230, 0.18) !important;
}
.spreadsheet-grid td.cell-focused {
    background-color: rgba(0, 180, 230, 0.08) !important;
    box-shadow: inset 0 0 0 2px var(--primary-color) !important;
    outline: none;
}
.spreadsheet-grid td[contenteditable="true"] {
    user-select: text;
    cursor: text;
}
.spreadsheet-grid td[contenteditable="true"]:focus {
    box-shadow: inset 0 0 0 2px var(--accent-color) !important;
    outline: none;
    background-color: var(--bg-color) !important;
}

/* Editable Mode Banner styling */
.editor-status-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.25s ease;
}
.editor-status-banner.locked {
    background-color: rgba(100, 116, 139, 0.1);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}
.editor-status-banner.unlocked {
    background-color: rgba(0, 180, 230, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(0, 180, 230, 0.25);
}

/* --- Sidebar Filter Groups & Nesting (UX Improvement) --- */
.filter-group {
    background-color: rgba(15, 23, 42, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-group .group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.filter-group .group-badge {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 700;
    background-color: var(--surface-hover);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.25s ease;
}

/* Style when the group is the active comparison dimension */
.filter-group.is-comparison {
    background-color: rgba(0, 180, 230, 0.03);
    border-color: rgba(0, 180, 230, 0.25);
    box-shadow: 0 0 12px rgba(0, 180, 230, 0.05);
}

.filter-group.is-comparison .group-header {
    color: var(--primary-color);
}

.filter-group.is-comparison .group-badge {
    background-color: rgba(0, 180, 230, 0.15);
    color: var(--primary-color);
}

/* Premium Segmented compare-mode-selector */
.compare-mode-selector {
    background-color: rgba(15, 23, 42, 0.4) !important;
    border: 1px solid var(--border-color) !important;
    padding: 2px !important;
    border-radius: 8px !important;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2) !important;
}

.compare-mode-selector .btn-comp-mode {
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
}

.compare-mode-selector .btn-comp-mode:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.03) !important;
    color: var(--text-color) !important;
}

.compare-mode-selector .btn-comp-mode.active {
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3) !important;
}

/* AgNes 2029 specific styles */
#tab-agnes .kpi-card:nth-child(1) { border-left-color: #ef4444; } /* Red/Orange for Peak */
#tab-agnes .kpi-card:nth-child(2) { border-left-color: var(--primary-color); } /* Blue for K_opt */
#tab-agnes .kpi-card:nth-child(3) { border-left-color: #f59e0b; } /* Orange for 100% cost */
#tab-agnes .kpi-card:nth-child(4) { border-left-color: var(--secondary-color); } /* Light Blue for Opt cost */
#tab-agnes .kpi-card:nth-child(5) { border-left-color: var(--success-color); } /* Green for savings */

/* AgNes Print Layout */
@media print, body.printing-report {
    /* Force light theme variables during printing to maintain perfect contrast on white paper */
    :root, [data-theme="dark"] {
        --bg-color: #ffffff !important;
        --surface-color: #ffffff !important;
        --surface-hover: #f8fafc !important;
        --text-main: #212529 !important;
        --text-muted: #6c757d !important;
        --border-color: #cbd5e1 !important;
        --primary-color: #005B82 !important;
        --primary-dark: #004462 !important;
        --secondary-color: #00B4E6 !important;
        --success-color: #10b981 !important;
        --warning-color: #f59e0b !important;
    }

    /* Reset heights and layout boxes for printing */
    html, body {
        height: auto !important;
        overflow: visible !important;
        background: #ffffff !important;
        color: #212529 !important;
        /* Force color printing of background graphics */
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }
    
    .screen, 
    .dashboard-layout, 
    .dashboard-content {
        display: block !important;
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
        position: static !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Hide all elements that are NOT part of the AgNes tab */
    #upload-screen,
    .module-sidebar,
    .sidebar,
    .top-nav,
    .tab-nav,
    .toast-container,
    .modal,
    #tab-timeline,
    #tab-comparison,
    #tab-daily,
    #agnes-timeframe-warning,
    .btn, 
    button, 
    .btn-info,
    [onclick] {
        display: none !important;
    }
}

.print-only-audit-banner {
    display: none;
}

@media print {
    .print-only-audit-banner {
        display: block !important;
        width: 100% !important;
    }

    #tab-agnes {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
        position: static !important;
        padding: 10px !important;
        margin: 0 !important;
        background: #ffffff !important;
        /* Keep theme variables intact for colors */
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }
    
    #tab-agnes-content {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    #tab-agnes, #tab-agnes * {
        visibility: visible !important;
    }
    
    /* Stack charts vertically in print layout to prevent overflow and clipping */
    .comparison-grid {
        display: block !important;
        width: 100% !important;
    }
    
    .chart-card {
        border: 1px solid #cccccc !important;
        box-shadow: none !important;
        background: #ffffff !important;
        page-break-inside: avoid !important;
        padding: 15px !important;
        min-height: auto !important;
        height: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
        margin-bottom: 20px !important;
    }
    
    .kpi-strip {
        border: 1px solid #cccccc !important;
        box-shadow: none !important;
        background: #ffffff !important;
        margin-bottom: 10px !important;
        width: 100% !important;
    }
    
    .kpi-strip-item {
        background: #ffffff !important;
        border-top: 3px solid #cccccc !important;
    }
    
    .data-table th {
        background-color: #f1f5f9 !important;
        color: #0f172a !important;
        border-bottom: 2px solid #cbd5e1 !important;
    }
    
    .data-table td {
        border-bottom: 1px solid #e2e8f0 !important;
    }

    .data-table tr {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    
    /* Target ECharts canvas to not stretch past screen bounds on print */
    .chart-card div[_echarts_instance_],
    .chart-card div[_echarts_instance_] canvas {
        max-width: 100% !important;
    }
}

/* ==========================================
   PRIMARY VERTICAL MODULE SIDEBAR
   ========================================== */
.module-sidebar {
    width: 70px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 0;
    gap: 1.5rem;
    z-index: 150;
    flex-shrink: 0;
    box-sizing: border-box;
}

.module-logo {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.module-logo svg {
    width: 28px;
    height: 28px;
}

.module-nav {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    align-items: center;
}

.module-btn {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s ease;
    position: relative;
    padding: 0;
}

.module-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2px;
}

.module-btn span {
    font-size: 0.65rem;
    font-weight: 500;
}

.module-btn:hover {
    color: var(--text-color);
    background-color: var(--surface-hover);
}

.module-btn.active {
    color: var(--primary-color);
    background-color: rgba(30, 41, 59, 0.4);
}

[data-theme="dark"] .module-btn.active {
    background-color: rgba(30, 41, 59, 0.8);
}

.module-btn.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 15%;
    height: 70%;
    width: 3px;
    background-color: var(--primary-color);
    border-radius: 0 4px 4px 0;
}

.main-workspace {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100vh;
    overflow: hidden;
    min-width: 0; /* Prevents overflow in flex layouts */
}

.comparison-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 1200px) {
    .comparison-grid {
        grid-template-columns: 1fr;
    }
}

/* Mobile dashboard: filters become a horizontal card strip, modules a bottom bar. */
@media (max-width: 768px) {
    #dashboard-screen {
        display: block;
        height: 100vh;
        overflow: hidden;
        padding-bottom: 62px;
    }

    .module-sidebar {
        position: fixed;
        inset: auto 0 0 0;
        width: 100%;
        height: 62px;
        padding: 0;
        flex-direction: row;
        justify-content: center;
        border-right: none;
        border-top: 1px solid var(--border-color);
        z-index: 500;
    }

    .module-logo {
        display: none;
    }

    .module-nav {
        width: min(100%, 420px);
        height: 100%;
        flex-direction: row;
        justify-content: space-around;
        gap: 0;
    }

    .module-btn {
        width: 110px;
        height: 56px;
    }

    .module-btn.active::before {
        top: auto;
        bottom: -3px;
        left: 15%;
        width: 70%;
        height: 3px;
        border-radius: 4px 4px 0 0;
    }

    .main-workspace {
        width: 100%;
        height: calc(100vh - 62px);
        min-width: 0;
        overflow: hidden;
    }

    .dashboard-header {
        height: auto;
        min-height: 60px;
        padding: 0.45rem 0.65rem;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0.45rem;
    }

    .brand {
        gap: 0.45rem;
        min-width: 0;
    }

    .brand svg {
        width: 21px;
        height: 21px;
        flex: 0 0 auto;
    }

    .brand h2 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.95rem;
    }

    .header-actions {
        justify-self: end;
    }

    #btn-header-menu-toggle span {
        display: none;
    }

    #btn-header-menu-toggle {
        width: 36px;
        padding: 0 !important;
        justify-content: center;
    }

    .header-center {
        grid-column: 1 / -1;
        order: 3;
        width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
        scrollbar-width: thin;
    }

    .header-center,
    .sidebar,
    .sidebar:hover,
    .sidebar.expanded {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .header-center::-webkit-scrollbar,
    .sidebar::-webkit-scrollbar {
        display: none;
    }

    .header-tabs {
        width: max-content;
        min-width: 100%;
        justify-content: flex-start;
        padding-bottom: 0.2rem;
    }

    .header-tabs .tab-btn {
        flex: 0 0 auto;
        padding: 0.45rem 0.65rem !important;
        font-size: 0.76rem !important;
    }

    .dashboard-layout {
        height: calc(100vh - 112px);
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .sidebar,
    .sidebar:hover,
    .sidebar.expanded {
        position: relative;
        inset: auto;
        width: 100%;
        min-height: 185px;
        max-height: 210px;
        padding: 0.6rem;
        display: flex;
        flex-direction: row;
        align-items: stretch;
        gap: 0.6rem;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: normal;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        box-shadow: none;
    }

    .sidebar .filter-section,
    .sidebar:hover .filter-section,
    .sidebar.expanded .filter-section {
        width: 270px;
        min-width: 270px;
        height: fit-content;
        max-height: 190px;
        margin: 0;
        padding: 0.55rem;
        overflow-y: auto;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        background: var(--bg-color);
    }

    .sidebar .section-title,
    .sidebar:hover .section-title,
    .sidebar.expanded .section-title,
    .sidebar .section-content,
    .sidebar:hover .section-content,
    .sidebar.expanded .section-content {
        opacity: 1;
        visibility: visible;
    }

    .sidebar .section-content,
    .sidebar:hover .section-content,
    .sidebar.expanded .section-content {
        max-height: 150px;
        overflow: visible;
    }

    .sidebar-icon {
        margin-left: 0.15rem;
        margin-right: 0.65rem;
    }

    .btn-sidebar-toggle {
        display: none !important;
    }

    .dashboard-content {
        margin-left: 0;
        padding: 0.75rem;
        flex: 0 0 auto;
        width: 100%;
        min-height: 620px;
        overflow: visible;
    }

    .tab-content,
    .tab-content.active {
        width: 100%;
        min-width: 0;
        overflow: visible;
    }

    .chart-card,
    .kpi-strip,
    .comparison-grid,
    .table-container {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .chart-card {
        padding: 0.85rem;
    }

    #tab-editor .chart-card {
        overflow: visible !important;
        max-height: none !important;
        padding: 0.85rem !important;
    }

    #tab-editor .chart-card > div:first-child,
    #tab-editor .chart-card > div:first-child > div:last-child {
        width: 100%;
        min-width: 0;
        justify-content: flex-start !important;
    }

    .kpi-grid,
    .kpi-strip,
    .comparison-grid {
        grid-template-columns: 1fr !important;
    }

    .kpi-strip {
        display: grid;
    }

    .toast-container {
        right: 0.75rem;
        bottom: 74px;
        left: 0.75rem;
    }

    .toast {
        min-width: 0;
        max-width: none;
        width: 100%;
    }
}
