/* Zalazium Dashboard - Futuristic Dark Theme */

/* CSS Variables for Design System */
:root {
    /* Primary Palette - Cyan/Electric Blue accent */
    --primary: #00d4ff;
    --primary-dim: rgba(0, 212, 255, 0.15);
    --primary-glow: 0 0 20px rgba(0, 212, 255, 0.15);
    --primary-glow-md: 0 0 12px rgba(0, 212, 255, 0.3);
    --success-dim: rgba(0, 229, 160, 0.15);
    --warning-dim: rgba(255, 178, 36, 0.15);
    --error-dim: rgba(255, 77, 106, 0.15);

    /* Semantic Colors */
    --success: #00e5a0;
    --warning: #ffb224;
    --error: #ff4d6a;
    --info: #38bdf8;

    /* Text Colors */
    --text-primary: #e8edf5;
    --text-secondary: #8494a7;
    --text-muted: #6b7a8d;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #00d4ff 0%, #7c3aed 100%);
    --gradient-success: linear-gradient(135deg, #00e5a0 0%, #10b981 100%);
    --gradient-warning: linear-gradient(135deg, #ffb224 0%, #f59e0b 100%);
    --gradient-error: linear-gradient(135deg, #ff4d6a 0%, #ef4444 100%);
    --gradient-info: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%);

    /* Surface Colors - Dark */
    --bg-base: #0a0e1a;
    --bg-surface: #111827;
    --bg-card: #151c2e;
    --bg-elevated: #1a2237;
    --bg-hover: #1e2840;
    --bg-input: #0f1525;

    /* Border Colors */
    --border: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.04);
    --border-focus: var(--primary);

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-12: 3rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Z-Index Scale */
    --z-sticky: 100;
    --z-overlay: 1000;
    --z-notification: 1200;

    /* Shadows - Dark-optimized */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 16px 40px rgba(0, 0, 0, 0.5);
    --shadow-2xl: 0 24px 60px rgba(0, 0, 0, 0.6);

    /* Typography */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;

    /* Animation */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    color-scheme: dark;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-base);
    font-size: var(--font-size-base);
    overflow-x: hidden;
}

/* App Container */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
}

/* Header Styles */
.header {
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    overflow-x: hidden;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-6);
    max-width: 1400px;
    margin: 0 auto;
    gap: var(--space-6);
}

.header-left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-width: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.logo-icon {
    font-size: var(--font-size-2xl);
}

.logo h1 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Shared Button Base */
.refresh-btn,
.export-btn,
.save-btn,
.logout-btn,
.nuke-btn,
.download-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-4);
    height: 36px;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-elevated);
}

.refresh-btn:hover,
.export-btn:hover,
.save-btn:hover,
.download-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    box-shadow: var(--primary-glow);
    transform: translateY(-1px);
}

.refresh-btn:active,
.export-btn:active,
.save-btn:active,
.download-btn:active {
    transform: translateY(0);
}

.refresh-btn.loading .refresh-icon {
    animation: spin 1s linear infinite;
}


.nuke-btn {
    border-color: rgba(255, 178, 36, 0.3);
}

.nuke-btn:hover {
    border-color: var(--warning);
    background: rgba(255, 178, 36, 0.1);
    box-shadow: 0 0 20px rgba(255, 178, 36, 0.15);
}

.nuke-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.logout-btn {
    border-color: rgba(255, 77, 106, 0.3);
}

.logout-btn:hover {
    border-color: var(--error);
    background: rgba(255, 77, 106, 0.1);
    box-shadow: 0 0 20px rgba(255, 77, 106, 0.15);
}

/* Dashboard Toolbar */
.dashboard-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-6);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-6);
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

@media (max-width: 768px) {
    .dashboard-toolbar {
        flex-wrap: wrap;
        padding: var(--space-3) var(--space-4);
    }

    .toolbar-left {
        width: 100%;
        flex-wrap: wrap;
    }

    .toolbar-left .customer-filter {
        flex: 1;
        min-width: 0;
    }

    .toolbar-right {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    .toolbar-left,
    .toolbar-right {
        width: 100%;
    }

    .toolbar-left .customer-filter {
        width: 100%;
    }

    .toolbar-right {
        justify-content: stretch;
    }

    .toolbar-right .refresh-btn,
    .toolbar-right .export-btn {
        flex: 1;
        justify-content: center;
    }
}

/* Main Content */
.main-content {
    flex: 1;
    padding: var(--space-6);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Sections */
section {
    margin-bottom: var(--space-8);
}

/* Overview Cards */
.overview-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.overview-header h2 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.section-badge {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td .section-badge {
    display: flex;
    align-items: center;
    justify-content: center;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-8);
}

.metric-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    opacity: 0.8;
}

.metric-card.success::before {
    background: var(--gradient-success);
}

.metric-card.warning::before {
    background: var(--gradient-warning);
}

.metric-card.info::before {
    background: var(--gradient-info);
}

.metric-card.secondary::before {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.metric-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.metric-card .card-icon {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--space-2);
    opacity: 0.8;
}

.metric-card h3 {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-1);
}

.card-value {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
    line-height: 1.2;
    overflow-wrap: break-word;
}

.card-subtitle {
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--text-secondary);
    word-break: break-word;
    hyphens: auto;
}

/* Charts Section */
.charts-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.charts-section .chart-card {
    margin-bottom: 0;
}

.charts-section .chart-header {
    margin-bottom: var(--space-3);
}

.usage-trend-card,
.daily-requests-card {
    position: relative;
}

.chart-canvas-container {
    position: relative;
    height: 400px;
    padding: 20px;
}

.usage-trend-card canvas,
.daily-requests-card canvas {
    width: 100%;
    height: 400px;
    display: block;
    max-width: 100%;
}

.rolling-model-distribution-card {
    width: 100%;
}

.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: var(--space-6);
}

.chart-card:last-child {
    margin-bottom: 0;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
}

.chart-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.chart-subtitle {
    display: block;
    font-size: var(--font-size-xs);
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
}

.chart-avg {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: var(--space-2);
}

.customer-filter {
    display: flex;
    align-items: center;
    margin-right: var(--space-3);
}

.customer-select {
    padding: 0 var(--space-4);
    height: 36px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    min-width: 150px;
}

.customer-select:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.customer-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

select option {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.time-range-controls {
    display: flex;
    gap: 2px;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 3px;
    border: 1px solid var(--border);
    height: 36px;
}

.time-btn {
    padding: 0 var(--space-4);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
}

.time-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.time-btn.active {
    background: var(--primary);
    color: var(--bg-base);
    font-weight: 600;
    box-shadow: var(--primary-glow-md);
}

/* Progress Bar (for tables) */
.progress-container {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    overflow: hidden;
    min-width: 60px;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: var(--transition-slow);
}

.progress-fill.normal {
    background: var(--gradient-success);
}

.progress-fill.warning {
    background: var(--gradient-warning);
}

.progress-fill.critical {
    background: var(--gradient-error);
}

.no-data {
    text-align: center;
    padding: var(--space-8);
    color: var(--text-secondary);
    font-style: italic;
}

/* Chart Toggle Group */
.chart-toggle-group {
    display: flex;
    gap: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
}

.chart-toggle-btn {
    padding: var(--space-2) var(--space-3);
    border: none;
    background: var(--bg-elevated);
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.chart-toggle-btn:not(:last-child) {
    border-right: 1px solid var(--border);
}

.chart-toggle-btn:hover:not(.active) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.chart-toggle-btn.active {
    background: var(--primary);
    color: var(--bg-base);
    font-weight: 600;
}

/* Table Styles */
.table-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-6);
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}

.table-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.table-controls {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}

.download-btn {
    height: 36px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box input {
    padding: var(--space-2) var(--space-8) var(--space-2) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--font-size-sm);
    outline: none;
    transition: var(--transition);
    width: 250px;
    height: 36px;
    background: var(--bg-input);
    color: var(--text-primary);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

.search-icon {
    position: absolute;
    right: var(--space-3);
    color: var(--text-muted);
}

.table-container {
    overflow-x: auto;
}

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

.data-table th {
    background: var(--bg-elevated);
    padding: var(--space-4);
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
}

.data-table th:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.data-table td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-light);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

.data-table tr:hover {
    background: rgba(0, 212, 255, 0.03);
}

.sort-icon {
    margin-left: var(--space-2);
    opacity: 0.4;
}

.sortable-th {
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.sortable-th:hover {
    background: var(--bg-hover);
}

.sortable-th.sort-active .sort-icon {
    opacity: 1;
    color: var(--primary);
}

.sortable-th.sort-asc .sort-icon::after {
    content: '\2191';
}

.sortable-th.sort-desc .sort-icon::after {
    content: '\2193';
}

/* Status Badges */
.status-badge {
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.success {
    background: var(--success-dim);
    color: var(--success);
}

.status-badge.warning {
    background: var(--warning-dim);
    color: var(--warning);
}

.status-badge.error {
    background: var(--error-dim);
    color: var(--error);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 26, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-overlay);
    backdrop-filter: blur(8px);
}

.loading-spinner {
    text-align: center;
    color: var(--text-primary);
}

.spinner {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(255, 255, 255, 0.08);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--space-4);
    box-shadow: var(--primary-glow);
}

.loading-spinner p {
    font-size: var(--font-size-lg);
    font-weight: 500;
}

.loading-timer {
    margin-top: var(--space-2);
    font-size: var(--font-size-base);
    color: var(--text-muted);
    font-weight: 400;
}

.loading-rebuild-bar {
    width: 220px;
    margin: var(--space-3) auto var(--space-2);
}

.loading-rebuild-detail {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

/* Notifications */
.notification {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    padding: var(--space-4) var(--space-6);
    border-radius: var(--radius-lg);
    color: var(--bg-base);
    font-weight: 600;
    z-index: var(--z-notification);
    animation: slideIn 0.3s ease-out;
    box-shadow: var(--shadow-lg);
}

.notification.success {
    background: var(--success);
}

.notification.error {
    background: var(--error);
}

.notification.info {
    background: var(--primary);
}

/* Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .charts-section {
        gap: var(--space-4);
    }

    .time-range-controls {
        flex-wrap: wrap;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: var(--space-4);
    }

    .header-content {
        padding: var(--space-3) var(--space-4);
        flex-wrap: wrap;
        gap: var(--space-3);
    }

    .header-left {
        flex-shrink: 1;
        width: 100%;
    }

    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-3);
    }

    .table-header {
        flex-direction: column;
        gap: var(--space-4);
        align-items: stretch;
    }

    .table-controls {
        flex-direction: column;
        width: 100%;
    }

    .download-btn {
        width: 100%;
        justify-content: center;
    }

    .search-box {
        width: 100%;
    }

    .search-box input {
        width: 100%;
    }
}

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

    .metric-card {
        padding: var(--space-4);
    }

    .card-value {
        font-size: var(--font-size-xl);
    }

    .chart-card {
        padding: var(--space-4);
    }

    .chart-canvas-container {
        height: 280px;
        padding: var(--space-2);
    }

    .usage-trend-card canvas,
    .daily-requests-card canvas {
        height: 200px;
    }

    .chart-header {
        flex-direction: column;
        gap: var(--space-3);
        align-items: stretch;
    }

    .time-range-controls {
        justify-content: center;
    }

    .latency-legend-section {
        padding: var(--space-2);
    }

    .legend-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }

    .model-chips-container {
        gap: 6px;
    }

    .model-chip {
        padding: 4px 8px;
        font-size: 11px;
    }

    .chip-indicator {
        width: 8px;
        height: 8px;
    }

    .chip-label {
        max-width: 100px;
    }

    .chip-latency {
        display: none;
    }

    .latency-chart-container {
        min-height: 280px;
    }
}

/* Utility Classes */
.text-sm { font-size: var(--font-size-sm); }

/* Code Styling */
code {
    background: var(--bg-elevated);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

::-webkit-scrollbar-track {
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
}

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

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* Focus Styles */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .header, .refresh-btn, .loading-overlay, .notification {
        display: none !important;
    }

    .main-content {
        padding: 0;
    }

    .metric-card, .chart-card, .table-card {
        box-shadow: none;
        border: 1px solid #333;
        break-inside: avoid;
    }
}

/* ============================================
   Login Page Styles - Dark Futuristic
   ============================================ */
body.login-page .app {
    background: none;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.login-page .app > .header {
    display: none;
}

body.login-page .main-content {
    padding: 0;
    max-width: none;
    margin: 0;
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.login-page {
    background: var(--bg-base);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Animated background */
.bg-animation {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
}

.bg-circle {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 212, 255, 0.08) 0%, transparent 70%);
    animation: float 8s ease-in-out infinite;
}

.bg-circle:nth-child(1) {
    width: 500px;
    height: 500px;
    top: -200px;
    right: -200px;
    animation-delay: 0s;
}

.bg-circle:nth-child(2) {
    width: 400px;
    height: 400px;
    bottom: -150px;
    left: -150px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.08) 0%, transparent 70%);
    animation-delay: 3s;
}

.bg-circle:nth-child(3) {
    width: 300px;
    height: 300px;
    top: 40%;
    left: -100px;
    background: radial-gradient(circle, rgba(0, 229, 160, 0.05) 0%, transparent 70%);
    animation-delay: 5s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px) scale(1);
        opacity: 0.6;
    }
    50% {
        transform: translateY(-30px) scale(1.05);
        opacity: 1;
    }
}

/* Login Container */
.login-container {
    background: var(--bg-card);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    padding: var(--space-12);
    width: 100%;
    max-width: 450px;
    position: relative;
    z-index: 10;
    border: 1px solid var(--border);
    backdrop-filter: blur(20px);
}

/* Logo Section */
.logo-section {
    text-align: center;
    margin-bottom: var(--space-8);
}

.logo-section .logo-icon {
    font-size: 4rem;
    margin-bottom: var(--space-4);
    display: inline-block;
}

.logo-title {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-2);
}

.logo-subtitle {
    color: var(--text-secondary);
    font-size: var(--font-size-base);
}

/* Form Styles */
.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.form-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-base);
    transition: var(--transition);
    background: var(--bg-input);
    color: var(--text-primary);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-dim);
}

.form-input:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

/* Login Button */
.login-btn {
    padding: var(--space-4) var(--space-6);
    background: var(--gradient-primary);
    color: var(--bg-base);
    border: none;
    border-radius: var(--radius-lg);
    font-size: var(--font-size-base);
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.35);
}

.login-btn:active {
    transform: translateY(0);
}

/* Error Message */
.error-message {
    background: rgba(255, 77, 106, 0.1);
    color: var(--error);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    font-weight: 500;
    text-align: center;
    border: 1px solid rgba(255, 77, 106, 0.2);
    display: none;
}

.error-message.show {
    display: block;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Loading State */
.login-btn.loading {
    position: relative;
    color: transparent;
}

.login-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid var(--bg-base);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Footer */
.login-footer {
    text-align: center;
    margin-top: var(--space-8);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

/* Burn Rate */
.burn-rate {
    font-weight: 600;
}

.burn-rate.normal {
    color: var(--success);
}

.burn-rate.warning {
    color: var(--warning);
}

.burn-rate.critical {
    color: var(--error);
}

/* Login Page Responsive */
@media (max-width: 768px) {
    body.login-page {
        padding: var(--space-4);
    }

    .login-container {
        padding: var(--space-8);
        max-width: 400px;
    }

    .logo-section .logo-icon {
        font-size: 3rem;
    }

    .logo-title {
        font-size: var(--font-size-2xl);
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: var(--space-6);
        margin: var(--space-4);
    }

    .logo-section .logo-icon {
        font-size: 2.5rem;
    }

    .logo-title {
        font-size: var(--font-size-xl);
    }
}

/* ============================================
   Cache Status Banner
   ============================================ */
.loading-rebuild-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.loading-rebuild-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: var(--radius-full);
    transition: width 0.5s ease-out;
}

/* ============================================
   Per Request Section
   ============================================ */
.per-request-section {
    margin-top: var(--space-6);
}

/* ============================================
   Cards Grid Variants
   ============================================ */
.cards-grid-7 {
    grid-template-columns: repeat(7, 1fr);
}

.cards-grid-6 {
    grid-template-columns: repeat(6, 1fr);
}

@media (max-width: 1400px) {
    .cards-grid-7 {
        grid-template-columns: repeat(4, 1fr);
    }
    .cards-grid-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .cards-grid-7,
    .cards-grid-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .cards-grid-7,
    .cards-grid-6 {
        grid-template-columns: repeat(2, 1fr);
    }

    .per-request-section {
        margin-top: var(--space-4);
    }
}

@media (max-width: 480px) {
    .cards-grid-7,
    .cards-grid-6 {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-2);
    }

    .section-badge {
        display: none;
    }
}

/* ============================================
   Tab Navigation
   ============================================ */
.tab-nav {
    display: flex;
    gap: var(--space-1);
    margin-left: var(--space-6);
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 3px;
    border: 1px solid var(--border);
    height: 36px;
}

.tab-link {
    padding: 0 var(--space-4);
    border-radius: var(--radius);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.tab-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tab-link.active {
    background: var(--primary);
    color: var(--bg-base);
    font-weight: 600;
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.25);
}

@media (max-width: 768px) {
    .tab-nav {
        margin-left: 0;
        margin-top: var(--space-2);
        flex-shrink: 1;
        min-width: 0;
    }

    .header-left {
        flex-wrap: wrap;
        min-width: 0;
        width: 100%;
    }

    .tab-link {
        padding: 0 var(--space-3);
        font-size: var(--font-size-xs);
    }
}

@media (max-width: 480px) {
    .tab-nav {
        margin-left: 0;
        margin-top: var(--space-2);
        width: 100%;
    }

    .tab-link {
        flex: 1;
        justify-content: center;
        padding: 0 var(--space-2);
    }

    .header-left {
        flex-wrap: wrap;
        width: 100%;
    }

    .logo h1 {
        font-size: var(--font-size-base);
    }
}

/* ============================================
   Shared Test Page Styles (Quality & Throughput)
   ============================================ */

/* Model selection grid */
.test-model-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-2);
    padding: var(--space-2) 0;
}

.test-model-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    white-space: nowrap;
}

.test-model-chip input[type="checkbox"] {
    display: none;
}

.test-model-chip:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: var(--bg-hover);
}

.test-model-chip.active {
    border-color: var(--primary);
    background: var(--primary-dim);
    color: var(--primary);
    font-weight: 600;
}

.test-chip-label {
    text-align: center;
    word-break: break-word;
}

/* Action buttons area */
.test-actions {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.test-start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--gradient-primary);
    color: var(--bg-base);
    border: none;
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.2);
    white-space: nowrap;
}

.test-start-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 0 25px rgba(0, 212, 255, 0.35);
}

.test-start-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.test-start-btn.stopping {
    background: linear-gradient(135deg, #ff4d6a, #ef4444);
    box-shadow: 0 0 15px rgba(255, 77, 106, 0.2);
}

.test-start-btn.stopping:hover:not(:disabled) {
    box-shadow: 0 0 25px rgba(255, 77, 106, 0.35);
}

/* Progress */
.test-progress-container {
    padding: var(--space-4) 0;
}

.test-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.test-progress-model-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.test-progress-phase {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    font-style: italic;
}

.test-progress-pct {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--primary);
}

.test-progress-phase-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.test-progress-phase-dot.phase-warmup {
    background: var(--info);
    animation: pulse 1s infinite;
}

.test-progress-phase-dot.phase-answering {
    background: var(--warning);
    animation: pulse 1s infinite;
}

.test-progress-phase-dot.phase-done {
    background: var(--success);
}

.test-progress-bar {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.test-progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width 0.5s ease-out;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.test-progress-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-3);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    gap: var(--space-4);
    flex-wrap: wrap;
}

.test-progress-completed {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.test-completed-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: rgba(0, 229, 160, 0.1);
    color: var(--success);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 500;
}

/* Quality slider */
.quality-slider-container {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.quality-slider-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 130px;
}

.quality-slider-label strong {
    color: var(--text-primary);
    font-weight: 600;
}

.quality-slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.quality-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
    transition: transform 0.15s ease;
}

.quality-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.quality-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}


/* Expandable table cells */
.cell-expandable {
    cursor: pointer;
    transition: color 0.15s;
}

.cell-expandable:hover {
    color: var(--primary);
}

.cell-expandable .cell-long {
    display: none;
    white-space: normal;
    word-break: break-word;
    line-height: 1.5;
}

.cell-expandable.expanded .cell-short {
    display: none;
}

.cell-expandable.expanded .cell-long {
    display: inline;
}

/* Table row states */
.row-dimmed {
    opacity: 0.35;
}

.cell-muted {
    color: var(--text-muted);
}

/* Detail view button */
.btn-detail-view {
    background: var(--gradient-primary);
    color: var(--bg-base);
    border: none;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-xs);
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    white-space: nowrap;
    line-height: inherit;
}

.btn-detail-view:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

/* Detail modal */
.detail-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    background: rgba(10, 14, 26, 0.75);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

.detail-modal-overlay.open {
    display: flex;
}

.detail-modal-panel {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
    width: min(90vw, 720px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: detailModalIn 0.2s ease-out;
}

@keyframes detailModalIn {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.detail-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-6);
    border-bottom: 1px solid var(--border);
}

.detail-modal-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.detail-modal-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius);
    transition: color 0.15s, background 0.15s;
}

.detail-modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.detail-modal-body {
    padding: var(--space-6);
    overflow-y: auto;
    flex: 1;
}

.detail-modal-section {
    margin-bottom: var(--space-4);
}

.detail-modal-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.detail-modal-value {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    line-height: 1.6;
}

.detail-modal-text {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-4);
    white-space: pre-wrap;
    word-break: break-word;
}

.detail-modal-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--space-6) 0;
}

@media (max-width: 600px) {
    .detail-modal-panel {
        width: 98vw;
        max-height: 95vh;
        border-radius: var(--radius-lg);
    }
}

/* Confirm Modal */
.confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    background: rgba(10, 14, 26, 0.8);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

.confirm-overlay.open {
    display: flex;
}

.confirm-panel {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
    padding: var(--space-8);
    width: min(90vw, 400px);
    text-align: center;
    animation: confirmIn 0.2s ease-out;
}

@keyframes confirmIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.confirm-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-4);
}

.confirm-title {
    margin: 0 0 var(--space-2);
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.confirm-text {
    margin: 0 0 var(--space-6);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.6;
}

.confirm-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
}

.confirm-btn {
    padding: var(--space-2) var(--space-6);
    border-radius: var(--radius);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.confirm-btn-cancel {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.confirm-btn-cancel:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.confirm-btn-danger {
    background: var(--gradient-error);
    color: #fff;
}

.confirm-btn-danger:hover {
    opacity: 0.9;
    box-shadow: 0 0 16px rgba(255, 77, 106, 0.3);
}

/* Test chart containers */
.test-chart-container {
    position: relative;
    padding: var(--space-4);
}

/* Summary cards */
.cards-grid-summary {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

@media (max-width: 1200px) {
    .cards-grid-summary {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .cards-grid-summary {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .cards-grid-summary {
        grid-template-columns: 1fr;
    }

    .test-actions {
        flex-wrap: wrap;
    }

    .test-model-grid {
        grid-template-columns: 1fr;
    }

    .test-model-chip {
        min-width: 0;
    }

    .quality-slider-label {
        min-width: unset;
        width: 100%;
    }

    .quality-slider {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .test-model-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .test-progress-header {
        flex-wrap: wrap;
        gap: var(--space-2);
    }

    .chart-header {
        flex-direction: column;
        gap: var(--space-3);
        align-items: stretch;
    }

    .test-actions {
        flex-wrap: wrap;
    }
}

/* ============================================
   Throughput Test Page
   ============================================ */
.throughput-config-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 170px;
}



.throughput-slider-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    width: 100%;
}

.throughput-slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.throughput-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
    transition: transform 0.15s ease;
}

.throughput-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.throughput-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.throughput-slider-value {
    min-width: 52px;
    text-align: center;
    color: var(--primary);
    font-weight: 700;
    font-size: var(--font-size-base);
    background: var(--primary-dim);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    padding: 4px 10px;
    font-variant-numeric: tabular-nums;
}

/* Filter bar */
.test-filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.test-filter-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.test-filter-btn {
    padding: var(--space-1) var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.test-filter-btn:hover:not(.active) {
    background: var(--bg-hover);
    border-color: rgba(255, 255, 255, 0.15);
}

.test-filter-btn.active {
    background: var(--primary);
    color: var(--bg-base);
    border-color: var(--primary);
    font-weight: 600;
}

@media (max-width: 768px) {
    .throughput-config-label {
        min-width: unset;
        width: 100%;
        white-space: normal;   /* the inline hint must wrap, not push the page wide */
    }
}

@media (max-width: 480px) {
    .test-filter-bar {
        flex-wrap: wrap;
    }
}

/* ============================================
   Score Badges
   ============================================ */
.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 26px;
    padding: 0;
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    font-weight: 700;
    letter-spacing: 0.3px;
    vertical-align: middle;
}

.score-badge.score-high {
    background: var(--success-dim);
    color: var(--success);
}


.score-badge.score-low {
    background: var(--error-dim);
    color: var(--error);
}

/* ============================================
   MC Choice Display (Detail Modal)
   ============================================ */
.mc-choices-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.mc-choice {
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

.mc-choice.choice-correct {
    border-color: rgba(0, 229, 160, 0.5);
    background: rgba(0, 229, 160, 0.08);
}

.mc-choice.choice-correct-selected {
    border-color: var(--success);
    background: var(--success-dim);
}

.mc-choice.choice-wrong {
    border-color: rgba(255, 77, 106, 0.5);
    background: rgba(255, 77, 106, 0.08);
}

/* ============================================
   Dataset Toggle Switch
   ============================================ */
.dataset-toggle-container {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.dataset-toggle-label {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    transition: var(--transition);
}

.dataset-toggle-label.active {
    color: var(--primary);
    font-weight: 600;
}

.dataset-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    display: inline-block;
    flex-shrink: 0;
}

.dataset-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.dataset-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.dataset-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition);
}

.dataset-toggle input:checked + .dataset-toggle-slider {
    border-color: var(--primary);
}

.dataset-toggle input:checked + .dataset-toggle-slider::before {
    transform: translateX(20px);
    background: var(--primary);
}

/* ============================================
   Throughput: Detail Rows (Expandable)
   ============================================ */
.detail-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    cursor: pointer;
    transition: var(--transition);
}

.detail-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-dim);
}

.detail-toggle.expanded {
    background: var(--primary-dim);
    border-color: var(--primary);
    color: var(--primary);
}

.detail-row {
    display: none;
}

.detail-row.visible {
    display: table-row;
}

.detail-content {
    padding: var(--space-4) var(--space-6);
    border-left: 3px solid var(--primary);
    background: var(--bg-elevated);
}

.detail-per-user {
    margin-top: var(--space-3);
}

.detail-per-user h5 {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-2);
}

.detail-user-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.detail-user-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.detail-user-chip strong {
    color: var(--text-primary);
}

/* ===== Selfhosting simulation ===== */
.sh-scenario { display: flex; flex-direction: column; gap: var(--space-5); }
.sh-control { display: flex; flex-direction: column; gap: var(--space-2); }
.sh-help { color: var(--text-muted); font-weight: 400; margin-left: var(--space-2); font-size: var(--font-size-sm); }
.sh-slider-end { color: var(--text-muted); font-size: var(--font-size-sm); min-width: 34px; text-align: center; }
.sh-mix { display: flex; flex-direction: column; gap: var(--space-2); }
.sh-hw-row {
    display: grid;
    grid-template-columns: minmax(170px, 280px) 1fr 40px;
    align-items: center;
    gap: var(--space-4);
}
.sh-hw-label { font-size: var(--font-size-sm); color: var(--text-secondary); display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.sh-hw-count { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.sh-hw-row input[type="range"] { width: 100%; }
.sh-badge {

    font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 6px;
    border-radius: var(--radius); background: var(--warning-dim); color: var(--warning);
}
.sh-hint { color: var(--text-secondary); font-size: var(--font-size-sm); }
.sh-results { display: flex; flex-direction: column; gap: var(--space-4); }
.sh-stats { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.sh-stats.is-loading { opacity: 0.55; }
.sh-stat {
    flex: 1;
    min-width: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.sh-stat-value { font-size: var(--font-size-xl); font-weight: 700; color: var(--text-primary); line-height: 1.3; font-variant-numeric: tabular-nums; }
.cell-danger { color: var(--error); font-weight: 700; }
.sh-stat-label { font-size: var(--font-size-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.sh-perhw { display: flex; flex-direction: column; gap: var(--space-1); }
.sh-perhw-row { color: var(--text-secondary); font-size: var(--font-size-sm); font-variant-numeric: tabular-nums; }
.sh-perhw-row strong { color: var(--text-primary); }
.sh-footnote { color: var(--text-secondary); font-size: var(--font-size-sm); }
.sh-footnote-muted { color: var(--text-muted); }
.sh-footnote-warn { color: var(--warning); }
.sh-chart { height: 280px; }


/* ============================================
   Throughput — test plan builder & result views
   ============================================ */

/* --- Setup card: label column + control column --- */
.tp-setup { padding: 0; overflow: hidden; }

.tp-setup-row {
    display: grid;
    grid-template-columns: 210px 1fr;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-light);
    align-items: start;
}

.tp-setup-row:last-of-type { border-bottom: 1px solid var(--border-light); }

.tp-setup-head { display: flex; flex-direction: column; gap: 2px; padding-top: 4px; }

.tp-setup-title {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

.tp-setup-hint { font-size: var(--font-size-xs); color: var(--text-muted); line-height: 1.45; }

.tp-setup-body { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }

.tp-setup-body .test-model-grid { padding: 0; }

/* --- Selectable chips (parallelism / context) --- */
.tp-chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.tp-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-width: 62px;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.tp-chip-row-wide .tp-chip { min-width: 88px; }

.tp-chip-main { font-size: var(--font-size-sm); font-weight: 700; font-variant-numeric: tabular-nums; }
.tp-chip-sub { font-size: 10px; color: var(--text-muted); letter-spacing: 0.02em; }

.tp-chip:hover { border-color: rgba(255, 255, 255, 0.18); background: var(--bg-hover); transform: translateY(-1px); }

.tp-chip.active {
    border-color: var(--primary);
    background: var(--primary-dim);
    color: var(--primary);
    box-shadow: var(--primary-glow);
}

.tp-chip.active .tp-chip-sub { color: rgba(0, 212, 255, 0.75); }

.tp-quick { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.tp-quick-btn {
    padding: 3px var(--space-3);
    border: 1px dashed var(--border);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.tp-quick-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-dim); }

/* --- Switch --- */
.tp-switch { display: flex; align-items: center; gap: var(--space-3); cursor: pointer; user-select: none; }
.tp-switch input { display: none; }

.tp-switch-track {
    position: relative;
    flex: 0 0 auto;
    width: 44px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--bg-input);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.tp-switch-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition);
}

.tp-switch input:checked + .tp-switch-track { background: var(--primary-dim); border-color: var(--primary); }
.tp-switch input:checked + .tp-switch-track .tp-switch-knob { transform: translateX(20px); background: var(--primary); box-shadow: var(--primary-glow-md); }

.tp-switch-text { display: flex; flex-direction: column; gap: 1px; }
.tp-switch-text strong { font-size: var(--font-size-sm); color: var(--text-primary); font-weight: 600; }
.tp-switch-text em { font-style: normal; font-size: var(--font-size-xs); color: var(--text-muted); }

/* --- Plan bar --- */
.tp-planbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-6);
    background: linear-gradient(180deg, rgba(0, 212, 255, 0.04), transparent);
}

.tp-planbar-stats { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tp-planbar-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.tp-plan-stat {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    min-width: 84px;
}

.tp-plan-value { font-size: var(--font-size-base); font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; line-height: 1.2; }
.tp-plan-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.tp-plan-stat.is-goal { border-color: rgba(0, 229, 160, 0.4); }
.tp-plan-stat.is-goal .tp-plan-value { color: var(--success); }
.tp-plan-stat.is-warn { border-color: rgba(255, 178, 36, 0.45); }
.tp-plan-stat.is-warn .tp-plan-value { color: var(--warning); }
.tp-plan-stat.is-empty .tp-plan-value { color: var(--error); }

.test-start-btn.is-disabled { opacity: 0.45; }

/* Plan is frozen while a run is in flight */
.tp-setup.is-locked .tp-setup-row { opacity: 0.55; pointer-events: none; }
.tp-setup.is-locked .tp-planbar-actions { pointer-events: auto; }

.tp-setup + .sh-hint,
.tp-setup .sh-hint { padding: 0 var(--space-6) var(--space-5); font-size: var(--font-size-xs); color: var(--text-muted); }

/* --- Capacity tiles --- */
.tp-model-summary { margin-bottom: var(--space-5); }
.tp-model-summary:last-child { margin-bottom: var(--space-2); }

.tp-model-name {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: var(--space-3);
}

.tp-model-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }

.tp-cap-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: var(--space-3); }

.tp-cap-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-4) var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(0, 229, 160, 0.07), transparent 70%), var(--bg-elevated);
}

.tp-cap-tile.is-zero { background: var(--bg-elevated); border-color: rgba(255, 77, 106, 0.35); }
.tp-cap-tile.is-pending { background: var(--bg-elevated); border-style: dashed; }
.tp-cap-tile.is-pending .tp-cap-value { color: var(--text-muted); }
.tp-cap-value { font-size: var(--font-size-2xl); font-weight: 700; color: var(--success); line-height: 1.1; font-variant-numeric: tabular-nums; }
.tp-cap-tile.is-zero .tp-cap-value { color: var(--error); }
.tp-cap-label { font-size: var(--font-size-xs); color: var(--text-secondary); text-align: center; }
.tp-cap-seats { font-size: 10px; color: var(--text-muted); }

#seatCard .sh-footnote { margin-top: var(--space-4); font-size: var(--font-size-xs); line-height: 1.6; }

/* --- Chart card extras --- */
.tp-chart { height: 380px; }
.tp-scatter { height: 260px; }

#chartCard .test-filter-bar,
#matrixCard .test-filter-bar { margin-bottom: var(--space-4); }

.test-filter-group {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-input);
    margin-right: var(--space-3);
}

.test-filter-group .test-filter-label { padding: 0 var(--space-2); }

.tp-legend { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }

.tp-legend-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 3px var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.tp-legend-item:hover { color: var(--text-primary); border-color: rgba(255, 255, 255, 0.18); }
.tp-legend-item.is-off { opacity: 0.4; text-decoration: line-through; }
.tp-legend-dot { width: 9px; height: 9px; border-radius: 50%; }

/* --- Matrix heatmap --- */
.tp-matrix-scroll { overflow-x: auto; padding-bottom: var(--space-2); }
.tp-matrix-grid { display: grid; gap: 4px; min-width: max-content; }

.tp-mx-corner,
.tp-mx-colhead {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: var(--space-1);
}

.tp-mx-corner { justify-content: flex-start; }

/* Sticky first column: the prompt size must stay readable while scrolling wide grids */
.tp-mx-rowhead,
.tp-mx-corner {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--bg-card);
}

.tp-mx-rowhead {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-right: var(--space-3);
}

.tp-mx-rowhead strong { font-size: var(--font-size-sm); color: var(--text-primary); font-variant-numeric: tabular-nums; }
.tp-mx-rowhead span { font-size: 10px; color: var(--text-muted); }

.tp-mx-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    min-height: 46px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.tp-mx-cell:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.tp-mx-cell.is-selected { outline: 2px solid var(--primary); outline-offset: 1px; }
.tp-mx-value { font-size: var(--font-size-sm); font-weight: 700; font-variant-numeric: tabular-nums; }
.tp-mx-sub { font-size: 10px; opacity: 0.75; line-height: 1; }

.tp-mx-cell.is-empty {
    background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.02) 0 6px, transparent 6px 12px);
    border: 1px dashed var(--border);
    color: var(--text-muted);
    cursor: default;
    font-size: var(--font-size-sm);
}

.tp-mx-cell.is-empty:hover { transform: none; box-shadow: none; }
.tp-mx-cell.is-failed { color: var(--error); border-color: rgba(255, 77, 106, 0.35); }

.tp-matrix-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.tp-swatch { width: 16px; height: 12px; border-radius: 3px; display: inline-block; }
.tp-swatch-empty { border: 1px dashed var(--border); background: transparent; }

.tp-cell-detail { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border-light); }
.tp-cell-detail .chart-header { margin-bottom: var(--space-3); }

.section-badge.is-live {
    color: var(--success);
    border-color: rgba(0, 229, 160, 0.45);
    background: var(--success-dim);
    animation: tp-pulse 1.6s ease-in-out infinite;
}

@keyframes tp-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

@media (max-width: 900px) {
    .tp-setup-row { grid-template-columns: 1fr; gap: var(--space-3); padding: var(--space-4); }
    .tp-setup-head { padding-top: 0; }
    .tp-planbar { padding: var(--space-4); }
    .tp-setup .sh-hint { padding: 0 var(--space-4) var(--space-4); }
}

@media (max-width: 640px) {
    .tp-chart { height: 320px; }
    .tp-planbar-actions { width: 100%; }
    .tp-planbar-actions > * { flex: 1; justify-content: center; }
    .tp-plan-stat { min-width: 74px; padding: var(--space-2) var(--space-3); }
    .tp-cap-row { grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); }
    /* One scrollable row per control group — a long option list must never be cut off */
    .test-filter-bar { flex-direction: column; align-items: stretch; gap: var(--space-2); }
    /* min-width:0 lets the group shrink below its content and scroll instead of
       pushing the page wider (flex items default to min-width:auto). */
    .test-filter-group { margin-right: 0; overflow-x: auto; justify-content: flex-start; scrollbar-width: thin; min-width: 0; max-width: 100%; }
    .test-filter-group .test-filter-btn,
    .test-filter-group .test-filter-label { flex: 0 0 auto; }
    .tp-chip { min-width: 54px; }
    .tp-chip-row-wide .tp-chip { min-width: 72px; }
}

/* ============================================
   Global refinement layer
   Applies to every tab; overrides sit last on purpose.
   ============================================ */

/* Numbers line up in columns wherever they carry meaning */
.card-value,
.data-table td,
.metric-card .card-subtitle,
.test-progress-details,
.sh-stat-value {
    font-variant-numeric: tabular-nums;
}

/* A quiet depth gradient instead of a flat slab */
body {
    background:
        radial-gradient(1200px 600px at 15% -10%, rgba(0, 212, 255, 0.055), transparent 60%),
        radial-gradient(900px 500px at 95% 0%, rgba(124, 58, 237, 0.05), transparent 55%),
        var(--bg-base);
    background-attachment: fixed;
}

h1, h2, h3 { letter-spacing: -0.01em; }

/* Section headings get an accent tick so the page reads as a stack of chapters */
.overview-header h2 {
    position: relative;
    padding-left: var(--space-4);
}

.overview-header h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 1.05em;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
}

/* Metric cards: the accent reads as a glow, not a printed rule */
.metric-card::before {
    height: 2px;
    opacity: 1;
    filter: blur(0.2px);
}

.metric-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 45%);
    pointer-events: none;
}

.metric-card:hover { border-color: rgba(0, 212, 255, 0.28); }

.card-value { font-size: var(--font-size-xl); letter-spacing: -0.02em; }

/* Cards lift a touch on hover so the surface feels alive but never busy */
.chart-card,
.table-card {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chart-card:hover,
.table-card:hover { border-color: rgba(255, 255, 255, 0.1); }

/* Tables: on desktop long result lists scroll inside the card with a pinned
   header; on touch viewports the page keeps its natural scroll (no nested trap). */
@media (min-width: 900px) {
    .table-container { max-height: 75vh; overflow: auto; }
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-elevated);
    backdrop-filter: blur(8px);
}

.data-table tbody tr:hover { background: rgba(0, 212, 255, 0.045); }
.data-table tr.row-dimmed td { opacity: 0.62; }
.status-badge { display: inline-block; white-space: nowrap; }

/* Keyboard users get the same affordances as pointer users */
a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
label.test-model-chip:focus-within {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius);
}

/* Scrollbars that belong to the theme */
* { scrollbar-color: rgba(255, 255, 255, 0.16) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: var(--radius-full); border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.26); background-clip: content-box; }

/* Nav reads as the primary switch on every page */
.tab-link.active { box-shadow: 0 0 18px rgba(0, 212, 255, 0.3); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .metric-card:hover,
    .tp-chip:hover,
    .tp-mx-cell:hover { transform: none; }
}

/* Phone toolbar: the customer picker owns its own row instead of fighting the
   range switch for space (flex:1 was collapsing it to an unreadable stub). */
@media (max-width: 560px) {
    .toolbar-left .customer-filter { flex: 1 0 100%; width: 100%; }
    .toolbar-left .time-range-controls { width: 100%; }
    .toolbar-left .time-btn { flex: 1; justify-content: center; }
    .toolbar-right { flex-wrap: wrap; }
    .toolbar-right .refresh-btn,
    .toolbar-right .export-btn,
    .toolbar-right .nuke-btn { white-space: nowrap; flex: 1 1 auto; justify-content: center; }
}

/* Latency Trend (per-model P95 / P99 / Max) */
.latency-trend-head {
    align-items: flex-start;
}

.latency-trend-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.latency-trend-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chart-subtitle {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    min-height: 1em;
}

.chart-toggle-btn .dash-sample {
    vertical-align: middle;
    margin-left: 2px;
    opacity: 0.85;
}

.model-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: var(--space-3) 0;
}

.model-chip {
    --chip: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    transition: var(--transition);
    max-width: 100%;
}

.model-chip:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.14);
}

.model-chip.active {
    color: var(--text-primary);
    border-color: color-mix(in srgb, var(--chip) 70%, transparent);
    background: color-mix(in srgb, var(--chip) 18%, var(--bg-elevated));
}

.model-chip:not(.active) .model-chip-dot {
    opacity: 0.35;
}

.model-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chip);
    flex: none;
}

.model-chip-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-chip-count {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.model-chip.more,
.model-chip.reset {
    border-style: dashed;
    background: transparent;
}

.model-chip.reset {
    color: var(--primary);
    border-color: var(--primary-dim);
}

.model-picker {
    margin: 0 0 var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
}

.model-picker-search {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

.model-picker-search:focus {
    outline: none;
    border-color: var(--border-focus);
}

.model-picker-list {
    max-height: 260px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 2px var(--space-3);
}

.model-picker-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 6px var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    cursor: pointer;
}

.model-picker-row:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.model-picker-row input {
    accent-color: var(--chip);
}

.model-picker-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-picker-empty {
    padding: var(--space-3);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.latency-trend-canvas {
    position: relative;
    min-height: 360px;
}

.chart-empty[hidden],
.model-picker[hidden] {
    display: none;
}

.chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    pointer-events: none;
}
