:root {
  color-scheme: dark;
  font-family: "Segoe UI", Arial, sans-serif;
  --bg: #06111e;
  --panel: rgba(12, 29, 46, 0.92);
  --panel-border: rgba(173, 210, 235, 0.14);
  --text: #f5f9fc;
  --muted: #9eb1c2;
  --blue: #2c8be6;
  --blue-light: #62b4ff;
  --green: #17b26a;
  --red: #f04438;
  --amber: #f79009;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -20%, rgba(44, 139, 230, 0.2), transparent 44%),
    var(--bg);
  color: var(--text);
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

.page-glow {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.12;
  pointer-events: none;
}

.page-glow-left {
  top: 20%;
  left: -260px;
  background: #3298ed;
}

.page-glow-right {
  right: -270px;
  bottom: -120px;
  background: #20bd83;
}

.app-header {
  min-height: 88px;
  padding: 16px 30px;
  display: grid;
  grid-template-columns: minmax(250px, 0.8fr) minmax(320px, 1.5fr) minmax(210px, 0.7fr);
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(6, 17, 30, 0.86);
  backdrop-filter: blur(18px);
}

.brand,
.header-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  padding: 3px;
}

.brand-caption,
.checkpoint-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand strong {
  font-size: 18px;
}

.checkpoint {
  text-align: center;
}

.checkpoint strong {
  display: block;
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  justify-content: flex-end;
  gap: 20px;
}

.header-actions time {
  min-width: 68px;
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.text-button {
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: transparent;
  color: #dce8f1;
  cursor: pointer;
}

.text-button:hover,
.text-button:focus-visible {
  border-color: rgba(98, 180, 255, 0.62);
  outline: none;
  color: #fff;
}

main {
  position: relative;
  z-index: 1;
}

.login-view {
  min-height: 100vh;
  padding: 34px 20px;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(520px, 100%);
  padding: 38px 42px 32px;
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  background: rgba(10, 27, 43, 0.94);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
}

.login-logo-wrap {
  width: 76px;
  height: 76px;
  margin-bottom: 22px;
  padding: 5px;
  border-radius: 50%;
  background: #fff;
}

.login-logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.eyebrow,
.result-kicker {
  margin: 0 0 8px;
  color: var(--blue-light);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.login-card h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.1;
}

.login-description {
  margin: 15px 0 28px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

form label,
.scan-input-label {
  display: block;
  margin: 18px 0 8px;
  color: #c7d6e2;
  font-size: 14px;
  font-weight: 600;
}

select,
#accessCode,
.scanner-input {
  width: 100%;
  min-height: 52px;
  padding: 0 15px;
  border: 1px solid rgba(183, 210, 229, 0.2);
  border-radius: 12px;
  outline: none;
  background: #091a2b;
  color: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

select:focus,
#accessCode:focus,
.scanner-input:focus {
  border-color: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(44, 139, 230, 0.16);
}

select {
  cursor: pointer;
}

.primary-button {
  width: 100%;
  min-height: 54px;
  margin-top: 24px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #1684e7, #2d9bed);
  box-shadow: 0 12px 30px rgba(22, 132, 231, 0.24);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.primary-button:hover,
.primary-button:focus-visible {
  filter: brightness(1.08);
  outline: none;
}

.primary-button:disabled {
  cursor: wait;
  filter: grayscale(0.4);
  opacity: 0.7;
}

.form-error {
  margin: 14px 0 -8px;
  color: #ffb4ae;
  font-size: 14px;
}

.login-status,
.connection-status {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
}

.login-status {
  justify-content: center;
  margin-top: 24px;
}

.connection-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(247, 144, 9, 0.1);
}

.connection-dot.online {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(23, 178, 106, 0.12);
}

.connection-dot.offline {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(240, 68, 56, 0.12);
}

.scanner-view {
  min-height: calc(100vh - 88px);
  padding: 28px 30px 34px;
}

.workspace {
  width: min(1440px, 100%);
  min-height: calc(100vh - 150px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.65fr);
  gap: 24px;
}

.result-card,
.scanner-panel {
  border: 1px solid var(--panel-border);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.22);
}

.result-card {
  position: relative;
  min-height: 540px;
  padding: clamp(38px, 5.5vw, 78px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-align: center;
  transition: background 180ms ease, border-color 180ms ease;
}

.result-card::after {
  position: absolute;
  inset: auto -20% -55% -20%;
  height: 70%;
  border-radius: 50%;
  background: rgba(44, 139, 230, 0.08);
  content: "";
  filter: blur(35px);
}

.status-icon {
  position: relative;
  z-index: 1;
  width: 96px;
  height: 96px;
  margin-bottom: 26px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(98, 180, 255, 0.35);
  border-radius: 50%;
  background: rgba(44, 139, 230, 0.1);
}

.status-icon span,
.status-icon span::before,
.status-icon span::after {
  position: absolute;
  display: block;
  content: "";
}

.state-idle .status-icon span {
  width: 32px;
  height: 32px;
  border: 3px solid var(--blue-light);
  border-radius: 8px;
}

.state-idle .status-icon span::before,
.state-idle .status-icon span::after {
  width: 8px;
  height: 8px;
  border: 2px solid var(--blue-light);
}

.state-idle .status-icon span::before {
  top: 5px;
  left: 5px;
}

.state-idle .status-icon span::after {
  right: 5px;
  bottom: 5px;
}

.result-card h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(42px, 6vw, 82px);
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.result-message {
  position: relative;
  z-index: 1;
  max-width: 660px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 22px);
}

.student-details {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  margin-top: 34px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(4, 13, 22, 0.34);
  text-align: left;
}

.detail-main,
.detail-row {
  padding: 16px 20px;
  display: grid;
  grid-template-columns: minmax(120px, 0.48fr) minmax(0, 1fr);
  align-items: center;
  gap: 20px;
}

.detail-main {
  padding-top: 20px;
  padding-bottom: 20px;
  background: rgba(255, 255, 255, 0.05);
}

.detail-row + .detail-row,
.detail-main + .detail-row {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.detail-main span,
.detail-row span {
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  text-transform: uppercase;
}

.detail-main strong {
  font-size: clamp(21px, 2.5vw, 30px);
}

.detail-row strong {
  font-size: 16px;
}

.state-checking .status-icon {
  border-color: rgba(247, 144, 9, 0.5);
  background: rgba(247, 144, 9, 0.1);
}

.state-checking .status-icon span {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(247, 144, 9, 0.25);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.state-allowed {
  border-color: rgba(23, 178, 106, 0.62);
  background: linear-gradient(145deg, rgba(10, 81, 54, 0.94), rgba(7, 45, 36, 0.96));
}

.state-allowed::after {
  background: rgba(23, 178, 106, 0.18);
}

.state-allowed .result-kicker {
  color: #9bf2c9;
}

.state-allowed .status-icon {
  border-color: rgba(155, 242, 201, 0.6);
  background: rgba(155, 242, 201, 0.13);
}

.state-allowed .status-icon span {
  width: 42px;
  height: 23px;
  border-bottom: 6px solid #b9f7d9;
  border-left: 6px solid #b9f7d9;
  transform: translateY(-4px) rotate(-45deg);
}

.state-denied {
  border-color: rgba(240, 68, 56, 0.66);
  background: linear-gradient(145deg, rgba(101, 28, 29, 0.96), rgba(55, 18, 25, 0.97));
}

.state-denied::after {
  background: rgba(240, 68, 56, 0.16);
}

.state-denied .result-kicker {
  color: #ffc2bd;
}

.state-denied .status-icon {
  border-color: rgba(255, 194, 189, 0.58);
  background: rgba(255, 194, 189, 0.1);
}

.state-denied .status-icon span {
  width: 46px;
  height: 5px;
  border-radius: 3px;
  background: #ffd0cc;
  transform: rotate(45deg);
}

.state-denied .status-icon span::after {
  width: 46px;
  height: 5px;
  border-radius: 3px;
  background: #ffd0cc;
  transform: rotate(90deg);
}

.scanner-panel {
  padding: 32px;
  display: flex;
  flex-direction: column;
}

.scanner-visual {
  position: relative;
  width: 150px;
  height: 150px;
  margin: 4px auto 24px;
  display: grid;
  place-items: center;
}

.corner {
  position: absolute;
  width: 30px;
  height: 30px;
  border-color: var(--blue-light);
  border-style: solid;
}

.corner-top-left {
  top: 0;
  left: 0;
  border-width: 3px 0 0 3px;
}

.corner-top-right {
  top: 0;
  right: 0;
  border-width: 3px 3px 0 0;
}

.corner-bottom-left {
  bottom: 0;
  left: 0;
  border-width: 0 0 3px 3px;
}

.corner-bottom-right {
  right: 0;
  bottom: 0;
  border-width: 0 3px 3px 0;
}

.qr-mini {
  width: 88px;
  height: 88px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  opacity: 0.75;
}

.qr-mini i {
  border: 3px solid #d6e9f8;
}

.qr-mini i:nth-child(2),
.qr-mini i:nth-child(4),
.qr-mini i:nth-child(8) {
  border: 0;
  background: #d6e9f8;
}

.scan-line {
  position: absolute;
  right: 10px;
  left: 10px;
  top: 50%;
  height: 2px;
  background: #56b5ff;
  box-shadow: 0 0 12px #56b5ff;
  animation: scan 2.2s ease-in-out infinite;
}

.scanner-panel h2 {
  margin: 0 0 10px;
  font-size: 24px;
}

.scanner-panel > p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.scanner-input {
  font-family: Consolas, monospace;
  font-size: 14px;
}

.input-hint {
  margin-top: 9px !important;
  font-size: 12px;
}

.connection-status {
  margin-top: auto;
  padding-top: 26px;
}

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

@keyframes scan {
  0%, 100% { transform: translateY(-48px); opacity: 0.5; }
  50% { transform: translateY(48px); opacity: 1; }
}

@media (max-width: 980px) {
  .app-header {
    grid-template-columns: 1fr auto;
  }

  .checkpoint {
    grid-column: 1 / -1;
    grid-row: 2;
    text-align: left;
  }

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

  .scanner-panel {
    min-height: 360px;
  }
}

@media (max-width: 620px) {
  .app-header,
  .scanner-view {
    padding-right: 16px;
    padding-left: 16px;
  }

  .brand-caption,
  .brand strong {
    display: none;
  }

  .header-actions {
    gap: 10px;
  }

  .header-actions time {
    font-size: 21px;
  }

  .text-button {
    padding: 9px;
    font-size: 13px;
  }

  .login-card {
    padding: 30px 22px 26px;
  }

  .result-card,
  .scanner-panel {
    border-radius: 20px;
  }

  .result-card {
    min-height: 480px;
    padding: 32px 20px;
  }

  .detail-main,
  .detail-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
