:root {
    /* Core palette */
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --neutral-50: #f8fafc;
    --neutral-100: #f1f5f9;
    --neutral-200: #e2e8f0;
    --neutral-300: #cbd5e1;
    --neutral-700: #334155;
    --neutral-900: #0f172a;

    /* Surfaces */
    --app-bg: var(--neutral-50);
    --card-bg: #ffffff;
    --dark-bg: #1e293b;
    --border-color: #e2e8f0;

    /* Spacing scale */
    --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;

    /* Radius & shadows */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 6px 16px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.12);
}

body {
    background-color: var(--app-bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--neutral-900);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Layout */
#app {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}
main.container {
    padding-top: var(--space-6);
    padding-bottom: var(--space-8);
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.skip-link:focus {
    position: fixed;
    left: var(--space-4);
    top: var(--space-4);
    width: auto;
    height: auto;
    padding: var(--space-3) var(--space-4);
    background: #fff;
    color: var(--primary-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 1050;
}

.navbar {
    background: linear-gradient(135deg, var(--primary-color), #3b82f6);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}
.app-navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.95), rgba(59, 130, 246, 0.95));
    backdrop-filter: saturate(160%) blur(8px);
}

.navbar-brand {
    font-weight: 700;
    color: white !important;
    letter-spacing: 0.2px;
}

.navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500;
    padding: .5rem .75rem;
    border-radius: var(--radius-sm);
    transition: color 0.2s, background-color .2s, transform .2s;
}

.navbar-nav .nav-link:hover {
    color: white !important;
    background-color: rgba(255,255,255,.08);
    transform: translateY(-1px);
}
.navbar-nav .nav-link.active {
    color: #fff !important;
    background-color: rgba(255,255,255,.16);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.navbar-nav .nav-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255,255,255,.35);
}

/* Global focus for accessibility */
a:focus-visible, button:focus-visible, [role="button"]:focus-visible, .form-control:focus-visible, .form-select:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
    border-color: rgba(37,99,235,.5);
}

/* Headings spacing */
h1, .h1 { margin-bottom: var(--space-4); letter-spacing: .2px; }
h5, .h5, h6, .h6 { letter-spacing: .2px; }

.card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    background: var(--card-bg);
}

.card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--dark-bg);
    padding: var(--space-4) var(--space-5);
}
.card-body {
    padding: var(--space-5);
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    box-shadow: var(--shadow-md);
}

.stat-card.success {
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
}

.stat-card.warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, #d97706 100%);
}

.stat-card.danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #dc2626 100%);
}

.stat-icon {
    font-size: 2rem;
    opacity: 0.8;
}

.table {
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    margin-bottom: var(--space-6);
}

.table thead th {
    border: none;
    background-color: #f8fafc;
    font-weight: 600;
    color: var(--dark-bg);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}
.table tbody tr:hover {
    background-color: var(--neutral-100);
}
.table-responsive {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: .4em .6em;
    letter-spacing: .2px;
}

.btn {
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}
.btn-outline-primary:hover {
    background-color: rgba(37, 99, 235, 0.08);
}

/* Forms */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border-color);
    padding-top: .6rem;
    padding-bottom: .6rem;
}
.form-control:focus, .form-select:focus {
    border-color: rgba(37,99,235,.5);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

.status-completed { background-color: var(--success-color); }
.status-running { background-color: var(--warning-color); animation: pulse 2s infinite; }
.status-failed { background-color: var(--danger-color); }
.status-unknown { background-color: var(--secondary-color); }

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

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Page content entrance animation for smoother feel */
#page-content > * {
    animation: fadeSlideIn .24s ease both;
}
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

footer {
    background-color: var(--dark-bg);
    color: white;
    margin-top: 4rem;
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
}

.footer-text {
    opacity: 0.8;
}

/* Pipeline Summary Styles */
.pipeline-summary {
    font-family: 'Inter', sans-serif;
    max-width: 100%;
    overflow: hidden;
}

.pipeline-summary .mb-2 {
    transition: all 0.2s ease;
}

.pipeline-summary .mb-2:hover {
    background-color: #f8fafc !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.pipeline-summary .text-capitalize {
    font-size: 0.9rem;
    font-weight: 600;
}

.pipeline-stepper {
    gap: var(--space-2);
    display: flex;
    flex-wrap: wrap;            /* allow wrapping to show all steps together */
    overflow: visible;          /* no scrollbars; wrap instead */
    max-width: 100%;
    row-gap: var(--space-4);
}
.pipeline-step {
    min-width: 64px;
    flex: 0 1 auto;             /* allow wrap while keeping intrinsic width */
}
.pipeline-step .step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--neutral-300);
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--neutral-700);
    box-shadow: var(--shadow-sm);
    font-size: 0.8rem;
}
.pipeline-step .step-dot .step-num {
    font-size: 0.75rem;
    line-height: 1;
}
.pipeline-step.completed .step-dot {
    background: var(--success-color);
    border-color: var(--success-color);
    color: #fff;
}
.pipeline-step.in-progress .step-dot {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #fff;
}
.pipeline-step.failed .step-dot {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: #fff;
}
.pipeline-connector {
    height: 2px;
    background: var(--neutral-200);
    border-radius: 999px;
    align-self: center;
}
.pipeline-connector.completed {
    background: var(--success-color);
}

.pipeline-arrow {
    font-size: 1rem;
    flex: 0 1 auto;             /* allow wrap with steps */
}

.pipeline-summary .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.pipeline-summary small {
    font-size: 0.8rem;
    line-height: 1.2;
}

/* Timeline Enhancements */
.timeline {
    position: relative;
    padding: 0;
}

/* Subtle scrollbar styling for stepper */
/* (Scrollbar styles removed since we no longer scroll horizontally) */

.timeline::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, #e2e8f0, #cbd5e1);
}

.timeline-item {
    position: relative;
    padding-left: 50px;
    padding-bottom: 1.5rem;
}

.timeline-marker {
    position: absolute;
    left: 10px;
    top: 5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.7rem;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.timeline-content {
    background: white;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Upload Page Styles */
#drop-zone {
    transition: all 0.3s ease;
    cursor: pointer;
}

#drop-zone:hover {
    border-color: #007bff !important;
    background-color: #f8f9fa;
}

#drop-zone.border-primary {
    border-color: #007bff !important;
}

/* Redirect Loading Overlay */
.redirect-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.redirect-content {
    text-align: center;
    padding: 2rem;
    border-radius: 10px;
    background: rgba(0, 123, 255, 0.1);
    border: 1px solid rgba(0, 123, 255, 0.3);
    max-width: 400px;
}

.countdown-container {
    font-size: 1.1rem;
    font-weight: 500;
}

.countdown-number {
    display: inline-block;
    background: #007bff;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 50%;
    min-width: 2rem;
    font-weight: bold;
    animation: pulse 1s infinite;
}

.countdown-text {
    color: rgba(255, 255, 255, 0.8);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Telemetry Page Styles */
.timeline-item {
    position: relative;
    padding-left: 30px;
    margin-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #6c757d;
}

.timeline-item.success::before {
    background-color: #28a745;
}

.timeline-item.error::before {
    background-color: #dc3545;
}

.timeline-item.warning::before {
    background-color: #ffc107;
}

.timeline-item.info::before {
    background-color: #17a2b8;
}

.timeline-item::after {
    content: '';
    position: absolute;
    left: 13px;
    top: 20px;
    width: 2px;
    height: calc(100% + 10px);
    background-color: #e9ecef;
}

.timeline-item:last-child::after {
    display: none;
}

.timeline-content {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px 16px;
    border-left: 4px solid #6c757d;
}

.timeline-item.success .timeline-content {
    border-left-color: #28a745;
}

.timeline-item.error .timeline-content {
    border-left-color: #dc3545;
}

.timeline-item.warning .timeline-content {
    border-left-color: #ffc107;
}

.timeline-item.info .timeline-content {
    border-left-color: #17a2b8;
}

/* GPT Concurrency Page Styles */
.stat-card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: all 0.15s ease-in-out;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.stat-card.success {
    border-left: 4px solid #28a745;
}

.stat-card.info {
    border-left: 4px solid #17a2b8;
}

.stat-card.warning {
    border-left: 4px solid #ffc107;
}

.stat-icon {
    font-size: 2rem;
    opacity: 0.8;
}

.table-responsive {
    max-height: 600px;
    overflow-y: auto;
}

.text-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

code {
    font-size: 0.875rem;
}

/* Health Page Styles */
.service-status {
    margin-bottom: 1rem;
}

.service-status:last-child {
    margin-bottom: 0;
}

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

.status-completed { background-color: var(--success-color); }
.status-running { background-color: var(--warning-color); animation: pulse 2s infinite; }
.status-failed { background-color: var(--danger-color); }
.status-unknown { background-color: var(--secondary-color); }

/* Notifications (Bootstrap alerts used as toasts) */
#notification-container {
    padding: var(--space-4);
}
#notification-container .alert {
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.95);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(6px);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
