* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #3b82f6;
    --color-gray: #6b7280;
    --color-gray-light: #f3f4f6;
    --color-gray-dark: #374151;
    --color-border: #e5e7eb;
    --color-text: #111827;
    --color-text-secondary: #6b7280;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--color-gray-light);
    color: var(--color-text);
    line-height: 1.6;
}

.header {
    background: white;
    border-bottom: 1px solid var(--color-border);
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-indicator .status-dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    background: var(--color-gray);
}

.status-indicator.online .status-dot {
    background: var(--color-success);
    animation: pulse 2s ease-in-out infinite;
}

.status-indicator.offline .status-dot {
    background: var(--color-error);
}

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

.error-banner {
    background: #fef2f2;
    border-left: 4px solid var(--color-error);
    color: #991b1b;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-retry {
    background: var(--color-error);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    font-weight: 500;
}

.btn-retry:hover {
    opacity: 0.9;
}

.refresh-controls {
    background: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--color-border);
}

.refresh-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.last-updated {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.countdown-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 120px;
}

.countdown-bar {
    height: 4px;
    background: var(--color-info);
    border-radius: 2px;
    transition: width 1s linear;
    flex: 1;
}

.countdown-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    min-width: 2rem;
}

.refresh-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-control {
    background: white;
    border: 1px solid var(--color-border);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--color-text);
}

.btn-control:hover {
    background: var(--color-gray-light);
}

.main-content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--color-text);
}

.cluster-overview .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
}

.stat {
    text-align: center;
    padding: 1rem;
    border-radius: 0.375rem;
    background: var(--color-gray-light);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

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

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

.data-table thead {
    background: var(--color-gray-light);
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border);
}

.data-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}

.data-table tbody tr:hover {
    background: var(--color-gray-light);
}

.mono {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8125rem;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.status-online,
.status-badge.status-running,
.status-badge.status-complete {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.status-busy,
.status-badge.status-pending,
.status-badge.status-scheduled {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.status-offline,
.status-badge.status-failed,
.status-badge.status-rejected {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge.status-unknown {
    background: #f3f4f6;
    color: #374151;
}

.badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge.status-healthy {
    background: #d1fae5;
    color: #065f46;
}

.badge.status-degraded {
    background: #fef3c7;
    color: #92400e;
}

.badge.status-unhealthy {
    background: #fee2e2;
    color: #991b1b;
}

.badge.status-unknown {
    background: #f3f4f6;
    color: #374151;
}

.category-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.category-badge.category-streaming {
    background: #dbeafe;
    color: #1e40af;
}

.category-badge.category-inferring {
    background: #e0e7ff;
    color: #4338ca;
}

.category-badge.category-relaying {
    background: #f3f4f6;
    color: #374151;
}

.category-badge.category-unknown {
    background: #f3f4f6;
    color: #6b7280;
}

.status-badge.availability-active {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.availability-paused {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.availability-drain {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge.availability-offline {
    background: #f3f4f6;
    color: #374151;
}

.text-secondary {
    color: var(--color-text-secondary);
}

.text-xs {
    font-size: 0.75rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .refresh-controls {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .refresh-buttons {
        justify-content: stretch;
    }

    .btn-control {
        flex: 1;
    }

    .cluster-overview .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .main-content {
        padding: 1rem;
    }

    .table-container {
        font-size: 0.8125rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }
}

/* --- Login screen --- */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-gray-light);
    padding: 1rem;
}

.login-card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-bottom: 1.5rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.login-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--color-text);
    background: white;
    outline: none;
    transition: border-color 0.15s ease;
}

.login-input:focus {
    border-color: var(--color-info);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.login-input:disabled {
    background: var(--color-gray-light);
    color: var(--color-text-secondary);
    cursor: not-allowed;
}

.btn-login {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    color: white;
    background: var(--color-info);
    border-color: var(--color-info);
    transition: opacity 0.15s ease;
}

.btn-login:hover:not(:disabled) {
    opacity: 0.9;
}

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

.login-error {
    font-size: 0.8125rem;
    color: var(--color-error);
    margin-top: 0.25rem;
}

.btn-logout {
    margin-top: 0.75rem;
}
