:root {
  --mbg: #0d0f14;
  --mcard: #151820;
  --mcard2: #1c2030;
  --mtext: #e0e4f0;
  --mtext2: #9098b0;
  --mgreen: #39ff8a;
  --mred: #ff3b5c;
  --morange: #ff9f3b;
  --mblue: #4a9eff;
  --mborder: #ffffff15;
  --mshadow: 0 4px 20px rgba(0,0,0,.4);
}

* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--mbg); color: var(--mtext);
  overflow: hidden; height: 100dvh; width: 100vw;
  user-select: none; -webkit-user-select: none;
}
button { border: none; background: none; color: inherit; cursor: pointer; font: inherit; }

/* ─── App Bar ─── */
.appbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--mcard);
  border-bottom: 1px solid var(--mborder); position: relative; z-index: 10;
}
.appbar-title {
  font-size: 1.1rem; font-weight: 700;
  background: linear-gradient(135deg, var(--mgreen), #39ff8a88);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.appbar-actions { display: flex; gap: 12px; align-items: center; }
.appbar-btn { font-size: 1.2rem; padding: 6px; opacity: .7; }
.appbar-btn:active { opacity: 1; }
.appbar-link { font-size: .75rem; padding: 6px 10px; opacity: .7; text-decoration: none; color: inherit; border-radius: 8px; border: 1px solid var(--mborder); white-space: nowrap; }
.appbar-link:active { opacity: 1; background: #ffffff15; }

/* ─── VM List ─── */
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px; }
.pull-indicator { text-align: center; padding: 8px; font-size: .75rem; color: var(--mtext2); display: none; }

.vm-card {
  background: var(--mcard); border: 1px solid var(--mborder); border-radius: 16px;
  padding: 16px; margin-bottom: 12px; box-shadow: var(--mshadow);
  transition: transform .15s, box-shadow .15s;
}
.vm-card:active { transform: scale(.98); }
.vm-card-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.status-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: var(--mtext2); transition: background .3s;
}
.status-dot.running { background: var(--mgreen); box-shadow: 0 0 8px var(--mgreen); }
.status-dot.paused { background: var(--morange); box-shadow: 0 0 8px var(--morange); }
.status-dot.error { background: var(--mred); box-shadow: 0 0 8px var(--mred); }
.vm-name { font-size: 1rem; font-weight: 600; flex: 1; }
.vm-status-text { font-size: .7rem; color: var(--mtext2); text-transform: uppercase; letter-spacing: .5px; }

.vm-details { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 10px; }
.vm-detail {
  font-size: .75rem; color: var(--mtext2); display: flex; align-items: center; gap: 4px;
}
.vm-detail .label { color: var(--mtext2); opacity: .6; }

.vm-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.vm-actions .btn {
  flex: 1; min-width: 60px; padding: 10px 12px; border-radius: 10px;
  font-size: .8rem; font-weight: 600; text-align: center;
  border: 1px solid var(--mborder); background: var(--mcard2);
  transition: background .15s, border-color .15s;
}
.vm-actions .btn:active { background: #ffffff15; }
.vm-actions .btn-start { border-color: var(--mgreen); color: var(--mgreen); }
.vm-actions .btn-stop { border-color: var(--mred); color: var(--mred); }
.vm-actions .btn-vnc { border-color: var(--mblue); color: var(--mblue); }
.vm-actions .btn-pause { border-color: var(--morange); color: var(--morange); }
.vm-actions .btn:disabled { opacity: .3; pointer-events: none; }

.hidden { display: none !important; }
#app { display: flex; flex-direction: column; height: 100dvh; }

/* ─── Empty State ─── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 60vh; color: var(--mtext2); text-align: center; padding: 32px;
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; opacity: .5; }
.empty-state .text { font-size: .9rem; }

/* ─── Auth Overlay ─── */
#auth-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--mbg);
}
#auth-overlay.hidden { display: none !important; }
.auth-box {
  width: 85vw; max-width: 340px; text-align: center;
}
.auth-box img { width: 200px; max-width: 70vw; margin-bottom: 8px; }
.auth-box h1 {
  font-size: 1.3rem; font-weight: 700; margin-bottom: 24px;
  background: linear-gradient(135deg, var(--mgreen), #39ff8a88);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.auth-input {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--mborder);
  background: var(--mcard); color: var(--mtext); font-size: 1rem;
  margin-bottom: 10px; outline: none;
}
.auth-input:focus { border-color: var(--mgreen); }
.auth-btn {
  width: 100%; padding: 14px; border-radius: 12px; font-size: 1rem; font-weight: 700;
  background: var(--mgreen); color: #000; margin-top: 4px;
}
.auth-btn:active { opacity: .8; }
.auth-error { font-size: .8rem; color: var(--mred); margin-bottom: 8px; min-height: 1.2em; }
.auth-lang {
  margin-top: 12px; padding: 10px; border-radius: 10px;
  border: 1px solid var(--mborder); background: var(--mcard); color: var(--mtext2); font-size: .85rem; width: 100%;
}

/* ─── Loading / Spinner ─── */
.spinner {
  width: 24px; height: 24px; border: 2px solid var(--mborder);
  border-top-color: var(--mgreen); border-radius: 50%;
  animation: spin .6s linear infinite; margin: 0 auto 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toast ─── */
.toast {
  position: fixed; bottom: 24px; left: 16px; right: 16px; z-index: 999;
  padding: 14px 16px; border-radius: 12px; background: var(--mcard2);
  border: 1px solid var(--mborder); font-size: .85rem; text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  transform: translateY(120%); transition: transform .3s ease;
}
.toast.show { transform: translateY(0); }
.toast.error { border-color: var(--mred); }
.toast.success { border-color: var(--mgreen); }

/* ─── Loading screen for initial ─── */
.loading-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 60vh; gap: 12px;
}
.loading-screen .text { font-size: .8rem; color: var(--mtext2); }
