/* ===== SHARED.CSS - Wspólne style dla wszystkich stron ===== */

/* === CHART COMPONENTS - Consolidated from all files === */

/* Chart Wrapper - Main container for all charts */
.chart-wrapper {
    background-color: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    width: 100%;
    display: block;
}

/* Chart Container - for chart content */
.chart-container {
    height: 280px;
    position: relative;
    width: 100%;
}

/* Chart size variations */
.chart-container.small { height: 200px; }
.chart-container.medium { height: 280px; }
.chart-container.large { height: 350px; }
.chart-container.extra-large { height: 450px; }

.chart-wrapper-small {
    flex-shrink: 0;
    width: 180px;
    height: 180px;
}

/* Chart Legend - Consolidated styling */
.chart-legend {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    max-width: 100%;
    overflow: hidden;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s;
}

.chart-legend.interactive .legend-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.chart-legend.interactive .legend-item.disabled {
    opacity: 0.5;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Chart.js Legend Horizontal Scrolling */
.chart-wrapper canvas + div {
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    white-space: nowrap !important;
}

.chart-wrapper .chartjs-legend ul,
.chart-wrapper [class*="legend"] ul {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    max-width: 600px !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    scrollbar-width: thin;
}

.chart-wrapper .chartjs-legend ul::-webkit-scrollbar,
.chart-wrapper [class*="legend"] ul::-webkit-scrollbar {
    height: 6px;
}

.chart-wrapper .chartjs-legend ul::-webkit-scrollbar-track,
.chart-wrapper [class*="legend"] ul::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chart-wrapper .chartjs-legend ul::-webkit-scrollbar-thumb,
.chart-wrapper [class*="legend"] ul::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chart-wrapper .chartjs-legend li,
.chart-wrapper [class*="legend"] li {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    margin-right: 16px !important;
}

/* === TABLE COMPONENTS - Consolidated from all files === */

/* Table Wrapper - Main container for tables */
.table-wrapper {
    background-color: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

/* Data Table - Main table styling */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted, #9ca3af);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light, #e5e7eb);
}

.data-table td {
    padding: 16px 0;
    font-size: 14px;
    color: var(--text-primary, #111827);
    border-bottom: 1px solid var(--gray-100, #f3f4f6);
}

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

.data-table tr:hover {
    background-color: rgba(246, 194, 62, 0.05);
}

/* Widget Table - for tables inside widgets */
.widget-table {
    width: 100%;
    border-collapse: collapse;
}

.widget-table th {
    text-align: left;
    padding: 0.75rem 0.5rem;
    color: var(--text-secondary, #6b7280);
    font-size: 0.875rem;
    font-weight: 500;
    border-bottom: 1px solid var(--border-light, #e5e7eb);
    position: sticky;
    top: 0;
    background: var(--bg-card, #ffffff);
}

.widget-table td {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.5);
    vertical-align: middle;
}

.widget-table tr:hover {
    background: rgba(246, 194, 62, 0.05);
}

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

.table-container {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

/* === STATS COMPONENTS - Consolidated from all files === */

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

/* Stat Card */
.stat-card {
    background-color: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.stat-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-title {
    font-size: 13px;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 4px;
    font-weight: 500;
}

.stat-period {
    color: var(--text-muted, #9ca3af);
    font-size: 0.75rem;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary, #111827);
    margin-bottom: 8px;
}

.stat-change {
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
}

/* Stat Icons */
.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-icon.visitors {
    background-color: rgba(59, 130, 246, 0.1);
    color: #3B82F6;
}

.stat-icon.views {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success, #10b981);
}

.stat-icon.source {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning, #f59e0b);
}

.stat-icon.orders {
    background-color: rgba(139, 92, 246, 0.1);
    color: var(--primary, #8b5cf6);
}

.stat-icon.revenue {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger, #ef4444);
}

.stat-icon.conversion {
    background-color: rgba(6, 182, 212, 0.1);
    color: var(--secondary, #06b6d4);
}

/* Stats List */
.stats-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light, #e5e7eb);
}

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

.stat-label {
    font-size: 13px;
    color: var(--text-secondary, #6b7280);
}

.stat-badge {
    background-color: var(--gray-100, #f3f4f6);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}

/* === DEVICE BREAKDOWN - Consolidated from all files === */

.device-breakdown {
    display: flex;
    gap: 2rem;
    align-items: center;
    padding: 1rem;
}

.device-chart {
    flex-shrink: 0;
    width: 200px;
    height: 200px;
}

.device-legend {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
}

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

.device-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.device-label {
    font-size: 0.875rem;
    color: var(--text-primary, #111827);
}

.device-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    margin-left: auto;
}

/* Device Breakdown - Small variant */
.devices-chart-container {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1rem;
    height: 250px;
}

.devices-chart-container-small {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    height: 240px;
}

.devices-legend {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
}

.devices-legend-small {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.legend-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.legend-label {
    font-size: 0.875rem;
    color: var(--text-primary, #111827);
}

.legend-value {
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
    font-weight: 600;
}

.legend-item-small {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.legend-item-small .legend-label {
    font-size: 0.75rem;
    color: var(--text-primary, #111827);
}

.legend-item-small .legend-value {
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
    font-weight: 600;
}

.legend-item-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* === BADGES - Consolidated from all files === */

.metric-badge {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.time-badge {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Monaco', 'Menlo', monospace;
}

.source-badge {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning, #f59e0b);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.user-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.user-badge.new {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success, #10b981);
}

.user-badge.returning {
    background: rgba(59, 130, 246, 0.1);
    color: #3B82F6;
}

.user-badge.customer {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary, #8b5cf6);
}

.consent-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.consent-badge.granted {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success, #10b981);
}

.consent-badge.denied {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger, #ef4444);
}

.consent-badge.unknown {
    background: rgba(156, 163, 175, 0.1);
    color: var(--gray-500, #6b7280);
}

/* === DATE PICKER - Consolidated from all files === */

.date-range-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background-color: var(--gray-50, #f9fafb);
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-base, all 0.2s);
    font-size: 13px;
    color: var(--text-secondary, #6b7280);
    position: relative !important;
}

.date-range-picker:hover {
    background-color: var(--gray-100, #f3f4f6);
    border-color: var(--gray-300, #d1d5db);
}

.date-range-picker i {
    color: var(--gray-500, #6b7280);
}

.date-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 12px;
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
    min-width: 350px;
    z-index: 1000;
    margin-top: 8px;
    padding: 20px;
}

.is-hidden {
    display: none;
}

.date-dropdown.force-open {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.date-dropdown-header {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #111827);
    margin-bottom: 16px;
}

.date-presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.date-preset {
    padding: 8px 12px;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 6px;
    background-color: var(--bg-primary, #ffffff);
    color: var(--text-secondary, #6b7280);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition-base, all 0.2s);
    text-align: center;
}

.date-preset:hover {
    background-color: var(--gray-50, #f9fafb);
    border-color: var(--gray-300, #d1d5db);
}

.date-preset.active {
    background-color: var(--primary, #8b5cf6);
    color: white;
    border-color: var(--primary, #8b5cf6);
}

.date-custom {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.date-custom.is-hidden {
    display: none;
}

.date-custom input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--gray-300, #d1d5db);
    border-radius: 6px;
    font-size: 14px;
}

.date-dropdown-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* === LIVE INDICATORS - Consolidated from all files === */

.live-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--success, #10b981);
}

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--success, #10b981);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.active {
    background: var(--success, #10b981);
    animation: pulse 1.5s infinite;
}

.status-indicator.inactive {
    background: var(--gray-400, #9ca3af);
}

/* === CELL COMPONENTS - Consolidated from all files === */

.page-cell {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.page-cell .page-title {
    font-size: 0.875rem;
    color: var(--text-primary, #111827);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.page-views {
    font-size: 0.75rem;
    color: var(--text-muted, #9ca3af);
}

.page-url {
    font-size: 0.75rem;
    color: var(--text-muted, #9ca3af);
    font-family: 'Monaco', 'Menlo', monospace;
    opacity: 0.8;
}

.time-cell {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.time-primary {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.875rem;
    color: var(--text-primary, #111827);
}

.time-secondary {
    font-size: 0.75rem;
    color: var(--text-muted, #9ca3af);
}

.device-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.device-cell i {
    color: var(--text-secondary, #6b7280);
}

.device-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.device-type {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary, #111827);
}

.browser-name {
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-id {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
    color: var(--text-primary, #111827);
}

.user-badges {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.consent-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

/* === ACTION BUTTONS - Consolidated from all files === */

.action-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 6px;
    background: var(--bg-primary, #ffffff);
    color: var(--text-secondary, #6b7280);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.action-btn:hover {
    background: var(--primary, #8b5cf6);
    border-color: var(--primary, #8b5cf6);
    color: white;
}

.journey-link {
    color: var(--text-secondary, #6b7280);
    text-decoration: none;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.journey-link:hover {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    text-decoration: none;
}

.journey-link i {
    display: inline-block;
}

/* === NO DATA STATE - Consolidated from all files === */

.no-data {
    text-align: center;
    color: var(--text-muted, #9ca3af);
    font-style: italic;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.no-data i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* === ALERTS - Consolidated from all files === */

.conversion-alert {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.conversion-alert i {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.conversion-alert .alert-text {
    line-height: 1.4;
}

/* === ANIMATIONS - Consolidated from all files === */

@keyframes pulse {
    0% {
        transform: scale(0.95);
        opacity: 1;
    }
    70% {
        transform: scale(1);
        opacity: 0.7;
    }
    100% {
        transform: scale(0.95);
        opacity: 1;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === RESPONSIVE DESIGN - Consolidated mobile optimizations === */

@media (max-width: 768px) {
    .chart-container {
        height: 200px;
    }
    
    .device-breakdown {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .device-chart {
        width: 150px;
        height: 150px;
    }
    
    .chart-legend {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .devices-chart-container {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }
    
    .devices-legend {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-cell .page-title {
        max-width: 150px;
    }
    
    .date-dropdown {
        min-width: 280px;
        padding: 16px;
    }
    
    .date-presets {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .chart-container {
        height: 180px;
    }
    
    .device-chart {
        width: 120px;
        height: 120px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card .stat-value {
        font-size: 20px;
    }
}

/* ===== WIDGETS ===== */

/* Widget Container */
.widget {
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.widget-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary, #111827);
    margin: 0;
}

.widget-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.widget-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    border-radius: 0.25rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.widget-btn:hover {
    background: var(--bg-gray-light, #f3f4f6);
    color: var(--text-primary, #111827);
}

/* Chart Components */
.chart-container {
    height: 280px;
    position: relative;
    width: 100%;
}

.chart-container.small { height: 200px; }
.chart-container.medium { height: 280px; }
.chart-container.large { height: 350px; }
.chart-container.extra-large { height: 450px; }

.chart-legend {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    max-width: 100%;
    overflow: hidden;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s;
}

.chart-legend.interactive .legend-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.chart-legend.interactive .legend-item.disabled {
    opacity: 0.5;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Table Components */
.table-container {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.widget-table {
    width: 100%;
    border-collapse: collapse;
}

.widget-table th {
    text-align: left;
    padding: 0.75rem 0.5rem;
    color: var(--text-secondary, #6b7280);
    font-size: 0.875rem;
    font-weight: 500;
    border-bottom: 1px solid var(--border-light, #e5e7eb);
    position: sticky;
    top: 0;
    background: var(--bg-card, #ffffff);
}

.widget-table td {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.5);
    vertical-align: middle;
}

.widget-table tr:hover {
    background: rgba(246, 194, 62, 0.05);
}

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

/* Badges */
.metric-badge {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.time-badge {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Monaco', 'Menlo', monospace;
}

.source-badge {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning, #f59e0b);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.no-data {
    text-align: center;
    color: var(--text-muted, #9ca3af);
    font-style: italic;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.no-data i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.widget.small { min-height: 200px; }
.widget.medium { min-height: 280px; }
.widget.large { min-height: 350px; }
.widget.extra-large { min-height: 450px; }
.widget.full-width { width: 100%; }

@media (max-width: 768px) {
    .device-breakdown {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .device-chart {
        width: 150px;
        height: 150px;
    }
    
    .chart-container {
        height: 200px;
    }
    
    .chart-legend {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .widget-table {
        font-size: 0.875rem;
    }
    
    .widget-table th,
    .widget-table td {
        padding: 0.5rem 0.25rem;
    }
}

@media (max-width: 480px) {
    .widget {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .chart-container {
        height: 180px;
    }
    
    .device-chart {
        width: 120px;
        height: 120px;
    }
}

.widget.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.widget.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid var(--border-light, #e5e7eb);
    border-top: 2px solid var(--primary, #8b5cf6);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Page layouts */
#dashboard-widgets-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
    width: 100%;
}

#dashboard-traffic-chart {
    grid-column: 1 / -1;
    width: 100%;
}

#dashboard-devices-widget { grid-column: 1; }
#dashboard-realtime-widget { grid-column: 2; }

#dashboard-sources-chart {
    grid-column: 1 / -1;
    width: 100%;
}

#traffic-sources-widgets-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

#traffic-sources-main-chart {
    width: 100%;
    min-height: 400px;
}

#traffic-sources-breakdown-table {
    width: 100%;
    min-height: 350px;
}

#conversions-widgets-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

#conversions-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

#conversions-main-chart {
    width: 100%;
    min-height: 400px;
}

#conversions-sources-table {
    width: 100%;
    min-height: 350px;
}

#devices-widgets-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

#devices-breakdown-chart {
    width: 100%;
    min-height: 300px;
}

#devices-trends-chart {
    width: 100%;
    min-height: 350px;
}

#devices-details-table {
    width: 100%;
    min-height: 400px;
}

#live-widgets-container {
    display: block;
    width: 100%;
}

#live-realtime-stats {
    width: 100%;
    margin-bottom: 1.5rem;
}

#live-activity-table {
    width: 100%;
    min-height: 500px;
}

#live-users-map {
    width: 100%;
    min-height: 400px;
    margin-top: 1.5rem;
}

#visitor-journey-widgets-container {
    display: block;
    width: 100%;
}

#visitor-journey-flow-chart {
    width: 100%;
    min-height: 500px;
    margin-bottom: 1.5rem;
}

#visitor-journey-paths-table {
    width: 100%;
    min-height: 400px;
}

#visitor-journey-funnel {
    width: 100%;
    min-height: 350px;
    margin-top: 1.5rem;
}

#product-mappings-widgets-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

#product-mappings-table {
    width: 100%;
    min-height: 600px;
}

#product-mappings-stats {
    width: 100%;
    margin-bottom: 1.5rem;
}

@media (min-width: 1400px) {
    #dashboard-widgets-container {
        grid-template-columns: 1fr 1fr;
        gap: 32px;
    }
}

@media (max-width: 1399px) and (min-width: 1200px) {
    #dashboard-widgets-container {
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }
}

@media (max-width: 1199px) and (min-width: 768px) {
    #dashboard-widgets-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    #dashboard-devices-widget,
    #dashboard-realtime-widget {
        grid-column: 1;
    }
    
    #conversions-stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 767px) {
    #dashboard-widgets-container,
    #traffic-sources-widgets-container,
    #conversions-widgets-container,
    #devices-widgets-container,
    #live-widgets-container,
    #visitor-journey-widgets-container,
    #product-mappings-widgets-container {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }
    
    #conversions-stats-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    #dashboard-traffic-chart,
    #dashboard-devices-widget,
    #dashboard-realtime-widget,
    #dashboard-sources-chart,
    #traffic-sources-main-chart,
    #traffic-sources-breakdown-table,
    #conversions-main-chart,
    #conversions-sources-table,
    #devices-breakdown-chart,
    #devices-trends-chart,
    #devices-details-table,
    #live-realtime-stats,
    #live-activity-table,
    #live-users-map,
    #visitor-journey-flow-chart,
    #visitor-journey-paths-table,
    #visitor-journey-funnel,
    #product-mappings-table,
    #product-mappings-stats {
        width: 100%;
        grid-column: 1;
    }
}

#dashboard-traffic-chart { min-height: 400px; }
#dashboard-devices-widget { min-height: 300px; }
#dashboard-realtime-widget { min-height: 300px; }
#dashboard-sources-chart { min-height: 450px; }

#traffic-sources-main-chart { min-height: 400px; }
#traffic-sources-breakdown-table { min-height: 350px; }

#conversions-main-chart { min-height: 400px; }
#conversions-sources-table { min-height: 350px; }

#devices-breakdown-chart { min-height: 300px; }
#devices-trends-chart { min-height: 350px; }
#devices-details-table { min-height: 400px; }

#live-realtime-stats { min-height: 150px; }
#live-activity-table { min-height: 500px; }
#live-users-map { min-height: 400px; }

#visitor-journey-flow-chart { min-height: 500px; }
#visitor-journey-paths-table { min-height: 400px; }
#visitor-journey-funnel { min-height: 350px; }

#product-mappings-table { min-height: 600px; }
#product-mappings-stats { min-height: 200px; }

.page-404-icon {
    font-size: 5rem;
}

/* Cache manager page: keep card/table overrides scoped locally */
body.page-cache-manager .card {
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

body.page-cache-manager .card-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.25rem;
}

body.page-cache-manager .card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

body.page-cache-manager .card-body {
    padding: 1.25rem;
}

body.page-cache-manager .table {
    margin-bottom: 0;
}

body.page-cache-manager .table th {
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-light);
}

body.page-cache-manager .table td {
    vertical-align: middle;
}

body.page-cache-manager code {
    background-color: var(--bg-secondary);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

body.page-cache-manager .spinner-border {
    width: 2rem;
    height: 2rem;
}

body.page-cache-manager .alert {
    border: none;
    border-radius: 0.5rem;
}

body.page-cache-manager .alert-info {
    background-color: rgba(13, 110, 253, 0.1);
    color: var(--text-primary);
}

body.page-cache-manager #cache-status .stat-box {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
}

body.page-cache-manager #cache-status .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

body.page-cache-manager #cache-status .stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Force cache clear page */
body.page-force-cache-clear {
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body.page-force-cache-clear .force-cache-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 40px;
    max-width: 600px;
    width: 90%;
    text-align: center;
}

body.page-force-cache-clear .force-cache-title {
    color: #333;
    margin-bottom: 10px;
}

body.page-force-cache-clear .force-cache-subtitle {
    color: #666;
    margin-bottom: 30px;
}

body.page-force-cache-clear .force-cache-alert {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
    padding: 15px;
    border-radius: 6px;
    margin: 20px 0;
}

body.page-force-cache-clear .force-cache-alert-success {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

body.page-force-cache-clear .force-cache-status-box {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

body.page-force-cache-clear .force-cache-steps {
    text-align: left;
    max-width: 400px;
    margin: 0 auto;
}

body.page-force-cache-clear .force-cache-btn {
    display: inline-block;
    padding: 12px 24px;
    margin: 10px 5px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s;
}

body.page-force-cache-clear .force-cache-btn-primary {
    background: #0d6efd;
    color: white;
}

body.page-force-cache-clear .force-cache-btn-primary:hover {
    background: #0b5ed7;
}

body.page-force-cache-clear .force-cache-btn-success {
    background: #198754;
    color: white;
}

body.page-force-cache-clear .force-cache-btn-success:hover {
    background: #157347;
}

body.page-force-cache-clear .force-cache-btn-secondary {
    background: #6c757d;
    color: white;
}

body.page-force-cache-clear .force-cache-btn-secondary:hover {
    background: #5c636a;
}

body.page-force-cache-clear #loading {
    display: none;
}

body.page-force-cache-clear #success-message {
    display: none;
}

body.page-force-cache-clear .force-cache-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0d6efd;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: force-cache-spin 1s linear infinite;
    margin: 20px auto;
}

body.page-force-cache-clear .force-cache-footer {
    margin-top: 30px;
}

body.page-force-cache-clear .force-cache-back-link {
    color: #0d6efd;
}

@keyframes force-cache-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Login page */
body.page-login {
    --login-primary-color: #F7A414;
    --login-bg-primary: #2d3748;
    --login-bg-secondary: #4a5568;
    --login-bg-card: #ffffff;
    --login-text-primary: #ffffff;
    --login-text-secondary: #a0aec0;
    --login-text-dark: #2d3748;
    --login-border-color: #4a5568;
    --login-danger-color: #e53e3e;

    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--login-text-primary);
    background: linear-gradient(135deg, var(--login-bg-primary) 0%, var(--login-bg-secondary) 100%);
}

body.page-login *,
body.page-login *::before,
body.page-login *::after {
    box-sizing: border-box;
}

body.page-login .login-container {
    width: 100%;
    max-width: 500px;
    padding: 2rem;
}

body.page-login .login-card {
    background: var(--login-bg-card);
    border-radius: 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    border: 1px solid var(--login-border-color);
}

body.page-login .login-header {
    background: linear-gradient(135deg, var(--login-bg-primary) 0%, var(--login-bg-secondary) 100%);
    padding: 2.5rem 2rem 2rem;
    text-align: center;
    color: var(--login-text-primary);
}

body.page-login .logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

body.page-login .logo img {
    height: 60px;
    width: auto;
}

body.page-login .login-subtitle {
    color: var(--login-text-secondary);
    font-size: 1rem;
    margin: 0;
}

body.page-login .login-form {
    padding: 2rem;
}

body.page-login .form-group {
    margin-bottom: 1.5rem;
}

body.page-login .form-label {
    color: var(--login-text-dark);
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: block;
}

body.page-login .form-control {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    transition: all 0.2s;
    color: var(--login-text-dark);
}

body.page-login .form-control:focus {
    border-color: var(--login-primary-color);
    box-shadow: 0 0 0 3px rgba(246, 194, 62, 0.1);
    background: #ffffff;
}

body.page-login .btn-login {
    background: var(--login-primary-color);
    border: none;
    border-radius: 0.75rem;
    padding: 1rem 2rem;
    font-weight: 600;
    font-size: 1rem;
    color: #fff;
    width: 100%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

body.page-login .btn-login:hover {
    background: rgba(247, 164, 20, 0.90);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(246, 194, 62, 0.4);
    color: #fff;
}

body.page-login .alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--login-danger-color);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    color: var(--login-danger-color);
    font-weight: 500;
}

body.page-login .setup-notice {
    background: var(--login-bg-card);
    border-radius: 1.5rem;
    padding: 2.5rem;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--login-border-color);
    color: var(--login-text-dark);
}

body.page-login .setup-notice h2 {
    color: var(--login-primary-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 700;
}

body.page-login .setup-notice p {
    color: var(--login-text-secondary);
    margin-bottom: 1rem;
}

body.page-login .btn-setup {
    background: var(--login-primary-color);
    border: none;
    border-radius: 0.75rem;
    padding: 1rem 2rem;
    font-weight: 600;
    color: #000;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

body.page-login .btn-setup:hover {
    background: #e6b035;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(246, 194, 62, 0.4);
    color: #000;
}

body.page-login .login-footer {
    background: #f8fafc;
    padding: 1.5rem 2rem;
    text-align: center;
    border-top: 1px solid #e2e8f0;
    color: var(--login-text-secondary);
    font-size: 0.875rem;
}

@media (max-width: 480px) {
    body.page-login .login-container {
        padding: 1rem;
    }

    body.page-login .login-header {
        padding: 2rem 1.5rem 1.5rem;
    }

    body.page-login .login-form {
        padding: 1.5rem;
    }

    body.page-login .logo-text {
        font-size: 1.5rem;
    }
}

/* ML settings page: extracted inline styles */
body.page-ml-settings .metric-bar {
    height: 8px;
    background: var(--border-light, #e5e7eb);
    border-radius: 999px;
    overflow: hidden;
    margin: 0.5rem 0 0.75rem;
}

body.page-ml-settings .metric-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    transition: width 0.3s ease;
}

body.page-ml-settings .metric-fill.green {
    background: #10b981;
}

body.page-ml-settings .metric-fill.orange {
    background: #f59e0b;
}

body.page-ml-settings .ml-training-info-error {
    color: #ef4444;
}

body.page-ml-settings .ml-training-info-success {
    color: #10b981;
}

body.page-ml-settings .active-jobs-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

body.page-ml-settings .job-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1rem;
    transition: var(--transition-base);
}

body.page-ml-settings .job-card.status-running {
    border-color: var(--primary-color);
    background: rgba(91, 33, 182, 0.02);
}

body.page-ml-settings .job-card.status-pending {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.02);
}

body.page-ml-settings .status-running .job-status {
    background: var(--primary-color);
    color: white;
}

body.page-ml-settings .status-pending .job-status {
    background: var(--warning);
    color: white;
}

body.page-ml-settings .sidebar-action-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

body.page-ml-settings .sidebar-action-card h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

body.page-ml-settings .sidebar-action-card h4 i {
    color: var(--primary-color);
}

body.page-ml-settings .sidebar-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    padding: 0 0.5rem;
}

body.page-ml-settings .training-log {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 1rem;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

body.page-ml-settings .training-log .log-entry {
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

body.page-ml-settings .training-log .error {
    color: #dc2626;
    font-weight: 600;
}

body.page-ml-settings .training-log .success {
    color: #059669;
    font-weight: 600;
}

body.page-ml-settings .metric-example {
    background: white;
    padding: 1rem;
    border-radius: 0.375rem;
    margin: 0.75rem 0;
    border: 1px solid #e5e7eb;
}

body.page-ml-settings .metric-note {
    background: #fef3c7;
    padding: 0.75rem;
    border-radius: 0.375rem;
    margin-top: 0.75rem;
    border: 1px solid #fbbf24;
    color: #92400e;
}

body.page-ml-settings .metric-formula {
    background: #1f2937;
    color: #f3f4f6;
    padding: 1rem;
    border-radius: 0.375rem;
    font-family: 'Courier New', monospace;
    text-align: center;
    margin: 0.75rem 0;
}

body.page-ml-settings .business-tips {
    background: #eff6ff;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #bfdbfe;
}

body.page-ml-settings .business-tips ul {
    margin: 0.5rem 0 0 1.5rem;
    padding: 0;
}

body.page-ml-settings .active-model {
    background-color: rgba(91, 33, 182, 0.05);
}

body.page-ml-settings .subpage-container {
    display: block !important;
    max-width: none !important;
    width: 100% !important;
}

body.page-ml-settings .filters-sidebar {
    display: none !important;
}

body.page-ml-settings .page-header {
    background: transparent !important;
}

body.page-ml-settings .ml-hidden {
    display: none;
}

body.page-ml-settings #progressBar,
body.page-ml-settings #trainingProgressBar {
    width: 0;
}

/* ===== PROFESSIONAL TONE OVERRIDES ===== */
.chart-wrapper,
.table-wrapper,
.stat-card,
.widget {
    border-color: var(--border-light, #e7ebf0);
    border-radius: 10px;
    box-shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
}

.data-table tr:hover,
.widget-table tr:hover {
    background: rgba(63, 95, 134, 0.045);
    box-shadow: inset 2px 0 0 rgba(63, 95, 134, 0.38);
}

.chart-legend.interactive .legend-item:hover {
    background-color: rgba(63, 95, 134, 0.06);
}

.data-table th,
.widget-table th {
    color: #7b8799;
}

.data-table td,
.widget-table td {
    color: #2c3646;
}

.legend-item,
.chart-legend .legend-item {
    border: 1px solid rgba(63, 95, 134, 0.12);
    background: rgba(255, 255, 255, 0.82);
}

.chart-wrapper canvas,
.widget .chart-container canvas,
.chart-container-pie canvas {
    filter: saturate(0.9);
}

.metric-badge {
    background: rgba(79, 111, 149, 0.12) !important;
    color: #3f5f86 !important;
    border: 1px solid rgba(79, 111, 149, 0.2);
}

.time-badge {
    background: rgba(76, 126, 120, 0.12) !important;
    color: #3f6a66 !important;
    border: 1px solid rgba(76, 126, 120, 0.2);
}

.source-badge {
    background: rgba(168, 131, 79, 0.12) !important;
    color: #8f6b3d !important;
    border: 1px solid rgba(168, 131, 79, 0.2);
}

.stat-badge {
    background: rgba(63, 95, 134, 0.1) !important;
    color: #3f5f86 !important;
    border: 1px solid rgba(63, 95, 134, 0.18);
}
