:root {
  color-scheme: dark;
  --bg: #050b14;
  --surface: #0a1422;
  --surface-2: #101d2e;
  --border: rgba(148, 180, 214, 0.14);
  --text: #f4f8fc;
  --muted: #91a3b8;
  --blue: #2d8cff;
  --blue-2: #62b4ff;
  --green: #31d47d;
  --amber: #ffb84d;
  --red: #ff6875;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at 85% 5%, rgba(45, 140, 255, 0.16), transparent 27rem),
    linear-gradient(180deg, #07111f 0%, var(--bg) 52%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.app-shell { width: min(100%, 760px); min-height: 100dvh; margin: 0 auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: calc(env(safe-area-inset-top, 0px) + 0.75rem) 1.1rem 0.75rem;
  background: rgba(5, 11, 20, 0.78);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(24px) saturate(145%);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.8rem;
  color: white;
  font-size: 1.15rem;
  font-weight: 800;
  background: linear-gradient(145deg, var(--blue-2), var(--blue));
  box-shadow: 0 0.7rem 1.8rem rgba(45, 140, 255, 0.24);
}
.brand-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.brand-copy strong { font-size: 1rem; line-height: 1.2; }
.brand-copy span { color: var(--muted); font-size: 0.75rem; line-height: 1.3; }
.icon-button, .refresh-button {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  background: rgba(255,255,255,0.035);
}
.icon-button svg, .refresh-button svg { width: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

main { padding: 1.25rem 1rem calc(2rem + var(--safe-bottom)); }
.login-view { min-height: calc(100dvh - 7rem); display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: 1.5rem 0.25rem 3rem; }
.login-orbit {
  position: relative;
  width: 5.25rem;
  height: 5.25rem;
  margin-bottom: 1.75rem;
  border: 1px solid rgba(98,180,255,0.3);
  border-radius: 50%;
  box-shadow: inset 0 0 2rem rgba(45,140,255,0.14), 0 0 3.5rem rgba(45,140,255,0.12);
}
.login-orbit::before, .login-orbit::after { content: ""; position: absolute; border-radius: 50%; }
.login-orbit::before { inset: 0.8rem; border: 1px dashed rgba(98,180,255,0.45); }
.login-orbit::after { inset: 1.7rem; background: linear-gradient(145deg, var(--blue-2), var(--blue)); box-shadow: 0 0 1.4rem rgba(45,140,255,0.45); }
.login-orbit span { position: absolute; z-index: 2; width: 0.55rem; height: 0.55rem; top: 0.4rem; left: 2.35rem; border-radius: 50%; background: white; box-shadow: 0 0 0.8rem white; }
.eyebrow { margin: 0 0 0.35rem; color: var(--blue-2); font-size: 0.75rem; font-weight: 750; letter-spacing: 0.12em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(2rem, 9vw, 3.4rem); line-height: 1.04; letter-spacing: -0.045em; }
.login-text { max-width: 34rem; margin: 1.1rem 0 1.8rem; color: var(--muted); font-size: 1.02rem; line-height: 1.55; }
.primary-button {
  display: inline-flex;
  justify-content: center;
  width: 100%;
  padding: 1rem 1.2rem;
  border-radius: 1rem;
  color: white;
  background: linear-gradient(135deg, var(--blue), #1669dc);
  box-shadow: 0 0.9rem 2rem rgba(45, 140, 255, 0.23);
  font-weight: 750;
  text-decoration: none;
}
.privacy-note { align-self: center; margin: 0.9rem 0 0; color: #65788e; font-size: 0.78rem; }

.dashboard { padding-top: 0.45rem; }
.welcome-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0.3rem 0 1.25rem; }
.welcome-row h1 { font-size: 2.25rem; }
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin-bottom: 1rem;
}
.stats div { padding: 0.85rem 0.75rem; border: 1px solid var(--border); border-radius: 1rem; background: rgba(16,29,46,0.72); }
.stats strong { display: block; font-size: 1.45rem; letter-spacing: -0.04em; }
.stats span { display: block; margin-top: 0.12rem; color: var(--muted); font-size: 0.72rem; }
.search-wrap { position: relative; margin-bottom: 0.75rem; }
.search-wrap svg { position: absolute; left: 0.95rem; top: 50%; width: 1.2rem; transform: translateY(-50%); fill: none; stroke: #7890aa; stroke-width: 1.8; stroke-linecap: round; }
.search-wrap input {
  width: 100%;
  min-height: 3.2rem;
  padding: 0.85rem 1rem 0.85rem 2.9rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  outline: none;
  color: var(--text);
  background: rgba(16,29,46,0.88);
  font-size: 1rem;
}
.search-wrap input:focus { border-color: rgba(98,180,255,0.65); box-shadow: 0 0 0 3px rgba(45,140,255,0.12); }
.filters { display: flex; gap: 0.5rem; margin-bottom: 1rem; overflow-x: auto; scrollbar-width: none; }
.filter { padding: 0.62rem 0.9rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); background: transparent; font-size: 0.86rem; font-weight: 650; white-space: nowrap; }
.filter.active { color: white; border-color: rgba(45,140,255,0.65); background: rgba(45,140,255,0.16); }

.agent-list { display: grid; gap: 0.72rem; }
.agent-card { padding: 1rem; border: 1px solid var(--border); border-radius: 1.15rem; background: linear-gradient(145deg, rgba(16,29,46,0.96), rgba(9,20,34,0.96)); box-shadow: 0 0.8rem 2rem rgba(0,0,0,0.12); }
.agent-main { display: flex; gap: 0.75rem; }
.status-dot { flex: 0 0 auto; width: 0.65rem; height: 0.65rem; margin-top: 0.42rem; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 0.3rem rgba(145,163,184,0.08); }
.agent-card.online .status-dot { background: var(--green); box-shadow: 0 0 0 0.3rem rgba(49,212,125,0.1); }
.agent-card.overdue .status-dot, .agent-card.offline .status-dot { background: var(--amber); box-shadow: 0 0 0 0.3rem rgba(255,184,77,0.1); }
.agent-copy { flex: 1; min-width: 0; }
.agent-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.agent-title-row h2 { overflow: hidden; margin: 0; font-size: 1.05rem; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.status-label { flex: 0 0 auto; color: var(--muted); font-size: 0.7rem; }
.agent-location, .agent-os { overflow: hidden; margin: 0.28rem 0 0; color: var(--muted); font-size: 0.8rem; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.agent-os { color: #6e8299; }
.agent-footer { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 0.9rem; padding-top: 0.8rem; border-top: 1px solid var(--border); }
.last-seen { color: #6f8399; font-size: 0.73rem; }
.rustdesk-button { display: inline-flex; align-items: center; gap: 0.38rem; min-height: 2.45rem; padding: 0.55rem 0.85rem; border-radius: 0.78rem; color: white; background: linear-gradient(135deg, #1b78eb, #1558c1); font-size: 0.82rem; font-weight: 750; text-decoration: none; }
.rustdesk-button svg { width: 1.05rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.loading, .empty-state, .error-card { margin-top: 2rem; padding: 1.5rem; text-align: center; }
.loading span { display: inline-block; width: 0.48rem; height: 0.48rem; margin: 0 0.15rem; border-radius: 50%; background: var(--blue-2); animation: pulse 1s infinite alternate; }
.loading span:nth-child(2) { animation-delay: 0.18s; }
.loading span:nth-child(3) { animation-delay: 0.36s; }
.loading p, .empty-state span { margin: 0.7rem 0 0; color: var(--muted); font-size: 0.85rem; }
.empty-state { display: flex; flex-direction: column; }
.error-card { border: 1px solid rgba(255,104,117,0.25); border-radius: 1rem; color: #ffc0c6; background: rgba(255,104,117,0.08); font-size: 0.9rem; }
@keyframes pulse { to { opacity: 0.25; transform: translateY(-0.2rem); } }

@media (min-width: 680px) {
  main { padding-inline: 1.5rem; }
  .agent-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .primary-button { width: auto; min-width: 19rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; } }
