/* Theme */
:root {
    --bg: #eaf0f8;
    --surface: #ffffff;
    --text: #0f254d;
    --muted-text: #4b5874;
    --primary: #1f3c88;
    --primary-600: #1a2f6d;
    --accent: #4cc3d9;
    --border: #d9e2ef;
    --shadow-sm: 0 6px 18px rgba(15, 31, 61, 0.08);
    --shadow-md: 0 10px 28px rgba(15, 31, 61, 0.12);
    --shadow-lg: 0 18px 45px rgba(15, 31, 61, 0.16);
}

/* Reset and base styles */
body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(circle at 20% 20%, rgba(76, 195, 217, 0.12) 0, rgba(76, 195, 217, 0) 25%),
                radial-gradient(circle at 80% 10%, rgba(31, 60, 136, 0.12) 0, rgba(31, 60, 136, 0) 28%),
                linear-gradient(135deg, #eef3fb 0%, #e8eef9 50%, #f7f9fe 100%);
    height: 100%;
    color: var(--text);
    overflow-x: hidden;  /* Prevent horizontal scroll */
    overflow-y: auto; /* Ensure the whole page is scrollable */
}

/* Layout Container */
.container {
    display: flex;
    min-height: 100vh;
    height: 100%;
    max-width: 100vw;
    overflow: hidden;
}

.top-nav {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1.5rem;
    background: linear-gradient(135deg, #0f254d 0%, #1a3a7a 100%);
    color: #f5f8ff;
    box-shadow: 0 14px 28px rgba(15, 31, 61, 0.25);
    position: sticky;
    top: 0;
    z-index: 1100;
    box-sizing: border-box;
}

.top-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.nav-btn {
    background: rgba(255,255,255,0.12);
    color: #f7fbff;
    border: 1px solid rgba(255,255,255,0.18);
    padding: 0.55rem 0.9rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.nav-btn:hover {
    background: rgba(255,255,255,0.22);
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.18);
}
.dropdown-div{
    height: 200px;
    overflow: auto; /* scrolls both directions when needed */
    scroll-behavior: smooth;
}

/* Filter dropdown (Select Filter) */
.filter-dropdown {
    width: 100%;
    box-sizing: border-box;
    background: transparent;
    border: none;
    border-radius: 14px;
    box-shadow: none;
    padding: 0;
    max-height: none;
    overflow: hidden;
}
.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}
.filter-tab {
    flex: 1;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(17,31,61,0.08);
    background: #eef2fb;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.filter-tab.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
    color: #fff;
    box-shadow: 0 10px 20px rgba(15, 31, 61, 0.15);
    border-color: rgba(255,255,255,0.2);
}
.filter-tab:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.filter-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}
.filter-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.pill-button {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 8px 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}
.pill-button.secondary {
    background: #f2f4fa;
    color: var(--text);
    border: 1px solid rgba(17,31,61,0.08);
}
.pill-button:hover {
    box-shadow: var(--shadow-md);
}
.filter-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid rgba(17,31,61,0.05);
    background: #fff;
}
.filter-option:hover {
    background: #f5f7fb;
}
.filter-range {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.filter-range input[type="date"],
.filter-range input[type="number"] {
    padding: 8px 10px;
    border: 1px solid rgba(17,31,61,0.12);
    border-radius: 8px;
    font-size: 0.95rem;
}

/* Checklist dropdown list items */
.checklist-item {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
    border: #1a365d 1px solid;
    border-radius: 3px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: normal; /* Allow text to wrap */
}

/* Site Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
}

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

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
}

.brand-meta {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-weight: 600;
    letter-spacing: 0.2px;
}

.brand-tagline {
    font-size: 0.85rem;
    color: #5b6b7a;
}

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

.btn-link {
    background: transparent;
    color: var(--text);
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.85;
    transition: background-color 0.2s ease, opacity 0.2s ease;
}

.btn-link:hover {
    opacity: 1;
    background-color: rgba(26, 54, 93, 0.08);
}

/* Sidebar Styles */
aside {
    background: rgba(255, 255, 255, 0.9);
    height: 100%;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border-right: 1px solid rgba(17, 31, 61, 0.08);
    backdrop-filter: blur(10px);
    overflow-y: auto;
    flex-shrink: 0; /* Prevent sidebars from shrinking */
}

#sidebar-left,
#sidebar-right {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: var(--layout-sidebar, 240px);
    min-width: var(--layout-sidebar, 200px);
}

#sidebar-left {
    padding-top: 1rem;
    margin-top: 0.85rem;
}

.logo-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(31,60,136,0.12), rgba(76,195,217,0.08));
    border: 1px solid rgba(17,31,61,0.08);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}

.logo-card img {
    width: 44px;
    height: 44px;
    border-radius: 10px;
}

.logo-text span {
    display: block;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.02em;
}

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

#sidebar-left h2,
#sidebar-right h2 {
    margin-top: 0;
    font-size: 1.05rem;
    color: var(--text);
    letter-spacing: 0.4px;
    font-weight: 700;
}

#graph-options {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    background: rgba(255, 255, 255, 0.9);
    padding: 0.75rem;
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(17,31,61,0.06);
}

#graph-options button {
    text-align: left;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    letter-spacing: 0.01em;
}

/* Buttons */
button {
    display: block;
    width: 100%;
    padding: 0.85rem;
    margin-bottom: 0.85rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
    color: #ffffff;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

button:hover {
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary) 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
    background-color: #e9eef7;
}

hr {
    border: none;
    border-top: 1px solid #ecf0f1;
    margin: 1rem 0;
}

/* Checkbox and Radio Inputs */
label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

input[type="checkbox"],
input[type="radio"] {
    margin-right: 0.5rem;
    vertical-align: middle;
    accent-color: var(--primary);
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2.25rem;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll */
    min-width: 0; /* Allow flex item to shrink below content size */
    gap: 1.2rem;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
}

/* Header with Search Bar */
#header_class {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    align-items: stretch;
}

.workspace-toolbar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 1.25rem;
    background: rgba(255,255,255,0.58);
    border: 1px solid rgba(17,31,61,0.08);
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 12px rgba(15, 31, 61, 0.08);
    min-height: 52px;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: thin;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.32rem 0.7rem;
    border-radius: 10px;
    border: 1px solid rgba(17,31,61,0.12);
    background: #ffffff;
    color: var(--text);
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.85), 0 4px 10px rgba(15, 31, 61, 0.08);
    transition: transform 0.12s ease, box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
    min-width: 108px;
    height: 36px;
    font-size: 0.92rem;
}

.toolbar-btn:hover {
    background: #f6f8fd;
    border-color: rgba(31,60,136,0.22);
    box-shadow: 0 8px 14px rgba(15, 31, 61, 0.12);
    transform: translateY(-1px);
}

.toolbar-btn:active {
    transform: translateY(0);
    box-shadow: 0 6px 14px rgba(15, 31, 61, 0.1);
}

.toolbar-btn:focus-visible {
    outline: 2px solid rgba(31,60,136,0.35);
    outline-offset: 2px;
}

.toolbar-btn.is-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #264b9d 100%);
    color: #f7fbff;
    border-color: rgba(255,255,255,0.3);
    box-shadow: 0 8px 16px rgba(31, 60, 136, 0.22);
}

.toolbar-btn.is-primary:hover {
    border-color: rgba(255,255,255,0.42);
    box-shadow: 0 12px 22px rgba(31, 60, 136, 0.28);
}

.toolbar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: var(--primary);
}

.toolbar-btn.is-primary .toolbar-icon {
    color: #f7fbff;
}

.toolbar-icon svg {
    width: 16px;
    height: 16px;
}

.content-header {
    margin-bottom: 0.5rem;
}
.content-header {
    margin-bottom: 0.5rem;
}

.search-hero {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    width: 100%;
}

.search-meta-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--muted-text);
    font-size: 0.95rem;
}

.search-pill {
    background: linear-gradient(135deg, rgba(31,60,136,0.14), rgba(76,195,217,0.2));
    color: var(--primary-600);
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: var(--shadow-sm);
}

.search-subtitle {
    color: #5b6b7a;
}

.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.45rem 0.65rem;
    border-radius: 18px;
    background: #f0f4ff;
    border: 1px solid rgba(17,31,61,0.08);
    box-shadow: 0 18px 42px rgba(15, 31, 61, 0.16);
    min-height: 64px;
}

.search-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(31,60,136,0.14), rgba(76,195,217,0.22));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    border: 1px solid rgba(17,31,61,0.06);
    box-shadow: var(--shadow-sm);
}

#search-bar,
.search-input {
    flex: 1;
    width: 100%;
    border: 1px solid rgba(17,31,61,0.08);
    border-radius: 14px;
    padding: 0 3.4rem 0 1rem;
    height: 52px;
    font-size: 1.05rem;
    color: var(--text);
    background: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.85);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#search-bar::placeholder,
.search-input::placeholder {
    color: #7b8699;
}

#search-bar:focus,
.search-input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(31, 60, 136, 0.12);
}

.search-input-action {
    width: 46px;
    height: 44px;
    border: 1px solid rgba(17,31,61,0.08);
    border-radius: 12px;
    background: linear-gradient(135deg, #8fb2ff 0%, #7696ff 45%, #5c7af5 100%);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 28px rgba(87, 115, 245, 0.32);
    transition: transform 0.12s ease, box-shadow 0.2s ease;
    padding: 0;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.search-input-action svg {
    width: 20px;
    height: 20px;
}

.search-input-action:hover {
    transform: translateY(-50%);
    box-shadow: 0 16px 36px rgba(87, 115, 245, 0.48);
}

.search-status,
.dashboard-search #ai-search-output {
    display: block;
    margin-top: 0.2rem;
    color: #4b5874;
    font-size: 0.95rem;
}

#search-results {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto 0.5rem;
    padding-top: 0.5rem;
}

#search-results.results {
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(135deg, #0f254d 0%, #152f63 45%, #1c3b7a 100%);
    color: #eef3ff;
    padding: 1.25rem 1.4rem;
}

.results-header {
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #f5f8ff;
}

.results-list {
    margin-top: 1.2rem;
    display: grid;
    gap: 1rem;
}

.result-item {
    border-radius: 14px;
    padding: 1rem 1.2rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 12px 28px rgba(0,0,0,0.18);
    transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.result-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(0,0,0,0.22);
    border-color: rgba(255,255,255,0.18);
}

.result-name {
    color: #f8fbff;
    font-weight: 700;
}

.result-id,
.result-meta,
.result-desc {
    color: rgba(235, 241, 249, 0.85);
}

.result-link {
    color: #dfe8ff;
    font-weight: 700;
}

.result-link.select-dataset-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(31,60,136,0.25);
    background: rgba(31,60,136,0.08);
    color: var(--primary);
    text-decoration: none;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
    transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.result-link.select-dataset-link:hover {
    background: rgba(31,60,136,0.16);
    border-color: rgba(31,60,136,0.45);
    color: var(--primary-600);
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(15, 31, 61, 0.14);
}

.columns-chip,
.column-chip {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: #f8fbff;
}

/* Main Graph Container */
.card,
#main-graph {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(17,31,61,0.06);
    margin-bottom: 1.5rem;
    border-radius: 18px;
    overflow: hidden; /* Prevent content from overflowing */
    min-height: 580px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#mainChart {
    width: 100%;
    min-height: 520px;
    height: 520px;
    overflow: hidden; /* Prevent SVG overflow */
    background: linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%);
    border-radius: 16px;
    border: 1px solid rgba(17,31,61,0.05);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.85);
    position: relative;
}

#mainChart svg {
    max-width: 100%;
    height: auto;
}

/* Open Graphs Preview Section */
#open-graphs {
    display: none; /* hidden (no longer needed) */
}

.graph-preview {
    background: linear-gradient(180deg, #ffffff 0%, #f7f9fb 100%);
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border-radius: 12px;
    flex: 1;
    max-width: 200px;
    min-width: 150px; /* Minimum width for readability */
    border: 1px solid rgba(17,31,61,0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.graph-preview p {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--muted-text);
}

/* Arrows */
.arrow {
    background: #eef2fb;
    border: 1px solid rgba(17,31,61,0.06);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 1.35rem;
    color: var(--primary);
    cursor: pointer;
    transition: color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
    box-shadow: var(--shadow-sm);
}

.arrow:hover {
    color: var(--primary-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Sidebar info buttons */
/* Removed sidebar info button styles (buttons moved to top nav) */

/* Dropdown Styles */
#dropdown,
#dataset-selection-dropdown-div,
#graph-type-dropdown-div {
    display: none;
    position: absolute;
    background-color: var(--surface);
    border: 1px solid var(--border);
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    border-radius: 6px;
    width: 30%; /* Fixed width at 30% of the parent container */
    word-wrap: break-word; /* Ensure text wraps within the dropdown */
    max-width: 300px; /* Optional: Set a maximum width */
    min-width: 200px; /* Optional: Set a minimum width */
    max-height: 300px; /* Set maximum height for dropdown */
    overflow-y: auto; /* Enable vertical scrolling for dropdown */
}

#dropdown ul,
#dataset-list,
#graph-type-dropdown {
    list-style: none;
    margin: 0;
    padding: 0;
}

#dropdown li,
#dataset-list li,
#graph-type-dropdown li {
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: normal; /* Allow text to wrap */
}

#dropdown li:hover,
#dataset-list li:hover,
#graph-type-dropdown li:hover {
    background-color: #f0f4f8;
}

/* Color selection dropdown */
/* Dropdown container (e.g., #graph-color-dropdown-div) */
#graph-color-dropdown-div,
#graph-type-dropdown-div {
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 8px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    z-index: 100;
    min-width: 180px;
    margin-top: 30px;
}

/* Color dropdown <ul> */
#graph-color-dropdown {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Graph type dropdown <ul> */
#graph-type-dropdown {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Color dropdown <li> */
.color-dropdown-item {
    cursor: pointer;
    padding: 0;
    border: none;
    background: none;
    margin: 0;
}

/* Graph type dropdown <li> */
.graph-type-dropdown-item {
    cursor: pointer;
    padding: 8px 12px;
    border: none;
    background: none;
    margin: 0;
    transition: background-color 0.2s ease;
}

.graph-type-dropdown-item:hover {
    background-color: #f0f4f8;
}

/* Color square */
.color-dropdown-square {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-radius: 4px;
    transition: border .15s;
    vertical-align: middle;
}

/* Hover effect */
.color-dropdown-item:hover .color-dropdown-square {
    border: 2px solid #555;
}

/* Data selection dropdowns */
#column-selection-dropdown-div,
#row-selection-dropdown-div {
    position: absolute;
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 8px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    z-index: 100;
    min-width: 250px;
    max-width: 300px;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 5px;
}

#column-selection-list,
#row-selection-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.data-selection-item {
    cursor: pointer;
    padding: 6px 8px;
    border: none;
    background: none;
    margin: 0;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.data-selection-item:hover:not(.disabled) {
    background-color: #f0f4f8;
}

.data-selection-item.disabled {
    cursor: not-allowed;
    color: #a0aec0;
    font-style: italic;
}

.data-selection-item.select-all-item {
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 4px;
    padding-bottom: 8px;
}

.data-selection-separator {
    padding: 0;
    margin: 4px 0;
}

.data-selection-separator hr {
    margin: 0;
    border: none;
    border-top: 1px solid #e2e8f0;
}

.data-selection-item input[type="checkbox"] {
    margin: 0;
    accent-color: #1a365d;
}

.data-selection-item label {
    margin: 0;
    cursor: pointer;
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.2;
}

/* Column color selector styles */
.data-selection-item.column-with-color,
.checkbox-container,
.column-color-selector,
.color-preview-square,
.column-color-dropdown,
.column-color-grid,
.column-color-option .color-square,
.column-color-reset {
    /* Remove these old styles */
}

/* New Column Color Selection Styles */
#column-color-dropdown-div {
    position: absolute;
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 12px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    z-index: 100;
    min-width: 400px;
    max-width: 500px;
    max-height: 350px;
    overflow-y: auto;
    margin-top: 5px;
}

#column-color-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.column-color-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 8px;
    border-bottom: 1px solid #f0f2f5;
    gap: 16px;
}

.column-color-item:last-child {
    border-bottom: none;
}

.column-color-item.disabled {
    cursor: not-allowed;
    color: #a0aec0;
    font-style: italic;
    justify-content: center;
}

.column-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.column-name {
    font-weight: 500;
    color: #2d3748;
    min-width: 100px;
}

.current-color-preview {
    width: 24px;
    height: 24px;
    border: 2px solid #e2e8f0;
    border-radius: 4px;
    display: inline-block;
}

.color-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inline-color-selector {
    display: flex;
    gap: 4px;
    align-items: center;
}

.color-option {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-radius: 3px;
    cursor: pointer;
    display: inline-block;
    transition: transform 0.1s ease, border-color 0.2s ease;
}

.color-option:hover {
    transform: scale(1.1);
    border-color: #1a365d;
}

.color-option.selected {
    border-color: #1a365d;
    box-shadow: 0 0 0 2px rgba(26, 54, 93, 0.2);
}

.reset-color-btn {
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    color: #6c757d;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.reset-color-btn:hover {
    background: #e9ecef;
    border-color: #ced4da;
    color: #495057;
}

/* Remove old styles that are no longer needed */
.column-color-option.reset-option {
    display: none;
}

/* File input styling */
#load-config-file {
    display: none !important;
}

/* New flyout panels for columns/filters */
.flyout-overlay {
    position: fixed;
    inset: 0;
    display: none;
    pointer-events: none;
    z-index: 1400;
}

.flyout-overlay.is-open {
    display: block;
    pointer-events: auto;
}

.flyout-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 31, 61, 0.7);
    backdrop-filter: blur(3px);
}

.flyout-panel {
    position: absolute;
    top: 70px;
    left: 280px;
    right: 28px;
    bottom: 0;
    transform: none;
    width: calc(100dvw - 280px - 28px);
    height: auto;
    max-height: none;
    max-width: calc(100dvw - 280px - 28px);
    box-sizing: border-box;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid rgba(17,31,61,0.08);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 22px 64px rgba(15, 31, 61, 0.26);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    overflow: hidden;
}

.flyout-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: space-between;
}

.flyout-title {
    font-weight: 700;
    color: var(--text);
}

.flyout-count {
    padding: 0.2rem 0.6rem;
    background: #eef2fb;
    border-radius: 999px;
    color: var(--primary-600);
    font-weight: 700;
    font-size: 0.9rem;
}

.flyout-close {
    border: none;
    background: #f1f4fb;
    color: var(--primary-600);
    font-size: 1.1rem;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    cursor: pointer;
}

.sheet-search input {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    border: 1px solid rgba(17,31,61,0.12);
    font-size: 0.95rem;
}

.flyout-list {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    padding: 0.25rem;
}

.flyout-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 0.35rem;
}

.flyout-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #6b7280;
    padding: 0.75rem;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.85rem 0.9rem;
    border-radius: 10px;
    border: 1px solid rgba(17,31,61,0.08);
    background: #fff;
    box-shadow: 0 6px 14px rgba(15, 31, 61, 0.08);
}

.filter-option {
    align-items: center;
    gap: 10px;
}

.column-color-input {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(17,31,61,0.18);
    border-radius: 8px;
    background: #fff;
    padding: 2px;
    cursor: pointer;
    margin-left: auto;
}

/* Applied filter bar */
#applied-filters-bar {
    width: 100%;
}

.applied-filter-bar {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(17,31,61,0.08);
    border-radius: 12px;
    background: #f8f9fc;
    box-shadow: var(--shadow-sm);
}

.applied-filter-header {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.applied-filter-title {
    font-weight: 700;
    color: var(--text);
}

.filter-toggle {
    white-space: nowrap;
}

.applied-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    flex: 1;
    min-width: 200px;
}

.applied-filter-hint {
    color: #607087;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    border: 1px solid rgba(17,31,61,0.12);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.chip-close {
    font-weight: 700;
}

.filter-clear-all {
    white-space: nowrap;
}

/* Responsive Design */
@media (max-width: 1280px) {
    .toolbar-btn {
        min-width: unset;
        padding: 0.28rem 0.55rem;
    }
}

@media (max-width: 1024px) {
    main {
        padding: 1rem;
    }

    #main-graph {
        padding: 1rem;
    }

    .workspace-toolbar {
        flex-wrap: wrap;
    }

    .toolbar-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
        overflow-x: visible;
    }

    .toolbar-btn {
        flex: 0 1 auto;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    #sidebar-left,
    #sidebar-right {
        width: 100%;
        min-width: unset;
        max-height: 200px;
        order: 2;
    }
    
    main {
        order: 1;
        padding: 0.5rem;
    }
    
    #open-graphs {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .graph-preview {
        flex: 1 1 calc(50% - 0.25rem);
        min-width: 120px;
    }

    .toolbar-btn {
        flex: 1 1 100%;
        width: 100%;
        justify-content: flex-start;
    }
}

/* Site Footer */
.site-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    color: #5b6b7a;
}

/* ═══════════════════════════════════════════════════════════════════════════
   DB-BODY OVERRIDES — neutralise legacy hardcoded chart heights when
   the new dashboard layout is active
   ═══════════════════════════════════════════════════════════════════════════ */

.db-body #mainChart {
    min-height: 0 !important;
    height: 100% !important;
}

.db-body #main-graph {
    min-height: 0 !important;
}
