:root {
  --bg: #080d16;
  --bg-elevated: #0f1724;
  --surface: #121c2b;
  --surface-2: #172234;
  --border: #243247;
  --border-strong: #334860;
  --text: #eef3f9;
  --muted: #8fa0b8;
  --accent: #22c55e;
  --accent-soft: #2bffa3;
  --accent-hover: #34d399;
  --accent-dim: rgba(34, 197, 94, 0.14);
  --danger: #ef6b6b;
  --danger-dim: rgba(239, 107, 107, 0.12);
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --display: "Sora", "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  line-height: 1.5;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 45% at 15% -5%, rgba(34, 197, 94, 0.16), transparent 55%),
    radial-gradient(ellipse 55% 40% at 95% 5%, rgba(56, 120, 220, 0.14), transparent 50%),
    radial-gradient(ellipse 50% 35% at 50% 100%, rgba(15, 40, 60, 0.55), transparent 60%);
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: 2.25rem 1.25rem 3.5rem;
}

.wrap:has(#gate:not(.hidden)) {
  max-width: 480px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: 3.5rem;
  padding-bottom: 3.5rem;
}

/* —— Hero —— */
.hero {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  margin-bottom: 1.75rem;
  animation: rise 0.55s ease both;
}

.wrap:has(#gate:not(.hidden)) .hero {
  flex-direction: column;
  text-align: center;
  gap: 1.35rem;
  margin-bottom: 2.25rem;
}

.hero-icon {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  box-shadow:
    0 0 0 1px rgba(43, 255, 163, 0.18),
    0 12px 40px rgba(0, 0, 0, 0.45),
    0 0 36px rgba(34, 197, 94, 0.18);
  flex-shrink: 0;
}

.wrap:has(#gate:not(.hidden)) .hero-icon {
  width: 104px;
  height: 104px;
  border-radius: 26px;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-soft);
}

.brand {
  font-family: var(--display);
  font-size: clamp(2rem, 5vw, 2.55rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  margin: 0;
  line-height: 1.05;
}

.tagline {
  color: var(--muted);
  margin: 0.55rem 0 0;
  font-size: 0.98rem;
  line-height: 1.45;
}

.wrap:has(#gate:not(.hidden)) .tagline {
  margin-top: 0.7rem;
  max-width: 28ch;
  margin-left: auto;
  margin-right: auto;
}

/* —— Cards —— */
.card {
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease both;
}

.card h2 {
  margin: 0 0 0.55rem;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-head h2 {
  margin: 0;
}

.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--accent-soft);
}

/* —— Gate / sign-in —— */
.gate-card {
  text-align: center;
  padding: 2.35rem 2rem 2.15rem;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.gate-card h2 {
  font-size: 1.3rem;
  margin: 0 0 0.85rem;
  letter-spacing: -0.02em;
}

.gate-card .muted {
  max-width: 34ch;
  margin: 0 auto 1.75rem;
  line-height: 1.55;
  font-size: 0.95rem;
}

.gate-card .btn-lg {
  margin-top: 0.15rem;
}

.wrap:has(#gate:not(.hidden)) footer {
  margin-top: 2.75rem;
  justify-content: center;
  text-align: center;
}

/* —— Profile —— */
.profile-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(43, 255, 163, 0.2);
  display: grid;
  place-items: center;
  background: var(--bg);
  flex-shrink: 0;
}

.avatar img {
  display: block;
}

.profile-text {
  flex: 1;
  min-width: 140px;
}

.profile-name {
  font-weight: 600;
  font-family: var(--display);
  letter-spacing: -0.02em;
}

.pill {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  color: var(--accent-soft);
  border: 1px solid rgba(43, 255, 163, 0.35);
  background: var(--accent-dim);
}

.pill-warn {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.12);
}

.pill-danger {
  color: var(--danger);
  border-color: rgba(239, 107, 107, 0.45);
  background: var(--danger-dim);
}

.badge.access-pending {
  border-color: rgba(251, 191, 36, 0.5);
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
}

.badge.access-approved {
  border-color: rgba(34, 197, 94, 0.45);
  color: var(--accent-hover);
  background: var(--accent-dim);
}

.badge.access-denied {
  border-color: rgba(239, 107, 107, 0.45);
  color: var(--danger);
  background: var(--danger-dim);
}

.badge.access-none {
  border-color: var(--border);
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.actions button {
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.15rem;
  padding-top: 1.05rem;
  border-top: 1px solid var(--border);
}

.meta-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

/* —— Controls —— */
.row,
.enroll-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.enroll-row {
  margin-top: 1rem;
}

button,
.btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1.05rem;
  font: inherit;
  font-weight: 560;
  cursor: pointer;
  background: linear-gradient(180deg, #2fd87a 0%, var(--accent) 100%);
  color: #04140c;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.22);
  transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease;
}

button:hover,
.btn:hover {
  filter: brightness(1.06);
}

button:active,
.btn:active {
  transform: translateY(1px);
}

.btn-lg {
  padding: 0.95rem 1.45rem;
  font-size: 1rem;
  width: 100%;
  max-width: 300px;
  min-height: 52px;
}

button.secondary {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  box-shadow: none;
}

button.secondary:hover {
  border-color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  filter: none;
}

button.danger {
  background: transparent;
  border: 1px solid rgba(239, 107, 107, 0.55);
  color: var(--danger);
  box-shadow: none;
}

button.danger:hover {
  background: var(--danger);
  color: #fff;
  filter: none;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input[type="text"] {
  flex: 1;
  min-width: 180px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  color: var(--text);
  font: inherit;
}

input:focus {
  outline: 2px solid rgba(43, 255, 163, 0.35);
  border-color: var(--accent);
}

/* —— Devices —— */
.device {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}

.device:first-of-type {
  border-top: none;
  padding-top: 0.15rem;
}

.device .name {
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.device .meta,
.meta {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: lowercase;
}

.badge.active {
  border-color: rgba(34, 197, 94, 0.45);
  color: var(--accent-hover);
  background: var(--accent-dim);
}

.badge.online {
  border-color: rgba(43, 255, 163, 0.55);
  color: var(--accent-soft);
  background: rgba(43, 255, 163, 0.1);
  box-shadow: 0 0 12px rgba(43, 255, 163, 0.12);
}

.badge.revoked {
  border-color: rgba(239, 107, 107, 0.45);
  color: var(--danger);
  background: var(--danger-dim);
}

.empty-state {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.25rem 0 0;
}

.flash {
  padding: 0.8rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
  animation: rise 0.35s ease both;
}

.flash.error {
  background: var(--danger-dim);
  border: 1px solid rgba(239, 107, 107, 0.4);
  color: #f5c4c4;
}

.flash.success {
  background: var(--accent-dim);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #b8e6ce;
}

.cidrs {
  font-family: var(--mono);
  font-size: 0.84rem;
  color: var(--muted);
  word-break: break-word;
}

.hidden {
  display: none !important;
}

footer {
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

footer img {
  border-radius: 4px;
  opacity: 0.9;
}

/* —— Tabs —— */
.tabs {
  display: flex;
  gap: 0.3rem;
  margin: 0 0 1rem;
  padding: 0.28rem;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: fit-content;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0.5rem 0.95rem;
  border-radius: 9px;
  font-weight: 550;
  box-shadow: none;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  filter: none;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}

/* —— Admin —— */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 0.15rem;
}

.stat {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}

.stat-value {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.gateway-line {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  line-height: 1.55;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.35rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.55rem 0.55rem;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 0.8rem 0.55rem;
  border-bottom: 1px solid rgba(36, 50, 71, 0.85);
  vertical-align: top;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.cell-strong {
  font-weight: 600;
}

.mono {
  font-family: var(--mono);
  font-size: 0.84rem;
}

.audit-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.audit-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 0.75rem;
  align-items: start;
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(36, 50, 71, 0.85);
}

.audit-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.audit-action {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent-soft);
}

.audit-time {
  white-space: nowrap;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .wrap:has(#gate:not(.hidden)) {
    padding-top: 2.5rem;
    justify-content: flex-start;
  }

  .hero {
    gap: 0.9rem;
  }

  .wrap:has(#gate:not(.hidden)) .hero {
    gap: 1.1rem;
    margin-bottom: 1.75rem;
  }

  .hero-icon {
    width: 72px;
    height: 72px;
    border-radius: 18px;
  }

  .wrap:has(#gate:not(.hidden)) .hero-icon {
    width: 88px;
    height: 88px;
    border-radius: 22px;
  }

  .gate-card {
    padding: 1.85rem 1.35rem 1.75rem;
  }

  .gate-card .muted {
    margin-bottom: 1.5rem;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .audit-row {
    grid-template-columns: 1fr;
  }

  .profile-top #logout-btn {
    width: 100%;
  }

  .enroll-row {
    flex-direction: column;
    align-items: stretch;
  }
}
