:root {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --border: #475569;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --premium: #a855f7;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.hidden { display: none !important; }

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-box {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: var(--radius);
    width: 380px;
    border: 1px solid var(--border);
}

.login-box h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

input, select, textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}

textarea { resize: vertical; min-height: 120px; font-family: monospace; }

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: #000; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
}

.sidebar h2 {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-nav {
    list-style: none;
    flex: 1;
}

.sidebar-nav li {
    margin-bottom: 0.3rem;
}

.sidebar-nav a {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
    background: var(--bg-input);
    color: var(--text);
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.main-content h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.stat-card .value {
    font-size: 1.8rem;
    font-weight: 700;
}

.stat-card .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.stat-card.premium { border-color: var(--premium); }
.stat-card.premium .value { color: var(--premium); }
.stat-card.success .value { color: var(--success); }
.stat-card.danger .value { color: var(--danger); }
.stat-card.warning .value { color: var(--warning); }

/* Table */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th, td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    background: var(--bg-card);
}

tr:hover { background: rgba(255,255,255,0.03); }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-premium { background: rgba(168,85,247,0.2); color: var(--premium); }
.badge-passed { background: rgba(34,197,94,0.2); color: var(--success); }
.badge-eliminated { background: rgba(239,68,68,0.2); color: var(--danger); }
.badge-pending { background: rgba(148,163,184,0.2); color: var(--text-muted); }
.badge-running { background: rgba(59,130,246,0.2); color: var(--primary); }

/* Progress bar */
.progress-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.progress-bar .fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s;
}

/* Pipeline steps */
.pipeline-steps {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.pipeline-step {
    flex: 1;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.pipeline-step.active {
    border-color: var(--primary);
}

.pipeline-step.done {
    border-color: var(--success);
}

.pipeline-step h4 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.pipeline-step .step-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Config panels */
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 768px) {
    .config-grid { grid-template-columns: 1fr; }
    .app-container { flex-direction: column; }
    .sidebar { width: 100%; }
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: rgba(239,68,68,0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.alert-success {
    background: rgba(34,197,94,0.15);
    border: 1px solid var(--success);
    color: var(--success);
}

.alert-info {
    background: rgba(59,130,246,0.15);
    border: 1px solid var(--primary);
    color: var(--primary);
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.toolbar select {
    width: auto;
}

/* Score bar */
.score-bar {
    display: inline-block;
    width: 60px;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    vertical-align: middle;
    margin-right: 0.4rem;
}

.score-bar .fill {
    height: 100%;
    border-radius: 3px;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-muted);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Flex utilities */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.text-right { text-align: right; }
