:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --border: #e2e5ea;
  --accent: #2f6feb;
  --accent-text: #ffffff;
  --danger: #d1453b;
  --log-bg: #0f1115;
  --log-text: #d6e2ff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card-bg: #1c1f26;
    --text: #e7e9ee;
    --muted: #9aa2b1;
    --border: #2a2e37;
    --accent: #5b8bf0;
    --accent-text: #0b0d12;
    --danger: #f0655c;
    --log-bg: #0a0c10;
    --log-text: #c9d6ff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.view { max-width: 760px; margin: 0 auto; padding: 32px 20px 80px; }
.view.hidden { display: none; }

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

h1 { font-size: 1.4rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 16px; }
.muted { color: var(--muted); font-size: 0.9rem; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

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

label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
label.checkbox { flex-direction: row; align-items: center; gap: 8px; }
label.checkbox input { width: auto; }

input[type="text"], input[type="password"] {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

button {
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}
button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
button.small { padding: 6px 10px; font-size: 0.8rem; }
button.danger { background: var(--danger); color: #fff; }

.error { color: var(--danger); font-size: 0.85rem; min-height: 1.2em; }

.log {
  margin-top: 14px;
  background: var(--log-bg);
  color: var(--log-text);
  padding: 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
}
.log.hidden { display: none; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 0.8rem; }

.note { margin-top: 10px; }

.led {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9aa2b1;
}
.led.on { background: #2fa84f; box-shadow: 0 0 6px #2fa84f88; }
.led.off { background: #d1453b; }

.rooms { display: flex; flex-direction: column; gap: 2px; }
.rooms .room-pill {
  font-size: 0.75rem;
  color: var(--muted);
}
.rooms .none { font-size: 0.8rem; color: var(--muted); font-style: italic; }

/* ============ Login: AgenteS futuristic portal ============ */

.login-view {
  max-width: none;
  padding: 0;
  min-height: 100vh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 0%, #10203a 0%, #060811 55%, #030407 100%);
}

#network-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.login-scanline {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(120, 200, 255, 0.035) 0px,
    rgba(120, 200, 255, 0.035) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: screen;
  opacity: 0.5;
}

.login-card {
  position: relative;
  z-index: 2;
  width: min(360px, 88vw);
  padding: 40px 32px 32px;
  border-radius: 20px;
  text-align: center;
  background: linear-gradient(180deg, rgba(18, 26, 42, 0.72), rgba(10, 14, 24, 0.82));
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(130, 190, 255, 0.16);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.02) inset,
    0 20px 60px rgba(0, 0, 0, 0.55),
    0 0 80px rgba(56, 189, 248, 0.08);
  color: #e8f1ff;
  animation: card-rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes card-rise {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card-glow {
  position: absolute;
  inset: -1px;
  border-radius: 20px;
  padding: 1px;
  background: conic-gradient(from var(--spin, 0deg), #38bdf8, #a855f7, #38bdf8cc, #22d3ee, #38bdf8);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: spin-border 6s linear infinite;
  opacity: 0.75;
  pointer-events: none;
}

@keyframes spin-border {
  to { --spin: 360deg; }
}
@property --spin {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

.login-brand { margin-bottom: 26px; }

.login-mark {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
}
.login-mark .core {
  position: absolute;
  inset: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #bff0ff, #38bdf8 55%, #6d28d9 100%);
  box-shadow: 0 0 18px 2px rgba(56, 189, 248, 0.75);
  animation: core-pulse 2.4s ease-in-out infinite;
}
@keyframes core-pulse {
  0%, 100% { box-shadow: 0 0 12px 1px rgba(56, 189, 248, 0.6); }
  50%      { box-shadow: 0 0 24px 6px rgba(168, 85, 247, 0.65); }
}
.login-mark .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(120, 200, 255, 0.35);
}
.login-mark .ring-1 { animation: ring-spin 5s linear infinite; border-top-color: #38bdf8; border-right-color: #38bdf8; }
.login-mark .ring-2 { inset: 8px; animation: ring-spin 4s linear infinite reverse; border-bottom-color: #a855f7; border-left-color: #a855f7; }
.login-mark .ring-3 { inset: 16px; animation: ring-spin 7s linear infinite; opacity: 0.6; }
@keyframes ring-spin {
  to { transform: rotate(360deg); }
}

.login-title {
  margin: 0 0 6px;
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, #7dd3fc, #e0c3fc 45%, #7dd3fc 90%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: title-sheen 4s linear infinite;
  text-shadow: 0 0 30px rgba(125, 211, 252, 0.25);
}
.login-title span {
  display: inline-block;
  opacity: 0;
  transform: translateY(10px);
  animation: letter-in 0.5s ease forwards;
}
.login-title span:nth-child(1) { animation-delay: 0.05s; }
.login-title span:nth-child(2) { animation-delay: 0.1s; }
.login-title span:nth-child(3) { animation-delay: 0.15s; }
.login-title span:nth-child(4) { animation-delay: 0.2s; }
.login-title span:nth-child(5) { animation-delay: 0.25s; }
.login-title span:nth-child(6) { animation-delay: 0.3s; }
.login-title span:nth-child(7) { animation-delay: 0.35s; }
@keyframes letter-in {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes title-sheen {
  to { background-position: 200% center; }
}

.login-sub {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7f9cc4;
}

.field-group {
  position: relative;
  margin-top: 8px;
  text-align: left;
}
.field-group input {
  width: 100%;
  padding: 14px 14px 8px;
  border-radius: 10px;
  border: 1px solid rgba(130, 190, 255, 0.22);
  background: rgba(255, 255, 255, 0.03);
  color: #e8f1ff;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field-group input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}
.field-group label {
  position: absolute;
  left: 14px;
  top: 14px;
  font-size: 0.95rem;
  color: #7f9cc4;
  pointer-events: none;
  transition: all 0.15s ease;
}
.field-group input:focus + label,
.field-group input:not(:placeholder-shown) + label {
  top: 5px;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: #38bdf8;
}
.field-group .field-line {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, #38bdf8, #a855f7);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
  border-radius: 2px;
}
.field-group input:focus ~ .field-line { transform: scaleX(1); }

.login-card button {
  margin-top: 18px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(90deg, #0ea5e9, #7c3aed);
  color: #f5f9ff;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.25);
}
.login-card button:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(124, 58, 237, 0.35); }
.login-card button:active { transform: translateY(0); }
.login-card button span { position: relative; z-index: 1; }
.login-card button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.35) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: btn-sheen 3s ease-in-out infinite;
}
@keyframes btn-sheen {
  0%, 60% { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

.login-card .error { min-height: 1.1em; margin-top: 10px; }

.login-status {
  margin: 10px 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: #4c6a94;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  min-height: 1.2em;
}
.login-status::before { content: '> '; color: #38bdf8; }

.login-card.shake { animation: card-shake 0.4s ease; }
@keyframes card-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

@media (prefers-reduced-motion: reduce) {
  .login-card, .login-title span, .login-mark *, .login-card button::before, .login-card-glow {
    animation: none !important;
  }
}
