/* ===== ENHANCED REPORT BUILDER STYLES ===== */

/* Connection Picker Styles */
.connection-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.connection-picker select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    min-width: 0;
}

.connection-picker select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.connection-picker .btn-icon {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.connection-picker .btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

/* Field Palette Header Updates */
.palette-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.palette-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.palette-search {
    position: relative;
    display: flex;
    align-items: center;
}

.palette-search input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
}

.palette-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.palette-search svg {
    position: absolute;
    left: 12px;
    color: var(--text-tertiary);
    pointer-events: none;
}

/* Pivot Configuration Styles */
.pivot-config {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.pivot-config-header h5 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.pivot-field-selectors {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.pivot-field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pivot-field-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pivot-field-group select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
}

.pivot-field-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.pivot-options {
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.pivot-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.notice-icon {
    font-size: 16px;
}

.notice-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Report Builder Modal */
.report-builder-modal {
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 0;
    box-shadow: none;
    border: none;
    overflow: visible; /* Allow submenus to extend beyond modal */
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10001;
    pointer-events: all;
    display: flex;
    flex-direction: column;
    min-width: 1200px;
    min-height: 600px;
}

.report-builder-modal::-webkit-scrollbar {
    width: 8px;
}

.report-builder-modal::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.report-builder-modal::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.report-builder-modal::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.report-builder-container {
    display: grid;
    grid-template-columns: 350px 1fr; /* Match field palette width */
    gap: 0;
    height: calc(100vh - 120px);
    flex: 1;
    overflow: visible; /* Allow scrolling */
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

/* Field Palette (Left Sidebar) */
.field-palette {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    overflow-x: visible; /* Allow submenus to extend beyond boundaries */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
    width: 350px; /* Make it wider */
    min-width: 350px; /* Ensure minimum width */
    box-shadow: inset -1px 0 20px rgba(0, 0, 0, 0.3);
}

.palette-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(15px);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.palette-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    overflow-x: visible; /* Allow submenus to extend beyond boundaries */
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.palette-content::-webkit-scrollbar {
    width: 6px;
}

.palette-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.palette-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.palette-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.palette-header h3 {
    color: #ffffff;
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0 0 1rem 0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.025em;
    padding-top: 0.5rem; /* Add padding above the text */
}

.palette-search {
    position: relative;
}

.palette-search input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: #ffffff;
    font-size: 0.875rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.palette-search input:focus {
    outline: none;
    border-color: #1e3a8a;
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 4px 16px rgba(30, 58, 138, 0.3);
    transform: translateY(-1px);
}

.palette-search input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: #ffffff;
    font-size: 0.875rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.palette-search input:focus {
    outline: none;
    border-color: #1e3a8a;
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 4px 16px rgba(30, 58, 138, 0.3);
    transform: translateY(-1px);
}

.palette-search input::placeholder {
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

.palette-search svg {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
}

.field-categories {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.field-category {
    margin-bottom: 1rem;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.05);
}

.category-header:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(2px);
}

.category-toggle {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    transition: transform 0.2s ease;
    margin-left: 0.5rem;
}

.category-toggle.collapsed {
    transform: rotate(-90deg);
}

.category-header h4 {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.75rem;
    font-weight: 600;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-count {
    background: rgba(30, 58, 138, 0.2);
    color: #1e3a8a;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    font-size: 0.625rem;
    font-weight: 600;
}

.category-fields {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    margin-left: 0.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.field-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    background: rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
    min-height: 48px;
    position: relative; /* Ensure submenus can position relative to this */
    color: #f8fafc !important;
    border-left: 3px solid transparent;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    overflow: visible; /* Allow submenus to extend beyond field item */
    z-index: 1; /* Lower than submenus */
}

.field-item.has-submenu {
    z-index: 10005; /* Higher than regular field items */
}

.field-item.has-submenu:hover {
    z-index: 10006; /* Even higher on hover */
}

.field-item:hover {
    background: rgba(30, 58, 138, 0.25) !important;
    backdrop-filter: blur(15px);
    border-left-color: #1e3a8a;
    color: #ffffff !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(30, 58, 138, 0.3);
    border-color: rgba(30, 58, 138, 0.3) !important;
}

.field-item:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(30, 58, 138, 0.4);
}

.field-item.dragging {
    opacity: 0.7;
    transform: rotate(2deg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.field-icon {
    font-size: 1.125rem;
    margin-right: 0.75rem;
    width: 24px;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.field-info {
    flex: 1;
    min-width: 0;
    color: #f8fafc !important;
    line-height: 1.4;
}

.field-name {
    color: #ffffff !important;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.025em;
}

.field-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.field-description {
    color: #d1d5db !important;
    font-size: 0.75rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.field-meta {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.125rem;
    color: #e5e7eb !important;
}

.field-type-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: inherit !important;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.field-type-badge.dimension {
    background: rgba(34, 197, 94, 0.25);
    color: #4ade80 !important;
    border-color: rgba(34, 197, 94, 0.3);
}

.field-type-badge.measure {
    background: rgba(59, 130, 246, 0.25);
    color: #60a5fa !important;
    border-color: rgba(59, 130, 246, 0.3);
}

.field-type-badge.string {
    background: rgba(168, 85, 247, 0.25);
    color: #a78bfa !important;
    border-color: rgba(168, 85, 247, 0.3);
}

.field-type-badge.number {
    background: rgba(245, 158, 11, 0.25);
    color: #fbbf24 !important;
    border-color: rgba(245, 158, 11, 0.3);
}

.field-type-badge.date {
    background: rgba(236, 72, 153, 0.25);
    color: #f472b6 !important;
    border-color: rgba(236, 72, 153, 0.3);
}

.aggregation {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 500;
}

.field-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.field-item:hover .field-actions {
    opacity: 1;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 4px;
    padding: 0.375rem;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: scale(1.1);
}

/* Configuration Panel (Right Side) */
.configuration-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: rgba(255, 255, 255, 0.02);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
    min-width: 0;
    flex: 1;
    /* Ensure proper scrolling */
    max-height: calc(100vh - 120px);
    position: relative;
    width: 100%;
    max-width: 100%;
}

/* Enhanced scrollbar for configuration panel */
.configuration-panel::-webkit-scrollbar {
    width: 8px;
}

.configuration-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.configuration-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.configuration-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.config-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.config-header h3 {
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.config-actions {
    display: flex;
    gap: 0.5rem;
}

.config-sections {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.config-sections::-webkit-scrollbar {
    width: 6px;
}

.config-sections::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.config-sections::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.config-sections::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.config-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h4 {
    color: white;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.section-count {
    background: rgba(30, 58, 138, 0.2);
    color: #1e3a8a;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Drop Zones */
.drop-zone {
    min-height: 120px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
    position: relative;
    background: rgba(255, 255, 255, 0.02);
}

.drop-zone.drag-over {
    border-color: #1e3a8a;
    background: rgba(30, 58, 138, 0.1);
    transform: scale(1.02);
}

.drop-zone-placeholder {
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    font-style: italic;
    margin-top: 2rem;
    font-size: 0.875rem;
}

.drop-zone.has-items .drop-zone-placeholder {
    display: none;
}

/* Selected Fields */
.selected-field {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.selected-field:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(30, 58, 138, 0.3);
}

.selected-field .field-icon {
    margin-right: 0.75rem;
    font-size: 1.25rem;
}

.selected-field .field-info {
    flex: 1;
}

.selected-field .field-name {
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.field-aggregation select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
}

.field-aggregation select:focus {
    outline: none;
    border-color: #1e3a8a;
}

/* Filters */
.filters-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.no-filters {
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    font-style: italic;
    padding: 2rem;
}

.filter-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-field .field-icon {
    font-size: 1rem;
}

.filter-field .field-name {
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
}

.filter-operator select,
.filter-value input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
    padding: 0.5rem;
    font-size: 0.875rem;
    min-width: 120px;
}

.filter-operator select:focus,
.filter-value input:focus {
    outline: none;
    border-color: #1e3a8a;
}

.filter-value input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Visualization Options */
.visualization-options {
    display: flex;
    gap: 0.75rem;
}

.viz-option {
    flex: 1;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.viz-option:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(30, 58, 138, 0.3);
}

.viz-option.active {
    background: rgba(30, 58, 138, 0.2);
    border-color: #1e3a8a;
}

.viz-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.viz-name {
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
}

/* Preview Section */
.preview-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: visible;
    position: relative;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.preview-header h4 {
    color: white;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.preview-actions {
    display: flex;
    gap: 0.5rem;
}

.preview-content {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
    min-height: 200px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-placeholder {
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    font-style: italic;
    margin-top: 4rem;
    font-size: 0.875rem;
}

/* Removed old .preview-table-container styles */

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.preview-table th,
.preview-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-table th {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-weight: 600;
    /* Remove sticky positioning completely - let headers scroll normally */
    z-index: 100 !important;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.preview-table td {
    color: rgba(255, 255, 255, 0.8);
}

.preview-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.preview-note {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    text-align: center;
    margin-top: 0.5rem;
    font-style: italic;
}

/* Filter Field Modal */
.filter-field-modal {
    z-index: 10002;
}

.filterable-fields {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
}

.filterable-field {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
}

.filterable-field:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(30, 58, 138, 0.3);
}

.filterable-field .field-icon {
    margin-right: 0.75rem;
    font-size: 1.25rem;
}

.filterable-field .field-info {
    flex: 1;
}

.filterable-field .field-name {
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.filterable-field .field-description {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .report-builder-container {
        grid-template-columns: 300px 1fr;
    }
}

@media (max-width: 480px) {
    .report-builder-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .field-palette {
        max-height: 300px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .configuration-panel {
        min-height: 500px;
    }
}

/* Animation Enhancements */
@keyframes fieldSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes configSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.field-item {
    animation: fieldSlideIn 0.3s ease-out;
}

.config-section {
    animation: configSlideIn 0.3s ease-out;
}

/* Loading States */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:disabled:hover {
    transform: none;
}

/* Dynamic Field Badges */
.dynamic-badge {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e !important;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-size: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Context Menu Styles */
.field-context-menu {
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 0.5rem 0;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    min-width: 200px;
    z-index: 10002;
    position: fixed;
}

.context-menu-header {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0.5rem;
}

.context-menu-header .field-name {
    display: block;
    font-weight: 600;
    color: white;
    font-size: 0.9rem;
}

.context-menu-header .field-type {
    display: block;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.1rem;
}

.context-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0.5rem 0;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    color: white;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
}

.context-menu-item:hover {
    background: rgba(30, 58, 138, 0.2);
    color: #1e3a8a;
}

.context-menu-item .menu-icon {
    font-size: 0.9rem;
}

.context-menu-item .menu-text {
    flex: 1;
}

.context-menu-item.has-submenu .submenu-arrow {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.context-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    padding: 0.5rem 0;
    min-width: 150px;
    display: none;
    backdrop-filter: blur(10px);
    z-index: 10003;
}

.context-submenu .context-menu-item {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.context-submenu .context-menu-item:hover {
    background: rgba(30, 58, 138, 0.2);
    color: #1e3a8a;
}

/* Show submenu on hover with better persistence */
.context-menu-item.has-submenu:hover .context-submenu {
    display: block !important;
}

/* Keep submenu visible when hovering over it */
.context-submenu:hover {
    display: block !important;
}

.context-menu-item svg {
    color: rgba(255, 255, 255, 0.7);
    transition: color 0.3s ease;
}

.context-menu-item:hover svg {
    color: #1e3a8a;
}

/* Field Information Modal */
.field-info-modal {
    z-index: 10002;
}

.field-info-modal .modal-content {
    max-width: 500px;
}

.field-info-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.info-row label {
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
    font-size: 0.875rem;
    min-width: 120px;
}

.info-row span {
    color: white;
    font-size: 0.875rem;
}

.info-row code {
    background: rgba(255, 255, 255, 0.1);
    color: #1e3a8a;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.75rem;
}

/* Refresh Button */
.refresh-fields-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 0.5rem;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.refresh-fields-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: rotate(180deg);
}

.refresh-fields-btn svg {
    width: 16px;
    height: 16px;
}

/* Field Loading States */
.field-item.loading {
    opacity: 0.6;
    pointer-events: none;
}

.field-item.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Field Loading Container */
.field-loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.field-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.field-loading-text {
    color: #e5e7eb;
    font-size: 0.875rem;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Data Sources Section */
.data-sources-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.data-sources-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.data-sources-section .section-header h3 {
    color: white;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

/* Connection Selector */
.connection-selector {
    margin-bottom: 1rem;
}

/* No Fields States */
.no-fields {
    text-align: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

.no-fields-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.7;
}

.no-fields-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 0.25rem;
}

.no-fields-subtext {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-style: normal;
}

.connection-selector label {
    display: block;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.connection-selector select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.connection-selector select:focus {
    outline: none;
    border-color: rgba(30, 58, 138, 0.5);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.2);
}

.connection-selector select option {
    background: rgba(26, 26, 46, 0.95);
    color: white;
}

/* Connection Status */
.connection-status {
    margin-bottom: 1rem;
}

.status-disconnected {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    font-style: italic;
    text-align: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border: 1px dashed rgba(255, 255, 255, 0.2);
}

.status-connected {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 8px;
    padding: 0.75rem;
}

.connection-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.connection-icon {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.connection-details {
    flex: 1;
}

.connection-name {
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
}

.connection-type {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    margin-bottom: 0.125rem;
}

.connection-database {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    font-family: monospace;
}

.connection-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Tables Section */
.tables-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.tables-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.tables-list::-webkit-scrollbar {
    width: 6px;
}

.tables-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.tables-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.tables-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.table-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.table-item:hover {
    background: rgba(30, 58, 138, 0.15);
    border-color: rgba(30, 58, 138, 0.3);
    transform: translateX(2px);
}

.table-item.selected {
    background: rgba(30, 58, 138, 0.2);
    border-color: rgba(30, 58, 138, 0.5);
}

.table-info {
    flex: 1;
}

.table-name {
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
}

.table-meta {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    display: flex;
    gap: 1rem;
}

.table-actions {
    display: flex;
    gap: 0.25rem;
}

/* Connections List */
.connections-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.no-connections {
    text-align: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.6);
}

.no-connections-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.no-connections-text {
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.connection-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.connection-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(30, 58, 138, 0.3);
}

.connection-item.active {
    background: rgba(30, 58, 138, 0.2);
    border-color: #1e3a8a;
}

.connection-icon {
    font-size: 1.25rem;
    margin-right: 0.75rem;
    width: 24px;
    text-align: center;
}

.connection-info {
    flex: 1;
    min-width: 0;
}

.connection-name {
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.connection-details {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
}

.connection-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.connection-item:hover .connection-actions {
    opacity: 1;
}

/* Tables Section */
.tables-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.tables-section .section-header h4 {
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
}

.tables-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.no-tables {
    text-align: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.6);
}

.no-tables-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.no-tables-text {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.no-tables-subtext {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
}

.table-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.table-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(30, 58, 138, 0.3);
}

.table-item.selected {
    background: rgba(34, 197, 94, 0.2);
    border-color: #22c55e;
}

.table-icon {
    font-size: 1rem;
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
}

.table-info {
    flex: 1;
    min-width: 0;
}

.table-name {
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-details {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
}

.table-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.table-item:hover .table-actions {
    opacity: 1;
}

/* Connection Modal - Override conflicting styles */
.connection-modal {
    z-index: 10003 !important;
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: rgba(0, 0, 0, 0.8) !important;
    justify-content: center !important;
    align-items: center !important;
    opacity: 1 !important;
    pointer-events: all !important;
    visibility: visible !important;
}

.connection-modal .modal-content {
    max-width: 450px;
    max-height: 70vh;
    background: var(--bg-secondary, #1f2937);
    border: 1px solid var(--border-color, #374151);
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    z-index: 10004;
    overflow-y: auto;
}

/* Connection Modal Specific Styles - Only apply to connection modal */
.connection-modal .form-group {
    margin-bottom: 0.5rem;
}

.connection-modal .form-group label {
    display: block;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.connection-modal .form-group input,
.connection-modal .form-group select {
    width: 100%;
    padding: 0.4rem 0.6rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: #ffffff;
    font-size: 0.8rem;
    transition: border-color 0.2s ease;
}

.connection-modal .form-group input:focus,
.connection-modal .form-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.connection-modal .modal-body {
    padding: 1rem;
    max-height: calc(70vh - 100px);
    overflow-y: auto;
}

.connection-modal .modal-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
}

/* ===== ENHANCED REPORT BUILDER LAYOUT ===== */

/* Report Builder Toolbar */
.report-builder-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.toolbar-left {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.toolbar-right {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Configuration Panel Tabs */
.config-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0;
    margin: 0;
}

.tab-btn {
    flex: 1;
    padding: 1rem 1.5rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.tab-btn.active {
    background: rgba(30, 58, 138, 0.2);
    color: white !important;
    border-bottom-color: #1e3a8a;
}

.tab-content {
    display: none;
    padding: 1.5rem;
    height: calc(100vh - 200px);
    overflow-y: auto;
    overflow-x: hidden;
}

.tab-content.active {
    display: block;
}

/* Section Headers */
.section-header {
    margin-bottom: 1rem;
}

.section-header h3 {
    color: white;
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

.section-header p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    margin: 0;
}

/* Field Drop Zones */
.field-drop-zone {
    min-height: 120px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
    position: relative;
    background: rgba(255, 255, 255, 0.02);
}

.field-drop-zone.drag-over {
    border-color: #1e3a8a;
    background: rgba(30, 58, 138, 0.1);
    transform: scale(1.02);
}

.empty-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
}

.drop-zone-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.7;
}

/* Configuration Field Items */
.config-field-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.config-field-item:hover {
    background: rgba(30, 58, 138, 0.3);
    border-color: #1e3a8a;
}

.config-field-item:last-child {
    margin-bottom: 0;
}

.config-field-item .field-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.config-field-item .field-info {
    flex: 1;
    min-width: 0;
}

.config-field-item .field-name {
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.config-field-item .field-type {
    color: #333 !important;
    background: rgba(255, 255, 255, 0.9) !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
}

.config-field-item .field-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.config-field-item:hover .field-actions {
    opacity: 1;
}

.btn-remove-field {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
    padding: 0.25rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-remove-field:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

/* Filters Container */
.filters-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.no-filters {
    text-align: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

.filter-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-field,
.filter-operator,
.filter-value {
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
    font-size: 0.875rem;
}

.filter-field:focus,
.filter-operator:focus,
.filter-value:focus {
    outline: none;
    border-color: #1e3a8a;
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.2);
}

.filter-value::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Range filter styles */
.filter-value-range {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    position: relative;
    overflow: visible !important;
}

.filter-item {
    position: relative;
    overflow: visible !important;
}

.filter-value-start,
.filter-value-end {
    flex: 1;
    padding: 0.5rem !important;
    border-radius: 4px !important;
    background: rgba(255,255,255,0.1) !important;
    color: white !important;
    border: 1px solid rgba(255,255,255,0.3) !important;
    font-size: 0.9rem !important;
    position: relative; /* Ensure proper positioning context for suggestions */
    z-index: 1;
}

.range-separator {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

.filter-suggestions {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 99999 !important;
    background: rgba(255, 0, 0, 0.9) !important;
    border: 3px solid rgba(255, 255, 0, 1) !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    max-height: 200px !important;
    overflow-y: auto !important;
    backdrop-filter: blur(10px) !important;
    min-height: 50px !important;
    width: 100% !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.suggestion-item {
    padding: 8px 12px !important;
    cursor: pointer !important;
    color: rgba(255, 255, 255, 0.9) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    transition: background-color 0.2s ease !important;
}

.suggestion-item:hover {
    background: rgba(30, 58, 138, 0.2) !important;
}

.suggestion-item:last-child {
    border-bottom: none !important;
}

.btn-remove-filter {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-remove-filter:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

/* Preview Container */
/* Clean Preview Container */
.preview-container {
    padding: 0;
    background: transparent;
    border: none;
    margin: 0;
    height: auto;
    overflow: visible;
}

.preview-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #1e3a8a;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
}

.preview-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.7;
}

/* Removed duplicate .preview-table-container styles */

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-count {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.preview-table-content {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.preview-table-content th,
.preview-table-content td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-table-content th {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
    /* Explicitly remove left positioning to allow horizontal scrolling */
    left: auto !important;
    right: auto !important;
}

.preview-table-content td {
    color: rgba(255, 255, 255, 0.8);
}

.preview-table-content tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.preview-more {
    text-align: center;
    padding: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    font-style: italic;
}

/* Enhanced Configuration Panel */
.enhanced-configuration-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

/* Preview Section (Top) */
.preview-section-top {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    flex-shrink: 0;
    min-height: 300px;
    max-height: 400px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-header h3 {
    color: var(--text-primary, #ffffff);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.preview-actions {
    display: flex;
    gap: 0.5rem;
}

.preview-content {
    height: calc(100% - 60px);
    overflow: auto;
}

/* Preview Empty State */
.preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary, #9ca3af);
}

.preview-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.preview-empty-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.preview-empty-hint {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Dynamic Table */
.dynamic-table-container {
    width: 100%;
    height: 100%;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.table-title {
    font-weight: 500;
    color: var(--text-primary, #ffffff);
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

.table-wrapper {
    /* Removed height constraint to allow natural table height */
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.dynamic-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.dynamic-table th,
.dynamic-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dynamic-table th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    color: var(--text-primary, #ffffff);
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    /* Explicitly remove left positioning to allow horizontal scrolling */
    left: auto !important;
    right: auto !important;
}

.dynamic-table td {
    color: var(--text-secondary, #d1d5db);
}

.totals-row {
    background: rgba(59, 130, 246, 0.1);
    font-weight: 600;
}

.totals-cell {
    color: var(--primary-color, #3b82f6) !important;
}

/* Configuration Sections Container */
.config-sections-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
    overflow: visible; /* Allow sections to expand */
    min-height: 0; /* Allow flex shrinking */
}

/* Collapsible Sections */
.collapsible-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: visible; /* Allow content to expand */
    transition: all 0.3s ease;
    position: relative; /* Ensure proper positioning */
}

/* This rule is now handled above - removing duplicate */

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    transition: background-color 0.2s ease;
}

.section-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-icon {
    font-size: 1.1rem;
}

.section-label {
    font-weight: 600;
    color: var(--text-primary, #ffffff);
}

.section-count {
    background: var(--primary-color, #3b82f6);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.section-toggle {
    transition: transform 0.3s ease;
    color: var(--text-secondary, #9ca3af);
}

.collapsible-section.collapsed .section-toggle {
    transform: rotate(-90deg);
}

.section-content {
    padding: 1rem;
    max-height: none; /* Remove height restriction */
    overflow: visible; /* Allow content to expand */
    transition: all 0.3s ease;
}

/* When collapsed, hide content properly */
.collapsible-section.collapsed .section-content {
    max-height: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    opacity: 0;
}

/* When expanded, ensure proper visibility and layering */
.collapsible-section:not(.collapsed) {
    z-index: 10; /* Ensure expanded sections appear above others */
}

.collapsible-section:not(.collapsed) .section-content {
    overflow: visible; /* Allow content to expand beyond container */
    position: relative;
    z-index: 11;
}

/* Data Subsections */
.data-sections {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.data-subsection {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 0.75rem;
}

.subsection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.subsection-header h4 {
    color: var(--text-primary, #ffffff);
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
}

.subsection-count {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary-color, #3b82f6);
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
}

.subsection-content {
    min-height: 60px;
}

/* Field Items */
.field-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.field-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(59, 130, 246, 0.3);
}

.field-info {
    flex: 1;
}

.field-name {
    font-weight: 500;
    color: var(--text-primary, #ffffff);
    font-size: 0.875rem;
}

.field-type {
    font-size: 0.75rem;
    color: #333 !important;
    background: rgba(255, 255, 255, 0.9) !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    margin-top: 0.1rem;
    font-weight: 500 !important;
}

.field-aggregation {
    font-size: 0.7rem;
    color: var(--primary-color, #3b82f6);
    font-weight: 600;
    margin-top: 0.1rem;
}

.field-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.aggregation-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--text-primary, #ffffff);
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    min-width: 80px;
}

.aggregation-select:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.remove-field {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
    padding: 0.2rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.remove-field:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

/* Empty States */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary, #9ca3af);
}

.empty-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.empty-text {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.empty-hint {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Visualization Options */
.visualization-options {
    padding: 0.5rem;
}

.viz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 0.75rem;
}

.viz-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.viz-option:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(59, 130, 246, 0.3);
}

.viz-option.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary-color, #3b82f6);
}

.viz-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.viz-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary, #ffffff);
}

/* Enhanced Button Styles */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(30, 58, 138, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: 1px solid rgba(239, 68, 68, 0.3);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    visibility: visible;
    opacity: 1;
}

.btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    border-color: rgba(220, 38, 38, 0.5);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

/* Report Results */
.report-results {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.results-metrics {
    display: flex;
    gap: 1.5rem;
}

.metric-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.metric-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    font-weight: 500;
}

.metric-value {
    color: white;
    font-size: 1rem;
    font-weight: 600;
}

.results-actions {
    display: flex;
    gap: 0.5rem;
}

.results-table-container {
    max-height: 400px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.02);
}

.results-table th,
.results-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.results-table th {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.results-table td {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
}

.results-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.table-note {
    padding: 0.75rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    font-style: italic;
}

/* Preview Components */
.preview-summary {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
}

.preview-section {
    margin-bottom: 1rem;
}

.preview-section:last-child {
    margin-bottom: 0;
}

.preview-section h5 {
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

.preview-fields {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    line-height: 1.4;
}

.preview-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.no-preview,
.no-data {
    text-align: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.6);
}

.no-preview-icon,
.no-data-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.no-preview-text,
.no-data-text {
    font-size: 0.875rem;
}

/* Drag and Drop Enhancements */
.field-item {
    cursor: grab;
    transition: all 0.3s ease;
}

.field-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
}

.field-item.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
    cursor: grabbing;
}

.drop-zone {
    min-height: 60px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
    position: relative;
}

.drop-zone.drag-over {
    border-color: #1e3a8a;
    background: rgba(30, 58, 138, 0.1);
    transform: scale(1.02);
}

.drop-zone-placeholder {
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    font-size: 0.875rem;
    font-style: italic;
    padding: 1rem;
}

.drop-zone:not(:empty) .drop-zone-placeholder {
    display: none;
}

/* Selected Field Items */
.selected-field-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: rgba(30, 58, 138, 0.2);
    border: 1px solid rgba(30, 58, 138, 0.3);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.selected-field-item:hover {
    background: rgba(30, 58, 138, 0.3);
    border-color: #1e3a8a;
}

.selected-field-item:last-child {
    margin-bottom: 0;
}

.selected-field-icon {
    font-size: 1rem;
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
}

.selected-field-info {
    flex: 1;
    min-width: 0;
}

.selected-field-name {
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.selected-field-details {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
}

.selected-field-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.selected-field-item:hover .selected-field-actions {
    opacity: 1;
}

/* Configuration Sections */
.config-group {
    margin-bottom: 1.5rem;
}

.config-group:last-child {
    margin-bottom: 0;
}

.config-group h4 {
    color: white;
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-count {
    background: rgba(30, 58, 138, 0.2);
    color: #1e3a8a;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Filters */
.filters-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
    min-height: 100px;
}

.no-filters {
    text-align: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.6);
}

.no-filters-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.no-filters-text {
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Advanced Filtering */
.filters-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.filter-item {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 1rem;
    align-items: end;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-field,
.filter-operator,
.filter-value {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-field label,
.filter-operator label,
.filter-value label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    font-weight: 500;
}

.filter-field select,
.filter-operator select,
.filter-value input,
.filter-value select {
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 4px;
    color: white !important;
    font-size: 0.875rem;
}

.filter-field select option,
.filter-operator select option,
.filter-value select option {
    background: #1a1a2e !important;
    color: white !important;
    padding: 0.5rem;
}

.filter-field select:focus,
.filter-operator select:focus,
.filter-value input:focus,
.filter-value select:focus {
    outline: none;
    border-color: #1e3a8a;
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.2);
    background: rgba(255, 255, 255, 0.15) !important;
    color: white !important;
}

.between-inputs {
    display: flex;
    gap: 0.5rem;
}

/* Additional select styling for Report Builder */
.report-builder-modal select,
.configuration-panel select {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    padding: 0.5rem !important;
    border-radius: 4px !important;
    font-size: 0.875rem !important;
}

.report-builder-modal select option,
.configuration-panel select option {
    background: #1a1a2e !important;
    color: white !important;
    padding: 0.5rem !important;
}

.report-builder-modal select:focus,
.configuration-panel select:focus {
    outline: none !important;
    border-color: #1e3a8a !important;
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.2) !important;
    background: rgba(255, 255, 255, 0.15) !important;
    color: white !important;
}

.between-inputs input {
    flex: 1;
}

.filter-actions {
    display: flex;
    align-items: center;
}

.add-filter-action {
    margin-top: 1rem;
    text-align: center;
}

.add-filter-action button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Visualization Options */
.visualization-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.viz-option {
    position: relative;
}

.viz-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.viz-option label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.viz-option input[type="radio"]:checked + label {
    background: rgba(30, 58, 138, 0.2);
    border-color: #1e3a8a;
    transform: translateY(-2px);
}

.viz-icon {
    font-size: 2rem;
}

.viz-label {
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
}

.chart-options {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.chart-type,
.chart-dimensions,
.chart-measures {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.chart-type:last-child,
.chart-dimensions:last-child,
.chart-measures:last-child {
    margin-bottom: 0;
}

.chart-type label,
.chart-dimensions label,
.chart-measures label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    font-weight: 500;
}

.chart-type select,
.chart-dimensions select,
.chart-measures select {
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
    font-size: 0.875rem;
}

.chart-type select:focus,
.chart-dimensions select:focus,
.chart-measures select:focus {
    outline: none;
    border-color: #1e3a8a;
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.2);
}

/* Chart Visualizations */
.simple-chart {
    display: flex;
    align-items: end;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
    min-width: 40px;
    background: linear-gradient(to top, #1e3a8a, #2563eb);
    border-radius: 4px 4px 0 0;
    position: relative;
    transition: all 0.3s ease;
}

.bar-item:hover {
    background: linear-gradient(to top, #2563eb, #1e3a8a);
    transform: scale(1.05);
}

.bar-value {
    position: absolute;
    top: -20px;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

.bar-label {
    position: absolute;
    bottom: -25px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
}

.line-chart,
.pie-chart {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    font-style: italic;
}

/* Cards Visualization */
.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.data-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(30, 58, 138, 0.1);
    border: 1px solid rgba(30, 58, 138, 0.2);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.data-card:hover {
    background: rgba(30, 58, 138, 0.2);
    border-color: #1e3a8a;
    transform: translateY(-2px);
}

.card-value {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
}

.card-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    text-align: center;
    word-break: break-word;
}

/* Enhanced Results Display */
.results-visualization {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.visualization-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.visualization-toggle button {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.visualization-toggle button.active {
    background: rgba(30, 58, 138, 0.2);
    border-color: #1e3a8a;
    color: white;
}

/* Export Modal */
.export-modal {
    max-width: 600px;
    width: 90%;
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.export-option:hover {
    background: rgba(30, 58, 138, 0.1);
    border-color: #1e3a8a;
    transform: translateY(-2px);
}

.export-icon {
    font-size: 2rem;
    width: 60px;
    text-align: center;
}

.export-info h4 {
    color: white;
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
}

.export-info p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    margin: 0;
    line-height: 1.4;
}

.export-info-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
}

.export-info-section h4 {
    color: white;
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
}

.export-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
}

.detail-value {
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Chart preview styles */
.chart-preview-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-header h4 {
    color: white;
    margin: 0;
    font-size: 18px;
}

.chart-controls select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    padding: 8px 12px;
    font-size: 14px;
}

.chart-controls select option {
    background: rgba(0, 0, 0, 0.9);
    color: white;
}

.chart-container {
    position: relative;
    height: 400px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    padding: 10px;
}

/* Pivot preview styles */
.pivot-preview-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.pivot-header h4 {
    color: white;
    margin: 0 0 10px 0;
    font-size: 18px;
}

.pivot-hint {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    margin: 0 0 20px 0;
}

.pivot-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border: 2px dashed rgba(255, 255, 255, 0.2);
}

.pivot-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.pivot-text {
    color: rgba(255, 255, 255, 0.6);
    font-size: 16px;
}

/* No data state */
.no-data {
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    padding: 40px 20px;
    font-style: italic;
}

/* Enhanced Pivot table styles */
.pivot-table-wrapper {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    background: white;
    border-radius: 8px;
}

/* Filter Configuration Modal */
.filter-config-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Report Builder Modal Overlay - Specific to avoid conflicts */
.report-builder-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 10001; /* Higher than other modals */
    overflow: hidden;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
}

/* Modal content styles moved to specific modal classes */

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%) !important;
    color: white;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Keep hidden for modal body, let children handle scrolling */
}

.filter-config-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

.filter-operator,
.filter-value {
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-operator:focus,
.filter-value:focus {
    outline: none;
    border-color: #1e3a8a;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-primary {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
}

/* Export Options Modal */
.export-options-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.export-format-section h4,
.export-options-section h4 {
    margin: 0 0 16px 0;
    color: #374151;
    font-size: 16px;
    font-weight: 600;
}

.format-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.format-option {
    cursor: pointer;
    display: block;
}

.format-option input[type="radio"] {
    display: none;
}

.format-card {
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    transition: all 0.2s;
    background: white;
}

.format-option input[type="radio"]:checked + .format-card {
    border-color: #1e3a8a;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
    color: white;
}

.format-card:hover {
    border-color: #1e3a8a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.2);
}

.format-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.format-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.format-desc {
    font-size: 12px;
    opacity: 0.8;
}

.option-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkbox-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #1e3a8a;
}

.checkbox-option span {
    font-size: 14px;
    color: #374151;
}

/* Date and Number Range Inputs */
.date-range-inputs,
.number-range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-range-separator,
.number-range-separator {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

.filter-date-start,
.filter-date-end,
.filter-number-min,
.filter-number-max {
    flex: 1;
    min-width: 120px;
}

.date-relative-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-days-count {
    width: 80px;
}

.date-relative-label {
    font-size: 14px;
    color: #6b7280;
}

.date-preset-info {
    padding: 12px;
    background: #f3f4f6;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.preset-description {
    font-size: 14px;
    color: #374151;
    font-style: italic;
}

/* Interactive Pivot and Drill-Down Styles */
.interactive-pivot .drillable {
    cursor: pointer;
    transition: all 0.2s;
}

.interactive-pivot .drillable:hover {
    background-color: rgba(30, 58, 138, 0.1);
    transform: scale(1.02);
}

.pivot-actions-cell {
    text-align: center;
    white-space: nowrap;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    margin: 0 2px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background-color: rgba(30, 58, 138, 0.1);
}

.drill-down-breadcrumb {
    margin-top: 12px;
    padding: 8px 12px;
    background: #f3f4f6;
    border-radius: 6px;
    border-left: 4px solid #1e3a8a;
}

.breadcrumb-label {
    font-weight: 600;
    color: #374151;
    margin-right: 8px;
}

.breadcrumb-items {
    display: inline;
    color: #6b7280;
}

.breadcrumb-item {
    background: #e5e7eb;
    padding: 2px 8px;
    border-radius: 4px;
    margin: 0 2px;
}

/* Drill-Down Modal Styles */
.pivot-drill-down-modal,
.drill-down-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.large-modal {
    min-width: 800px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
}

.drill-down-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
}

.summary-item {
    font-size: 14px;
}

.summary-item strong {
    color: #374151;
}

.drill-down-data {
    max-height: 400px;
    overflow: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.drill-down-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.drill-down-table th,
.drill-down-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.drill-down-table th {
    background: #f9fafb;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.focus-column {
    background-color: rgba(30, 58, 138, 0.1) !important;
    font-weight: 600;
}

.pivot-controls {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.pivot-controls .btn {
    font-size: 12px;
    padding: 6px 12px;
}

/* True Pivot Table Styles */
.pivot-table-info {
    background: #f3f4f6;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #374151;
    border-left: 4px solid #1e3a8a;
}

.true-pivot {
    border: 2px solid #e5e7eb;
}

.pivot-corner {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
    color: white;
    font-weight: 600;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 20;
}

.pivot-col-header {
    background: #e3f2fd;
    color: #1976d2;
    font-weight: 600;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 15;
    cursor: pointer;
    transition: background-color 0.2s;
}

.pivot-col-header:hover {
    background: #bbdefb;
}

.pivot-row-header {
    background: #e8f5e9;
    color: #2e7d32;
    font-weight: 600;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 10;
    cursor: pointer;
    transition: background-color 0.2s;
}

.pivot-row-header:hover {
    background: #c8e6c9;
}

.pivot-data-cell {
    text-align: right;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Roboto Mono', monospace;
}

.pivot-data-cell:hover {
    background: rgba(30, 58, 138, 0.1);
    transform: scale(1.05);
    font-weight: 600;
}

.pivot-row-total,
.pivot-col-total {
    background: #fff3e0;
    color: #f57c00;
    font-weight: 600;
    text-align: right;
    font-family: 'Roboto Mono', monospace;
}

.pivot-grand-total {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    color: white;
    font-weight: 700;
    text-align: right;
    font-family: 'Roboto Mono', monospace;
    font-size: 14px;
}

.pivot-total-header,
.pivot-total-label {
    background: #fff3e0;
    color: #f57c00;
    font-weight: 600;
    text-align: center;
}

.pivot-total-row {
    border-top: 2px solid #ff9800;
}

.pivot-data-row:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

.pivot-data-row:hover {
    background: rgba(30, 58, 138, 0.05);
}

/* Calculated Field Styles */
.calc-field-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.calc-field-button {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.calc-field-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.calc-icon {
    font-size: 18px;
}

.calc-text {
    flex: 1;
}

/* Calculated Field Modal */
.calculated-field-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calculated-field-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-section label {
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-input,
.form-textarea {
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: #1e3a8a;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.form-textarea {
    resize: vertical;
    font-family: 'Courier New', monospace;
}

.expression-help {
    background: #f9fafb;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    margin-top: 8px;
}

.expression-help h4 {
    margin: 0 0 12px 0;
    color: #374151;
    font-size: 14px;
}

.function-categories {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.function-category {
    font-size: 13px;
    color: #6b7280;
}

.function-category strong {
    color: #374151;
}

.available-fields {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
}

.field-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.field-item:hover {
    background-color: #f3f4f6;
}

.field-icon {
    font-size: 16px;
}

.field-name {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #374151;
}

.field-type {
    font-size: 12px;
    color: #333 !important;
    background: rgba(255, 255, 255, 0.9) !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    font-weight: 500 !important;
}

.no-fields {
    padding: 20px;
    text-align: center;
    color: #6b7280;
    font-style: italic;
}

.expression-preview {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    background: #f9fafb;
    min-height: 80px;
}

.preview-placeholder {
    color: #6b7280;
    font-style: italic;
}

.preview-success {
    color: #059669;
}

.preview-error {
    color: #dc2626;
}

.preview-label {
    font-weight: 600;
    margin-bottom: 8px;
}

.preview-sql,
.preview-sample,
.preview-message {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    background: white;
    padding: 8px;
    border-radius: 4px;
    margin-top: 4px;
}

.pivot-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: white;
}

.pivot-table th {
    background: #f8f9fa;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 10;
}

.pivot-dimension {
    background: #e3f2fd !important;
    color: #1976d2 !important;
}

.pivot-count {
    background: #f3e5f5 !important;
    color: #7b1fa2 !important;
}

.pivot-measure {
    background: #e8f5e8 !important;
    color: #388e3c !important;
}

.pivot-table td {
    padding: 10px 16px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: top;
    background: white;
}

.pivot-dimension-cell {
    font-weight: 500;
    color: #1976d2;
    background: #f8fbff !important;
}

.pivot-count-cell {
    text-align: center;
    font-weight: 500;
    color: #7b1fa2;
    background: #faf8fb !important;
}

.pivot-measure-cell {
    text-align: right;
    font-weight: 500;
    color: #388e3c;
    background: #f8fdf8 !important;
}

.pivot-table tr:hover {
    background: #f5f5f5 !important;
}

.pivot-table tr:hover .pivot-dimension-cell,
.pivot-table tr:hover .pivot-count-cell,
.pivot-table tr:hover .pivot-measure-cell {
    background: #f0f0f0 !important;
}

/* ===== NO TABLE SELECTED MESSAGE ===== */

.no-table-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
}

.no-table-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-table-selected p {
    margin: 0;
    font-size: 0.875rem;
    font-style: italic;
}

.single-panel-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem;
    height: 100%;
    overflow-y: auto;
}

.table-selection-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
}

.table-selection-section .table-selector {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.table-selection-section label {
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
    min-width: 80px;
}

.table-selection-section select {
    flex: 1;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    font-size: 0.875rem;
}

.table-selection-section select:focus {
    outline: none;
    border-color: #1e3a8a;
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.2);
}

.table-selection-section select option {
    background: #1a1a1a;
    color: white;
}

.selected-table-info {
    padding: 0.5rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 6px;
    color: #10b981;
    font-size: 0.875rem;
}

.fields-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
}

.fields-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.fields-subsection h4 {
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.filters-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.filters-header h4 {
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
}

.preview-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    flex: 1;
    min-height: 200px;
}

.preview-section h4 {
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.connection-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.connection-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
}

.connection-section h4 {
    color: white;
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.connection-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    font-weight: 500;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
}

.status-indicator.active {
    background: #10b981;
}

.connection-details {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
    line-height: 1.5;
}

.connection-details p {
    margin: 0.25rem 0;
}

.table-selector {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.table-selector select {
    flex: 1;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    font-size: 0.875rem;
}

.table-selector select:focus {
    outline: none;
    border-color: #1e3a8a;
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.2);
}

.table-selector select option {
    background: #1a1a1a;
    color: white;
}

.selected-table-info {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 6px;
}

.selected-table-info h5 {
    color: #10b981;
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

.selected-table-info p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
    margin: 0;
}

/* ===== ENHANCED FIELDS CONTAINER ===== */

/* Fields Container */
.fields-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.fields-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
}

.fields-section h4 {
    color: white;
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Pivot Button Styling */
.btn-pivot-field {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #10b981;
    padding: 0.25rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 0.25rem;
}

.btn-pivot-field:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.4);
    transform: scale(1.1);
}

.btn-pivot-field.active {
    background: rgba(16, 185, 129, 0.3);
    border-color: #10b981;
    color: #10b981;
}

/* Pivot Indicator */
.pivot-indicator {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border: 1px solid rgba(16, 185, 129, 0.3);
    backdrop-filter: blur(5px);
}

.pivot-indicator::before {
    content: "🔄";
    font-size: 0.875rem;
}

/* ===== TABBED PANEL LAYOUT ===== */

.tabbed-panel-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tab-navigation {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0;
    margin: 0;
    border-radius: 0; /* Ensure clean edges */
    overflow: hidden; /* Prevent border bleeding */
    position: relative; /* Create stacking context */
    z-index: 1; /* Ensure proper layering */
    isolation: isolate; /* Prevent border conflicts with parent */
}

.tab-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    position: relative;
    margin: 0; /* Remove any default margins */
    border-radius: 0; /* Ensure clean edges */
}

.tab-button:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.05);
}

.tab-button.active {
    color: white !important;
    border-bottom-color: #1e3a8a;
    background: rgba(30, 58, 138, 0.1);
    border-radius: 0; /* Ensure clean edges */
    box-shadow: none; /* Remove any conflicting shadows */
}

.tab-button svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.tab-button.active svg {
    opacity: 1;
}

.tab-content {
    flex: 1;
    overflow: visible;
}

.tab-panel {
    display: none;
    height: 100%;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Special handling for preview tab - allow natural scrolling */
#previewTab {
    overflow-y: visible !important;
    padding: 1rem !important;
    height: auto !important;
    max-height: none !important;
}

.tab-panel.active {
    display: block;
}

/* ===== CLEAN LIVE PREVIEW STYLING ===== */

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.preview-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.row-count {
    color: #1e3a8a;
    font-weight: 600;
    font-size: 0.9rem;
}

.pivot-badge {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.preview-description {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    max-width: 400px;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
    border-radius: 0;
    overflow: visible;
    box-shadow: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== CLEAN LIVE PREVIEW STYLING ===== */
/* Removed conflicting .live-preview-container styles - now using .full-preview-table */

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-header h3 {
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.preview-stats {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

.stat-label {
    font-weight: 500;
}

.stat-value {
    font-weight: 600;
    color: #1e3a8a;
}

.pivot-badge {
    background: rgba(26, 26, 46, 0.8);
    color: #1e3a8a;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(30, 58, 138, 0.3);
}

/* Removed conflicting .preview-table-container styles - now using .preview-table-scroll-container */

.table-wrapper {
    overflow-x: auto;
    background: transparent;
    /* Ensure sticky headers work properly */
    position: relative;
}

.clean-table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
    margin: 0;
}

.clean-table thead th {
    background: rgba(30, 58, 138, 0.3);
    color: #ffffff;
    padding: 1rem 0.75rem;
    font-weight: 600;
    font-size: 0.85rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.clean-table tbody td {
    padding: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    word-wrap: break-word !important;
    word-break: break-word !important;
    white-space: normal !important;
    max-width: 200px !important;
    overflow-wrap: break-word !important;
    vertical-align: top !important;
}

.clean-table tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.03);
}

/* Ensure word wrapping persists through DataTables operations */
#previewDataTable tbody td,
.dataTables_wrapper #previewDataTable tbody td,
.clean-table.dataTable tbody td {
    word-wrap: break-word !important;
    word-break: break-word !important;
    white-space: normal !important;
    max-width: 200px !important;
    overflow-wrap: break-word !important;
    vertical-align: top !important;
}

/* ===== FULL-WIDTH/HIGHT PREVIEW TABLE ===== */
.full-preview-table {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 2rem); /* Account for tab padding */
    width: 100%;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: visible;
}

.preview-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(26, 26, 46, 0.8);
    border-bottom: 1px solid rgba(102, 126, 234, 0.2);
    flex-shrink: 0;
}

.preview-header-left {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.preview-header-left h3 {
    margin: 0;
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
}

.preview-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
}

.stat-label {
    color: rgba(255, 255, 255, 0.7);
}

.stat-value {
    color: white;
    font-weight: 600;
}

.pivot-badge {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.preview-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.preview-table-scroll-container {
    flex: 1;
    overflow-x: auto; /* Allow horizontal scrolling */
    overflow-y: auto; /* Allow vertical scrolling */
    position: relative;
    min-height: calc(100vh - 120px); /* Account for header and padding */
}

.preview-table-scroll-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.preview-table-scroll-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.preview-table-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 4px;
}

.preview-table-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.7);
}

/* Removed duplicate preview tab styles - handled above */

#previewContainer {
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Pivoted column styling */
.pivoted-column {
    background: rgba(26, 26, 46, 0.3) !important;
    border-left: 2px solid rgba(30, 58, 138, 0.4) !important;
    border-right: 2px solid rgba(30, 58, 138, 0.4) !important;
}

.pivoted-column:hover {
    background: rgba(26, 26, 46, 0.5) !important;
}

/* Clean DataTables controls */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.controls-left {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.length-control select,
.search-control input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #ffffff;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

.length-control select:focus,
.search-control input:focus {
    outline: none;
    border-color: #1e3a8a;
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.3);
}

.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.info-control {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

.pagination-control .paginate_button {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.9);
    padding: 0.5rem 0.75rem;
    margin: 0 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-control .paginate_button:hover {
    background: rgba(30, 58, 138, 0.3);
    border-color: rgba(30, 58, 138, 0.5);
}

.pagination-control .paginate_button.current {
    background: rgba(30, 58, 138, 0.5);
    border-color: #1e3a8a;
    color: #ffffff;
}

.pagination-control .paginate_button.disabled {
    background: rgba(0, 0, 0, 0.1);
    color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
    opacity: 0.5;
}

/* Loading and empty states */
.preview-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: rgba(255, 255, 255, 0.8);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #1e3a8a;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
}

.preview-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.preview-empty p {
    margin: 0.5rem 0;
    font-size: 1.1rem;
}

.preview-hint {
    font-size: 0.9rem !important;
    opacity: 0.7;
}

.preview-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

/* Pivoted column styling */
.preview-table th[data-pivoted="true"],
.preview-table td[data-pivoted="true"] {
    background: rgba(30, 58, 138, 0.1);
    border-left: 2px solid #1e3a8a;
    border-right: 2px solid #1e3a8a;
}

.preview-table th[data-pivoted="true"] {
    position: relative;
}

.preview-table th[data-pivoted="true"]::after {
    content: "📊";
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
}

/* DataTables controls styling */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: rgba(255, 255, 255, 0.8);
    margin: 0.5rem 0;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem;
    border-radius: 4px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white !important;
    padding: 0.5rem 0.75rem;
    margin: 0 0.25rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: rgba(30, 58, 138, 0.3);
    border-color: #1e3a8a;
    color: white !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #1e3a8a;
    color: white !important;
    border-color: #1e3a8a;
}

#previewDataTable thead th {
    background: linear-gradient(135deg, #1e3a8a 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    font-weight: 600;
    font-size: 13px;
    padding: 16px 14px;
    text-align: center;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#previewDataTable thead th:first-child {
    border-top-left-radius: 12px;
}

#previewDataTable thead th:last-child {
    border-top-right-radius: 12px;
}

#previewDataTable tbody td {
    background: rgba(255, 255, 255, 0.02) !important;
    color: rgba(255, 255, 255, 0.95) !important;
    border: none !important;
    padding: 14px 12px;
    text-align: center;
    white-space: nowrap;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 13px;
    font-weight: 500;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#previewDataTable tbody tr {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#previewDataTable tbody tr:hover {
    background: rgba(30, 58, 138, 0.08) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.15);
}

#previewDataTable tbody tr:hover td {
    background: transparent !important;
    color: white !important;
}

#previewDataTable tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.01);
}

#previewDataTable tbody tr:nth-child(even):hover {
    background: rgba(30, 58, 138, 0.12) !important;
}

#previewDataTable tbody tr:last-child td:first-child {
    border-bottom-left-radius: 12px;
}

#previewDataTable tbody tr:last-child td:last-child {
    border-bottom-right-radius: 12px;
}

/* Column width optimization for pivoted data */
#previewDataTable th,
#previewDataTable td {
    min-width: 120px;
    max-width: 200px;
}

/* Special styling for pivoted columns */
#previewDataTable th[data-pivoted="true"],
#previewDataTable td[data-pivoted="true"] {
    background: rgba(30, 58, 138, 0.1) !important;
    border-left: 2px solid rgba(30, 58, 138, 0.3) !important;
    border-right: 2px solid rgba(30, 58, 138, 0.3) !important;
}

#previewDataTable th[data-pivoted="true"] {
    background: linear-gradient(135deg, #1e3a8a 0%, #764ba2 100%) !important;
    position: relative;
}

#previewDataTable th[data-pivoted="true"]::after {
    content: "📊";
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 10px;
    opacity: 0.7;
}

/* DataTables controls styling */
.dataTables_wrapper {
    color: white;
    background: transparent;
    padding: 1rem 0;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 13px;
    font-weight: 500;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: white !important;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus {
    outline: none !important;
    border-color: #1e3a8a !important;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.2) !important;
    background: rgba(255, 255, 255, 0.12) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: white !important;
    border-radius: 8px;
    margin: 0 3px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: rgba(30, 58, 138, 0.2) !important;
    border-color: #1e3a8a !important;
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: linear-gradient(135deg, #1e3a8a 0%, #764ba2 100%) !important;
    border-color: #1e3a8a !important;
    color: white !important;
    font-weight: 600;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    background: rgba(255, 255, 255, 0.03) !important;
    color: rgba(255, 255, 255, 0.3) !important;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Improve spacing and layout */
.dataTables_wrapper .row {
    margin: 0;
    align-items: center;
}

.dataTables_wrapper .col-sm-12,
.dataTables_wrapper .col-md-6 {
    padding: 0.5rem;
}

/* Search input styling */
.dataTables_wrapper .dataTables_filter input {
    min-width: 200px;
}

.dataTables_wrapper .dataTables_filter label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dataTables_wrapper .dataTables_length label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Responsive table styling */
@media (max-width: 768px) {
    .table-responsive {
        font-size: 0.875rem;
    }
    
    #previewDataTable thead th,
    #previewDataTable tbody td {
        padding: 8px 6px;
    }
}

.preview-section {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-header h3 {
    margin: 0;
    color: #1e3a8a;
    font-size: 1.25rem;
    font-weight: 600;
}

.preview-actions {
    display: flex;
    gap: 0.75rem;
}

.preview-info {
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.preview-count {
    font-weight: 600;
    color: #1e3a8a;
}

.preview-description {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
}

.preview-hint {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    margin-top: 0.5rem;
}

/* Removed duplicate .preview-table-container styles */

/* ===== DATE FIELD SUBMENU STYLING ===== */
.date-field-submenu {
    position: relative;
    display: inline-block;
    margin-right: 8px;
    z-index: 10004;
}

.btn-submenu-toggle {
    background: rgba(30, 58, 138, 0.2);
    border: 1px solid rgba(30, 58, 138, 0.3);
    color: #1e3a8a;
    border-radius: 4px;
    padding: 4px 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-submenu-toggle:hover {
    background: rgba(30, 58, 138, 0.3);
    border-color: #1e3a8a;
    color: white;
}

.date-submenu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0; /* Extend to full width of parent */
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid rgba(30, 58, 138, 0.3);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10010 !important; /* Higher than field items */
    min-width: 140px;
    backdrop-filter: blur(10px);
    margin-top: 4px; /* Add small gap from parent */
}

.submenu-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.submenu-item:last-child {
    border-bottom: none;
}

.submenu-item:hover {
    background: rgba(30, 58, 138, 0.2);
    color: white;
}

.submenu-icon {
    margin-right: 8px;
    font-size: 14px;
}

.submenu-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
}

.submenu-item:hover .submenu-text {
    color: white;
}

/* Close submenu when clicking outside */
body.click-outside-submenu .date-submenu {
    display: none !important;
}

.preview-table {
    flex: 1;
    overflow-x: auto;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 100%;
}

/* ===== RESPONSIVE TAB DESIGN ===== */

@media (max-width: 768px) {
    .tab-navigation {
        flex-direction: column;
    }
    
    .tab-button {
        justify-content: center;
        padding: 0.75rem 1rem;
    }
    
    .preview-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .preview-actions {
        justify-content: center;
    }
}

/* ===== ANIMATED TITLE ===== */
.animated-title {
    background: linear-gradient(135deg, #ffffff 0%, #e0e7ff 50%, #c7d2fe 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease-in-out infinite;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Fallback for browsers that don't support background-clip */
@supports not (-webkit-background-clip: text) {
    .animated-title {
        background: none;
        -webkit-text-fill-color: #ffffff;
        color: #ffffff;
        text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    }
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* ===== MODAL-BASED SUGGESTIONS SYSTEM ===== */

.suggestions-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.4) !important;
    z-index: 99999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    backdrop-filter: blur(3px) !important;
    animation: modalFadeIn 0.2s ease-out !important;
}

.suggestions-modal {
    background: rgba(26, 26, 46, 0.95) !important;
    border: 1px solid rgba(30, 58, 138, 0.3) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(10px) !important;
    max-width: 400px !important;
    width: 90% !important;
    max-height: 400px !important;
    overflow: hidden !important;
    position: relative !important;
    animation: modalSlideIn 0.3s ease-out !important;
}

.suggestions-modal-header {
    padding: 1rem !important;
    border-bottom: 1px solid rgba(30, 58, 138, 0.2) !important;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%) !important;
}

.suggestions-modal-header h3 {
    margin: 0 !important;
    color: white !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
}

.suggestions-modal-header p {
    margin: 0.25rem 0 0 0 !important;
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 0.875rem !important;
}

.suggestions-modal-body {
    max-height: 300px !important;
    overflow-y: auto !important;
    padding: 0.5rem !important;
}

.suggestions-modal-body .suggestion-item {
    padding: 0.75rem 1rem !important;
    cursor: pointer !important;
    color: rgba(255, 255, 255, 0.9) !important;
    border-radius: 6px !important;
    margin: 0.25rem 0 !important;
    transition: all 0.2s ease !important;
    border: 1px solid transparent !important;
}

.suggestions-modal-body .suggestion-item:hover {
    background: rgba(30, 58, 138, 0.2) !important;
    border-color: rgba(30, 58, 138, 0.4) !important;
    color: white !important;
}

.suggestions-modal-footer {
    padding: 1rem !important;
    border-top: 1px solid rgba(30, 58, 138, 0.2) !important;
    background: rgba(0, 0, 0, 0.1) !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.suggestions-modal-footer button {
    background: rgba(30, 58, 138, 0.2) !important;
    border: 1px solid rgba(30, 58, 138, 0.3) !important;
    color: white !important;
    padding: 0.5rem 1rem !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-size: 0.875rem !important;
    transition: all 0.2s ease !important;
}

.suggestions-modal-footer button:hover {
    background: rgba(30, 58, 138, 0.3) !important;
}

/* ===== SMART AUTOCOMPLETE ENHANCEMENTS ===== */

.suggestions-container {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 99999 !important;
    background: rgba(26, 26, 46, 0.95) !important;
    border: 1px solid rgba(30, 58, 138, 0.3) !important;
    border-radius: 8px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(10px) !important;
    max-height: 200px !important;
    overflow-y: auto !important;
    margin-top: 4px !important;
    animation: suggestionsSlideIn 0.2s ease-out !important;
}

.suggestions-container .suggestion-item {
    padding: 8px 12px !important;
    cursor: pointer !important;
    color: rgba(255, 255, 255, 0.9) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    transition: all 0.2s ease !important;
    font-size: 14px !important;
}

.suggestions-container .suggestion-item:hover,
.suggestions-container .suggestion-item.active {
    background: rgba(30, 58, 138, 0.3) !important;
    color: white !important;
}

.suggestions-container .suggestion-item:last-child {
    border-bottom: none !important;
}

.multi-value-indicator {
    font-size: 11px !important;
    color: #6b7280 !important;
    margin-top: 4px !important;
    padding: 4px 8px !important;
    background: #f3f4f6 !important;
    border-radius: 4px !important;
    display: none !important;
    animation: indicatorFadeIn 0.3s ease-out !important;
}

.field-loading-indicator {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    background: linear-gradient(135deg, rgba(30, 58, 138, 0.95) 0%, rgba(37, 99, 235, 0.95) 100%) !important;
    color: white !important;
    padding: 16px 20px !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
    backdrop-filter: blur(10px) !important;
    z-index: 99999 !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    animation: loadingSlideIn 0.3s ease-out !important;
}

.loading-spinner {
    width: 20px !important;
    height: 20px !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    border-top: 2px solid white !important;
    border-radius: 50% !important;
    animation: spin 1s linear infinite !important;
}

.loading-text {
    font-size: 14px !important;
    font-weight: 500 !important;
}

@keyframes suggestionsSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes indicatorFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes loadingSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Removed conflicting .live-preview-container .preview-header styles - now using .preview-table-header */

.preview-header-left {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.preview-header-left h3 {
    margin: 0;
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
}

.preview-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ===== DATATABLES HEADERS (NO STICKY) ===== */
.dataTables_wrapper .dataTables_scrollHead table thead th {
    z-index: 100 !important;
    background: rgba(30, 58, 138, 0.3) !important;
    backdrop-filter: blur(10px) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.dataTables_wrapper table thead th {
    z-index: 100 !important;
    background: rgba(30, 58, 138, 0.3) !important;
    backdrop-filter: blur(10px) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* Target DataTables-generated classes specifically */
.dataTables_wrapper table thead th.regular-column,
.dataTables_wrapper table thead th.sorting,
.dataTables_wrapper table thead th.sorting_asc,
.dataTables_wrapper table thead th.sorting_desc,
.dataTables_wrapper table thead th.sorting_disabled {
    z-index: 100 !important;
    background: rgba(30, 58, 138, 0.3) !important;
    backdrop-filter: blur(10px) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* Target the specific table ID */
#previewDataTable thead th {
    z-index: 100 !important;
    background: rgba(30, 58, 138, 0.3) !important;
    backdrop-filter: blur(10px) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* Force Live Preview headers to scroll normally - Override ALL inline styles */
.preview-table th,
.preview-table-content th,
.dynamic-table th,
#previewDataTable th {
    position: static !important; /* Force static positioning */
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: auto !important; /* Override any inline width */
    min-width: auto !important;
    max-width: none !important;
    background: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
    font-weight: 600 !important;
    z-index: 100 !important;
    backdrop-filter: blur(10px) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    display: table-cell !important;
    visibility: visible !important;
    opacity: 1 !important;
    /* Override any inline styles that might be set */
    margin: 0 !important;
    padding: 0.75rem 1rem !important;
    border: none !important;
    outline: none !important;
}

/* Animated title for Corsearch BI Report Developer v1.0 */
.animated-title {
    animation: titleGlow 3s ease-in-out infinite alternate;
    text-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

@keyframes titleGlow {
    0% {
        text-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
        transform: scale(1);
    }
    50% {
        text-shadow: 0 0 20px rgba(102, 126, 234, 0.5), 0 0 30px rgba(102, 126, 234, 0.3);
        transform: scale(1.02);
    }
    100% {
        text-shadow: 0 0 15px rgba(102, 126, 234, 0.4);
        transform: scale(1);
    }
}

/* Ensure the title maintains its original color */
.modal-subtitle.animated-title {
    color: inherit !important;
}

/* Report Viewing Page Styles - SIMPLIFIED */
#report-view {
    /* Remove conflicting styles - let main.css handle the layout */
}

.report-view-container {
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.report-stats {
    padding: 1.5rem 2rem;
    background: transparent;
    border: none;
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.report-stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.report-stat-label {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

.report-stat-value {
    font-size: 1.25rem;
    color: white;
    font-weight: 600;
}

.report-content {
    padding: 2rem;
    min-height: 600px;
}

.report-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 4rem 2rem;
    color: rgba(255, 255, 255, 0.8);
}

.report-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(102, 126, 234, 0.2);
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* REMOVED CONFLICTING RULE - USING CONSOLIDATED VERSION BELOW */

.report-table-container table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

.report-table-container thead th {
    background: rgba(30, 58, 138, 0.3);
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid rgba(102, 126, 234, 0.2);
    position: sticky;
    top: 0;
    z-index: 10;
}

.report-table-container tbody td {
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    max-width: 200px;
    overflow-wrap: break-word;
    vertical-align: top;
}

.report-table-container tbody tr:hover {
    background: rgba(102, 126, 234, 0.1);
}

.report-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 4rem 2rem;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
}

.report-empty-icon {
    font-size: 3rem;
    opacity: 0.5;
}

.report-empty-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
}

.report-empty-description {
    font-size: 0.875rem;
    max-width: 400px;
    line-height: 1.5;
}

/* DataTables Styling for Report View */
.report-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

.report-table-info h3 {
    margin: 0 0 0.25rem 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.25rem;
    font-weight: 600;
}

.report-table-info p {
    margin: 0;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
}

.report-table-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    visibility: visible;
    opacity: 1;
}

.report-table-scroll-container {
    max-height: calc(100vh - 300px);
    overflow: auto;
    background: rgba(255, 255, 255, 0.02);
}

/* DataTables Controls Styling */
.dataTables_wrapper {
    padding: 0 2rem 2rem 2rem;
    background: rgba(255, 255, 255, 0.02);
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: rgba(255, 255, 255, 0.8) !important;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: rgba(255, 255, 255, 0.9) !important;
    border-radius: 4px !important;
    padding: 0.25rem 0.5rem !important;
}

.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus {
    outline: none !important;
    border-color: #667eea !important;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    border-radius: 4px !important;
    margin: 0 2px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: rgba(102, 126, 234, 0.2) !important;
    border-color: #667eea !important;
    color: white !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #667eea !important;
    border-color: #667eea !important;
    color: white !important;
}

/* Ensure all DataTables pagination buttons have white text */
.dataTables_wrapper .dataTables_paginate .paginate_button,
.dataTables_wrapper .dataTables_paginate .paginate_button:hover,
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    color: white !important;
}

/* Bootstrap pagination buttons (page-link class) */
.dataTables_wrapper .dataTables_paginate .page-link,
.dataTables_wrapper .dataTables_paginate .page-link:hover,
.dataTables_wrapper .dataTables_paginate .page-link:focus,
.dataTables_wrapper .dataTables_paginate .page-item.active .page-link,
.dataTables_wrapper .dataTables_paginate .page-item.disabled .page-link {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.dataTables_wrapper .dataTables_paginate .page-link:hover {
    background-color: rgba(30, 58, 138, 0.3) !important;
    border-color: #1e3a8a !important;
}

.dataTables_wrapper .dataTables_paginate .page-item.active .page-link {
    background-color: #1e3a8a !important;
    border-color: #1e3a8a !important;
}

.dataTables_wrapper .dataTables_paginate .page-item.disabled .page-link {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    opacity: 0.5 !important;
}

/* Gap Overlay Toggle Styles - REMOVED CONFLICTING RULES */

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* ===== SIMPLIFIED REPORT TABLE STRUCTURE - FULL SCREEN ===== */

/* Main wrapper for report table - takes full available space */
.report-table-wrapper {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

/* Report table header - fixed height */
.report-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0; /* Prevent header from shrinking */
}

.report-table-info h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
}

.report-table-info p {
    margin: 0.25rem 0 0 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.report-table-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* REMOVED DUPLICATE RULE - USING CONSOLIDATED VERSION ABOVE */

/* Clean table styling - full width with proper scrolling */
.clean-table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    font-size: 0.875rem;
    margin: 0;
    table-layout: auto;
}

.clean-table th {
    background: linear-gradient(135deg, #e2e8f0 0%, #ffffff 50%, #f1f5f9 100%);
    color: #1f2937;
    font-weight: 600;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap; /* Prevent header text wrapping */
}

.clean-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    background: var(--bg-card);
    white-space: nowrap; /* Prevent cell text wrapping for better table appearance */
}

.clean-table tr:hover td {
    background: rgba(255, 255, 255, 0.05);
}

/* Pivoted column styling */
.pivoted-column {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 50%, #f59e0b 100%) !important;
    color: #92400e !important;
    font-weight: 600 !important;
}

.clean-table tr:hover .pivoted-column {
    background: linear-gradient(135deg, #fde68a 0%, #f59e0b 50%, #d97706 100%) !important;
}

/* ARR Pivot Table - Move controls to the right */
.pivot-table-container .table-header .mode-toggles {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.pivot-table-container .table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.pivot-table-container .table-header h3 {
    margin: 0;
    flex-shrink: 0;
}

/* Gap overlay toggle - CLEAN STABLE POSITIONING */
.gap-overlay-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    position: static;
    flex-shrink: 0;
    white-space: nowrap;
}

.gap-overlay-toggle .toggle-switch {
    position: static;
    margin: 0;
    flex-shrink: 0;
}

.gap-overlay-toggle .toggle-label {
    position: static;
    margin: 0;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Responsive design */
@media (max-width: 768px) {
    .report-table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .report-table-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .clean-table th,
    .clean-table td {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #1e3a8a;
    border-color: #1e3a8a;
}

.toggle-label {
    color: white;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

/* Gap overlay styles for missing months */
.gap-overlay-cell {
    background-color: rgba(255, 193, 7, 0.1) !important;
    border: 2px dashed rgba(255, 193, 7, 0.3) !important;
    color: #ffc107 !important;
    font-style: italic !important;
    text-align: center !important;
}

.gap-overlay-cell::after {
    content: "No Data";
    font-size: 12px;
    opacity: 0.7;
}

/* Pivot Column Styling for Report View */
#reportDataTable .pivoted-column {
    background: rgba(102, 126, 234, 0.1) !important;
    color: #667eea !important;
    font-weight: 600 !important;
}

#reportDataTable tbody .pivoted-column {
    background: rgba(102, 126, 234, 0.05) !important;
    color: rgba(102, 126, 234, 0.9) !important;
}

/* ===== REPORT VIEW PAGE ANIMATIONS ===== */

/* Page entrance animation */
@keyframes pageSlideIn {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header animation */
@keyframes headerGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(102, 126, 234, 0.6), 0 0 60px rgba(102, 126, 234, 0.3);
    }
}

/* Button hover animations */
@keyframes buttonPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    }
}

@keyframes buttonShimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Table animations */
@keyframes tableRowSlideIn {
    0% {
        opacity: 0;
        transform: translateX(-20px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes tableHeaderGlow {
    0%, 100% {
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    }
    50% {
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    }
}

/* Stats animation */
@keyframes statsCounter {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Loading animation */
@keyframes dataFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Floating elements */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Report view page styles - REMOVED DUPLICATE */

#report-view .page-header {
    animation: headerGlow 3s ease-in-out infinite;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    margin-bottom: 2rem;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

#report-view .page-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: buttonShimmer 3s infinite;
}

#report-view .page-title {
    animation: statsCounter 1s ease-out 0.3s both;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    text-shadow: 0 0 30px rgba(102, 126, 234, 0.5);
}

#report-view .page-subtitle {
    animation: statsCounter 1s ease-out 0.5s both;
    color: rgba(255, 255, 255, 0.8);
}

/* Header actions animation */
#report-view .header-actions {
    animation: statsCounter 1s ease-out 0.7s both;
}

#report-view .header-actions .btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    animation: float 3s ease-in-out infinite;
}

#report-view .header-actions .btn:nth-child(1) {
    animation-delay: 0s;
}

#report-view .header-actions .btn:nth-child(2) {
    animation-delay: 0.5s;
}

#report-view .header-actions .btn:hover {
    animation: buttonPulse 0.6s ease-in-out;
    transform: translateY(-3px) scale(1.05);
}

/* Report stats animation */
#reportStats {
    animation: statsCounter 1s ease-out 0.9s both;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    backdrop-filter: blur(5px);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Report table container - CONSOLIDATED VERSION WITH PROPER SCROLLING */
.report-table-container {
    flex: 1;
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
    min-height: 0;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* Add bottom padding so table doesn't touch bottom of screen */
    padding: 0 0 2rem 0;
    backdrop-filter: none;
    box-shadow: none;
}

/* DataTables wrapper padding for better spacing */
.report-table-container .dataTables_wrapper {
    padding-bottom: 4rem;
    overflow-x: auto;
    overflow-y: visible;
}

.report-table-container .dataTables_wrapper.dt-bootstrap5.no-footer {
    padding-bottom: 4rem;
    overflow-x: auto;
    overflow-y: visible;
}

/* Report View Table - Enhanced horizontal scrolling */
#report-view .report-table-container {
    padding: 1rem;
    margin: 0;
    padding-bottom: 2rem;
    overflow-x: auto;
    overflow-y: visible;
    max-width: 100%;
    /* Force horizontal scrollbar to always be visible when content overflows */
    scrollbar-width: thin;
    scrollbar-color: rgba(102, 126, 234, 0.5) rgba(26, 26, 36, 0.3);
    /* Ensure container has a defined width */
    width: 100%;
    min-width: 0;
}

#report-view .report-table-container::-webkit-scrollbar {
    height: 12px;
}

#report-view .report-table-container::-webkit-scrollbar-track {
    background: rgba(26, 26, 36, 0.3);
    border-radius: 6px;
}

#report-view .report-table-container::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.6);
    border-radius: 6px;
    border: 2px solid rgba(26, 26, 36, 0.3);
}

#report-view .report-table-container::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.8);
}

#report-view .report-table-wrapper {
    min-width: 100%;
    overflow-x: auto;
    width: max-content;
}

#report-view table {
    min-width: 100%;
    white-space: nowrap;
    width: max-content;
}

#report-view .dataTables_wrapper {
    overflow-x: auto !important;
    overflow-y: visible;
    width: 100%;
    /* Ensure horizontal scrollbar is visible */
    min-height: 0;
}

/* ReportDataTable specific scrolling */
#reportDataTable_wrapper {
    overflow-x: auto !important;
    overflow-y: visible !important;
    max-height: none;
}

/* Additional DataTables scrolling for report-view */
/* Remove conflicting DataTables overflow rules - let scrollX handle it */
#report-view .dataTables_wrapper .dataTables_scrollBody {
    /* Let DataTables scrollX handle scrolling */
}

#report-view .dataTables_wrapper .dataTables_scrollHead {
    /* Let DataTables scrollX handle scrolling */
}

/* Force table cells to not wrap and maintain minimum widths */
#report-view table th,
#report-view table td {
    white-space: nowrap !important;
    min-width: 150px !important; /* Increased minimum width */
    max-width: none !important;
    padding: 0.75rem 1rem !important;
    word-wrap: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    /* Ensure cells don't shrink */
    flex-shrink: 0;
}

#reportDataTable {
    min-width: 100%;
    white-space: nowrap;
}

.report-table-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2, #667eea);
    background-size: 200% 100%;
    animation: dataFlow 3s ease-in-out infinite;
}

/* Table header animation */
.report-table-header {
    animation: tableHeaderGlow 4s ease-in-out infinite;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    backdrop-filter: blur(5px);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.report-table-header h3 {
    animation: statsCounter 1s ease-out 1.3s both;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
}

/* Table actions animation */
.report-table-actions {
    animation: statsCounter 1s ease-out 1.5s both;
}

.report-table-actions .btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    animation: float 4s ease-in-out infinite;
}

.report-table-actions .btn:nth-child(1) {
    animation-delay: 0s;
}

.report-table-actions .btn:nth-child(2) {
    animation-delay: 0.3s;
}

.report-table-actions .btn:nth-child(3) {
    animation-delay: 0.6s;
}

.report-table-actions .btn:hover {
    animation: buttonPulse 0.6s ease-in-out;
    transform: translateY(-2px) scale(1.03);
}

/* Table animation */
.report-table-scroll-container {
    animation: statsCounter 1s ease-out 1.7s both;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#reportDataTable {
    animation: tableRowSlideIn 0.8s ease-out 1.9s both;
}

#reportDataTable thead th {
    animation: tableHeaderGlow 5s ease-in-out infinite;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    backdrop-filter: blur(5px);
    border: none;
    color: white;
    font-weight: 600;
    padding: 1rem;
    position: relative;
}

#reportDataTable thead th::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    background-size: 200% 100%;
    animation: dataFlow 3s ease-in-out infinite;
}

#reportDataTable tbody tr {
    animation: tableRowSlideIn 0.6s ease-out both;
    transition: all 0.3s ease;
}

#reportDataTable tbody tr:nth-child(1) { animation-delay: 2.1s; }
#reportDataTable tbody tr:nth-child(2) { animation-delay: 2.2s; }
#reportDataTable tbody tr:nth-child(3) { animation-delay: 2.3s; }
#reportDataTable tbody tr:nth-child(4) { animation-delay: 2.4s; }
#reportDataTable tbody tr:nth-child(5) { animation-delay: 2.5s; }

#reportDataTable tbody tr:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    transform: translateX(5px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

#reportDataTable tbody td {
    padding: 1rem;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
}

#reportDataTable tbody td:hover {
    background: rgba(102, 126, 234, 0.1);
    color: white;
}

/* Gap overlay toggle animation - REMOVED TO PREVENT BOUNCING */

.toggle-switch {
    animation: float 3s ease-in-out infinite;
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.5);
}

/* DataTables pagination animation */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    transition: all 0.3s ease;
    animation: float 5s ease-in-out infinite;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:nth-child(1) { animation-delay: 0s; }
.dataTables_wrapper .dataTables_paginate .paginate_button:nth-child(2) { animation-delay: 0.2s; }
.dataTables_wrapper .dataTables_paginate .paginate_button:nth-child(3) { animation-delay: 0.4s; }

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    animation: buttonPulse 0.6s ease-in-out;
    transform: translateY(-2px) scale(1.05);
}

/* Responsive animations */
@media (max-width: 768px) {
    #report-view .page-header {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .report-table-container {
        padding: 1.5rem;
    }
    
    .report-table-header {
        padding: 1rem;
    }
}

/* Dual Scrollbar Styles */
.table-scrollbar-top {
    overflow-x: auto;
    overflow-y: hidden;
    height: 17px; /* Standard scrollbar height */
    margin-bottom: 8px;
    border-radius: 4px;
    background: rgba(26, 26, 46, 0.3);
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.table-scrollbar-top::-webkit-scrollbar {
    height: 17px;
}

.table-scrollbar-top::-webkit-scrollbar-track {
    background: rgba(26, 26, 46, 0.3);
    border-radius: 4px;
}

.table-scrollbar-top::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    border: 2px solid rgba(26, 26, 46, 0.3);
}

.table-scrollbar-top::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

.scrollbar-content {
    height: 1px;
    background: transparent;
}

/* Removed conflicting sticky header styles for old containers - now handled by .full-preview-table */
