:root {
    --primary: #3b82f6;
    /* Blue 500 */
    --primary-dark: #2563eb;
    /* Blue 600 */
    --success: #10b981;
    /* Emerald 500 */
    --danger: #ef4444;
    /* Red 500 */
    --warning: #f59e0b;
    /* Amber 500 */
    --dark: #f8fafc;
    /* Slate 50 (Text) */
    --bg-dark: #0f172a;
    /* Slate 900 (Body) */
    --bg-panel: #1e293b;
    /* Slate 800 (Panels) */
    --bg-input: #334155;
    /* Slate 700 (Inputs) */
    --border: #334155;
    /* Slate 700 */
    --text-muted: #94a3b8;
    /* Slate 400 */
}

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

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-dark);
    color: var(--dark);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

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

.login-box {
    background: var(--bg-panel);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border);
}

.logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo img {
    max-width: 120px;
    height: auto;
}

.logo h1 {
    color: var(--dark);
    margin-top: 15px;
    font-size: 24px;
    font-weight: 700;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--dark);
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Alert Messages */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Navbar */
.navbar {
    background: var(--bg-panel);
    padding: 15px 30px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 15px;
}

.navbar-brand img {
    height: 40px;
}

.navbar-brand h2 {
    color: var(--dark);
    font-size: 20px;
    font-weight: 700;
}

.navbar-menu {
    display: flex;
    gap: 20px;
    align-items: center;
}

.navbar-menu a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.navbar-menu a:hover {
    color: var(--primary);
}

/* Dashboard Layout */
.dashboard-container {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 20px;
    margin-top: 20px;
    height: calc(100vh - 120px);
}

.panel {
    background: var(--bg-panel);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    border: 1px solid var(--border);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.panel-header h3 {
    color: var(--dark);
    font-size: 18px;
    font-weight: 600;
}

/* Job List */
.job-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.job-item {
    padding: 15px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.job-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.job-item.active {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.job-status-icon {
    font-size: 24px;
}

.job-info h4 {
    color: var(--dark);
    font-size: 14px;
    margin-bottom: 4px;
    font-weight: 600;
}

.job-info p {
    color: var(--text-muted);
    font-size: 12px;
}

/* Job Details */
.job-details {
    display: none;
}

.job-details.active {
    display: block;
}

.detail-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.detail-label {
    font-weight: 600;
    color: var(--text-muted);
}

.detail-value {
    color: var(--dark);
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-in_progress {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-passed {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-failed {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-aborted {
    background: rgba(148, 163, 184, 0.1);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.status-waiting {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Admin Dashboard */
.admin-container {
    background: var(--bg-panel);
    border-radius: 16px;
    padding: 30px;
    margin-top: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.admin-header h2 {
    color: var(--dark);
}

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

.user-table th {
    background: var(--bg-input);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--dark);
    border-bottom: 2px solid var(--border);
}

.user-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}

.user-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.badge-admin {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
}

.badge-user {
    background: rgba(148, 163, 184, 0.1);
    color: #cbd5e1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-panel);
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    color: var(--dark);
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.close-btn:hover {
    color: var(--dark);
}

/* Submit Form */
.submit-container {
    background: var(--bg-panel);
    border-radius: 16px;
    padding: 40px;
    margin-top: 20px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
}

.step-indicator {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
}

.step {
    flex: 1;
    text-align: center;
    position: relative;
}

.step::after {
    content: '';
    position: absolute;
    top: 15px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: var(--border);
    z-index: -1;
}

.step:last-child::after {
    display: none;
}

.step.active .step-number {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.step.completed .step-number {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.step-number {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 2px solid var(--border);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-bottom: 8px;
    transition: all 0.3s;
}

.step-label {
    font-size: 12px;
    color: var(--text-muted);
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--dark);
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    background: var(--bg-input);
    transition: all 0.2s;
}

.radio-item:hover {
    border-color: var(--primary);
}

.radio-item label {
    color: var(--dark);
    cursor: pointer;
}

.radio-item input[type="radio"]:checked+label {
    color: var(--primary);
    font-weight: 600;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 30px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    margin-bottom: 10px;
    color: var(--dark);
}

/* Context Menu */
.context-menu {
    display: none;
    position: absolute;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    min-width: 150px;
}

.context-menu-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
    color: var(--dark);
}

.context-menu-item:hover {
    background: var(--bg-input);
}

.context-menu-item:first-child {
    border-radius: 8px 8px 0 0;
}

.context-menu-item:last-child {
    border-radius: 0 0 8px 8px;
}

.context-menu-icon {
    font-size: 16px;
}

/* Branch Validation */
.branch-validation {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    display: none;
}

.branch-validation.success {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.branch-validation.error {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.branch-validation.loading {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

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

    100% {
        transform: rotate(360deg);
    }
}

.btn:disabled {
    background: var(--bg-input);
    cursor: not-allowed;
    opacity: 0.6;
    color: var(--text-muted);
}

/* Scenario Tree Styles */
.scenario-controls {
    margin: 20px 0;
    padding: 15px;
    background: var(--bg-input);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
}

.scenario-tree {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    background: var(--bg-panel);
    margin: 20px 0;
    max-height: 500px;
    overflow-y: auto;
}

.tree-layer {
    margin-bottom: 15px;
}

.tree-stack {
    margin-left: 20px;
    margin-bottom: 10px;
}

.tree-scenario {
    margin-left: 40px;
    margin-bottom: 5px;
}

.tree-node {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    cursor: pointer;
    user-select: none;
    color: var(--dark);
}

.tree-toggle {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--primary);
    font-weight: bold;
    cursor: pointer;
}

.tree-spacer {
    width: 16px;
    height: 16px;
}

.tree-label {
    font-weight: 500;
    cursor: pointer;
    margin: 0;
}

.layer-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
}

.stack-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
}

.scenario-label {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-muted);
}

.tree-children {
    margin-top: 5px;
}

.layer-checkbox,
.stack-checkbox,
.scenario-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

.layer-node:hover {
    background: rgba(59, 130, 246, 0.05);
    border-radius: 4px;
}

.stack-node:hover {
    background: rgba(16, 185, 129, 0.05);
    border-radius: 4px;
}

.scenario-node:hover {
    background: rgba(245, 158, 11, 0.05);
    border-radius: 4px;
}

/* Indeterminate checkbox styling */
input[type="checkbox"]:indeterminate {
    background-color: var(--primary);
    border-color: var(--primary);
}

input[type="checkbox"]:indeterminate::before {
    content: '−';
    color: white;
    font-weight: bold;
    display: block;
    text-align: center;
    line-height: 14px;
}

/* Selection count styling */
#selectionCount {
    color: var(--primary);
    font-size: 14px;
}

/* Scenario Table & Log Styles */
#scenarioTable {
    margin-top: 10px;
    font-size: 13px;
    width: 100%;
    border-collapse: collapse;
}

#scenarioTable th {
    padding: 10px;
    background: var(--bg-input);
    color: var(--dark);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

#scenarioTable td {
    padding: 10px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

#queue-log {
    border: 1px solid var(--border);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
    background: #000;
    color: #0f0;
    padding: 10px;
    font-family: monospace;
    border-radius: 8px;
}

#scenarioSearch {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--dark);
    padding: 8px 12px;
    border-radius: 6px;
}

#scenarioSearch:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}