:root {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color-scheme: light;
  --bg: #f5eee9;
  --bg-soft: #f9f4ef;
  --card: #fffdfa;
  --text: #3f2f2a;
  --muted: #8a7266;
  --primary: #b9866f;
  --primary-hover: #a7745d;
  --primary-strong: #9a654e;
  --border: #ead7cc;
  --ring: rgba(185, 134, 111, 0.25);
  --shadow: 0 10px 24px rgba(100, 66, 49, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top right, #fbf7f4, var(--bg) 60%);
  color: var(--text);
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.2rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.9rem;
  box-shadow: var(--shadow);
}

.logo {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 0.2rem;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.2px;
}

.subtitle {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 0.5rem;
  color: var(--primary-strong);
}

label {
  display: block;
  margin-top: 1rem;
  margin-bottom: 0.35rem;
  font-weight: 600;
  color: #654c40;
}

.destino-box {
  margin-top: 1rem;
  background: #f7eee8;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.8rem;
  color: #63483c;
  display: grid;
  gap: 0.35rem;
}

.destino-box a {
  color: var(--primary-strong);
  text-decoration: none;
  font-weight: 600;
  word-break: break-word;
}

.destino-box a:hover {
  text-decoration: underline;
}

input,
button {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0.72rem;
  font-size: 1rem;
}

input {
  background: #fff;
  color: var(--text);
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}

button {
  margin-top: 1rem;
  color: #fff;
  background: linear-gradient(180deg, #c29179, var(--primary));
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 6px 14px rgba(146, 98, 76, 0.22);
}

button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

#iniciarCamara {
  background: #6a4f43;
}

#iniciarCamara:hover {
  background: #5a443a;
}

#capturar {
  background: linear-gradient(180deg, #cf9c82, #bc856b);
}

#enviar {
  background: linear-gradient(180deg, #b07a62, #9a654e);
}

.secundario {
  background: #7d5f52;
}

.secundario:hover {
  background: #6f5448;
}

button:disabled {
  background: #d2beb3;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.camera-wrap {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: #3a2d2a;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

#video,
#preview {
  width: 100%;
  display: block;
  min-height: 240px;
  object-fit: cover;
}

#video {
  background: #2f2522;
}

.panel-captura {
  border: 1px solid #d7b6a7;
  background: #fffaf7;
}

.capture-wrap {
  margin-top: 0.6rem;
  border: 1px dashed #d7bfb2;
  border-radius: 16px;
  overflow: hidden;
  background: #fcf8f5;
  min-height: 160px;
  padding: 0.6rem;
}

.bloque-titulo {
  margin: 1rem 0 0.5rem;
  font-size: 0.98rem;
  color: #6f5245;
}

.placeholder-captura {
  margin: 0;
  min-height: 160px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 500;
  padding: 1rem;
  text-align: center;
}

.miniaturas {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.miniatura-item {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.miniatura-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.miniatura-item figcaption {
  font-size: 0.72rem;
  color: #735a4e;
  padding: 0.3rem 0.35rem 0.4rem;
  text-align: center;
}

.lote-id {
  display: inline-block;
  margin-top: 0.2rem;
  font-size: 0.82rem;
  color: #7e6256;
  font-weight: 600;
}

[hidden] {
  display: none !important;
}

.estado {
  min-height: 1.2rem;
  margin-top: 1rem;
  color: #6e5549;
  font-weight: 500;
  background: #f6eee9;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
}

.estado-camara {
  margin-top: 0.75rem;
  margin-bottom: 0;
  min-height: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: #8b3a2a;
  font-size: 0.92rem;
}

.estado-camara:not(:empty) {
  padding: 0.65rem 0.75rem;
  background: #fff4f0;
  border: 1px solid #e8b4a8;
  border-radius: 10px;
}

.estado-camara--ok {
  color: #4a6b4f;
  background: #f0f7f1 !important;
  border-color: #b8d4bc !important;
}

.destino-box--requerido #referenciaLote {
  border-color: #c97a68;
  box-shadow: 0 0 0 3px rgba(201, 122, 104, 0.25);
}

.destino-box--requerido .lote-id::before {
  content: "⚠ ";
}
