* {
  box-sizing: border-box;
}

html {
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: #f4f6f8;
  color: #18222c;
}

body {
  margin: 0;
}

button,
input {
  font: inherit;
}

.app {
  width: min(760px, 100%);
  margin: 0 auto;
  padding:
    24px
    16px
    calc(40px + env(safe-area-inset-bottom));
}

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

.header h1 {
  margin: 5px 0 4px;
  font-size: clamp(28px, 6vw, 42px);
  line-height: 1;
}

.header p {
  margin: 0;
  color: #64717d;
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .09em;
  color: #596774;
}

.lab-badge {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #bec8d0;
  background: #fff;
  font-size: 12px;
  font-weight: 900;
}

.card {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid #dce2e7;
  border-radius: 18px;
  background: white;
  box-shadow: 0 8px 22px rgba(20, 30, 40, .05);
}

.card.disabled {
  opacity: .5;
}

.step-header {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.step-number {
  display: grid;
  flex: 0 0 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: #18222c;
  color: white;
  font-weight: 900;
}

.step-header h2,
.card h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.step-header p,
.card p {
  margin: 0;
  color: #697681;
  line-height: 1.4;
}

.btn {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 13px;
  padding: 12px 16px;
  font-weight: 900;
  cursor: pointer;
}

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

.btn-primary {
  background: #18222c;
  color: white;
}

.btn-secondary {
  width: auto;
  min-height: 42px;
  background: #edf1f4;
  color: #26323c;
}

.btn-danger {
  margin-top: 16px;
  background: #d83933;
  color: white;
}

.result-box {
  margin-top: 16px;
  padding: 15px;
  border: 1px solid #cbd4db;
  border-radius: 13px;
  background: #f8fafb;
}

.result-box strong {
  display: block;
  margin-top: 5px;
  font-size: 23px;
  word-break: break-all;
}

.result-label {
  display: block;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .09em;
  color: #63707b;
}

.raw {
  margin-top: 10px;
  font-size: 12px;
  color: #62707b;
  word-break: break-all;
}

.raw code {
  color: #17212a;
}

.contador {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f4f6f8;
}

.contador strong {
  font-size: 24px;
}

.card-title-row {
  display: flex;
  gap: 15px;
  justify-content: space-between;
  align-items: flex-start;
}

.empty {
  margin-top: 18px;
  padding: 20px;
  border: 1px dashed #c8d0d7;
  border-radius: 12px;
  text-align: center;
  color: #71808c;
}

.scan-list {
  margin-top: 14px;
}

.scan-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #edf0f2;
}

.scan-index {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: #edf1f4;
  font-size: 12px;
  font-weight: 900;
}

.scan-code {
  font-weight: 800;
  word-break: break-all;
}

.scan-raw {
  margin-top: 3px;
  font-size: 11px;
  color: #76838e;
  word-break: break-all;
}

.scan-time {
  white-space: nowrap;
  font-size: 11px;
  color: #76838e;
}

.message {
  min-height: 24px;
  margin: 12px 0 0;
  font-weight: 800;
  text-align: center;
}

.message.ok {
  color: #167447;
}

.message.error {
  color: #bf2727;
}

.message.info {
  color: #425363;
}

.hidden {
  display: none !important;
}

.scanner-modal {
  position: fixed;
  z-index: 9999;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding:
    max(18px, env(safe-area-inset-top))
    18px
    max(18px, env(safe-area-inset-bottom));
  background: rgba(8, 14, 20, .87);
}

.scanner-box {
  width: min(520px, 100%);
  max-height: 94vh;
  overflow: auto;
  padding: 18px;
  border-radius: 20px;
  background: white;
}

.scanner-box h2 {
  margin: 5px 0;
}

.scanner-box p {
  margin: 0 0 14px;
  color: #65727e;
}

.scanner-type {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .09em;
  color: #64727d;
}

#scannerReader {
  overflow: hidden;
  width: 100%;
  border-radius: 14px;
}

@media (max-width: 520px) {
  .card-title-row {
    display: block;
  }

  .card-title-row .btn {
    width: 100%;
    margin-top: 14px;
  }
}

/* =====================================================
   SCANNER CONTINUO EMBALAJE LAB V0.2
   ===================================================== */

.scanner-live {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  margin-top: 12px;
}

.scanner-live-item {
  padding: 12px;
  border: 1px solid #dce2e7;
  border-radius: 12px;
  background: #f5f7f9;
}

.scanner-live-item span {
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  color: #687681;
}

.scanner-live-item strong {
  display: block;
  font-size: 22px;
  word-break: break-all;
}

.scanner-live-last strong {
  font-size: 16px;
}

@media (max-width: 420px) {
  .scanner-live {
    grid-template-columns: 90px 1fr;
  }
}


/* =====================================================
   EMBALAJE LAB V0.3
   CAMARA AMPLIA + SELECTOR
   ===================================================== */

.camera-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  margin: 12px 0;
  padding: 10px 12px;

  border: 1px solid #dce2e7;
  border-radius: 12px;

  background: #f6f8fa;
}

.camera-status span {
  display: block;

  font-size: 9px;
  font-weight: 900;
  letter-spacing: .09em;

  color: #687681;
}

.camera-status strong {
  display: block;

  margin-top: 2px;

  font-size: 15px;
  color: #18222c;
}

.camera-switch {
  min-height: 40px;

  padding: 8px 13px;

  border: 0;
  border-radius: 10px;

  background: #18222c;
  color: #fff;

  font-size: 11px;
  font-weight: 900;

  cursor: pointer;
}


/*
 * El video ocupa prácticamente todo
 * el ancho disponible del modal.
 */
#scannerReader {
  width: 100% !important;
  min-height: 260px;

  overflow: hidden;

  border-radius: 16px;

  background: #111820;
}


/*
 * html5-qrcode crea internamente
 * video/canvas.
 */
#scannerReader video {
  width: 100% !important;
  max-width: none !important;

  object-fit: cover;

  border-radius: 16px;
}


@media (max-width: 520px) {

  .scanner-box {
    width: 100%;

    padding: 14px;

    border-radius: 18px;
  }

  #scannerReader {
    min-height: 300px;
  }

  .camera-toolbar {
    margin-top: 8px;
  }

}
