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

:root {
  --bg:       #0d0d0f;
  --surface:  #18181c;
  --border:   #2a2a30;
  --accent:   #6c63ff;
  --accent-h: #574fe0;
  --text:     #e8e8f0;
  --muted:    #7a7a90;
  --danger:   #e05a5a;
  --success:  #4caf50;
}

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

/* ── auth page ──────────────────────────────────────────────────────────────── */

.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 380px;
}

.auth-card h1 {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.auth-card .subtitle {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 28px;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

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

.form label { font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; display: block; }

.form input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color .15s;
}

.form input:focus { border-color: var(--accent); }

.btn {
  padding: 11px 20px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  margin-top: 4px;
}

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

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
}

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }

.msg {
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 4px;
}
.msg-err { background: rgba(224,90,90,.12); color: var(--danger); }
.msg-ok  { background: rgba(76,175,80,.12);  color: var(--success); }

/* ── dashboard ──────────────────────────────────────────────────────────────── */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-logo { font-size: 1.1rem; font-weight: 600; color: var(--accent); }

.nav-right { display: flex; align-items: center; gap: 14px; }

.nav-user  { font-size: 0.85rem; color: var(--muted); }
.nav-brand { font-size: 0.95rem; font-weight: 600; color: var(--text); letter-spacing: 0.01em; }

.btn-outline {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.dashboard-body { padding: 32px; max-width: 1100px; margin: 0 auto; }

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

.section-header h2 { font-size: 1.1rem; }

.refresh-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.refresh-btn:hover { color: var(--text); border-color: var(--text); }

.instances-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.instance-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color .15s;
}

.instance-card:hover { border-color: var(--accent); }

.instance-id {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: monospace;
}

.instance-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  margin-right: 6px;
  animation: pulse 2s infinite;
}

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

.card-preview {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
}

.card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .15s;
}

.card-preview:hover img { opacity: .85; }

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

.btn-view {
  flex: 1;
  background: var(--accent);
  color: #fff;
}
.btn-view:hover { background: var(--accent-h); }

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

.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

.empty-state p { font-size: 0.9rem; line-height: 1.6; }

/* ── viewer ─────────────────────────────────────────────────────────────────── */

.viewer-wrap {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #000;
}

.viewer-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.viewer-bar .instance-label { font-size: 0.85rem; color: var(--muted); font-family: monospace; }

.viewer-bar .status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.viewer-bar .status-dot.live { background: var(--success); animation: pulse 2s infinite; }

.viewer-actions {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.viewer-canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#screen {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ── misc ───────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
