:root {
    --bg-color: #030712;
    --card-bg: rgba(17, 24, 39, 0.45);
    --card-border: rgba(255, 255, 255, 0.06);
    --accent-color: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --text-color: #f3f4f6;
    --text-muted: #9ca3af;
    --success-color: #10b981;
    --success-glow: rgba(16, 185, 129, 0.15);
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
}

body.light-theme {
    --bg-color: #f3f4f6;
    --card-bg: rgba(255, 255, 255, 0.8);
    --card-border: rgba(0, 0, 0, 0.08);
    --accent-color: #2563eb;
    --accent-glow: rgba(37, 99, 235, 0.1);
    --accent-gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --success-color: #059669;
    --success-glow: rgba(5, 150, 105, 0.1);
    --warning-color: #d97706;
    --danger-color: #dc2626;
}

body.light-theme select,
body.light-theme select option,
body.light-theme input[type="text"],
body.light-theme input[type="password"],
body.light-theme input[type="number"],
body.light-theme .editor-input-price-row {
    background-color: rgba(0, 0, 0, 0.03) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    color: #1f2937 !important;
}

body.light-theme select option {
    background-color: #ffffff !important;
}

body.light-theme .dropzone {
    border-color: rgba(0, 0, 0, 0.12);
    background: rgba(0, 0, 0, 0.01);
}

body.light-theme .dropzone-icon {
    background: rgba(0, 0, 0, 0.03);
}

body.light-theme .distributor-tabs {
    border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}

body.light-theme .dist-tab-content {
    background: rgba(0, 0, 0, 0.02) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

body.light-theme .slider {
    background-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .slider:before {
    background-color: #ffffff;
}

body.light-theme .segmented-control {
    background-color: rgba(0, 0, 0, 0.05) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

body.light-theme code {
    background-color: rgba(0, 0, 0, 0.05) !important;
    color: #1f2937 !important;
}

body.light-theme #intro-card h3 svg,
body.light-theme #intro-card p strong,
body.light-theme #editor-form-title,
body.light-theme #tab-editor-content h3,
body.light-theme #tab-editor-content h4,
body.light-theme #tab-editor-content strong,
body.light-theme #tab-downloader-content h2,
body.light-theme #tab-downloader-content h3,
body.light-theme #tab-downloader-content h4,
body.light-theme #tab-downloader-content strong,
body.light-theme .dist-tab-content h4,
body.light-theme .dist-tab-content strong {
    color: #1f2937 !important;
}

html {
    overflow-x: clip;
    background-color: var(--bg-color);
}

body.light-theme .blob-1 {
    background: radial-gradient(circle, rgba(59, 130, 246, 0.4) 0%, rgba(29, 78, 216, 0.1) 70%);
}

body.light-theme .blob-2 {
    background: radial-gradient(circle, rgba(139, 92, 246, 0.4) 0%, rgba(109, 40, 217, 0.1) 70%);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    overflow-x: clip;
    position: relative;
    padding: 24px;
    max-width: 100vw;
}

/* Ambient animated blobs */
.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.3;
    pointer-events: none;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #3b82f6 0%, #1d4ed8 70%);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #8b5cf6 0%, #6d28d9 70%);
    bottom: -150px;
    right: -100px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Container & Layout */
.container {
    max-width: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
}

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

/* ── Mobile (≤640px) ─────────────────────────────────────── */
@media (max-width: 640px) {
    body {
        padding: 10px;
    }

    .blob-1, .blob-2 {
        width: 220px;
        height: 220px;
        filter: blur(70px);
    }

    /* Header: stack logo above buttons */
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px 14px;
        border-radius: 14px;
    }

    header > div:last-child {
        width: 100%;
        justify-content: flex-end;
    }

    .logo h1 {
        font-size: 14px;
        letter-spacing: -0.01em;
    }

    .logo p {
        display: none;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
    }

    /* Cards */
    .card {
        padding: 14px;
        border-radius: 14px;
    }

    .card h2 {
        font-size: 14px;
        margin-bottom: 14px;
    }

    /* KPI grid: 2 columns */
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .kpi-card {
        padding: 12px 10px;
        border-radius: 12px;
    }

    .kpi-value {
        font-size: 18px;
    }

    .kpi-title {
        font-size: 9px;
    }

    .kpi-desc {
        font-size: 10px;
    }

    /* Tabs: horizontal scroll, no wrap */
    .tabs {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        padding: 7px 11px;
        font-size: 12px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Chart area header: stack tabs above date nav */
    .card > div:first-child {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    /* Shorter charts on mobile */
    .chart-container {
        height: 280px;
    }

    /* Legend: auto height, wrap freely — no vertical scrollbar */
    .custom-chart-legend {
        height: auto;
        max-height: none;
        overflow: visible;
        gap: 5px;
        padding: 5px 8px;
    }

    .legend-item {
        font-size: 10px;
        padding: 3px 7px;
        gap: 5px;
    }

    /* Table */
    th, td {
        padding: 9px 10px;
        font-size: 12px;
    }

    .diagonal-split {
        width: 110px;
        min-width: 110px;
    }

    /* Touch-friendly switch rows */
    .switch-container {
        padding: 4px 0;
        min-height: 40px;
    }

    /* File meta in header: smaller */
    #file-meta {
        font-size: 11px;
    }
}

/* Header */
header {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(16px);
    border-radius: 20px;
    margin-bottom: 8px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.logo h1 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, var(--text-color), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo p {
    font-size: 11px;
    color: var(--text-muted);
}

/* Cards & Glassmorphism */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(16px);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    height: fit-content;
}

body.light-theme .card {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.card h2 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-color);
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 12px;
}

/* Dropzone styling */
.dropzone {
    border: 2px dashed rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 32px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    background: rgba(255, 255, 255, 0.01);
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.05);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.1);
}

.dropzone-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.25s;
}

.dropzone:hover .dropzone-icon {
    color: var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
    transform: translateY(-2px);
}

.dropzone p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.dropzone strong {
    color: var(--text-color);
    display: block;
    margin-bottom: 4px;
}

/* Config Controls / Forms */
.control-group {
    margin-bottom: 18px;
}

.control-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

select {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: var(--text-color);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
}

select option {
    color: #111827 !important;
    background-color: #ffffff !important;
}

select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-style: dashed;
}

/* Toggle Switches */
.switch-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.switch-label {
    font-size: 13px;
    color: var(--text-color);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-image: var(--accent-gradient);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Main content workspace */
.main-workspace {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    width: fit-content;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 8px 18px;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.25s ease;
}

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

.tab-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

body.light-theme .tab-btn.active {
    background: rgba(0, 0, 0, 0.05);
}

/* Chart Canvas Container */
.chart-container {
    position: relative;
    width: 100%;
    height: 650px;
    margin-top: 10px;
}

/* Comparison Table */
.table-wrapper {
    overflow-x: auto;
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--card-border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
    background: var(--card-bg);
}

th, td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--card-border);
}

th {
    background: rgba(255, 255, 255, 0.02);
    font-weight: 700;
    color: var(--text-color);
}

body.light-theme th {
    background: rgba(0, 0, 0, 0.02);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

body.light-theme tr:hover td {
    background: rgba(0, 0, 0, 0.01);
}

.crossed-out {
    text-decoration: line-through;
    color: var(--text-muted) !important;
    opacity: 0.5;
}

.badge {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-best {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-t1 {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent-color);
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.badge-t2 {
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent-color);
    border: 1px solid rgba(139, 92, 246, 0.25);
}

/* Warnings */
.warning-box {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: var(--warning-color);
    border-radius: 14px;
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 16px;
    display: none;
    align-items: center;
    gap: 10px;
}

/* Stats / KPI Widgets */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 8px;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kpi-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.kpi-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-color);
}

.kpi-desc {
    font-size: 11px;
    color: var(--text-muted);
}

.kpi-subtile {
    flex: 1;
    min-width: 130px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
}

body.light-theme .kpi-subtile {
    background: rgba(0, 0, 0, 0.015);
    border-color: rgba(0, 0, 0, 0.07);
}

.kpi-subtile-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.kpi-subtile-value {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-color);
}

/* Utility classes */
.hidden {
    display: none !important;
}

.active-row {
    background: rgba(59, 130, 246, 0.04) !important;
}

/* Used only for the savings KPI widget to signal positive / negative delta */
.green-text {
    color: var(--success-color);
}

.red-text {
    color: var(--danger-color);
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    color: var(--text-color);
}

.checkbox-item input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox-item input[type="checkbox"]:checked {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.checkbox-item input[type="checkbox"]:checked:after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Custom Chart Legend */
.custom-chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    padding: 8px 12px;
    height: 75px; /* Fixed height so the graph is always in the exact same place! */
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    margin-bottom: 12px;
    align-content: flex-start;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-color);
    padding: 4px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: all 0.2s ease;
    user-select: none;
}

.legend-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.12);
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Diagonal split cell for table matrix header */
.diagonal-split {
    position: relative;
    padding: 0 !important;
    background: linear-gradient(to bottom left, transparent calc(50% - 0.5px), rgba(255, 255, 255, 0.15) calc(50% - 0.5px), rgba(255, 255, 255, 0.15) calc(50% + 0.5px), transparent calc(50% + 0.5px)) !important;
    width: 170px;
    min-width: 170px;
}

body.light-theme .diagonal-split {
    background: linear-gradient(to bottom left, transparent calc(50% - 0.5px), rgba(0, 0, 0, 0.12) calc(50% - 0.5px), rgba(0, 0, 0, 0.12) calc(50% + 0.5px), transparent calc(50% + 0.5px)) !important;
}

.diagonal-split-container {
    position: relative;
    height: 50px;
    box-sizing: border-box;
}

.diagonal-split-bottom-left {
    position: absolute;
    bottom: 6px;
    left: 14px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

.diagonal-split-top-right {
    position: absolute;
    top: 6px;
    right: 14px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Tariff Editor Styles */
.tariff-list-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-muted);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.tariff-list-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

.tariff-list-item.active {
    background: rgba(59, 130, 246, 0.12);
    border-color: var(--accent-color);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.1);
}

.tariff-list-item .tariff-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
    color: var(--text-muted);
    text-transform: uppercase;
}

.tariff-list-item.active .tariff-badge {
    background: var(--accent-color);
    color: white;
}

body.light-theme .tariff-list-item {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .tariff-list-item:hover {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.12);
}

body.light-theme .tariff-list-item.active {
    background: rgba(37, 99, 235, 0.1);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

body.light-theme .tariff-list-item .tariff-badge {
    background: rgba(0, 0, 0, 0.06);
}

body.light-theme .tariff-list-item.active .tariff-badge {
    background: var(--accent-color);
    color: white;
}

.editor-form-pane input[type="text"],
.editor-form-pane input[type="number"],
.editor-form-pane select,
.editor-form-pane textarea {
    transition: all 0.2s ease;
}

.editor-form-pane input[type="text"]:focus,
.editor-form-pane input[type="number"]:focus,
.editor-form-pane select:focus,
.editor-form-pane textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: rgba(255,255,255,0.06);
}

.editor-input-price-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    padding: 8px 12px;
    border-radius: 8px;
}

/* Spinner Animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner-svg {
    animation: spin 0.8s linear infinite;
    display: inline-block;
}
#calc-spinner {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    background: rgba(30, 41, 59, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 8px 16px;
    border-radius: 30px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    transition: opacity 0.2s, transform 0.2s;
}
#calc-spinner.hidden {
    display: none !important;
}

/* Custom Flatpickr Styling */
.flatpickr-calendar {
    background: #111827 !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5) !important;
    border-radius: 12px !important;
    font-family: inherit !important;
}

.flatpickr-calendar:before, .flatpickr-calendar:after {
    border-bottom-color: #111827 !important;
}

.flatpickr-calendar.arrowTop:before {
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

.flatpickr-calendar.arrowBottom:before {
    border-top-color: rgba(255, 255, 255, 0.08) !important;
}
.flatpickr-calendar.arrowBottom:after {
    border-top-color: #111827 !important;
}

.flatpickr-months .flatpickr-month {
    background: transparent !important;
    color: #f3f4f6 !important;
}

.flatpickr-months .flatpickr-prev-month, 
.flatpickr-months .flatpickr-next-month {
    color: #9ca3af !important;
    fill: #9ca3af !important;
}

.flatpickr-months .flatpickr-prev-month:hover, 
.flatpickr-months .flatpickr-next-month:hover {
    color: #3b82f6 !important;
}

.flatpickr-current-month .numInputWrapper span.arrowUp:after {
    border-bottom-color: #f3f4f6 !important;
}
.flatpickr-current-month .numInputWrapper span.arrowDown:after {
    border-top-color: #f3f4f6 !important;
}

span.flatpickr-weekday {
    color: #9ca3af !important;
    font-weight: 600 !important;
}

.flatpickr-day {
    color: #f3f4f6 !important;
    border-radius: 8px !important;
}

.flatpickr-day.flatpickr-disabled, 
.flatpickr-day.flatpickr-disabled:hover {
    color: rgba(255, 255, 255, 0.15) !important;
    background: transparent !important;
}

.flatpickr-day:hover, 
.flatpickr-day.prevMonthDay:hover, 
.flatpickr-day.nextMonthDay:hover, 
.flatpickr-day.today:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: transparent !important;
    color: #ffffff !important;
}

.flatpickr-day.today {
    border-color: rgba(59, 130, 246, 0.4) !important;
    color: #3b82f6 !important;
}

.flatpickr-day.selected, 
.flatpickr-day.selected:focus, 
.flatpickr-day.selected:hover {
    background: var(--accent-gradient) !important;
    border-color: transparent !important;
    color: white !important;
    box-shadow: 0 2px 6px var(--accent-glow) !important;
}

.flatpickr-day.prevMonthDay, 
.flatpickr-day.nextMonthDay {
    color: rgba(255, 255, 255, 0.3) !important;
}

/* Light Theme overrides for Flatpickr */
body.light-theme .flatpickr-calendar {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1) !important;
}

body.light-theme .flatpickr-calendar:before, 
body.light-theme .flatpickr-calendar:after {
    border-bottom-color: #ffffff !important;
}

body.light-theme .flatpickr-calendar.arrowTop:before {
    border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}

body.light-theme .flatpickr-calendar.arrowBottom:before {
    border-top-color: rgba(0, 0, 0, 0.08) !important;
}
body.light-theme .flatpickr-calendar.arrowBottom:after {
    border-top-color: #ffffff !important;
}

body.light-theme .flatpickr-months .flatpickr-month {
    color: #1f2937 !important;
}

body.light-theme .flatpickr-months .flatpickr-prev-month, 
body.light-theme .flatpickr-months .flatpickr-next-month {
    color: #6b7280 !important;
    fill: #6b7280 !important;
}

body.light-theme .flatpickr-current-month .numInputWrapper span.arrowUp:after {
    border-bottom-color: #1f2937 !important;
}
body.light-theme .flatpickr-current-month .numInputWrapper span.arrowDown:after {
    border-top-color: #1f2937 !important;
}

body.light-theme span.flatpickr-weekday {
    color: #6b7280 !important;
}

body.light-theme .flatpickr-day {
    color: #1f2937 !important;
}

body.light-theme .flatpickr-day.flatpickr-disabled, 
body.light-theme .flatpickr-day.flatpickr-disabled:hover {
    color: rgba(0, 0, 0, 0.15) !important;
}

body.light-theme .flatpickr-day:hover, 
body.light-theme .flatpickr-day.prevMonthDay:hover, 
body.light-theme .flatpickr-day.nextMonthDay:hover, 
body.light-theme .flatpickr-day.today:hover {
    background: rgba(0, 0, 0, 0.03) !important;
    color: #000000 !important;
}

body.light-theme .flatpickr-day.today {
    border-color: rgba(37, 99, 235, 0.4) !important;
    color: #2563eb !important;
}

body.light-theme .flatpickr-day.prevMonthDay, 
body.light-theme .flatpickr-day.nextMonthDay {
    color: rgba(0, 0, 0, 0.3) !important;
}

.main-chart-card {
    min-height: 500px;
}

@media (min-width: 641px) {
    .main-chart-card {
        min-height: 850px;
    }
}

/* Structural layout on desktop */
@media (min-width: 1025px) {
    body {
        height: 100vh;
        overflow: hidden;
    }

    .container {
        height: 100%;
        min-height: 0;
        grid-template-rows: auto auto 1fr;
        overflow: hidden;
    }

    aside.main-workspace {
        height: 100%;
        overflow-y: auto;
        min-height: 0;
        padding-right: 4px;
    }

    main.main-workspace {
        height: 100%;
        overflow-y: auto;
        min-height: 0;
    }

    .main-chart-card {
        min-height: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

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

    .tab-content.hidden {
        display: none !important;
    }

    .chart-container {
        flex: 1;
        height: 100% !important;
        min-height: 350px;
    }
}

.sidebar-copyright {
    margin-top: auto;
    padding: 16px 0 8px 0;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    border-top: 1px solid var(--card-border);
}

.sidebar-copyright a {
    color: var(--text-color);
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s ease;
}

.sidebar-copyright a:hover {
    color: var(--accent-color, #3b82f6);
}

.editor-action-btn {
    width: 100%;
    padding: 8px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.editor-action-btn:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.15);
}

body.light-theme .editor-action-btn {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .editor-action-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.15);
}

.preset-date-btn:hover {
    background: var(--accent-gradient) !important;
    color: white !important;
    border-color: var(--accent-color) !important;
    box-shadow: 0 2px 6px var(--accent-glow);
}

body.light-theme .preset-date-btn {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--text-muted);
}

body.light-theme .preset-date-btn:hover {
    background: var(--accent-gradient) !important;
    color: white !important;
    border-color: var(--accent-color) !important;
    box-shadow: 0 2px 6px var(--accent-glow);
}

.preset-shift-btn:hover {
    background: var(--accent-gradient) !important;
    color: white !important;
}

body.light-theme .preset-shift-btn {
    color: var(--text-muted);
}

body.light-theme .preset-shift-btn:hover {
    background: var(--accent-gradient) !important;
    color: white !important;
}

