:root {
    --bg: #0a0a0f;
    --surface: #12121a;
    --surface2: #1a1a26;
    --border: #1e1e2e;
    --accent: #7c6ff7;
    --accent2: #4fd1c5;
    --text: #e2e8f0;
    --muted: #64748b;
    --green: #22d3a5;
    --red: #f43f5e;
    --yellow: #fbbf24;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Syne', sans-serif;
    min-height: 100vh;
    padding: 2rem;
}
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(ellipse at 20% 20%, rgba(124,111,247,0.08) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 80%, rgba(79,209,197,0.06) 0%, transparent 60%);
    pointer-events: none; z-index: 0;
}
.container { max-width: 1100px; margin: 0 auto; position: relative; z-index: 1; }
header {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-bottom: 2.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border);
}
.logo { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.03em; }
.logo span { color: var(--accent); }
.meta { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; color: var(--muted); text-align: right; }
.logout {
    font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: var(--muted);
    text-decoration: none; border: 1px solid var(--border); padding: 0.3rem 0.8rem;
    border-radius: 4px; transition: all 0.2s; margin-left: 1rem;
}
.logout:hover { color: var(--text); border-color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 1.2rem 1.5rem; position: relative; overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.stat-label { font-family: 'JetBrains Mono', monospace; font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.5rem; }
.stat-value { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.stat-sub { font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: var(--muted); margin-top: 0.3rem; }
.bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 0.8rem; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.bar-fill.warning { background: linear-gradient(90deg, var(--yellow), #f97316); }
.bar-fill.danger { background: linear-gradient(90deg, var(--red), #f97316); }
.health-panel {
    background: rgba(18,18,26,0.72); border: 1px solid var(--border); border-radius: 14px;
    padding: 1rem 1.25rem; margin-bottom: 2rem; backdrop-filter: blur(10px);
}
.health-grid {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem;
}
.health-item {
    min-width: 0; padding: 0.35rem 0;
}
.health-label {
    font-family: 'JetBrains Mono', monospace; font-size: 0.65rem; text-transform: uppercase;
    letter-spacing: 0.1em; color: var(--muted); margin-bottom: 0.35rem;
}
.health-value { font-size: 0.95rem; font-weight: 700; }
.health-sub {
    font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status-pills { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.2rem; }
.status-pill {
    font-family: 'JetBrains Mono', monospace; font-size: 0.66rem; padding: 0.22rem 0.5rem; border-radius: 999px;
    border: 1px solid var(--border); color: var(--muted); background: rgba(255,255,255,0.02);
}
.status-pill.online { color: var(--green); border-color: rgba(34,211,165,0.35); background: rgba(34,211,165,0.08); }
.status-pill.offline { color: var(--red); border-color: rgba(244,63,94,0.35); background: rgba(244,63,94,0.08); }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.section-title { font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.15em; }
.section-tools { display: flex; gap: 0.5rem; }
.btn {
    font-family: 'Syne', sans-serif; font-weight: 700; font-size: 0.8rem;
    padding: 0.5rem 1.2rem; border-radius: 6px; border: none; cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { opacity: 0.85; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--muted); color: var(--accent2); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); font-size: 0.7rem; padding: 0.3rem 0.8rem; }
.btn-danger:hover { background: var(--red); color: white; }
.btn-restart { background: transparent; color: var(--yellow); border: 1px solid var(--yellow); font-size: 0.7rem; padding: 0.3rem 0.8rem; }
.btn-restart:hover { background: var(--yellow); color: var(--bg); }
.btn-stop { background: transparent; color: var(--muted); border: 1px solid var(--muted); font-size: 0.7rem; padding: 0.3rem 0.8rem; }
.btn-stop:hover { color: var(--text); border-color: var(--text); }
.experiments { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 2.5rem; }
.experiment-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 1.15rem 1.35rem; display: grid; grid-template-columns: auto minmax(0, 1fr);
    align-items: start; column-gap: 1rem; row-gap: 0.9rem; transition: border-color 0.2s;
}
.experiment-card:hover { border-color: var(--border); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 0.35rem; }
.status-dot.running { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }
.status-dot.stopped { background: var(--red); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.exp-main { min-width: 0; }
.exp-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.exp-name { font-weight: 700; font-size: 1rem; min-width: 0; }
.exp-meta { display: flex; align-items: center; gap: 0.55rem; flex-shrink: 0; }
.exp-url { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; color: var(--muted); margin-top: 0.28rem; }
.exp-url a { color: var(--accent2); text-decoration: none; }
.exp-url a:hover { text-decoration: underline; }
.exp-port { font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; color: var(--muted); background: var(--border); padding: 0.2rem 0.55rem; border-radius: 999px; }
.exp-status { font-family: 'JetBrains Mono', monospace; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; padding: 0.2rem 0.55rem; border-radius: 999px; border: 1px solid transparent; }
.exp-status.running { color: var(--green); border-color: rgba(34,211,165,0.35); background: rgba(34,211,165,0.08); }
.exp-status.stopped { color: var(--red); border-color: rgba(244,63,94,0.35); background: rgba(244,63,94,0.08); }
.exp-actions { grid-column: 2; display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: center; gap: 0.45rem; }
.exp-actions .btn {
    font-size: 0.72rem; line-height: 1.15; padding: 0.38rem 0.78rem;
}
.no-experiments { text-align: center; padding: 3rem; color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; border: 1px dashed var(--border); border-radius: 12px; }

/* Modal */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    z-index: 100; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    padding: 2rem; width: 100%; max-width: 520px; position: relative;
}
.modal-large {
    max-width: 900px;
    height: 80vh;
    display: flex;
    flex-direction: column;
}
.modal-large .log-terminal {
    display: block !important;
    flex: 1;
    height: 100%;
}
.modal-title { font-size: 1.2rem; font-weight: 800; margin-bottom: 0.3rem; }
.modal-sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-label { font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.4rem; display: block; }
input[type=text], input[type=password], input[type=number] {
    width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 0.7rem 1rem; color: var(--text); font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem; outline: none; transition: border-color 0.2s;
}
input:focus { border-color: var(--accent); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.modal-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.btn-cancel { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-cancel:hover { color: var(--text); border-color: var(--muted); }
.btn-full { flex: 1; padding: 0.75rem; }

/* Log terminal */
.log-terminal {
    display: none; margin-top: 1.5rem; background: var(--bg); border: 1px solid var(--border);
    border-radius: 8px; padding: 1rem; height: 250px; overflow-y: auto;
    font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; line-height: 1.6;
}
.log-terminal.active { display: block; }
.log-line { color: var(--muted); }
.log-line.success { color: var(--green); }
.log-line.error { color: var(--red); }
.log-line.info { color: var(--accent2); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 360px; }
.login-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 0.5rem; }
.login-sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 2rem; }
.error-msg { color: var(--red); font-size: 0.8rem; font-family: 'JetBrains Mono', monospace; margin-bottom: 1rem; }
.btn-login { width: 100%; padding: 0.8rem; font-size: 0.95rem; }

@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .health-grid { grid-template-columns: 1fr 1fr; }
    .section-header { flex-direction: column; align-items: stretch; gap: 0.75rem; }
    .section-tools { width: 100%; }
    .section-tools .btn { flex: 1; }
    .experiment-card { grid-template-columns: auto 1fr; gap: 0.85rem; }
    .exp-head { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .exp-meta { flex-wrap: wrap; }
    .exp-actions { grid-column: 1 / -1; }
}
