:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #647084;
  --line: #e1e6ef;
  --paper: #f3f6fa;
  --panel: #ffffff;
  --accent: #155eef;
  --accent-dark: #0b4bc7;
  --accent-soft: #e8f0ff;
  --brand-start: #12b76a;
  --brand-mid: #155eef;
  --brand-end: #0b4bc7;
  --button-colour: #155eef;
  --button-text-colour: #ffffff;
  --success: #067647;
  --success-soft: #dcfae6;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --warning: #b54708;
  --shadow: 0 12px 30px rgba(16, 24, 40, .08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  background: linear-gradient(110deg, var(--brand-start) 0%, var(--brand-mid) 72%, var(--brand-end) 100%);
  color: #fff;
  z-index: 10;
  box-shadow: 0 8px 22px rgba(21, 94, 239, .18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 800;
}

.brand-logo {
  display: block;
  height: 42px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
}

.sidebar {
  position: fixed;
  top: 64px;
  bottom: 0;
  left: 0;
  width: 260px;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 24px 14px;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav a,
.side-nav button {
  min-height: 44px;
  justify-content: flex-start;
  width: 100%;
  border: 0;
  background: transparent;
  color: #273244;
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 600;
}

.side-nav a.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  box-shadow: 0 8px 18px rgba(21, 94, 239, .20);
}

.nav-icon {
  width: 22px;
  min-width: 22px;
  display: inline-flex;
  justify-content: center;
  font-size: 15px;
}

.app {
  padding-top: 64px;
  padding-left: 260px;
  min-height: 100vh;
}

.hero {
  min-height: 78px;
  display: flex;
  align-items: center;
  padding: 18px 32px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-start) 0%, var(--brand-mid) 66%, var(--brand-end) 100%);
}

.hero h1 {
  margin: 0 0 4px;
  font-size: 21px;
  color: #fff;
}

.hero p {
  margin: 0;
  font-size: 13px;
  opacity: .94;
  font-weight: 600;
}

h1 {
  margin: 0;
  font-size: 22px;
}

h2 {
  margin: 0 0 16px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

h3 {
  margin: 18px 0 10px;
  font-size: 15px;
}

a,
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

button.primary,
.button.primary {
  background: linear-gradient(135deg, var(--accent-dark), var(--button-colour));
  color: var(--button-text-colour);
  border-color: var(--button-colour);
  box-shadow: 0 8px 18px rgba(21, 94, 239, .18);
}

button.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

button.ghost {
  background: transparent;
}

main {
  padding: 22px 32px 34px;
  max-width: 1700px;
  margin: 0 auto;
}

section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(170px, 1fr));
  gap: 18px;
  margin-bottom: 16px;
}

.stat-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 16px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 20px;
}

.stat-label {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 5px;
}

.stat-value {
  font-size: 25px;
  font-weight: 800;
}

.stat-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}

.qr-panel {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 24px;
  align-items: start;
}

.qr-code {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.qr-code svg {
  display: block;
  width: 100%;
  height: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  background: #f6f8fb;
  border: 1px solid var(--line);
  border-radius: 6px;
}

code {
  padding: 2px 5px;
}

pre {
  padding: 14px;
  overflow-x: auto;
  line-height: 1.45;
}

input,
select {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid #cfd6e2;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid rgba(21, 94, 239, .16);
  border-color: var(--accent);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

label span {
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  align-items: end;
}

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

.inline-form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 0;
}

.inline-form input {
  width: auto;
}

.password-wrap {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 42px;
  gap: 6px;
  align-items: center;
}

.password-wrap input {
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.password-toggle {
  min-width: 42px;
  width: 42px;
  padding: 0;
}

.notice {
  padding: 12px;
  border: 1px solid #99e6d8;
  background: #ecfdf7;
  border-radius: 6px;
  margin-bottom: 16px;
}

.impersonation-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.error {
  padding: 12px;
  border: 1px solid #f3aaa3;
  background: #fff1f0;
  color: var(--danger);
  border-radius: 6px;
  margin-bottom: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f6;
  font-size: 12px;
}

.pill.on {
  background: var(--success-soft);
  color: var(--success);
}

.pill.off {
  background: var(--danger-soft);
  color: var(--danger);
}

.secret {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.session-user {
  color: var(--muted);
  font-size: 14px;
}

.empty {
  color: var(--muted);
  padding: 28px 0;
  text-align: center;
}

.table-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.count-pill {
  background: #f2f4f7;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 12px;
}

.search-panel form {
  display: grid;
  gap: 14px;
}

.search-panel input {
  min-height: 45px;
}

.portal-public {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 20%, rgba(18, 183, 106, .18), transparent 28%),
    linear-gradient(135deg, #0a2540 0%, #155eef 52%, #f7fafc 52%, #eef3f8 100%);
}

.portal-public .app {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.portal-public main {
  width: min(100%, 440px);
  padding: 0;
  margin: 0;
}

.login {
  margin: 0;
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, .62);
  box-shadow: 0 24px 60px rgba(16, 24, 40, .20);
}

.login .login-mark {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  margin-bottom: 18px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 20px;
}

.login h2 {
  margin-bottom: 6px;
  font-size: 24px;
}

.login p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.5;
}

.login form.grid {
  grid-template-columns: 1fr;
}

.login input {
  min-height: 46px;
}

.login button.primary,
.login .button.primary {
  width: 100%;
  min-height: 46px;
}

.login .button:not(.primary) {
  width: 100%;
  border-color: transparent;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
}

@media (max-width: 1100px) {
  .stats {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar {
    position: static;
    height: auto;
    padding: 14px;
    align-items: flex-start;
    flex-direction: column;
  }

  .sidebar {
    position: static;
    width: auto;
    padding: 12px;
  }

  .app {
    padding: 0;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
    padding: 20px 16px;
  }

  main {
    padding: 14px;
  }

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

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .portal-public {
    background: #eef3f8;
  }

  .portal-public .app {
    padding: 16px;
  }
}
