/* ── Sistema de inventarios · tema claro ─────────────────────
   Un solo acento (azul). Los verdes/ámbar/rojo se reservan para
   el significado del stock, no para decorar.                     */
:root {
  --ia-ink:        #0f172a;
  --ia-ink-2:      #334155;
  --ia-muted:      #64748b;
  --ia-line:       #e8edf4;
  --ia-bg:         #fbfcfe;
  --ia-accent:     #15803d;   /* verde Fontanar */
  --ia-accent-dk:  #166534;
  --ia-accent-sf:  #ecfdf3;
  --ia-ok:         #15803d;
  --ia-warn:       #b45309;
  --ia-bad:        #b91c1c;
}

body {
  background: var(--ia-bg);
  color: var(--ia-ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 { color: var(--ia-ink); letter-spacing: -.011em; }
.text-muted { color: var(--ia-muted) !important; }
a { text-decoration: none; }

/* ── Sidebar claro ───────────────────────────────────────── */
.sidebar {
  width: 244px; min-height: 100vh; background: #fff;
  border-right: 1px solid var(--ia-line); position: sticky; top: 0; z-index: 1040;
}
.sidebar .brand { color: var(--ia-ink); letter-spacing: .16em; }
.sidebar .brand small { letter-spacing: .1em; color: var(--ia-muted); }
.sidebar .nav-link {
  color: var(--ia-ink-2); border-radius: 9px; font-size: .93rem; font-weight: 500;
  padding: .5rem .7rem; display: flex; align-items: center;
}
.sidebar .nav-link i { font-size: 1.05rem; color: var(--ia-muted); }
.sidebar .nav-link:hover { background: #f4f7fb; color: var(--ia-ink); }
.sidebar .nav-link:hover i { color: var(--ia-ink-2); }
.sidebar .nav-link.active { background: var(--ia-accent-sf); color: var(--ia-accent-dk); font-weight: 600; }
.sidebar .nav-link.active i { color: var(--ia-accent); }
.sidebar .usuario { border: 1px solid var(--ia-line); border-radius: 11px; }
.sidebar .ayuda { border-top: 1px solid var(--ia-line); font-size: .78rem; color: var(--ia-muted); }
.sidebar .ayuda a { color: var(--ia-accent); }
.content { min-width: 0; }

.topbar-movil { display: none; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 1044; }

@media (max-width: 991.98px) {
  .topbar-movil {
    display: flex; align-items: center; gap: .6rem; background: #fff; color: var(--ia-ink);
    border-bottom: 1px solid var(--ia-line); padding: .6rem .9rem; position: sticky; top: 0; z-index: 1043;
  }
  .sidebar { position: fixed; top: 0; left: 0; height: 100vh; width: 260px; transform: translateX(-100%);
    transition: transform .22s ease; z-index: 1045; } /* por encima del backdrop (1044) o el velo tapa el menú */
  .sidebar.show { transform: translateX(0) !important; box-shadow: 0 0 40px rgba(15,23,42,.18); }
  .sidebar-backdrop.show { display: block; }
  .content { padding: 1.1rem !important; }
}

/* ── Superficies ─────────────────────────────────────────── */
.card { border: 1px solid var(--ia-line); box-shadow: none; border-radius: 14px; background: #fff; }
.card .card-body { padding: 1.15rem 1.25rem; }
.content h4 { font-size: 1.55rem; font-weight: 650; margin-bottom: .2rem; }
.content > .d-flex > div > p, .encabezado p { font-size: .9rem; }

.btn { border-radius: 9px; font-weight: 500; }
.btn-accent { background: var(--ia-accent); color: #fff; border: 1px solid var(--ia-accent); }
.btn-accent:hover, .btn-accent:focus { background: var(--ia-accent-dk); border-color: var(--ia-accent-dk); color: #fff; }
.btn-suave { background: #fff; border: 1px solid var(--ia-line); color: var(--ia-ink-2); }
.btn-suave:hover { border-color: #cfdaea; background: #f8fafd; color: var(--ia-ink); }
.text-accent { color: var(--ia-accent); }

.form-control, .form-select { border-color: var(--ia-line); border-radius: 9px; color: var(--ia-ink); }
.form-control:focus, .form-select:focus { border-color: #bcd3fb; box-shadow: 0 0 0 3px var(--ia-accent-sf); }
.form-control::placeholder { color: #9aa7b8; }
.input-group-text { border-color: var(--ia-line); }

.table > :not(caption) > * > * { border-bottom-color: var(--ia-line); }
.table thead th { font-weight: 600; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ia-muted); background: #fafcfe !important; }
.tabla-limpia td, .tabla-limpia th { vertical-align: middle; }

/* ── Chips de categoría ──────────────────────────────────── */
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .3rem; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: .35rem; background: #fff;
  border: 1px solid var(--ia-line); border-radius: 999px; padding: .34rem .82rem; font-size: .82rem;
  color: var(--ia-ink-2); white-space: nowrap; transition: border-color .12s, color .12s;
}
.chip:hover { border-color: #c7d7f5; color: var(--ia-accent-dk); }
.chip.active { background: var(--ia-accent-sf); border-color: #bcd3fb; color: var(--ia-accent-dk); font-weight: 600; }
.chip-n { font-size: .7rem; color: var(--ia-muted); }
.chip.active .chip-n { color: var(--ia-accent); }

/* ── Marcador cuando el material no tiene foto ───────────── */
.ph {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .18rem;
  background: #f6f8fb; background: color-mix(in srgb, var(--ph, #94a3b8) 9%, #fff);
  border-radius: 10px;
}
.ph-cod { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-weight: 650;
  font-size: 1rem; color: var(--ph, #64748b); letter-spacing: .02em; }
.ph-cat { font-size: .62rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ph, #64748b); opacity: .72; font-weight: 600; }
.ph.sm .ph-cat { display: none; }
.ph.sm .ph-cod { font-size: .72rem; }

/* ── Tarjetas de producto ────────────────────────────────── */
.grid-productos { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }
.producto {
  background: #fff; border: 1px solid var(--ia-line); border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden;
  transition: box-shadow .16s ease, border-color .16s ease;
}
.producto:hover { border-color: #d8e3f5; box-shadow: 0 8px 24px -12px rgba(15,23,42,.16); }
.producto .foto { height: 168px; padding: 12px; display: flex; align-items: center; justify-content: center; }
.producto .foto img { max-height: 100%; max-width: 100%; object-fit: contain; }
.producto .cuerpo { padding: .1rem 1rem 0; flex: 1 1 auto; }
.producto .titulo {
  font-size: .98rem; font-weight: 600; line-height: 1.3; color: var(--ia-ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5rem;
}
.producto .codigo { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: .76rem; color: var(--ia-muted); margin-top: .35rem; }
.producto .desc { font-size: .78rem; color: var(--ia-muted); line-height: 1.4; margin-top: .4rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.producto .pie { padding: .85rem 1rem 1rem; }

.badge-stock { font-size: .76rem; font-weight: 600; display: inline-flex; align-items: center; gap: .3rem; }
.badge-stock .punto { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.badge-stock.ok   { color: var(--ia-ok);   } .badge-stock.ok   .punto { background: var(--ia-ok); }
.badge-stock.bajo { color: var(--ia-warn); } .badge-stock.bajo .punto { background: var(--ia-warn); }
.badge-stock.cero { color: var(--ia-bad);  } .badge-stock.cero .punto { background: var(--ia-bad); }

/* Control de cantidad */
.qty { display: flex; align-items: center; border: 1px solid var(--ia-line); border-radius: 9px; overflow: hidden; }
.qty button { border: 0; background: #fff; width: 36px; height: 36px; color: var(--ia-ink-2); font-size: 1.05rem; line-height: 1; }
.qty button:hover:not(:disabled) { background: #f4f7fb; color: var(--ia-accent); }
.qty button:disabled { opacity: .3; }
.qty input { border: 0; text-align: center; width: 100%; min-width: 0; height: 36px; font-weight: 600;
  color: var(--ia-ink); -moz-appearance: textfield; }
.qty input:focus { outline: 0; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.producto.en-carrito { border-color: #bcd3fb; }

/* ── Panel del carrito ───────────────────────────────────── */
.panel-carrito { width: 320px; flex: 0 0 320px; position: sticky; top: 1.25rem; align-self: flex-start;
  max-height: calc(100vh - 2.5rem); display: flex; flex-direction: column; }
.panel-carrito .lista { overflow-y: auto; flex: 1 1 auto; margin: 0 -.25rem; padding: 0 .25rem; }
.linea-carrito { display: flex; gap: .7rem; padding: .7rem 0; border-bottom: 1px solid var(--ia-line); }
.linea-carrito:last-child { border-bottom: 0; }
.linea-carrito .mini { width: 44px; height: 44px; flex: 0 0 44px; overflow: hidden; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; background: #f8fafd; }
.linea-carrito .mini img { max-width: 100%; max-height: 100%; object-fit: contain; }
.linea-carrito .nom { font-size: .82rem; font-weight: 600; color: var(--ia-ink); line-height: 1.25; }
.linea-carrito .cod { font-family: ui-monospace, monospace; font-size: .71rem; color: var(--ia-muted); }
.carrito-vacio { color: var(--ia-muted); font-size: .86rem; }

@media (max-width: 1199.98px) {
  .panel-carrito { width: 100%; flex: 1 1 auto; position: static; max-height: none; }
}

/* ── Autenticación ───────────────────────────────────────── */
.auth-body { background: var(--ia-bg); }
.auth-card { width: 400px; border: 1px solid var(--ia-line); border-radius: 16px; }

/* ── Trazabilidad ────────────────────────────────────────── */
.timeline { list-style: none; padding-left: 0; margin: 0; }
.timeline li { position: relative; padding-left: 1.65rem; padding-bottom: 1rem; }
.timeline li::before { content: ''; position: absolute; left: .3rem; top: .35rem; width: 9px; height: 9px;
  border-radius: 50%; background: #fff; border: 2px solid var(--ia-accent); }
.timeline li:not(:last-child)::after { content: ''; position: absolute; left: .69rem; top: 1.05rem; bottom: 0;
  width: 1px; background: var(--ia-line); }

.mini-foto { width: 42px; height: 42px; object-fit: contain; background: #f8fafd; border-radius: 9px; }
.celda-mini { width: 42px; height: 42px; }
.kpi .valor { font-size: 1.75rem; font-weight: 650; line-height: 1; letter-spacing: -.02em; }
.kpi .rotulo { font-size: .8rem; color: var(--ia-muted); }
.pagination .page-link { border-color: var(--ia-line); color: var(--ia-ink-2); border-radius: 8px; margin: 0 2px; }
.pagination .active .page-link { background: var(--ia-accent); border-color: var(--ia-accent); }
/* Insignias de estado en versión suave: color solo en el texto, fondo tintado.
   bg-primary se deja sólido porque marca contadores (carrito), no estados. */
.badge { font-weight: 600; border-radius: 7px; padding: .34em .62em; }
.badge.bg-secondary { background: #f1f5f9 !important; color: #475569 !important; }
.badge.bg-info      { background: #e0f2fe !important; color: #0369a1 !important; }
.badge.bg-success   { background: #dcfce7 !important; color: #15803d !important; }
.badge.bg-warning   { background: #fef3c7 !important; color: #b45309 !important; }
.badge.bg-danger    { background: #fee2e2 !important; color: #b91c1c !important; }
.badge.bg-dark      { background: #e2e8f0 !important; color: #1e293b !important; }
.alert { border-radius: 11px; }
.alert-light { background: #f8fafd; border-color: var(--ia-line) !important; }

/* ── Fase 2: despacho y firma ────────────────────────────── */
.firma-caja { border: 1px dashed #c7d2e2; border-radius: 12px; background: #fff; position: relative; }
.firma-caja canvas { display: block; width: 100%; height: 190px; touch-action: none; border-radius: 12px; }
.firma-caja .pista { position: absolute; left: 0; right: 0; bottom: 34px; text-align: center;
  color: #b6c0cf; font-size: .82rem; pointer-events: none; }
.firma-caja .linea { position: absolute; left: 32px; right: 32px; bottom: 30px; border-top: 1px solid #dfe6f0; pointer-events: none; }
.firma-caja.firmada .pista, .firma-caja.firmada .linea { display: none; }
.picking tr.listo { background: #f4fbf6; }
.picking .ubicacion { font-family: ui-monospace, monospace; font-size: .76rem; color: var(--ia-muted); }

/* ── Activos: calificación por estrellas ─────────────────── */
.estrellas { display: inline-flex; flex-direction: row-reverse; gap: .15rem; }
.estrellas input { position: absolute; opacity: 0; width: 0; height: 0; }
.estrellas label { cursor: pointer; font-size: 1.6rem; line-height: 1; color: #dde3ec; transition: color .1s; }
.estrellas label:hover, .estrellas label:hover ~ label,
.estrellas input:checked ~ label { color: #f59e0b; }
.estrellas input:focus-visible + label { outline: 2px solid var(--ia-accent); border-radius: 4px; }

.estrellas-ro { color: #f59e0b; letter-spacing: .04em; font-size: .95rem; }
.estrellas-ro .vacia { color: #dde3ec; }

.puntaje { display: inline-flex; align-items: baseline; gap: .15rem; font-weight: 700; letter-spacing: -.02em; }
.puntaje .de { font-size: .7rem; font-weight: 500; color: var(--ia-muted); }
.barra-puntaje { height: 6px; border-radius: 999px; background: #eef2f7; overflow: hidden; }
.barra-puntaje span { display: block; height: 100%; border-radius: 999px; }

.tarjeta-activo { border: 1px solid var(--ia-line); border-radius: 14px; background: #fff; padding: 1rem 1.1rem;
  transition: box-shadow .16s ease, border-color .16s ease; height: 100%; }
.tarjeta-activo:hover { border-color: #d8e3f5; box-shadow: 0 8px 24px -12px rgba(15,23,42,.16); }
.tarjeta-activo .cod { font-family: ui-monospace, monospace; font-size: .74rem; color: var(--ia-muted); }
.punto-cat { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.tendencia { display: flex; align-items: flex-end; gap: 5px; height: 88px; }
.tendencia .col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.tendencia .barra { width: 100%; border-radius: 5px 5px 0 0; min-height: 3px; }
.tendencia .rot { font-size: .6rem; color: var(--ia-muted); white-space: nowrap; }

/* ── Fase 3: etiquetas QR ────────────────────────────────── */
.grid-etiquetas { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.etiqueta { display: flex; gap: 10px; align-items: center; border: 1px dashed #b9c4d4; border-radius: 8px;
  padding: 10px; background: #fff; break-inside: avoid; }
.etiqueta img { width: 74px; height: 74px; flex: 0 0 74px; }
.etiqueta .nom { font-size: .74rem; font-weight: 600; line-height: 1.2; color: #111;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.etiqueta .cod { font-family: ui-monospace, monospace; font-size: .72rem; color: #333; margin-top: 2px; }
.etiqueta .ubi { font-size: .68rem; color: #666; }

@media print {
  .sidebar, .topbar-movil, .no-imprimir, .alert { display: none !important; }
  .content { padding: 0 !important; }
  body { background: #fff; }
  .grid-etiquetas { grid-template-columns: repeat(3, 1fr); gap: 4mm; }
}

/* ── Fase 3: escáner de códigos en el picking ────────────── */
.escaner-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.88); z-index: 2000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 1rem; }
.escaner-overlay video { width: min(560px, 94vw); border-radius: 14px; background: #000; }
.escaner-overlay .estado { color: #cbd5e1; font-size: .9rem; text-align: center; }
.escaner-overlay .estado b { color: #4ade80; }
.fila-escaneada { animation: destello 1.2s ease; }
@keyframes destello { 0% { background: #bbf7d0; } 100% { background: #f4fbf6; } }

/* Fotos de activos en las tarjetas */
.foto-activo { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 10px; background: #f6f8fb;
  display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 1.4rem; }
.foto-activo img { width: 100%; height: 100%; object-fit: cover; }
