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

:root {
  --bg: #0d0f18;
  --surface: #151824;
  --surface2: #1c2032;
  --border: #252a3d;
  --text: #e2e8f0;
  --muted: #6b7280;
  --accent: #4f6ef7;
  --accent-h: #3d5ce8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --radius: 10px;
}

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

/* ── Login ── */
#login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login-box h1 { font-size: 20px; margin-bottom: 8px; }
.login-box input { padding: 10px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; width: 100%; }
.login-box button { padding: 10px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.login-box button:hover { background: var(--accent-h); }

/* ── Nav ── */
nav { padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.nav-title { font-weight: 700; font-size: 16px; flex: 1; }

/* ── Buttons ── */
.btn-primary { padding: 9px 20px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-primary:hover { background: var(--accent-h); }
.btn-outline { padding: 7px 16px; background: transparent; color: var(--accent); border: 1px solid var(--accent); border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-outline:hover { background: var(--accent); color: #fff; }
.btn-ghost { padding: 7px 16px; background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; cursor: pointer; }
.btn-ghost:hover { color: var(--text); border-color: var(--text); }
.btn-red { padding: 6px 14px; background: transparent; color: var(--red); border: 1px solid #3a1c1c; border-radius: 8px; font-size: 12px; cursor: pointer; }
.btn-red:hover { background: var(--red); color: #fff; }
.btn-green { padding: 6px 14px; background: transparent; color: var(--green); border: 1px solid #1a3a1a; border-radius: 8px; font-size: 12px; cursor: pointer; }
.btn-green:hover { background: var(--green); color: #fff; }

/* ── Main ── */
main { padding: 28px; max-width: 1200px; margin: 0 auto; }

/* ── Device Grid ── */
#device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }

.device-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; }

.card-header { display: flex; align-items: center; gap: 10px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-running { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot-stopped { background: var(--muted); }
.dot-creating { background: var(--yellow); animation: pulse 1s infinite; }
.dot-error { background: var(--red); }

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

.card-name { font-weight: 700; font-size: 15px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-status { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.card-meta { display: flex; flex-direction: column; gap: 5px; }
.meta-row { display: flex; justify-content: space-between; font-size: 12px; }
.meta-label { color: var(--muted); }
.meta-val { color: var(--text); }

.proxy-edit { display: flex; flex-direction: column; gap: 6px; }
.proxy-edit input { padding: 7px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 12px; width: 100%; }
.proxy-edit input::placeholder { color: var(--muted); }

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

.open-link { display: block; text-align: center; padding: 10px; background: #1a2340; color: #60a5fa; border: 1px solid #1e3a6b; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 13px; }
.open-link:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

#empty-state { text-align: center; padding: 80px 20px; color: var(--muted); font-size: 16px; }

/* ── Modal ── */
#modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; width: 440px; max-width: 95vw; display: flex; flex-direction: column; gap: 16px; }
.modal h2 { font-size: 18px; margin-bottom: 4px; }
.modal label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.modal label input, .modal label select { padding: 9px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 7px; color: var(--text); font-size: 13px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

.err { color: var(--red); font-size: 12px; min-height: 16px; }

.mitm-badge { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #4ade80; background: #0d2218; border: 1px solid #166534; border-radius: 6px; padding: 5px 10px; }
.mitm-badge::before { content: ''; width: 6px; height: 6px; background: #4ade80; border-radius: 50%; box-shadow: 0 0 6px #4ade80; }
