:root {
  --ink: #182039;
  --muted: #687089;
  --brand: #4b2fff;
  --brand-dark: #3520c7;
  --surface: #ffffff;
  --line: #e5e7f0;
  --canvas: #f3f4f9;
  --danger: #9f1f2f;
  --success: #0f7a48;
  --warning: #f1a62f;
  --unknown: #8c94a8;
  --radius: 18px;
  --logo-gap: 16px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

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

.hidden {
  display: none !important;
}

.landing-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: var(--surface);
}

.landing-card {
  width: min(560px, 100%);
  padding: clamp(26px, 5vw, 42px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 18px 55px rgba(29, 35, 62, .1);
}

.landing-card h1 {
  margin: 10px 0 12px;
  font-size: clamp(2.15rem, 7vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

.landing-card p {
  max-width: 460px;
  margin: 0 0 24px;
  color: var(--muted);
  font-size: clamp(.95rem, 2vw, 1.05rem);
  line-height: 1.55;
}

.eyebrow {
  color: #cfcaff;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .15em;
}

.eyebrow.dark {
  color: var(--brand);
}

.primary-link,
.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
  transition: transform .15s ease, background .15s ease;
}

.primary-link {
  width: max-content;
  gap: 18px;
  padding: 0 22px;
  background: var(--brand);
  color: white;
}

.button {
  width: 100%;
  padding: 0 16px;
  background: var(--brand);
  color: white;
}

.button:hover:not(:disabled),
.primary-link:hover {
  transform: translateY(-1px);
}

.button.primary:hover,
.primary-link:hover {
  background: var(--brand-dark);
  color: white;
}

.button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.button.secondary {
  border: 1px solid #d6d3ff;
  background: #f0eeff;
  color: var(--brand-dark);
}

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

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: var(--canvas);
}

.login-card {
  width: min(430px, 100%);
  padding: clamp(26px, 5vw, 42px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 55px rgba(29, 35, 62, .12);
}

.mini-brand {
  display: flex;
  width: 112px;
  margin-bottom: var(--logo-gap);
  text-decoration: none;
}

.mini-brand img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.system-instruction {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: .95rem;
  font-weight: 650;
  line-height: 1.45;
}

.login-form {
  display: grid;
  gap: 9px;
}

.login-form label {
  margin-top: 6px;
  font-size: .78rem;
  font-weight: 750;
}

.login-form input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid #cdd1df;
  border-radius: 9px;
  outline: none;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 750;
}

.scan-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
  align-items: stretch;
}

.scan-field input {
  min-width: 0;
}

.scan-button {
  min-height: 46px;
  margin: 0;
}

.login-form .scan-button {
  margin-top: 0;
}

.scanner-panel {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid #dcd9ff;
  border-radius: 12px;
  background: #f8f7ff;
}

.scanner-viewport {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  background: #202638;
}

.scanner-viewport video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 260px;
  object-fit: cover;
}

.scanner-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(68%, 260px);
  aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, .92);
  border-radius: 16px;
  box-shadow: 0 0 0 999px rgba(18, 22, 43, .28);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.scanner-panel p {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 650;
  line-height: 1.35;
}

.scanner-panel .button {
  margin-top: 0;
}

.login-form input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(75, 47, 255, .13);
}

.login-form .button {
  margin-top: 12px;
}

.login-form .scan-field .button,
.login-form .scanner-panel .button {
  margin-top: 0;
}

.login-back {
  display: block;
  margin-top: 20px;
  color: var(--muted);
  font-size: .78rem;
  text-align: center;
}

.message {
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 10px;
}

.message.error {
  background: #fff0f2;
  color: #a32235;
  font-size: .82rem;
}

.app-shell {
  width: min(1160px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px clamp(18px, 3vw, 40px) 22px;
}

.app-header {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--logo-gap);
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

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

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 650;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--unknown);
}

.connection-status.connected .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px #d9f4e8;
}

.connection-status.waiting .status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 4px #fff0d5;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: clamp(14px, 2vw, 26px);
  align-items: start;
}

.device-card,
.session-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(29, 35, 62, .06);
}

.device-card {
  min-height: 0;
  padding: clamp(18px, 2.4vw, 28px);
}

.session-panel h1 {
  margin: 7px 0 8px;
  font-size: clamp(1.55rem, 2.4vw, 2rem);
}

.system-heading {
  display: flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  gap: 8px;
  margin: 7px 0 12px;
  padding: 0;
}

.system-label {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 0 10px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.system-value {
  display: inline-flex;
  min-height: 34px;
  min-width: 128px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 9px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px #e3e0ff;
  color: var(--ink);
  font-size: clamp(1rem, 2.2vw, 1.22rem);
  font-weight: 850;
  letter-spacing: .08em;
  line-height: 1;
  overflow-wrap: anywhere;
}

.panel-copy {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.55;
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.fact {
  min-height: 78px;
  padding: 12px;
  border: 1px solid #dcd9ff;
  border-radius: 12px;
  background: #f8f7ff;
}

.fact span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.fact strong {
  display: block;
  color: var(--ink);
  font-size: clamp(1.08rem, 2.4vw, 1.55rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.badges {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.badge {
  display: grid;
  min-height: 48px;
  place-items: center;
  padding: 8px;
  border-radius: 10px;
  background: #eef0f6;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
  text-align: center;
}

.badge.ok {
  background: var(--success);
  color: #ffffff;
}

.badge.bad {
  background: var(--danger);
  color: #ffffff;
}

.badge.pending {
  background: #fff0d5;
  color: #8b5e14;
}

.badge.hidden {
  display: none;
}

.session-panel {
  position: sticky;
  top: 20px;
  min-height: 0;
  padding: 22px;
}

.test-state {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin: 7px 0 14px;
  padding: 11px;
  border-radius: 10px;
  background: #f0eeff;
}

.status {
  margin: 0;
  color: var(--brand-dark);
  font-size: .86rem;
  font-weight: 750;
  line-height: 1.4;
}

.session-actions {
  display: grid;
  gap: 8px;
}

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

  .session-panel {
    position: static;
    min-height: 0;
  }
}

@media (max-width: 660px) {
  .app-shell {
    padding: 8px;
  }

  .app-header {
    height: 38px;
    margin-bottom: 8px;
  }

  .brand {
    min-width: 0;
  }

  .brand-logo {
    width: 96px;
  }

  .connection-status span:last-child {
    display: none;
  }

  .device-card,
  .session-panel {
    padding: 12px;
    border-radius: 14px;
  }

  .session-panel h1 {
    margin: 4px 0 5px;
    font-size: 1.18rem;
  }

  .system-heading {
    width: 100%;
    gap: 5px;
    margin: 4px 0 7px;
    padding: 0;
  }

  .system-label {
    min-height: 30px;
    padding: 0 7px;
    font-size: .55rem;
  }

  .system-value {
    min-height: 30px;
    min-width: 0;
    flex: 1;
    padding: 0 8px;
    font-size: .9rem;
  }

  .eyebrow {
    font-size: .58rem;
  }

  .panel-copy {
    margin-bottom: 10px;
    font-size: .76rem;
    line-height: 1.35;
  }

  .facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-bottom: 9px;
  }

  .fact {
    min-height: 54px;
    padding: 8px;
    border-radius: 9px;
  }

  .fact span {
    margin-bottom: 3px;
    font-size: .58rem;
  }

  .fact strong {
    min-height: 0;
    font-size: .9rem;
    line-height: 1.15;
  }

  .badges {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .badge {
    min-height: 36px;
    padding: 5px 3px;
    border-radius: 8px;
    font-size: clamp(.52rem, 2.7vw, .66rem);
    line-height: 1.05;
  }

  .workspace {
    gap: 8px;
  }

  .session-panel .panel-copy {
    display: none;
  }

  .test-state {
    min-height: 34px;
    margin: 4px 0 8px;
    padding: 8px;
    border-radius: 9px;
  }

  .status {
    font-size: .72rem;
  }

  .button {
    min-height: 38px;
    border-radius: 9px;
    font-size: .82rem;
  }

  .landing-page {
    padding: 16px;
  }

  .landing-card {
    padding: 24px;
  }

  .landing-card h1 {
    font-size: clamp(2rem, 12vw, 3rem);
  }

  .scan-field {
    grid-template-columns: minmax(0, 1fr) 74px;
    gap: 6px;
  }

  .scan-button {
    padding: 0 10px;
    font-size: .78rem;
  }

  .scanner-panel {
    gap: 7px;
    padding: 8px;
  }

  .scanner-viewport video {
    max-height: 210px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
