:root {
  --bg: #0b0b10;
  --bg-elev: #14141d;
  --bg-elev-2: #1c1c28;
  --text: #e9e9f4;
  --muted: #8b8ba3;
  --border: #262636;
  --accent: #7c5cff;
  --green: #3ddc84;
  --amber: #ffb454;
  --red: #ff5a6e;
  --blue: #58a6ff;
  --radius: 18px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #1a1a2e 0%, transparent 60%),
              radial-gradient(900px 500px at 100% 110%, #20152e 0%, transparent 60%),
              var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior: none;
}

main {
  max-width: 520px;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 1.25rem) 1.25rem 2rem;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.9rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--muted);
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 var(--muted);
  transition: background 0.3s var(--ease), box-shadow 0.6s var(--ease);
}
.status.online .dot {
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(61, 220, 132, 0.15);
  animation: pulse 2.4s var(--ease) infinite;
}
.status.online .label { color: var(--green); }
.status.offline .dot { background: var(--red); }
.status.offline .label { color: var(--red); }
.status.unauth .dot { background: var(--amber); }
.status.unauth .label { color: var(--amber); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(61, 220, 132, 0.12); }
  50%      { box-shadow: 0 0 0 10px rgba(61, 220, 132, 0.02); }
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.ghost {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 12px;
  padding: 0.5rem 0.8rem;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.ghost:hover { color: var(--text); background: var(--bg-elev-2); }

.meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
}
.meta div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.meta span {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.meta strong {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 1.25rem;
  min-height: 140px;
  text-align: left;
  background: linear-gradient(160deg, var(--bg-elev) 0%, var(--bg-elev-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), opacity 0.2s var(--ease);
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(300px 120px at 10% 0%, currentColor 0%, transparent 60%);
  opacity: 0.08;
  pointer-events: none;
}
.card .icon {
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: auto;
}
.card .name {
  font-size: 1.05rem;
  font-weight: 600;
}
.card .sub {
  font-size: 0.78rem;
  color: var(--muted);
}
.card:active:not(:disabled) {
  transform: scale(0.97);
}
.card:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.card.busy {
  opacity: 0.6;
  pointer-events: none;
}

.card.wake     { color: var(--green); border-color: rgba(61, 220, 132, 0.25); }
.card.sleep    { color: var(--blue);  border-color: rgba(88, 166, 255, 0.25); }
.card.lock     { color: var(--accent); border-color: rgba(124, 92, 255, 0.25); }
.card.rdp      { color: #4fd1c5;      border-color: rgba(79, 209, 197, 0.25); }
.card.restart  { color: var(--amber); border-color: rgba(255, 180, 84, 0.25); }
.card.shutdown { color: var(--red);   border-color: rgba(255, 90, 110, 0.25); }

a.card {
  text-decoration: none;
  color: inherit;
}
a.card[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
}

.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 1.2rem);
  left: 50%;
  transform: translateX(-50%) translateY(140%);
  max-width: min(480px, calc(100vw - 2rem));
  margin: 0;
  padding: 0.75rem 1rem;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  opacity: 0;
  transition: transform 0.4s var(--ease), opacity 0.3s var(--ease);
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error { border-color: rgba(255, 90, 110, 0.5); color: var(--red); }
.toast.success { border-color: rgba(61, 220, 132, 0.5); color: var(--green); }

footer {
  margin-top: auto;
  text-align: center;
  color: var(--muted);
  opacity: 0.6;
}

.hint {
  margin: -0.4rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}
.hint a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
  padding-bottom: 1px;
}

/* Settings dialog */
dialog {
  border: none;
  background: var(--bg-elev);
  color: var(--text);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: min(460px, 92vw);
  width: 100%;
  box-shadow: var(--shadow);
}
dialog::backdrop {
  background: rgba(5, 5, 10, 0.7);
  backdrop-filter: blur(6px);
}
dialog h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}
dialog label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.9rem;
  font-size: 0.85rem;
  color: var(--muted);
}
dialog input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  color: var(--text);
  font: inherit;
}
dialog input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}
dialog small { font-size: 0.72rem; }

dialog fieldset {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.9rem 0.2rem;
  margin: 0.6rem 0 0.9rem;
}
dialog fieldset legend {
  padding: 0 0.4rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
dialog fieldset label { margin-bottom: 0.6rem; }
dialog .row {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}
.primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 0.6rem 1rem;
  font-weight: 600;
}
.primary:hover { filter: brightness(1.1); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition-duration: 0.01ms !important; }
}
