:root {
    --bg-color: #0d0f14;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #8b5cf6;
    --terminal-bg: #090a0f;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.glass-bg {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.05) 0%, rgba(13, 15, 20, 1) 50%);
    z-index: -1;
    pointer-events: none;
}

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

/* ─── Header ─── */
header {
    margin-bottom: 2rem;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-box {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent));
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

h1 {
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ─── Navigation ─── */
.nav-links {
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 4px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.06);
}

.nav-link.active {
    color: white;
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

/* ─── Grid Layout (Home) ─── */
.grid-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
    height: calc(100vh - 120px);
}

.left-col {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    padding-right: 4px;
}

.right-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ─── Settings Layout ─── */
.settings-layout {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card-desc {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin: -0.8rem 0 1rem;
}

/* ─── Records Layout ─── */
.records-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
}

.records-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.records-toolbar h2 {
    margin-bottom: 0;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
}

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

.btn-sm {
    padding: 6px 14px;
    border-radius: 6px;
    border: none;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-sm.primary {
    background: rgba(99,102,241,0.15);
    color: var(--primary-color);
    border: 1px solid rgba(99,102,241,0.25);
}
.btn-sm.primary:hover { background: rgba(99,102,241,0.25); }

.btn-sm.success {
    background: rgba(16,185,129,0.15);
    color: var(--success);
    border: 1px solid rgba(16,185,129,0.25);
}
.btn-sm.success:hover { background: rgba(16,185,129,0.25); }

.btn-sm.danger {
    background: rgba(239,68,68,0.15);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,0.25);
}
.btn-sm.danger:hover { background: rgba(239,68,68,0.25); }

.btn-sm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.records-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.record-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255,255,255,0.05);
    transition: border-color 0.2s;
}

.record-item:hover {
    border-color: rgba(255,255,255,0.12);
}

.record-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.record-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.record-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.record-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.record-meta .ok { color: var(--success); font-weight: 600; }
.record-meta .fail { color: var(--danger); font-weight: 600; }

/* ─── Glassmorphism Cards ─── */
.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.glass-card h2 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.view-all {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 400;
}
.view-all:hover { text-decoration: underline; }

/* ─── Queue Stats ─── */
.queue-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.stat-item {
    text-align: center;
    padding: 10px 0;
    border-radius: 10px;
    background: rgba(0,0,0,0.2);
}

.stat-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.running-pulse {
    color: var(--primary-color) !important;
    animation: pulse-badge 1.5s infinite;
}

/* ─── Forms ─── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

input,
select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

select {
    appearance: none;
    cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

select option {
    background: #111827;
    color: var(--text-primary);
}

input:focus,
select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.proxy-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
    color: var(--text-primary);
    cursor: pointer;
}

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

.status-msg {
    min-height: 20px;
    margin-top: 10px;
    font-size: 0.85rem;
}

/* ─── Buttons ─── */
.btn {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    border: none;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn.primary {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.1);
}
.btn.primary:hover { background: rgba(255,255,255,0.15); }

.btn.action {
    background: linear-gradient(135deg, var(--primary-color), var(--accent));
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}
.btn.action:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
}

.btn.secondary {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.btn.secondary:hover { background: rgba(16, 185, 129, 0.2); }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ─── Task List (Home mini) ─── */
.task-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empty-hint {
    color: var(--text-secondary);
    text-align: center;
    padding: 1.5rem 0;
    font-size: 0.9rem;
}

.task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255,255,255,0.05);
    transition: border-color 0.2s;
}

.task-item:hover { border-color: rgba(255,255,255,0.12); }

.task-item.active-task {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.task-item .task-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.task-item .task-id,
.record-main .task-id {
    font-size: 0.9rem;
    font-weight: 500;
}

.task-item .task-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.task-item .task-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.task-item .task-counts {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
}

.task-item .task-counts .ok { color: var(--success); font-weight: 600; }
.task-item .task-counts .fail { color: var(--danger); font-weight: 600; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.running {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-color);
    border: 1px solid rgba(99, 102, 241, 0.3);
    animation: pulse-badge 1.5s infinite;
}

.badge.completed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge.pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge.stopping {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.25);
    animation: pulse-badge 1.5s infinite;
}

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

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

/* ─── Terminal ─── */
.terminal-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    min-height: 0;
}

.terminal-card.fullscreen {
    position: fixed;
    top: 2rem;
    left: 2rem;
    right: 2rem;
    bottom: 2rem;
    z-index: 1000;
}

.terminal-header {
    background: rgba(0,0,0,0.3);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--card-border);
}

.circles {
    display: flex;
    gap: 6px;
    margin-right: 1rem;
}

.circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.circle.red { background: #ff5f56; }
.circle.yellow { background: #ffbd2e; }
.circle.green { background: #27c93f; }

.terminal-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.terminal-body {
    flex: 1;
    background: var(--terminal-bg);
    padding: 1rem;
    overflow-y: auto;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #a8b2c4;
}

.log-line {
    margin-bottom: 0.2rem;
    word-break: break-all;
}

.log-line.sys { color: var(--text-secondary); font-style: italic; }
.log-line.success { color: var(--success); }
.log-line.error { color: var(--danger); }
.log-line.info { color: #60a5fa; }

.status-msg {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    text-align: center;
    color: var(--success);
}

/* ─── Toggle Switch ─── */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 8px 0;
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(255,255,255,0.1);
    border-radius: 24px;
    border: 1px solid rgba(255,255,255,0.1);
    transition: 0.3s;
}

.slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: 0.3s;
}

.switch input:checked + .slider {
    background: rgba(99, 102, 241, 0.3);
    border-color: rgba(99, 102, 241, 0.5);
}

.switch input:checked + .slider::before {
    transform: translateX(20px);
    background: var(--primary-color);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}
