* { box-sizing: border-box; }

html,
body {
  height: 100%;
  overflow: hidden;
}

:root {
  --pdt-black: #000000;
  --pdt-cream: #f8f3e9;
  --pdt-brown: #c06e32;
  --pdt-panel: #fff8ed;
  --pdt-border: #e2cfae;
  --pdt-text: #1d130b;
  --pdt-muted: #5f4634;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: var(--pdt-cream);
  color: var(--pdt-text);
  padding: 0 10px 0;
}

.container {
  max-width: 1200px;
  height: 100vh;
  margin: 0 auto;
  background: transparent;
  padding: 8px 0 10px;
  border-radius: 0;
  border: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

h1 { margin: 0 0 6px; font-size: 26px; color: var(--pdt-black); }
.header {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:14px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, rgba(248,243,233,0.96) 0%, rgba(248,243,233,0.88) 100%);
  padding-top: 4px;
  padding-bottom: 6px;
}
.header-actions { display:flex; align-items:center; gap:12px; flex-wrap:wrap; justify-content:flex-end; }

.segmented { display:inline-flex; background:#ecd8bf; border-radius:999px; padding:4px; gap:4px; border:1px solid #d8bc99; }
.segmented-btn { border:none; background:transparent; color:#4b2f1e; padding:8px 14px; border-radius:999px; font-weight:700; cursor:pointer; }
.segmented-btn.active { background:var(--pdt-brown); color:#fff; }

.eyebrow { font-weight:700; text-transform:uppercase; letter-spacing:.08em; font-size:12px; color:var(--pdt-brown); margin:0 0 4px; }
.subtitulo { margin:0; color:var(--pdt-muted); }
.solo-subtitulo { max-width: 620px; font-size: 1.02rem; line-height: 1.25; }

.grid {
  display:grid;
  grid-template-columns:1fr 2fr;
  gap:24px;
  flex: 1 1 auto;
  min-height: 0;
  align-items: stretch;
}
.panel {
  background:var(--pdt-panel);
  border:1px solid var(--pdt-border);
  border-radius:12px;
  padding:18px;
  min-height:0;
}
.panel h2 { margin-top:0; font-size:18px; color: var(--pdt-black); }

.panel-registros {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lote-list {
  list-style:none;
  padding:0 6px 0 0;
  margin:0;
  display:flex;
  flex-direction:column;
  gap:10px;
  width:100%;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}
.lote-item { display:grid; grid-template-columns:20px 1fr; gap:8px; align-items:start; width:100%; }
.lote-list:not(.ajustes-activo) .lote-item { grid-template-columns:1fr; }
.lote-list:not(.ajustes-activo) .lote-check { display:none; }
.lote-check { width:18px; height:18px; accent-color: var(--pdt-brown); }

.lote-btn { width:100%; text-align:left; background:#fff; border:1px solid var(--pdt-border); border-radius:10px; padding:12px 14px; color:var(--pdt-text); display:flex; flex-direction:column; gap:6px; cursor:pointer; }
.lote-btn:hover,
.lote-btn:focus-visible,
.lote-btn.activo {
  background: var(--pdt-brown);
  border-color: var(--pdt-brown);
  color: #fff;
  box-shadow: 0 6px 18px rgba(192,110,50,.24);
}
.lote-codigo { font-weight:700; font-size:15px; color: var(--pdt-black); }
.lote-meta { font-size:12px; color:var(--pdt-muted); }

.lote-btn:hover .lote-codigo,
.lote-btn:hover .lote-meta,
.lote-btn:focus-visible .lote-codigo,
.lote-btn:focus-visible .lote-meta,
.lote-btn.activo .lote-codigo,
.lote-btn.activo .lote-meta {
  color: #fff;
}

.detalle { display:flex; flex-direction:column; gap:14px; overflow:hidden; min-height: 0; }
.detalle form { display:flex; flex-direction:column; gap:14px; min-height: 0; flex: 1 1 auto; }
.productos { display:grid; gap:16px; overflow-y:auto; padding-right:4px; min-height:0; max-height: calc(100vh - 220px); }
.producto-row { background:#fff; border-radius:12px; border:1px solid var(--pdt-border); padding:14px; display:grid; grid-template-columns:minmax(0,1.1fr) minmax(260px,.9fr); gap:16px; }
.producto-info { display:grid; gap:6px; }
.producto-codigo { font-weight:700; font-size:16px; color: var(--pdt-black); }
.producto-descripcion { color:var(--pdt-text); font-size:14px; }
.producto-lote, .producto-cantidad { color:var(--pdt-muted); font-size:12px; }
.producto-cestas { color:#3a2a1e; font-size:12px; font-weight:700; }
.producto-input label { display:block; font-size:12px; color:var(--pdt-muted); margin-bottom:6px; }

.ajustes {
  margin-top:18px;
  max-height: 30vh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.ajustes-row { display:grid; gap:8px; margin-bottom:12px; }
.ajustes-row:last-child { margin-bottom:0; }

input {
  padding:10px 12px;
  border:1px solid #d7c7a8;
  border-radius:8px;
  font-size:14px;
  width:100%;
  background: #fff;
  color: var(--pdt-text);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

button {
  background: var(--pdt-brown);
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}
button:hover { background: #000000; }
button.secondary { background:#f1d8bf; color:var(--pdt-black); }
button.secondary:hover { background:#dfbf9e; color:var(--pdt-black); }
button.danger { background:#000000; color:#fff; }
button.danger:hover { background:#7a1f1f; }
button:disabled { background:#d6b79a; color:#4d3a2e; cursor:not-allowed; }

.acciones { display:flex; justify-content:flex-end; gap:8px; flex-wrap:wrap; }
.muted { color:var(--pdt-muted); margin-top:16px; }
.estado { margin-top:16px; min-height:20px; }
.ajustes-row { display:grid; gap:8px; margin-bottom:12px; }
.ajustes-subtitulo { margin:8px 0 0; font-size:14px; color:#3a2a1e; }
.errores-lista { list-style:none; margin:0; padding:0; display:grid; gap:6px; }
.errores-lista li {
  font-size:12px;
  line-height:1.45;
  color:var(--pdt-muted);
  background:#fff;
  border:1px solid var(--pdt-border);
  border-radius:8px;
  padding:10px 12px;
  overflow-wrap:anywhere;
  word-break:break-word;
}
.estado.error { color:#9b1c1c; font-weight:700; }
.estado.ok { color:#1f6a35; font-weight:700; }
@media (max-width: 880px){
  .grid { grid-template-columns:1fr; }
  .header { flex-direction:column; align-items:stretch; }
  .header-actions { width:100%; justify-content:space-between; flex-wrap:wrap; }
  .panel-registros { max-height: 320px; }
  .productos { max-height: 44vh; }
  .producto-row { grid-template-columns:1fr; }
}
