:root {
  --rojo: #c62828;
  --rojo-oscuro: #8e0000;
  --fondo: #f5f5f5;
  --borde: #ddd;
  --texto: #212121;
  --naranja: #e65100;
  --verde: #2e7d32;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  padding-bottom: 76px;
}

#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--rojo);
  color: white;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 10;
}
#topbar-title { font-size: 1.1rem; font-weight: 600; flex: 1; }
.icon-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
}

#app { padding: 12px; max-width: 640px; margin: 0 auto; }

#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 4px;
  background: white;
  border-top: 1px solid var(--borde);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  box-shadow: 0 -1px 6px rgba(0,0,0,0.06);
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  border-radius: 10px;
  padding: 6px 2px;
  min-height: 54px;
  font-size: 0.72rem;
  color: #757575;
  white-space: nowrap;
}
.nav-btn .nav-icon { font-size: 1.35rem; line-height: 1; }
.nav-btn.active {
  color: var(--rojo);
  font-weight: 600;
  background: #fdecea;
}

.hidden { display: none !important; }

input, select, textarea, button {
  font-family: inherit;
  font-size: 1rem;
}
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--borde);
  border-radius: 6px;
  margin-bottom: 10px;
  background: white;
}
/* Los checkbox/radio quedaban atrapados en la regla de arriba (width:100%,
   padding:10px, borde redondeado) -- un checkbox nativo terminaba siendo
   una caja gigante y deformada en vez de un cuadradito chico, y dentro de
   una fila flex con texto al lado, cada uno tomaba un ancho distinto según
   cuánto texto tuviera cerca -- de ahí el escalonado desprolijo. */
input[type="checkbox"], input[type="radio"] {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  margin: 0;
  accent-color: var(--rojo);
}
label { font-size: 0.85rem; color: #555; display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }

button.btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 6px;
  background: var(--rojo);
  color: white;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
}
button.btn:disabled { background: #bbb; cursor: not-allowed; }
button.btn.secundario { background: #eee; color: var(--texto); }
button.btn.chico { width: auto; padding: 8px 14px; font-weight: 500; margin: 0; }

.card {
  background: white;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.card-titulo { font-weight: 600; margin-bottom: 2px; }
.card-sub { font-size: 0.85rem; color: #666; }
.card-fila { display: flex; align-items: center; gap: 10px; }
.card-fila .info { flex: 1; }

.badge { font-size: 0.75rem; padding: 2px 8px; border-radius: 10px; }
.badge-pendiente { background: #fff3e0; color: var(--naranja); }
.badge-error { background: #ffebee; color: var(--rojo); }
.badge-ok { background: #e8f5e9; color: var(--verde); }

.error-msg { color: var(--rojo); margin-bottom: 10px; }
.aviso { background: #fff3e0; color: #8a5300; padding: 10px; border-radius: 6px; margin-bottom: 12px; }

.fab {
  position: fixed;
  right: 20px;
  bottom: 76px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--rojo);
  color: white;
  border: none;
  font-size: 1.6rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  cursor: pointer;
}

.search-box { margin-bottom: 12px; }

.centro { text-align: center; color: #888; padding: 24px 0; }

.signature-canvas {
  width: 100%;
  height: 240px;
  border: 1px solid var(--borde);
  border-radius: 6px;
  background: white;
  touch-action: none;
}

.top-actions { display: flex; justify-content: flex-end; margin-bottom: 8px; }

.baraki-tab.active-tab { background: var(--rojo); color: white; }
.acciones-check { background: white; border: 1px solid var(--borde); border-radius: 6px; padding: 10px; margin-bottom: 6px; }

.cp-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--borde);
  border-radius: 6px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  margin-top: -6px;
}
.cp-opt { padding: 10px 12px; border-bottom: 1px solid #eee; }
.cp-opt:last-child { border-bottom: none; }
.cp-opt.cp-vacio { color: #888; }
