:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: rgba(17, 31, 50, 0.88);
  --surface-2: #14243a;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f4f7fb;
  --muted: #8fa3ba;
  --cyan: #54e0d0;
  --blue: #5b8cff;
  --red: #ff6b79;
  --green: #63e6a5;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% -10%, rgba(84, 224, 208, 0.16), transparent 35%),
    radial-gradient(circle at 90% 10%, rgba(91, 140, 255, 0.2), transparent 34%),
    var(--bg);
}

button, input { font: inherit; }

.shell {
  width: min(1100px, calc(100% - 28px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.2rem, 7vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.35rem;
}

.subtitle, .card p, .metric span, label { color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(5, 12, 24, 0.65);
  white-space: nowrap;
}

.pill span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f5b85a;
  box-shadow: 0 0 18px currentColor;
}

.pill.online span { background: var(--green); }
.pill.offline span { background: var(--red); }

.card {
  margin-bottom: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(20, 36, 58, 0.92), rgba(10, 23, 39, 0.95));
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.login-card {
  width: min(460px, 100%);
  margin: 80px auto 0;
}

form { display: grid; gap: 14px; }

label {
  display: grid;
  gap: 7px;
  font-size: 0.86rem;
  font-weight: 650;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  color: var(--text);
  background: rgba(2, 8, 18, 0.48);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(84, 224, 208, 0.12);
}

button {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  color: #04111e;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(115deg, var(--cyan), #86f0bd);
  transition: transform 0.16s, filter 0.16s;
}

.button-link {
  display: inline-flex;
  min-height: 48px;
  padding: 0 18px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  color: #04111e;
  font-weight: 800;
  text-decoration: none;
  background: linear-gradient(115deg, var(--cyan), #86f0bd);
  transition: transform 0.16s, filter 0.16s;
}

.button-link:hover { filter: brightness(1.06); transform: translateY(-1px); }

button:hover { filter: brightness(1.06); transform: translateY(-1px); }
button:disabled { opacity: 0.5; cursor: wait; transform: none; }

button.secondary {
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.button-link.secondary {
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

button.danger {
  min-height: 38px;
  color: #ffdbe0;
  background: rgba(255, 107, 121, 0.12);
  border: 1px solid rgba(255, 107, 121, 0.26);
}

button.compact { min-height: 38px; padding: 0 13px; }
.button-link.compact { min-height: 38px; padding: 0 13px; }
button.permanent { border-color: rgba(255, 107, 121, 0.65); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 118px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(15, 29, 48, 0.72);
}

.metric span { display: block; margin-bottom: 12px; font-size: 0.82rem; }
.metric strong { font-size: 1.7rem; letter-spacing: -0.04em; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.profile-form {
  grid-template-columns: minmax(0, 1.5fr) minmax(180px, 1fr) auto;
  align-items: end;
}

.created {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 24px;
  align-items: center;
  border-color: rgba(84, 224, 208, 0.35);
}

.created img {
  width: 180px;
  height: 180px;
  padding: 8px;
  border-radius: 16px;
  background: white;
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.profile-list { display: grid; gap: 10px; }

.profile-row {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr 0.8fr 0.9fr minmax(210px, auto);
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(3, 12, 24, 0.36);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.profile-title strong, .profile-title small { display: block; }
.profile-title small, .profile-cell small { color: var(--muted); }
.profile-cell { display: grid; gap: 3px; }

.status {
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
}

.status.online { color: var(--green); background: rgba(99, 230, 165, 0.1); }
.status.offline { color: #ffc86f; background: rgba(255, 200, 111, 0.1); }
.status.revoked { color: #b3bdc9; background: rgba(179, 189, 201, 0.1); }

.error { min-height: 1.2em; margin: 10px 0 0; color: var(--red) !important; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  opacity: 0;
  transform: translateY(12px);
  background: #14243a;
  transition: 0.2s;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 820px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .profile-form { grid-template-columns: 1fr; }
  .profile-row { grid-template-columns: 1fr 1fr; }
  .profile-row > :last-child { grid-column: 1 / -1; justify-self: stretch; }
  .row-actions { justify-content: flex-start; }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 18px, 1100px); padding-top: 26px; }
  .hero { display: block; }
  .pill { margin-top: 14px; }
  .card { padding: 18px; border-radius: 18px; }
  .created { grid-template-columns: 1fr; }
  .created img { width: min(220px, 100%); height: auto; justify-self: center; }
  .profile-row { grid-template-columns: 1fr; }
  .profile-row > :last-child { grid-column: 1; justify-self: stretch; }
  .row-actions > * { flex: 1 1 auto; }
}
