:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6ec;
  --accent: #f2a900; --accent-ink: #1d2330; --ok: #1f8a4c; --warn: #b45309; --bad: #c0392b; --info: #2563eb;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
header { background: #1d2330; color: #fff; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
header h1 { font-size: 18px; margin: 0; }
header h1::before { content: "⚡ "; color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #2d3546; border-radius: 99px; padding: 3px 10px; font-size: 13px; }
.chip b { color: var(--accent); }
.chip.alerta b { color: #ff8a7a; }

nav { display: flex; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--line); }
nav button { flex: none; border: 0; background: none; padding: 12px 14px; font: inherit; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; }
nav button.activo { color: var(--text); border-color: var(--accent); font-weight: 600; }

main { max-width: 1000px; margin: 0 auto; padding: 16px; }
.panel { display: none; }
.panel.activo { display: block; }

input, select, textarea { font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
button { font: inherit; padding: 10px 16px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; white-space: nowrap; }
button.secundario { background: #e7e9ee; color: var(--text); }
button.peligro { background: var(--bad); color: #fff; }
button.mini { padding: 6px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }

.scanbar { display: flex; gap: 8px; }
.scanbar input { font-size: 18px; }
#lector { margin-top: 12px; background: #000; border-radius: 10px; overflow: hidden; }
.barra { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.barra .buscar { flex: 1; }
.check { display: flex; gap: 6px; align-items: center; color: var(--muted); flex: 1; }
.check input { width: auto; }

.tarjeta { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-top: 14px; }
.tarjeta h2 { margin: 0 0 4px; font-size: 20px; }
.tarjeta .sub { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.stock { font-size: 32px; font-weight: 700; }
.stock small { font-size: 15px; color: var(--muted); font-weight: 400; }
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 12px 0; }
.campos label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.segmentos { display: flex; gap: 6px; }
.segmentos button { flex: 1; background: #e7e9ee; color: var(--text); }
.segmentos button.activo.entrada { background: var(--ok); color: #fff; }
.segmentos button.activo.salida { background: var(--bad); color: #fff; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; }

.tabla { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.fila { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px; border-top: 1px solid var(--line); align-items: center; }
.fila:first-child { border-top: 0; }
.fila.click { cursor: pointer; }
.fila.click:hover { background: #fafbfc; }
.fila .t { font-weight: 600; }
.fila .d { color: var(--muted); font-size: 13px; }
.fila .der { text-align: right; }
.vacio { padding: 24px; text-align: center; color: var(--muted); }

.badge { display: inline-block; border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 600; }
.b-disponible, .b-entrada, .b-buena { background: #dcf3e5; color: var(--ok); }
.b-prestada, .b-salida { background: #fde8e5; color: var(--bad); }
.b-mantenimiento, .b-ajuste, .b-dañada, .b-incompleta, .b-bajo { background: #fdf0d9; color: var(--warn); }
.b-baja { background: #eee; color: var(--muted); }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(520px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.45); }
#modal-form { padding: 18px; }
#modal-form h3 { margin: 0 0 6px; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(120px); background: #1d2330; color: #fff; padding: 12px 18px; border-radius: 10px; transition: transform .2s; max-width: 92vw; z-index: 10; }
#toast.ver { transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--bad); }

@media (max-width: 600px) {
  main { padding: 12px; }
  .scanbar { flex-wrap: wrap; }
  .scanbar input { flex-basis: 100%; }
  .scanbar button { flex: 1; }
}
.segmentos button.activo.ajuste { background: var(--warn); color: #fff; }
header .cabecera-der { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.qr { width: 220px; margin: 8px auto; background: #fff; }
.qr svg { width: 100%; height: auto; display: block; }
#modal-form .d { color: var(--muted); font-size: 13px; }
#modal-form hr { border: 0; border-top: 1px solid var(--line); }

/* Sesión y perfiles */
body.sin-sesion #app { display: none; }
body:not(.sin-sesion) #acceso { display: none; }
body:not(.es-admin) .solo-admin { display: none !important; }
.acceso { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: #1d2330; }
.acceso .tarjeta { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; margin: 0; }
.acceso label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.acceso p { margin: 0; color: var(--muted); font-size: 14px; }
.acceso .aviso { color: var(--warn); }
.marca { margin: 0 0 4px; font-size: 22px; }
.marca::before { content: "⚡ "; color: var(--accent); }
.filtro-bajas { margin: -4px 2px 10px; font-size: 14px; }
.aviso-baja { background: #f3f4f6; border-left: 4px solid var(--muted); padding: 10px 12px; border-radius: 6px; margin: 10px 0 14px; font-size: 14px; }
button.peligro-texto { color: var(--bad); }
button.peligro { background: var(--bad); color: #fff; }
textarea { font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px; width: 100%; resize: vertical; }
.d { color: var(--muted); font-size: 13px; }

.barra-historial { flex-wrap: wrap; }
.nota-respaldo { margin: -4px 2px 12px; }

.cliente-licencia { display: block; font-size: 12px; font-weight: 400; color: #c9ced8; margin-top: 2px; }
.cliente-licencia:empty { display: none; }
.codigo-equipo { display: flex; gap: 8px; align-items: center; }
.codigo-equipo code { flex: 1; white-space: nowrap; font-size: 17px; font-weight: 700; letter-spacing: 1px; color: var(--text); background: #f4f5f7; border-radius: 8px; padding: 8px 10px; text-align: center; }
.boton-wa { display: block; text-align: center; background: #1f8a4c; color: #fff; text-decoration: none; font-weight: 600; border-radius: 8px; padding: 10px; }
.acceso textarea { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* Fotos y combos */
[hidden] { display: none !important; }
.con-mini { display: flex; gap: 10px; align-items: center; }
.miniatura { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; background: #eef0f3; }
.sin-foto { display: flex; align-items: center; justify-content: center; color: #9aa1ad; font-weight: 700; font-size: 14px; }
.foto-lateral { float: right; width: 116px; margin: 0 0 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.foto-tarjeta { width: 116px; height: 116px; border-radius: 10px; object-fit: cover; background: #eef0f3; cursor: zoom-in; }
.foto-vacia { display: flex; align-items: center; justify-content: center; color: #9aa1ad; font-size: 13px; cursor: default; }
.foto-botones { display: flex; flex-direction: column; gap: 4px; }
.boton-archivo { display: block; text-align: center; background: #e7e9ee; color: var(--text); border-radius: 8px; padding: 6px 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.boton-archivo:hover { background: #dde0e6; }
.foto-ampliada { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 8px; background: #f4f5f7; margin-bottom: 10px; }
.campo-foto { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; font-size: 13px; color: var(--muted); }
.fila-botones { display: flex; gap: 8px; }
.fila-botones .boton-archivo { flex: 1; padding: 9px; }
.tarjeta::after { content: ""; display: block; clear: both; }
.tabla-combo { clear: both; margin: 12px 0; }
.tabla-combo .fila { padding: 8px 10px; }
.en-combo { margin: 6px 0 10px; font-size: 14px; color: var(--muted); }
button.enlace { background: none; padding: 0; color: var(--info); font-weight: 600; text-decoration: underline; font-size: inherit; }
.subtitulo { font-size: 15px; margin: 14px 0 2px; }
.devolucion { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px; }
.dev-fila { display: flex; gap: 8px; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.dev-fila .check { flex: 1; color: var(--text); align-items: flex-start; }
.dev-fila select { width: auto; }
.lista-check { max-height: 40vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin: 6px 0; }
.lista-check .check { color: var(--text); padding: 6px 0; border-bottom: 1px solid #f0f1f4; }
.grupo { padding: 8px 14px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; background: #f8f9fa; border-top: 1px solid var(--line); }
.grupo:first-child { border-top: 0; }
.b-combo { background: #e7f1fb; color: var(--info); }
.b-incompleto { background: #fdf0d9; color: var(--warn); }
@media (max-width: 600px) {
  header .cabecera-der { width: 100%; justify-content: flex-end; margin-left: 0; }
  header .cabecera-der button { white-space: normal; }
  .barra { flex-wrap: wrap; }
  .barra .buscar { flex-basis: 100%; }
}
