:root {
  --bg: #eef2f7;
  --fg: #121826;
  --muted: #5d687d;
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.75);
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.14);
  --accent: #3b6ef6;
  --accent-hover: #2c5be0;
  --danger: #e5484d;
  --input-bg: rgba(255, 255, 255, 0.78);
  --b1: #93c5fd;
  --b2: #c4b5fd;
  --b3: #6ee7b7;
}

html[data-theme="dark"] {
  --bg: #0b0f17;
  --fg: #edf2f7;
  --muted: #9aa5b8;
  --glass-bg: rgba(19, 25, 38, 0.82);
  --glass-border: rgba(255, 255, 255, 0.12);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  --accent: #5b8cff;
  --accent-hover: #4778f5;
  --danger: #f2555a;
  --input-bg: rgba(15, 20, 32, 0.82);
  --b1: #1d4ed8;
  --b2: #6d28d9;
  --b3: #047857;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  user-select: none;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  animation: drift 18s ease-in-out infinite alternate;
}

.b1 { width: 45vw; height: 45vw; background: var(--b1); top: -12%; left: -10%; }
.b2 { width: 40vw; height: 40vw; background: var(--b2); bottom: -15%; right: -8%; animation-delay: -6s; }
.b3 { width: 32vw; height: 32vw; background: var(--b3); top: 38%; left: 42%; animation-delay: -11s; }

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(40px, -30px) scale(1.08); }
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}

.center-wrap {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card {
  width: 100%;
  max-width: 420px;
  border-radius: 26px;
  padding: 28px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.brand {
  font-family: "Unbounded", sans-serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 600;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--input-bg);
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
}

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

.pass-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.pass-wrap input { padding-right: 44px; }

.eye-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 6px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
  cursor: pointer;
}

.primary-btn {
  width: 100%;
  padding: 13px 18px;
  border-radius: 14px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

.primary-btn:hover { background: var(--accent-hover); }
.primary-btn:active { transform: scale(0.99); }
.primary-btn:disabled { opacity: 0.6; cursor: wait; }

.err {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(229, 72, 77, 0.14);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.card-foot {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

.badge { font-size: 12px; color: var(--muted); }

.icon-btn, .pill-btn, .danger-btn {
  border: 1px solid var(--glass-border);
  background: var(--input-bg);
  color: var(--fg);
  border-radius: 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 7px 11px;
  transition: opacity .15s, background .15s;
}

.icon-btn { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; }
.danger-btn { background: rgba(229, 72, 77, 0.16); color: var(--danger); border-color: rgba(229, 72, 77, 0.35); }
.danger-btn.armed { background: var(--danger); color: #fff; }

/* Рабочий стол */
.desk-wrap {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
}

.toolbar {
  position: relative;
  z-index: 20;
  border-radius: 18px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.tb-left, .tb-center, .tb-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
}
.dot.online { background: #22c55e; box-shadow: 0 0 10px #22c55e; }
.dot.warn { background: #f59e0b; box-shadow: 0 0 10px #f59e0b; }

.muted { font-size: 12px; color: var(--muted); }

.tb-ctl {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.tb-ctl select, .popover select, .popover input {
  background: var(--input-bg);
  color: var(--fg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 5px 8px;
  font: inherit;
  font-size: 12px;
  outline: none;
}

.power-wrap { position: relative; }

.popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 290px;
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 50;
}

.pop-status {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.16);
  color: #f59e0b;
  font-size: 12px;
  font-weight: 700;
}

.pop-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.pop-inline {
  display: flex;
  gap: 8px;
}

.pop-inline input { width: 84px; }

.pop-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--glass-border);
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
}

#screen {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  outline: none;
  cursor: crosshair;
  border-radius: 10px;
}

.overlay {
  position: absolute;
  padding: 22px 28px;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--glass-border);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

[hidden] { display: none !important; }