/* ===== Inventario — tabla-producto, expediente, formulario, escaneo ===== */

/* --- Barra de herramientas (búsqueda + filtros) --- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar form.search-form { flex: 1; min-width: 200px; }
.search-input { width: 100%; min-height: var(--tap-min); padding: 10px 14px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill); background: var(--surface); font-size: 14px; font-family: inherit; color: var(--text-primary); }
.search-input:focus { outline: none; border-color: var(--c-cyan); box-shadow: var(--focus-ring); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select { min-height: var(--tap-min); padding: 8px 30px 8px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); font-size: 13px; font-family: inherit; color: var(--text-primary);
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235C7688' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.filters select:focus { outline: none; border-color: var(--c-cyan); box-shadow: var(--focus-ring); }

/* Chips de filtros activos */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 5px 6px 5px 12px; color: var(--text-secondary); }
.chip .k { font-family: var(--font-data); font-size: 9px; text-transform: uppercase; color: var(--text-faint); }
.chip a { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--text-tertiary); font-size: 12px; }
.chip a:hover { background: var(--danger); color: #fff; }
.chips .clear { color: var(--brand); font-size: 12px; align-self: center; }

/* Chips de estado (conteos) */
.statusbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.statusbar a { font-size: 12px; padding: 6px 11px; border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--surface); color: var(--text-tertiary); }
.statusbar a .n { font-family: var(--font-data); font-weight: 700; color: var(--text-primary); }
.statusbar a.on { background: var(--surface-2); color: var(--text-primary); border-color: var(--border-strong); box-shadow: inset 0 -2px 0 var(--accent); }

/* --- Tabla --- */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid thead th { position: sticky; top: 0; background: var(--surface-elev); z-index: 2;
  text-align: left; font-family: var(--font-data); font-size: 10px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-tertiary); padding: 11px 12px; border-bottom: 1.5px solid var(--border-strong); white-space: nowrap; }
table.grid thead th a { color: inherit; }
table.grid thead th.num, table.grid td.num { text-align: right; }
table.grid tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid tbody tr:nth-child(even) { background: rgba(237,243,247,.4); }
table.grid tbody tr:nth-child(even):hover { background: var(--surface-2); }
.cell-id { font-weight: 600; color: var(--text-primary); }
.cell-id small { display: block; font-weight: 400; color: var(--text-faint); font-family: var(--font-data); font-size: 11px; }

/* Densidad */
.density-compact table.grid tbody td { padding: 6px 12px; }
.density-comfy table.grid tbody td { padding: 15px 12px; }

/* --- Badges por tono de estado --- */
.st { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-data); font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: var(--radius-pill); white-space: nowrap; }
.st::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-ok    { background: rgba(18,183,156,.12); color: #0d8f7a; }
.st-brand { background: rgba(24,119,224,.12); color: var(--brand); }
.st-warn  { background: rgba(219,142,34,.14); color: #a8690f; }
.st-danger{ background: rgba(206,81,81,.12); color: #b23b3b; }
.st-info  { background: rgba(15,161,201,.12); color: #0b7f9e; }
.st-muted { background: var(--surface-2); color: var(--text-tertiary); }

/* --- Barra de acciones en lote --- */
.bulkbar { position: sticky; bottom: 0; display: none; align-items: center; gap: 12px; margin-top: 12px;
  background: var(--text-primary); color: #fff; border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); }
.bulkbar.on { display: flex; }
.bulkbar b { font-family: var(--font-data); }
.bulkbar select { min-height: 38px; border-radius: var(--radius-sm); border: 0; padding: 6px 10px; font-size: 13px; }
.bulkbar .btn { min-height: 38px; padding: 7px 14px; font-size: 13px; }

/* --- Paginación --- */
.pager { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-tertiary); }
.pager .pages { display: flex; gap: 4px; margin-left: auto; }
.pager .pages a, .pager .pages span { min-width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-secondary); }
.pager .pages .cur { background: var(--grad); color: #fff; border-color: transparent; }
.pager select { min-height: 36px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 4px 8px; }

/* --- Expediente (detalle) --- */
.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.spec { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; }
.spec .row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.spec .row .l { font-family: var(--font-data); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
.spec .row .v { font-size: 14px; color: var(--text-primary); margin-top: 2px; }
.money { font-family: var(--font-data); }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Timeline */
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 14px 4px; }
.tl-item::before { content: ""; position: absolute; left: -18px; top: 3px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent); }
.tl-item .when { font-family: var(--font-data); font-size: 11px; color: var(--text-faint); }
.tl-item .what { font-size: 13px; color: var(--text-primary); }

/* --- Formulario --- */
.form-sections { display: flex; flex-direction: column; gap: 16px; }
.fieldset { padding: 16px 18px; }
.fieldset > h3 { font-size: 13px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
.fld { display: flex; flex-direction: column; }
.fld.col-2 { grid-column: span 2; }
.fld > label { font-size: 12.5px; font-weight: 600; color: var(--text-primary); margin-bottom: 5px; }
.fld__input, .fld__select { min-height: var(--tap-min); padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 14px; background: var(--surface); color: var(--text-primary); width: 100%; }
.fld__select { -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235C7688' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 30px; }
.fld__input:focus, .fld__select:focus { outline: none; border-color: var(--c-cyan); box-shadow: var(--focus-ring); }
.fld__input.mono { font-family: var(--font-data); letter-spacing: .04em; }
.fld__check { width: 20px; height: 20px; accent-color: var(--brand); }
.fld.check { flex-direction: row; align-items: center; gap: 9px; }
.fld .err { color: #b23b3b; font-size: 12px; margin-top: 4px; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }

/* --- Toasts (mensajes) --- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  box-shadow: var(--shadow); border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13.5px; max-width: 340px; }
.toast.error { border-left-color: var(--danger); }

/* --- Etiqueta imprimible --- */
.label-sheet { display: grid; place-items: center; min-height: 100vh; background: #fff; }
.label { width: 62mm; border: 1px dashed #bbb; border-radius: 8px; padding: 10px 12px; text-align: center; font-family: var(--font-ui); }
.label .qr { width: 42mm; height: 42mm; margin: 0 auto; }
.label .code { font-family: var(--font-data); font-size: 11px; letter-spacing: .05em; margin-top: 4px; }
.label .model { font-weight: 700; font-size: 13px; }
.label .imei { font-family: var(--font-data); font-size: 12px; }
@media print { .noprint { display: none !important; } .label { border-color: transparent; } }

/* --- Escaneo --- */
.scan-wrap { max-width: 520px; margin: 0 auto; }
#reader { width: 100%; aspect-ratio: 3/4; background: #0e2230; border-radius: var(--radius); overflow: hidden; position: relative; display: grid; place-items: center; }
#reader video { width: 100%; height: 100%; object-fit: cover; }
.scan-reticle { position: absolute; inset: 18% 12%; border: 2px solid rgba(255,255,255,.85); border-radius: 12px; box-shadow: 0 0 0 100vmax rgba(14,34,48,.35); }
.scan-hint { color: #fff; font-size: 13px; text-align: center; padding: 20px; }

@media (max-width: 860px) {
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid, .spec { grid-template-columns: 1fr; }
  .fld.col-2 { grid-column: auto; }
  table.grid thead th { top: 0; }
}
