:root {
  color-scheme: dark;
  --bg: #080a0f;
  --panel: rgba(17, 20, 29, 0.9);
  --panel-solid: #11141d;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f3f5f9;
  --muted: #9aa3b5;
  --faint: #6d7688;
  --cyan: #25f4ee;
  --pink: #fe2c55;
  --green: #3ddc97;
  --amber: #ffc857;
  --red: #ff5c7a;
  --radius: 18px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  width: 46vw;
  height: 46vw;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.16;
  pointer-events: none;
}

body::before {
  top: -18vw;
  left: -10vw;
  background: var(--cyan);
}

body::after {
  right: -14vw;
  bottom: -20vw;
  background: var(--pink);
}

a {
  color: var(--cyan);
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 14px;
  line-height: 1.4;
}

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

.faint {
  color: var(--faint);
}

/* Authentication page */

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
}

.auth-shell {
  width: min(430px, 100%);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  color: #07090d;
  background: linear-gradient(135deg, var(--cyan), #8ff9f5 48%, var(--pink));
  box-shadow: 0 8px 24px rgba(37, 244, 238, 0.18);
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.auth-brand {
  justify-content: center;
}

.auth-brand .brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  font-size: 16px;
}

.auth-brand .brand-text {
  font-size: 19px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-card p {
  color: var(--muted);
  font-size: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: #0b0e15;
  color: var(--text);
  font: inherit;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

input:focus,
textarea:focus {
  border-color: rgba(37, 244, 238, 0.55);
  box-shadow: 0 0 0 3px rgba(37, 244, 238, 0.09);
}

form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 650;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, filter 0.16s ease, background 0.16s ease;
  white-space: nowrap;
}

.btn:hover {
  filter: brightness(1.08);
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
  transform: none;
}

.btn.primary {
  background: linear-gradient(135deg, var(--cyan), #63f7f1 55%, var(--pink));
  color: #06080c;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-strong);
}

.btn.danger {
  color: var(--red);
}

.btn.danger:hover {
  background: rgba(255, 92, 122, 0.08);
}

.btn.block {
  width: 100%;
}

.btn.small {
  padding: 7px 12px;
  font-size: 13px;
}

.form-error,
.alert {
  border: 1px solid rgba(255, 92, 122, 0.35);
  background: rgba(255, 92, 122, 0.09);
  color: #ffc2ce;
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 13px;
}

.fineprint {
  text-align: center;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.5;
}

.auth-foot {
  text-align: center;
  color: var(--faint);
  font-size: 12px;
}

/* Application shell */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 10, 15, 0.78);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
}

.user-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(61, 220, 151, 0.7);
}

.layout {
  width: min(1140px, calc(100% - 40px));
  margin: 32px auto 64px;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.85fr);
  gap: 20px;
  align-items: start;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 10px;
  font-weight: 700;
  color: var(--faint);
  margin-bottom: 5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  padding: 5px 11px;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.ok {
  color: var(--green);
  border-color: rgba(61, 220, 151, 0.3);
  background: rgba(61, 220, 151, 0.08);
}

.badge.warn {
  color: var(--amber);
  border-color: rgba(255, 200, 87, 0.3);
  background: rgba(255, 200, 87, 0.08);
}

.badge.error {
  color: var(--red);
  border-color: rgba(255, 92, 122, 0.3);
  background: rgba(255, 92, 122, 0.08);
}

.badge.subtle {
  color: var(--faint);
}

.badge.live {
  color: var(--pink);
  border-color: rgba(254, 44, 85, 0.35);
  background: rgba(254, 44, 85, 0.1);
}

.field textarea {
  resize: vertical;
  min-height: 96px;
}

.account-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 0 18px;
}

.account-row strong {
  display: block;
  font-size: 16px;
  margin-bottom: 2px;
}

.account-row p {
  color: var(--muted);
  font-size: 13px;
}

.avatar {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  flex: none;
  background:
    linear-gradient(145deg, rgba(37, 244, 238, 0.2), rgba(254, 44, 85, 0.2)),
    #131722;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-weight: 750;
  letter-spacing: -0.02em;
}

.live-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
  background: var(--pink);
  box-shadow: 0 0 0 0 rgba(254, 44, 85, 0.45);
  animation: live-pulse 1.8s ease-out infinite;
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(254, 44, 85, 0.45);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(254, 44, 85, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(254, 44, 85, 0);
  }
}

.room-active {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.room-live-row {
  padding-top: 0;
}

.credential {
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(9, 12, 18, 0.82);
  padding: 12px 14px;
}

.credential-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
}

.credential-actions {
  display: flex;
  gap: 6px;
}

.credential-actions .btn {
  text-transform: none;
  letter-spacing: 0;
}

.credential input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.field-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.field-foot .hint {
  margin-top: 0;
}

.counter {
  color: var(--faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.room-end-row {
  margin-top: 4px;
}

.facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0 0 18px;
  border: 1px solid var(--border);
  border-radius: 13px;
  overflow: hidden;
  background: var(--border);
}

.facts > div {
  background: rgba(9, 12, 18, 0.82);
  padding: 12px 14px;
  min-width: 0;
}

.facts dt {
  font-size: 11px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 4px;
}

.facts dd {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.hint {
  color: var(--faint);
  font-size: 12px;
  line-height: 1.55;
  margin-top: 14px;
}

.warnings {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.warnings li {
  border-left: 2px solid var(--amber);
  padding: 4px 0 4px 12px;
  color: #ecd9a8;
  font-size: 13px;
}

.steps {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding-left: 36px;
  color: var(--muted);
  font-size: 13px;
}

.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(37, 244, 238, 0.08);
  border: 1px solid rgba(37, 244, 238, 0.25);
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
}

.side-card h2 {
  margin-bottom: 8px;
}

.side-card p {
  color: var(--muted);
  font-size: 13px;
}

/* QR dialog */

dialog {
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  background: var(--panel-solid);
  color: var(--text);
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.65);
}

dialog::backdrop {
  background: rgba(3, 5, 9, 0.74);
  backdrop-filter: blur(4px);
}

.qr-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.qr-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.qr-head p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.icon-button {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 9px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex: none;
}

.icon-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.qr-image-wrap {
  background: #ffffff;
  border-radius: 16px;
  padding: 14px;
  display: grid;
  place-items: center;
  min-height: 240px;
}

.qr-image-wrap img {
  width: min(100%, 280px);
  height: auto;
  display: block;
  image-rendering: crisp-edges;
}

.qr-placeholder {
  color: #333;
  font-size: 13px;
}

.qr-status-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  flex: none;
  animation: pulse 1.8s ease-in-out infinite;
}

.status-dot.scanned {
  background: var(--amber);
}

.status-dot.confirmed {
  background: var(--green);
  animation: none;
}

.status-dot.error,
.status-dot.expired,
.status-dot.fallback {
  background: var(--red);
  animation: none;
}

.status-dot.starting {
  background: var(--cyan);
}

.status-dot.waiting,
.status-dot.validating {
  background: var(--amber);
}

.browser-fallback {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(37, 244, 238, 0.28);
  background: rgba(37, 244, 238, 0.06);
  border-radius: 12px;
}

.browser-fallback[hidden] {
  display: none;
}

.browser-fallback .hint {
  margin: 0;
}

dialog.browser-dialog {
  width: min(1040px, calc(100vw - 24px));
}

.browser-body {
  gap: 12px;
}

.browser-viewport {
  position: relative;
  background: #0b0f19;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 220px;
}

.browser-viewport canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  background: #0b0f19;
  cursor: crosshair;
  touch-action: none;
  outline: none;
}

.browser-viewport canvas:focus-visible {
  box-shadow: inset 0 0 0 2px var(--cyan);
}

.browser-viewport .qr-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  background: rgba(11, 15, 25, 0.86);
}

.browser-viewport .qr-placeholder[hidden] {
  display: none;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(37, 244, 238, 0.35);
  }
  50% {
    opacity: 0.65;
    box-shadow: 0 0 0 6px rgba(37, 244, 238, 0);
  }
}

.qr-message {
  color: var(--muted);
  font-size: 13px;
  min-height: 20px;
}

.countdown {
  color: var(--faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 16px);
  background: #171b26;
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  max-width: calc(100vw - 40px);
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  border-color: rgba(255, 92, 122, 0.4);
  color: #ffc2ce;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-top-color: #06080c;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .side-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 14px 16px;
  }

  .brand-text small {
    display: none;
  }

  .layout {
    width: calc(100% - 24px);
    margin-top: 20px;
  }

  .card {
    padding: 18px;
  }

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

  .side-col {
    display: flex;
  }

  .user-chip {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.security-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.security-block:first-of-type {
  margin-top: 0;
}

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

.security-head h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.session-list,
.audit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.session-item.current {
  border-color: rgba(37, 244, 238, 0.3);
  background: rgba(37, 244, 238, 0.05);
}

.session-main,
.audit-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.session-main strong,
.audit-main strong {
  font-size: 13px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.session-meta,
.audit-meta {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.audit-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.audit-detail {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .session-item {
    align-items: flex-start;
    flex-direction: column;
  }
}
