/* ValvisPoint — azul marino + naranja, móvil primero */
:root {
  --navy: #0d2338;
  --navy-2: #12314e;
  --orange: #f26a1b;
  --orange-dark: #d9550f;
  --cream: #f7f3ec;
  --card: #fffdf8;
  --ink: #1c2733;
  --muted: #6b7683;
  --line: #e5ddd0;
  --green: #1e8e4f;
  --red: #c0392b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; }

/* --- Cabecera --- */
.app { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
header.top {
  background: var(--navy);
  color: #fff;
  padding: 14px 16px 18px;
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; background: #fff; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: .4px; }
.brand small { display: block; font-size: 12px; color: #b9c8d8; font-weight: 400; }
.btn-lock {
  margin-left: auto; background: transparent; color: #fff;
  border: 1.5px solid rgba(255,255,255,.55); border-radius: 999px;
  padding: 8px 16px; font-weight: 700; letter-spacing: 1px; font-size: 13px;
}
.totals { display: flex; align-items: baseline; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.totals .big { font-size: 64px; font-weight: 800; line-height: .9; }
.totals .big-label { font-size: 21px; font-weight: 800; line-height: 1.05; text-transform: uppercase; }
.totals .sub { width: 100%; color: #b9c8d8; font-size: 14px; margin-top: 2px; }
.totals .today { display: flex; gap: 18px; margin-top: 10px; font-size: 15px; }
.totals .today b { font-size: 18px; }
.totals .down { color: var(--orange); }
.totals .up { color: #58c98a; }

/* --- Pestañas --- */
.tabs { display: flex; gap: 8px; padding: 14px 14px 0; }
.tabs button {
  flex: 1; padding: 12px 4px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--card); font-weight: 800; font-size: 14px; letter-spacing: .4px; color: var(--ink);
}
.tabs button.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* --- Contenido --- */
main { flex: 1; padding: 14px; }
.search {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--card); margin-bottom: 12px;
}
.btn {
  display: block; width: 100%; padding: 16px; border: 0; border-radius: 12px;
  font-size: 17px; font-weight: 800; letter-spacing: .4px;
}
.btn-dark { background: var(--navy); color: #fff; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:active { background: var(--orange-dark); }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn-danger { background: var(--red); color: #fff; }
.btn + .btn, .btn + .card { margin-top: 12px; }
.cta-scan { margin-bottom: 14px; }

.card {
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card h2, .card h3 { margin: 0 0 8px; }
.card h2 { font-size: 19px; }
.card h3 { font-size: 17px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.empty {
  border: 2px dashed var(--line); border-radius: var(--radius);
  text-align: center; padding: 44px 20px; background: var(--card);
}
.empty h2 { font-size: 24px; margin: 0 0 10px; letter-spacing: .5px; }
.empty p { color: var(--muted); margin: 0; line-height: 1.5; }

.pkg { cursor: pointer; }
.pkg .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pkg .code { font-family: monospace; font-weight: 800; font-size: 17px; }
.pkg .client { font-weight: 800; font-size: 17px; }
.pkg .meta { color: var(--muted); font-size: 14px; margin-top: 6px; line-height: 1.5; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 800; letter-spacing: .5px;
}
.badge.in { background: #e3f2e9; color: var(--green); }
.badge.out { background: #eceff1; color: var(--muted); }
.pkg img.thumb { width: 100%; border-radius: 10px; margin-top: 10px; object-fit: cover; max-height: 220px; }
.barcode-box { text-align: center; margin: 10px 0 4px; cursor: pointer; }
.barcode-box svg { max-width: 100%; height: auto; }
.barcode-hint { font-size: 12px; color: var(--muted); text-align: center; }

.kv { display: grid; grid-template-columns: 118px 1fr; gap: 6px 10px; font-size: 15px; margin: 10px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* --- Formularios --- */
form .field { margin-bottom: 12px; }
form label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 5px; }
form input, form select, form textarea {
  width: 100%; padding: 12px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff;
}
form textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.photo-preview { width: 100%; border-radius: 10px; margin-top: 8px; object-fit: cover; max-height: 240px; }
input[type=file] { padding: 8px; }

/* --- Pantalla de bloqueo / PIN --- */
.lock {
  position: fixed; inset: 0; background: var(--navy); color: #fff; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
}
.lock img { width: 96px; height: 96px; border-radius: 20px; background: #fff; object-fit: cover; }
.lock h1 { margin: 16px 0 4px; font-size: 26px; }
.lock p { color: #b9c8d8; margin: 0 0 20px; line-height: 1.5; }
.pin-dots { display: flex; gap: 12px; margin-bottom: 22px; }
.pin-dots span {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; display: inline-block;
}
.pin-dots span.on { background: var(--orange); border-color: var(--orange); }
.keypad { display: grid; grid-template-columns: repeat(3, 84px); gap: 12px; }
.keypad button {
  width: 84px; height: 84px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.4);
  background: transparent; color: #fff; font-size: 28px; font-weight: 700;
}
.keypad button:active { background: rgba(255,255,255,.15); }
.keypad .fn { font-size: 16px; }
.lock .error { color: #ffb3a7; min-height: 20px; margin-top: 14px; font-weight: 600; }

/* --- Modal --- */
.modal-back {
  position: fixed; inset: 0; background: rgba(13,35,56,.55); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--cream); width: 100%; max-width: 520px; max-height: 92vh;
  overflow-y: auto; border-radius: 18px 18px 0 0; padding: 18px 16px 28px;
}
.modal h2 { margin: 0 0 4px; font-size: 21px; }
.modal .close-x {
  float: right; background: transparent; border: 0; font-size: 26px; line-height: 1; color: var(--muted);
}
.scan-box { text-align: center; }
.scan-box video { width: 100%; border-radius: 12px; background: #000; max-height: 320px; }
.scan-box canvas { display: none; }
.scan-result { margin-top: 12px; font-weight: 700; }
.scan-result.ok { color: var(--green); }
.scan-result.bad { color: var(--red); }

/* --- Etiqueta imprimible --- */
.label {
  background: #fff; color: #111; border: 2px solid #111; border-radius: 6px;
  padding: 22px 18px; text-align: center; margin: 12px 0;
}
.label h3 { font-size: 15px; letter-spacing: 2px; margin: 0 0 8px; text-transform: uppercase; }
.label .label-code { font-family: monospace; font-size: 30px; font-weight: 800; margin: 8px 0 2px; }
.label svg { max-width: 100%; height: auto; }
.label .label-rows { text-align: left; margin-top: 12px; font-size: 16px; line-height: 1.7; }
.label .label-rows b { display: inline-block; min-width: 92px; }
.label img { width: 100%; border-radius: 6px; margin-top: 10px; max-height: 240px; object-fit: cover; }

.history-item { border-bottom: 1px solid var(--line); padding: 10px 0; }
.history-item:last-child { border-bottom: 0; }
.history-item .t { font-weight: 800; }
.history-item .when { color: var(--muted); font-size: 13px; }
.history-item .note { font-size: 14px; margin-top: 3px; }

footer.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 14px; }
.hidden { display: none !important; }

@media print {
  body { background: #fff; }
  body > * { display: none !important; }
  body > #print-area { display: block !important; }
  #print-area .label { border: 2px solid #111; }
}
@media (min-width: 560px) {
  .modal-back { align-items: center; }
  .modal { border-radius: 18px; }
}
