:root {
  color-scheme: dark;
  --bg: #06111f;
  --surface: #0b1b30;
  --surface-2: #102640;
  --line: #24405f;
  --text: #f5f8fc;
  --muted: #9db0c7;
  --accent: #2bbcff;
  --accent-2: #6ad7ff;
  --success: #46d392;
  --warning: #f3bd58;
  --danger: #ff6f7d;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 90% -10%, rgba(43, 188, 255, .16), transparent 34rem),
    var(--bg);
  color: var(--text);
}

a { color: inherit; }

button, input, select, textarea { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(107, 145, 181, .2);
  background: rgba(6, 17, 31, .94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  letter-spacing: .17em;
  text-decoration: none;
}

.brand small {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(106, 215, 255, .45);
  border-radius: 12px;
  background: linear-gradient(145deg, #142c4b, #091629);
  color: var(--accent-2);
  font-size: 1.2rem;
}

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

.page {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 24px max(16px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.page-heading, .section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.page-heading { margin: 4px 0 20px; }
.section-heading { margin: 34px 0 14px; }
.section-heading h2 { margin-bottom: 0; font-size: 1.45rem; }

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

h1 { margin-bottom: 4px; font-size: clamp(1.75rem, 8vw, 2.45rem); line-height: 1.05; }

h2 { margin-bottom: 3px; font-size: 1.12rem; }

.eyebrow {
  margin-bottom: 7px;
  color: var(--accent-2);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.muted, small { color: var(--muted); }

.panel, .user-card, .stat {
  border: 1px solid rgba(79, 113, 147, .35);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(16, 38, 64, .93), rgba(9, 25, 44, .96));
  box-shadow: 0 18px 50px rgba(0, 0, 0, .18);
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 750;
  line-height: 1;
  text-align: center;
  text-decoration: none;
}

.button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(43, 188, 255, .34);
  outline-offset: 2px;
}

.button-primary { background: var(--accent); color: #03101d; }
.button-primary:hover { background: var(--accent-2); }
.button-secondary { border-color: #42627f; background: #183653; color: var(--text); }
.button-ghost { border-color: #304c68; background: transparent; color: #dbe9f7; }
.button-danger { border-color: rgba(255, 111, 125, .5); background: rgba(255, 111, 125, .1); color: #ffadb5; }
.button-small { min-height: 38px; padding: 8px 11px; font-size: .85rem; }
.button-block { width: 100%; }

.messages { display: grid; gap: 9px; margin-bottom: 18px; }

.message {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
}
.message-error { border-color: rgba(255, 111, 125, .55); color: #ffd0d5; }
.message-success { border-color: rgba(70, 211, 146, .48); color: #baf2d7; }
.message-warning { border-color: rgba(243, 189, 88, .5); color: #ffe0a3; }

.auth-shell {
  display: grid;
  min-height: calc(100vh - 150px);
  place-items: center;
}

.auth-panel { width: min(440px, 100%); padding: 25px; }

.form-panel, .credentials-panel, .danger-panel { width: min(720px, 100%); padding: clamp(18px, 5vw, 28px); }
.danger-panel { margin-top: 18px; }

.form-stack { display: grid; gap: 18px; }

label { display: grid; gap: 8px; color: #e8f1fa; font-weight: 700; }
label b { color: var(--accent-2); font-size: .72rem; text-transform: uppercase; }

input, select, textarea {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid #3f5f7c;
  border-radius: 13px;
  background: #071527;
  color: var(--text);
  font-size: 16px;
}

textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #7189a3; }
input:disabled, select:disabled, button:disabled { cursor: not-allowed; opacity: .55; }

.notice, .optional-heading {
  margin-bottom: 20px;
  padding: 13px 14px;
  border-left: 3px solid var(--accent);
  border-radius: 5px 12px 12px 5px;
  background: rgba(43, 188, 255, .08);
  color: #cdeeff;
}

.optional-heading { display: grid; gap: 3px; margin: 4px 0 0; }
.optional-heading span { color: var(--muted); font-size: .88rem; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(7, 21, 39, .7);
}
.switch-row span { display: grid; gap: 3px; }
.switch-row input { width: 25px; min-height: 25px; accent-color: var(--accent); }

.form-actions, .card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}
.form-actions { margin-top: 5px; }

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

.stat { display: grid; gap: 2px; padding: 13px; }
.stat strong { font-size: 1.3rem; }
.stat span { color: var(--muted); font-size: .76rem; }

.search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  margin-bottom: 18px;
}

.user-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.source-grid { margin-bottom: 10px; }
.user-card { padding: 17px; }

.user-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.user-card-head p { margin: 0; color: var(--muted); font-size: .88rem; }

.status {
  flex: 0 0 auto;
  padding: 6px 9px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 800;
}
.status-active { color: var(--success); }
.status-warning, .status-expired { color: var(--warning); }
.status-disabled { color: var(--danger); }

.user-details { display: grid; gap: 9px; margin: 0 0 17px; }
.user-details div { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 8px; }
.user-details dt { color: var(--muted); font-size: .8rem; }
.user-details dd { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: .88rem; }
.user-details.large { margin-top: 22px; }

.card-actions form { display: inline-flex; margin: 0; }
.card-actions .button { min-height: 40px; padding: 9px 11px; font-size: .8rem; }

.empty { padding: 35px 22px; text-align: center; }

.credentials-panel { display: grid; gap: 15px; }
.credential-row {
  display: grid;
  grid-template-columns: 95px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #071527;
}
.credential-row > span { color: var(--muted); font-size: .82rem; }
.credential-row code { overflow-wrap: anywhere; color: #fff; font-size: .96rem; font-weight: 800; }
.credential-summary { position: absolute; left: -9999px; white-space: pre-line; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  .page { padding-top: 18px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-grid { grid-template-columns: 1fr; }
  .search { grid-template-columns: 1fr auto; }
  .search .button-ghost { grid-column: 1 / -1; }
  .brand small { display: none; }
}

@media (max-width: 480px) {
  .page-heading, .section-heading { align-items: flex-start; }
  .page-heading > .button, .section-heading > .button { min-height: 42px; padding-inline: 12px; }
  .page-heading > .form-actions { justify-content: flex-end; }
  .topbar { min-height: 62px; }
  .brand { font-size: .9rem; }
  .brand-mark { width: 34px; height: 34px; }
  .credential-row { grid-template-columns: 1fr auto; }
  .credential-row > span { grid-column: 1 / -1; }
  .form-actions .button { width: 100%; }
  .card-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-actions form, .card-actions .button { width: 100%; }
}

.duration-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin: 0;
  padding: 0;
  border: 0;
}

.duration-options legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  color: #e8f1fa;
  font-weight: 800;
}

.duration-option {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border: 1px solid #3f5f7c;
  border-radius: 13px;
  background: #071527;
  cursor: pointer;
  text-align: center;
}

.duration-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(43, 188, 255, .13);
  box-shadow: 0 0 0 2px rgba(43, 188, 255, .12);
}

.duration-option input {
  width: 19px;
  min-height: 19px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.danger-zone {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 111, 125, .28);
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .top-actions {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }
  .top-actions, .top-actions form { flex-wrap: nowrap; }
  .top-actions .button { white-space: nowrap; }
}

@media (max-width: 480px) {
  .duration-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.download-admin-panel {
  display: grid;
  gap: 18px;
  padding: clamp(18px, 5vw, 28px);
}

.download-release-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.download-release-head h2,
.download-release-head p { margin-bottom: 3px; }

.download-created-panel {
  margin: 20px auto 0;
}

.download-code-display {
  display: grid;
  gap: 12px;
  padding: clamp(18px, 5vw, 28px);
  border: 1px solid rgba(106, 215, 255, .5);
  border-radius: var(--radius);
  background: rgba(43, 188, 255, .08);
  text-align: center;
}

.download-code-display > span {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.download-code-display code {
  color: #fff;
  font-size: clamp(2.4rem, 13vw, 4.7rem);
  font-weight: 900;
  letter-spacing: .2em;
  line-height: 1;
}

.install-page {
  width: 100%;
  min-height: 100vh;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.install-shell {
  display: grid;
  min-height: calc(100vh - 48px);
  place-items: center;
}

.install-panel {
  width: min(720px, 100%);
  padding: clamp(28px, 6vw, 58px);
  text-align: center;
}

.install-brand-mark {
  display: grid;
  width: 82px;
  height: 82px;
  margin: 0 auto 22px;
  place-items: center;
  border: 2px solid rgba(106, 215, 255, .58);
  border-radius: 25px;
  background: linear-gradient(145deg, #19395f, #091629);
  color: var(--accent-2);
  font-size: 2.5rem;
  font-weight: 900;
}

.install-success {
  border-color: rgba(70, 211, 146, .65);
  color: var(--success);
}

.install-lead {
  max-width: 570px;
  margin: 10px auto 28px;
  color: #d8e7f5;
  font-size: clamp(1.05rem, 2.4vw, 1.3rem);
  line-height: 1.55;
}

.install-form {
  width: min(520px, 100%);
  margin: 0 auto;
  text-align: left;
}

.install-code-input {
  min-height: 76px;
  border-width: 2px;
  text-align: center;
  font-size: clamp(2rem, 7vw, 3.25rem);
  font-weight: 900;
  letter-spacing: .22em;
}

.install-action {
  min-height: 64px;
  padding: 16px 22px;
  font-size: 1.15rem;
}

.install-action:focus-visible {
  outline: 5px solid rgba(106, 215, 255, .48);
  outline-offset: 5px;
  transform: scale(1.015);
}

.install-help {
  max-width: 540px;
  margin: 24px auto 0;
  color: var(--muted);
  font-size: .94rem;
  line-height: 1.5;
}

.install-details {
  width: min(540px, 100%);
  margin: 0 auto 26px;
  text-align: left;
}

.install-notice {
  margin: 26px 0 0;
  text-align: left;
}

@media (min-width: 1000px) {
  .install-panel h1 { font-size: 3.1rem; }
  .install-panel .eyebrow { font-size: .9rem; }
  .install-action { min-height: 72px; font-size: 1.3rem; }
  .install-code-input { min-height: 88px; }
}

@media (max-width: 480px) {
  .download-release-head { align-items: flex-start; flex-direction: column; }
  .download-code-display code { letter-spacing: .12em; }
  .install-page { padding: 16px; }
  .install-shell { min-height: calc(100vh - 32px); }
  .install-panel { padding: 26px 18px; }
}
