:root {
  --bg: #0A0F1C;
  --bg-elev: #0F172A;
  --bg-card: #111a2e;
  --border: #1f2a44;
  --text: #E5E7EB;
  --text-dim: #94A3B8;
  --accent: #3B82F6;
  --accent-hover: #2563EB;
  --success: #22C55E;
  --error: #EF4444;
  --warn: #EAB308;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }

/* ---------- LOGIN / DASHBOARD ---------- */
.page-login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.brand-logo {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #60a5fa);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
}
.brand-title { font-size: 18px; font-weight: 600; }
.brand-sub { font-size: 12px; color: var(--text-dim); }

.container {
  width: 100%;
  max-width: 1100px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.card-login {
  max-width: 440px;
  margin: 60px auto 0;
}

h1, h2, h3 { font-weight: 600; color: #fff; }
h1 { font-size: 22px; margin-bottom: 6px; }
h2 { font-size: 18px; margin-bottom: 16px; }
.subtitle { color: var(--text-dim); margin-bottom: 24px; font-size: 13px; }

label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, select {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--accent); }

.form-group { margin-bottom: 16px; }

.checkbox-row {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 0 22px;
  font-size: 13px; color: var(--text-dim);
}
.checkbox-row input { width: auto; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center; justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, transform .05s;
  width: 100%;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  width: auto;
  padding: 7px 12px;
  font-size: 13px;
}
.btn-ghost:hover { background: var(--bg-elev); }

.btn-danger { background: var(--error); }
.btn-danger:hover { background: #DC2626; }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Dashboard grid */
.dashboard-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.kiosk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.kiosk-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  display: flex; flex-direction: column; gap: 10px;
}
.kiosk-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.kiosk-card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
}
.kiosk-card-name { font-weight: 600; color: #fff; font-size: 15px; }
.kiosk-card-desc { font-size: 12px; color: var(--text-dim); }
.kiosk-card-host { font-size: 12px; color: var(--text-dim); font-family: ui-monospace, Menlo, monospace; }

.status-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.status-dot.offline { background: var(--error); }
.status-dot.connecting { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.status-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim);
}

.error-msg {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: #FCA5A5;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.hidden { display: none !important; }

/* ---------- VIEWER ---------- */
.page-viewer {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #000;
}

.toolbar {
  height: 48px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  z-index: 10;
  flex-shrink: 0;
  transition: transform .25s ease;
}
.toolbar.hidden-bar {
  transform: translateY(-100%);
  position: absolute;
  top: 0; left: 0; right: 0;
}

.toolbar-left, .toolbar-right {
  display: flex; align-items: center; gap: 10px;
}
.toolbar-center { flex: 1; display: flex; justify-content: center; }

.toolbar .brand-logo { width: 28px; height: 28px; font-size: 14px; }
.kiosk-label { font-weight: 500; color: #fff; font-size: 14px; }

.tool-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s;
}
.tool-btn:hover { background: rgba(255,255,255,0.05); color: #fff; }
.tool-btn.danger:hover { background: rgba(239,68,68,0.15); color: var(--error); }
.tool-btn svg { width: 16px; height: 16px; }

.hover-zone {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 8px;
  z-index: 9;
}

.vnc-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}
#vnc-container {
  width: 100%;
  height: 100%;
}
#vnc-container canvas {
  display: block;
  margin: 0 auto;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10,15,28,0.85);
  backdrop-filter: blur(6px);
  z-index: 20;
}
.overlay-box {
  text-align: center;
  padding: 32px 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 400px;
}
.overlay-box h2 { margin-bottom: 10px; }
.overlay-box p { color: var(--text-dim); margin-bottom: 18px; font-size: 13px; }
.overlay-box .big-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

/* Status dot in toolbar center */
.conn-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-dim);
}
