/* ─── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:          #0a0a0f;
    --bg-2:        #111118;
    --bg-3:        #18181f;
    --bg-card:     rgba(255,255,255,0.04);
    --border:      rgba(255,255,255,0.08);
    --border-2:    rgba(255,255,255,0.12);
    --text:        #e8e8f0;
    --text-muted:  #6b7080;
    --text-sub:    #9ca3af;
    --accent:      #6366f1;
    --accent-2:    #8b5cf6;
    --accent-glow: rgba(99,102,241,0.25);
    --success:     #10b981;
    --success-bg:  rgba(16,185,129,0.1);
    --warning:     #f59e0b;
    --warning-bg:  rgba(245,158,11,0.1);
    --danger:      #ef4444;
    --danger-bg:   rgba(239,68,68,0.1);
    --info:        #3b82f6;
    --info-bg:     rgba(59,130,246,0.1);
    --radius:      12px;
    --radius-sm:   8px;
    --sidebar-w:   240px;
    --sidebar-w-collapsed: 64px;
    --font:        'Inter', system-ui, sans-serif;
    --font-mono:   'JetBrains Mono', 'Fira Code', monospace;
    --transition:  0.2s ease;
}

html { font-size: 15.5px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ─── Login ─────────────────────────────────────────────────────────────────── */
.login-mode {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.15) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.1) 0%, transparent 50%),
                var(--bg);
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 24px;
}

.login-card {
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-2);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.02);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-icon.small { width: 32px; height: 32px; border-radius: 8px; }
.logo-icon.small svg { width: 24px; height: 24px; }

.logo-title {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.logo-sub {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.login-heading {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 6px;
}

.login-subheading {
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 0.9rem;
}

.alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 20px;
}

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

.login-form { display: flex; flex-direction: column; gap: 18px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-sub);
    letter-spacing: 0.02em;
}

.form-group input,
.password-wrap input {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.password-wrap input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder,
.password-wrap input::placeholder { color: var(--text-muted); }

.password-wrap {
    position: relative;
}

.password-wrap input { padding-right: 44px; }

.toggle-pw {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: color var(--transition);
}

.toggle-pw:hover { color: var(--text); }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    outline: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn-primary:hover { background: #4f51dd; box-shadow: 0 0 20px var(--accent-glow); }

.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 0.92rem; }

.btn-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(16,185,129,0.2);
}
.btn-success:hover { background: rgba(16,185,129,0.2); }

.btn-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: rgba(245,158,11,0.2);
}
.btn-warning:hover { background: rgba(245,158,11,0.2); }

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-card); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 0.77rem; }

.btn:disabled { opacity: 0.5; pointer-events: none; }

/* ─── Dashboard Layout ───────────────────────────────────────────────────────── */
.dashboard-mode { overflow: hidden; }

.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    transition: width 0.22s ease;
    overflow: hidden;
}

.sidebar--collapsed {
    width: var(--sidebar-w-collapsed);
}

.sidebar--collapsed .sidebar-header-text,
.sidebar--collapsed .nav-label,
.sidebar--collapsed .nav-progress,
.sidebar--collapsed .user-info-text {
    display: none;
}

.sidebar--collapsed .sidebar-header {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar--collapsed .nav-item {
    justify-content: center;
    padding: 10px 0;
}

.sidebar--collapsed .sidebar-footer {
    flex-direction: column;
    align-items: center;
    padding-left: 0;
    padding-right: 0;
    gap: 8px;
}

.sidebar--collapsed .user-info {
    justify-content: center;
}

/* ─── Sidebar Toggle Button (Topbar) ────────────────────────────────────────── */
.sidebar-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition);
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--border-2);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.sidebar-title {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
}

.nav-item:hover { background: var(--bg-card); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); }
.nav-item.active svg { stroke: var(--accent); }

.nav-progress {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 10px;
    background: rgba(99,102,241,0.18);
    color: var(--accent);
    font-family: var(--font-mono);
    flex-shrink: 0;
    animation: navProgressPulse 2s ease-in-out infinite;
}

/* ─── Nav Process Status Spinner ────────────────────────────────────────────── */
.nav-proc-status {
    margin-left: auto;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    display: none;
}

.nav-proc-status--online {
    display: block;
    border: 1.5px solid rgba(16, 185, 129, 0.2);
    border-top-color: var(--success);
    animation: navProcSpin 0.85s linear infinite;
}

.nav-proc-status--stopped {
    display: block;
    background: rgba(107, 112, 128, 0.25);
}

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

.sidebar--collapsed .nav-proc-status { display: none !important; }
.nav-progress.nav-progress-done {
    background: rgba(16,185,129,0.18);
    color: var(--success);
    animation: none;
}
@keyframes navProgressPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* ─── Sidebar Progress Area ─────────────────────────────────────────────────── */
.sidebar-progress-area {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
}

.sidebar-progress-area.has-content {
    display: flex;
}

.sidebar--collapsed .sidebar-progress-area {
    display: none !important;
}

.sidebar-progress-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    transition: opacity 0.4s ease, border-color 0.3s ease;
}

.sidebar-progress-item.is-done {
    border-color: rgba(16,185,129,0.3);
    opacity: 0.6;
}

.sidebar-progress-item.is-overall {
    border-color: rgba(99,102,241,0.35);
    background: rgba(99,102,241,0.07);
    margin-bottom: 3px;
}

.sidebar-progress-bar-fill.overall {
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    opacity: 1;
}

.sidebar-progress-header {
    display: flex;
    align-items: flex-start;
    gap: 5px;
    margin-bottom: 5px;
    min-width: 0;
}

.sidebar-progress-proc {
    font-size: 0.64rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent);
    flex-shrink: 0;
}

.sidebar-progress-label {
    font-size: 0.68rem;
    color: var(--text-sub);
    flex: 1;
    min-width: 0;
    word-break: break-word;
    line-height: 1.35;
}

.sidebar-progress-pct {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    flex-shrink: 0;
}

.sidebar-progress-bar-wrap {
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    height: 3px;
    overflow: hidden;
}

.sidebar-progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width 0.35s ease;
    position: relative;
}

.sidebar-progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    animation: progressShimmer 1.5s infinite;
}

.sidebar-progress-bar-fill.done {
    background: var(--success);
}

.sidebar-progress-bar-fill.done::after,
.sidebar-progress-bar-fill.error::after {
    animation: none;
}

.sidebar-progress-bar-fill.error {
    background: var(--danger);
}

.sidebar-footer {
    padding: 16px 20px 0;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info { flex: 1; display: flex; align-items: center; gap: 10px; }

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-name { font-size: 0.82rem; font-weight: 600; }
.user-since { font-size: 0.7rem; color: var(--text-muted); }

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 8px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: all var(--transition);
}
.btn-logout:hover { background: var(--danger-bg); color: var(--danger); border-color: rgba(239,68,68,0.3); }

/* ─── Main ───────────────────────────────────────────────────────────────────── */
.main {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-2);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-title-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.page-title-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.page-filename {
    font-size: 0.8rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-weight: 400;
}

.page-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
    line-height: 1.3;
}

.refresh-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.refresh-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

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

.last-update { font-size: 0.78rem; color: var(--text-muted); }

/* ─── Sections ───────────────────────────────────────────────────────────────── */
.section {
    display: none;
    padding: 24px 28px;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.section.active { display: flex; }

/* ─── Global Controls ────────────────────────────────────────────────────────── */
.global-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
}

.controls-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 4px;
}

/* ─── Process Grid ───────────────────────────────────────────────────────────── */
.process-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.process-card {
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: border-color var(--transition), box-shadow var(--transition);
    position: relative;
    overflow: hidden;
}

.process-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--card-accent, var(--border));
    transition: background var(--transition);
}

.process-card.status-online { --card-accent: var(--success); border-color: rgba(16,185,129,0.2); }
.process-card.status-stopped { --card-accent: var(--text-muted); }
.process-card.status-errored { --card-accent: var(--danger); border-color: rgba(239,68,68,0.2); }
.process-card.status-launching { --card-accent: var(--warning); border-color: rgba(245,158,11,0.2); }
.process-card.status-unknown { --card-accent: var(--info); }

.process-card:hover { border-color: var(--border-2); box-shadow: 0 8px 30px rgba(0,0,0,0.2); }

.process-card-readonly { opacity: 0.92; }
.process-card-readonly:hover { border-color: var(--border); }

.process-actions-readonly { padding-top: 4px; }
.readonly-hint { font-size: 0.75rem; color: var(--text-muted); }

.process-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.process-name {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.process-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.process-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    gap: 12px;
}

.process-stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.process-stat-value {
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text);
}

.process-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.card-name {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.card-script {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: 2px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-online  { background: var(--success-bg); color: var(--success); }
.badge-stopped { background: rgba(107,112,128,0.15); color: var(--text-muted); }
.badge-errored { background: var(--danger-bg); color: var(--danger); }
.badge-launching { background: var(--warning-bg); color: var(--warning); }
.badge-unknown { background: var(--info-bg); color: var(--info); }

.card-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.stat-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
}

.stat-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 0.92rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text);
}

.card-cron {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ─── Loading ────────────────────────────────────────────────────────────────── */
.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px;
    color: var(--text-muted);
    font-size: 0.85rem;
    width: 100%;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ─── Log Viewer ─────────────────────────────────────────────────────────────── */
.log-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
}

.log-select-wrap, .log-lines-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.log-select-wrap label, .log-lines-wrap label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.pm2-proc-buttons-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pm2-proc-buttons-wrap .controls-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.pm2-proc-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pm2-proc-buttons .btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.pm2-proc-buttons .btn.active:hover {
    background: var(--accent);
    color: white;
    opacity: 0.9;
}

select {
    background: var(--bg-3);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
    padding: 6px 10px;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition);
}

select:focus { border-color: var(--accent); }

.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
}

.log-meta-bar {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 4px 0;
    font-family: var(--font-mono);
}

.log-viewer {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    overflow: hidden;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.log-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 20px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-sub);
    scroll-behavior: smooth;
}

.log-content::-webkit-scrollbar { width: 6px; }
.log-content::-webkit-scrollbar-track { background: transparent; }
.log-content::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

.log-viewer-err .log-content { color: #fca5a5; }

.log-line-error   { color: var(--danger); }
.log-line-warning { color: var(--warning); }
.log-line-success { color: var(--success); }
.log-line-info    { color: var(--info); }

.pm2-log-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.log-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}
.log-label-err { color: #f87171; }

/* ─── Prozess-Live-Console ──────────────────────────────────────────────────── */
.process-console-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.process-console-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.process-console-name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.process-console-script {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.process-runtime-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 5px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-sub);
    background: rgba(245,158,11,0.08);
    border: 1px solid rgba(245,158,11,0.2);
    border-radius: 20px;
    padding: 2px 8px 2px 6px;
    width: fit-content;
}
.process-runtime-badge svg {
    color: var(--warning);
    flex-shrink: 0;
}

.process-console-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.process-console-runtime {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-left: 4px;
    padding-left: 8px;
}

.process-console-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 0 4px;
    font-size: 0.82rem;
}

.process-console-status .process-stat {
    min-width: 110px;
}

.process-console-status .pm2-config-row {
    flex-basis: 100%;
    margin-top: 2px;
}

/* Layout: Consolen-Fenster fix, Progress-Balken seitlich kompakt */
.process-console-layout {
    display: flex;
    gap: 16px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.process-console-main {
    flex: 1 1 50%;
    min-width: 120px;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.progress-sidebar {
    flex-shrink: 0;
    width: 220px;
    max-height: calc(100vh - 320px);
    overflow-y: auto;
}

.progress-sidebar .progress-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.process-console-viewer {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.process-console-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-3);
    border-bottom: 1px solid var(--border);
}

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--success);
}

.live-indicator.inactive {
    color: var(--text-muted);
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}

.live-indicator.inactive .live-dot {
    animation: none;
    opacity: 0.5;
}

.process-console-output {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 20px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-sub);
    scroll-behavior: smooth;
}

.process-console-output::-webkit-scrollbar { width: 6px; }
.process-console-output::-webkit-scrollbar-track { background: transparent; }
.process-console-output::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

.process-console-output .line-stderr { color: #fca5a5; }
.process-console-output .line-stdout { color: var(--text-sub); }
.process-console-output .line-sys { color: var(--warning); }
.process-console-output .line-progress {
  color: var(--accent);
  font-weight: 500;
}

.process-console-output:empty::before {
    content: 'Prozess starten, um Live-Ausgabe zu sehen…';
    color: var(--text-muted);
    font-style: italic;
}

/* ─── Inline Log-Panels (rechte Spalte neben Console) ───────────────────────── */
.log-panel-sidebar {
    flex: 1 1 50%;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow: hidden;
}

.inline-log-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    flex: 1;
    min-height: 120px;
}

.inline-log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 12px;
    background: var(--bg-3);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.inline-log-title {
    font-size: 0.71rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inline-log-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.inline-log-viewer {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 14px;
    font-family: var(--font-mono);
    font-size: 0.71rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-sub);
    scroll-behavior: smooth;
}

.inline-log-viewer::-webkit-scrollbar { width: 4px; }
.inline-log-viewer::-webkit-scrollbar-track { background: transparent; }
.inline-log-viewer::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

/* ─── Sidebar Resizer ───────────────────────────────────────────────────────── */
.sidebar-resizer {
    flex-shrink: 0;
    width: 5px;
    cursor: col-resize;
    background: transparent;
    position: relative;
    z-index: 10;
    transition: background var(--transition);
}

.sidebar-resizer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 40px;
    background: transparent;
    border-radius: 2px;
    transition: background var(--transition), height var(--transition);
}

.sidebar-resizer:hover,
.sidebar-resizer.is-dragging {
    background: var(--accent-glow);
}

.sidebar-resizer:hover::after,
.sidebar-resizer.is-dragging::after {
    background: var(--accent);
    height: 60px;
}

.sidebar--collapsed + .sidebar-resizer {
    display: none;
}

/* ─── Console ↔ Log-Panel Resizer ────────────────────────────────────────────── */
.console-resizer {
    flex-shrink: 0;
    width: 6px;
    cursor: col-resize;
    border-radius: 3px;
    background: var(--border);
    position: relative;
    transition: background var(--transition), width var(--transition);
    align-self: stretch;
}

.console-resizer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 48px;
    background: var(--border-2);
    border-radius: 2px;
    transition: background var(--transition), height var(--transition);
}

.console-resizer:hover,
.console-resizer.is-dragging {
    background: var(--accent-glow);
    width: 8px;
}

.console-resizer:hover::after,
.console-resizer.is-dragging::after {
    background: var(--accent);
    height: 72px;
}

/* ─── Progress Bars ─────────────────────────────────────────────────────────── */
.progress-container {
    display: none;
    flex-direction: column;
    gap: 6px;
}

.progress-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    transition: opacity 0.4s ease, border-color 0.3s ease;
}

.progress-sidebar .progress-item {
    padding: 6px 10px;
}

.progress-item.is-done {
    border-color: rgba(16,185,129,0.3);
    opacity: 0.7;
}

.progress-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    gap: 8px;
}

.progress-sidebar .progress-label {
    margin-bottom: 4px;
}

.progress-label-text {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-sub);
}

.progress-sidebar .progress-label-text {
    font-size: 0.72rem;
}

.progress-label-pct {
    font-size: 0.72rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    white-space: nowrap;
}

.progress-sidebar .progress-label-pct {
    font-size: 0.68rem;
}

.progress-bar-wrap {
    background: rgba(255,255,255,0.06);
    border-radius: 4px;
    height: 5px;
    overflow: hidden;
}

.progress-sidebar .progress-bar-wrap {
    height: 4px;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width 0.35s ease;
    position: relative;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    animation: progressShimmer 1.5s infinite;
}

.progress-bar-fill.done {
    background: var(--success);
}

.progress-bar-fill.done::after {
    animation: none;
}

.progress-bar-fill.error {
    background: var(--danger);
}

.progress-bar-fill.error::after {
    animation: none;
}

@keyframes progressShimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: var(--bg-3);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    animation: slideIn 0.25s ease;
    pointer-events: auto;
    max-width: 340px;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger);  }
.toast-info    { border-left: 3px solid var(--accent);  }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(20px); }
}
.toast.fade-out { animation: fadeOut 0.3s ease forwards; }

/* ─── Badge (process cards) ──────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-idle    { background: rgba(99,102,241,0.12); color: #818cf8; }

/* ─── PM2 Cron-Config Row ────────────────────────────────────────────────────── */
.pm2-config-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    width: 100%;
    margin-top: 4px;
    padding: 10px 14px;
    background: rgba(99,102,241,0.06);
    border: 1px solid rgba(99,102,241,0.18);
    border-radius: var(--radius-sm);
}

.pm2-config-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 120px;
}

.pm2-config-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pm2-config-value {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-sub);
    line-height: 1.4;
}

.pm2-cron-expr {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--text-muted);
}

.cron-times {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    color: var(--text);
}

.cron-more {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
}

.cron-countdown {
    font-size: 0.75rem;
    color: #818cf8;
    font-style: italic;
}

.cron-yes { color: var(--success); font-weight: 600; }
.cron-no  { color: var(--text-muted); }

.cron-hint-inline {
    font-size: 0.72rem;
    color: #818cf8;
    font-style: italic;
    margin-left: 2px;
}

/* ─── Scrollbar ─────────────────────────────────────────────────────────────── */
.main::-webkit-scrollbar { width: 6px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { width: 200px; }
    --sidebar-w: 200px;
    .process-grid { grid-template-columns: 1fr; }
    .pm2-log-grid { grid-template-columns: 1fr; }
    .card-stats { grid-template-columns: repeat(2, 1fr); }
    .global-controls { gap: 6px; }
    .topbar { flex-direction: column; align-items: flex-start; gap: 8px; }
    .process-console-layout { flex-direction: column; }
    .console-resizer { display: none; }
    .process-console-main,
    .log-panel-sidebar { flex: none; width: 100%; min-width: 0; }
    .progress-sidebar {
        width: 100%;
        max-height: 120px;
        order: -1;
    }
    .log-panel-sidebar {
        max-height: 200px;
        flex-direction: row;
        order: -1;
    }
    .inline-log-panel { min-height: 80px; }
}

@media (max-width: 540px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; height: auto; padding: 12px; }
    .sidebar-nav { flex-direction: row; padding: 0; }
    .sidebar-footer { display: none; }
    .main { height: calc(100vh - 80px); }
}

/* ─── Wiki ───────────────────────────────────────────────────────────────────── */
.wiki-section {
    overflow-y: auto;
}

.wiki-body {
    max-width: 900px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 40px;
}

.wiki-hero {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 28px 32px;
    background: linear-gradient(135deg, rgba(99,102,241,0.12) 0%, rgba(139,92,246,0.08) 100%);
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: var(--radius);
}

.wiki-hero-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wiki-h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
    margin-bottom: 4px;
}

.wiki-lead {
    color: var(--text-sub);
    font-size: 0.9rem;
    line-height: 1.5;
}

.wiki-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.wiki-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wiki-card--full {
    grid-column: 1 / -1;
}

.wiki-h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.wiki-h2 svg {
    color: var(--accent);
    flex-shrink: 0;
}

.wiki-card p {
    font-size: 0.85rem;
    color: var(--text-sub);
    line-height: 1.7;
}

.wiki-card p code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    color: var(--accent);
}

/* Prozess-Liste */
.wiki-proc-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wiki-proc-item {
    padding: 14px 16px;
    background: rgba(255,255,255,0.025);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wiki-proc-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
}

.wiki-proc-name svg {
    color: var(--accent);
    flex-shrink: 0;
}

.wiki-proc-file {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 4px;
}

.wiki-proc-item p {
    font-size: 0.83rem;
    color: var(--text-sub);
    line-height: 1.65;
}

.wiki-proc-item p strong {
    color: var(--text);
    font-weight: 600;
}

.wiki-proc-item p code {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    color: var(--accent);
}

/* Status-Tabelle */
.wiki-status-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wiki-status-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.wiki-status-item .badge {
    flex-shrink: 0;
    margin-top: 1px;
    min-width: 68px;
    justify-content: center;
}

.wiki-status-desc {
    font-size: 0.82rem;
    color: var(--text-sub);
    line-height: 1.55;
}

.wiki-status-desc strong {
    color: var(--text);
    font-weight: 600;
}

.wiki-status-desc em {
    color: var(--text-muted);
    font-style: italic;
}

/* UI-Elemente Liste */
.wiki-ui-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wiki-ui-item {
    padding: 10px 14px;
    background: rgba(255,255,255,0.02);
    border-left: 3px solid rgba(99,102,241,0.35);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.wiki-ui-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 3px;
}

.wiki-ui-desc {
    font-size: 0.8rem;
    color: var(--text-sub);
    line-height: 1.55;
}

.wiki-ui-desc code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    color: var(--accent);
}

/* Wiki — SSH-Befehle */
.wiki-cmd-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wiki-cmd-item {
    padding: 12px 16px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wiki-cmd-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wiki-cmd {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-2);
    border-radius: 6px;
    padding: 3px 10px;
}

.wiki-cmd-badge {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 20px;
    flex-shrink: 0;
}

.wiki-cmd-badge--start   { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.wiki-cmd-badge--stop    { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.2); }
.wiki-cmd-badge--restart { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }

.wiki-cmd-desc {
    font-size: 0.81rem;
    color: var(--text-sub);
    line-height: 1.55;
}

.wiki-cmd-desc code {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    color: var(--accent);
}

.wiki-hint {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(99,102,241,0.06);
    border: 1px solid rgba(99,102,241,0.18);
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    margin-top: 4px;
}

.wiki-hint svg { flex-shrink: 0; color: var(--accent); }

.wiki-hint code {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--accent);
}

.nav-item--wiki {
    margin-top: 8px;
    border-top: 1px solid var(--border);
    padding-top: 14px;
}

@media (max-width: 768px) {
    .wiki-grid { grid-template-columns: 1fr; }
    .wiki-hero { flex-direction: column; align-items: flex-start; gap: 12px; }
}
