:root {
  --bg-a: #f4f7ff;
  --bg-b: #fff4ec;
  --ink: #1c2240;
  --card: #ffffffcc;
  --primary: #ff5b2e;
  --primary-strong: #d8471e;
  --ok: #0f7a3f;
  --warn: #9b5600;
  --error: #b42020;
  --line: #d5daee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 10%, #ffffff, transparent 30%), radial-gradient(circle at 90% 0, #ffe2cf, transparent 35%), linear-gradient(140deg, var(--bg-a), var(--bg-b));
}

.screen {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.2rem;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  letter-spacing: -0.03em;
}

.status-sub {
  margin-top: 0.4rem;
  color: #45507f;
}

.card {
  background: var(--card);
  border: 1px solid #ffffff;
  backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 1rem;
  margin-top: 1rem;
  box-shadow: 0 16px 35px -25px #5560aa;
}

.albaran-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 0.6rem;
}

.info-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6070a3;
}

.info-value {
  margin: 0.2rem 0 0;
  font-size: 1.18rem;
  font-weight: 700;
  color: #1e2753;
}

.monto {
  color: #0f7a3f;
}

.firma-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 99;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  margin: 0;
  background: rgba(14, 19, 42, 0.82);
}

.firma-card {
  width: 100%;
  min-height: 100%;
  background: #f8f9ff;
  padding: 1rem;
  overflow: auto;
}

.firma-card-datos {
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 720px;
  margin: auto;
  border-radius: 0;
}

.firma-card-canvas {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 100%;
}

.firma-canvas-header {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  justify-content: space-between;
}

.firma-canvas-header h2,
.firma-canvas-header p {
  margin-top: 0;
  margin-bottom: 0.2rem;
}

.firma-canvas-wrap {
  flex: 1 1 auto;
  min-height: 45vh;
  display: flex;
}

#canvasFirma {
  width: 100%;
  height: 100%;
  margin-top: 0;
  border: 2px dashed #b6bfdc;
  border-radius: 12px;
  background: #fff;
  touch-action: none;
}

.firma-actions-sticky {
  margin-top: 0;
}

.firma-card h2 {
  margin-top: 0;
}

.actions {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  flex-wrap: wrap;
}

.actions input {
  flex: 1 1 260px;
  margin-top: 0;
}

.actions-row {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.select,
input {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  background: #fff;
}

input {
  width: 100%;
  margin-top: 0.35rem;
}

.btn {
  font: inherit;
  border: 0;
  border-radius: 12px;
  padding: 0.65rem 0.95rem;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

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

.primary {
  background: var(--primary);
  color: #fff;
}

.primary:hover {
  background: var(--primary-strong);
}

.ghost {
  background: #eff2ff;
  color: #2a3360;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.62rem;
  border-bottom: 1px solid var(--line);
}

th {
  font-weight: 800;
  font-size: 0.85rem;
  text-transform: uppercase;
}

.mono {
  font-family: "JetBrains Mono", monospace;
}

.tag {
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.tag.pending {
  background: #fff2d9;
  color: var(--warn);
}

.tag.ok {
  background: #ddf7e7;
  color: var(--ok);
}

.scanner-wrap {
  margin-top: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem;
  background: #fff;
}

#scannerReader {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

#scannerReader video {
  border-radius: 10px;
}

.hidden {
  display: none;
}

.status {
  margin-top: 0.9rem;
  font-weight: 600;
}

.status.ok {
  color: var(--ok);
}

.status.warning {
  color: var(--warn);
}

.status.error {
  color: var(--error);
}

@media (max-width: 720px) {
  .screen {
    padding: 0.8rem;
  }

  .actions {
    align-items: stretch;
  }

  .actions .btn,
  .actions .select,
  .actions input {
    width: 100%;
  }

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

  .info-value {
    font-size: 1.08rem;
  }

  .firma-card {
    padding: 0.85rem;
  }

  .firma-canvas-header {
    flex-direction: column;
  }

  th,
  td {
    font-size: 0.85rem;
  }
}
