* { box-sizing: border-box; }
body { font-family: 'Segoe UI', Arial, Helvetica, sans-serif; margin: 0; background: #f2f5f8; color: #222; }

.topbar { display: flex; align-items: center; justify-content: space-between; background: #16324f; color: #fff; padding: 12px 24px; flex-wrap: wrap; gap: 8px; }
.topbar .logo { font-weight: bold; font-size: 18px; white-space: nowrap; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px; }
.topbar nav a { color: #cfe0f0; text-decoration: none; padding: 8px 12px; border-radius: 6px; font-size: 14px; transition: background .15s; }
.topbar nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.topbar nav a.activo { background: #2f80ed; color: #fff; font-weight: bold; }
.logout-form { display: flex; align-items: center; gap: 8px; }
.logout-form span { font-size: 13px; color: #cfe0f0; }
.logout-form button { background: #d9534f; border: none; color: #fff; padding: 7px 12px; border-radius: 5px; cursor: pointer; }
.logout-form button:hover { background: #c9302c; }

.content { max-width: 1050px; margin: 24px auto; background: #fff; padding: 24px 32px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.07); }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #16324f, #2f80ed); }
.login-box, .install-box { background: #fff; padding: 32px; border-radius: 10px; width: 440px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 4px 20px rgba(0,0,0,.2); }
.install-box { width: 480px; }
.login-box h1, .install-box h1 { font-size: 19px; text-align: center; margin-bottom: 6px; }
.install-box h2 { font-size: 15px; color: #16324f; }
.login-box input, .install-box input, .install-box select { padding: 9px; border: 1px solid #ccc; border-radius: 5px; }
.login-box button, .install-box button { margin-top: 6px; }
.error { color: #d9534f; font-size: 13px; background: #fdecea; padding: 8px; border-radius: 5px; }

.form-grid fieldset { border: 1px solid #e2e6ea; border-radius: 8px; margin-bottom: 18px; padding: 14px 18px; background: #fafbfc; }
.form-grid legend { font-weight: bold; padding: 0 8px; color: #16324f; }
.form-grid label { display: block; margin-top: 10px; font-size: 13px; color: #555; font-weight: 600; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 5px; margin-top: 3px; font-size: 14px; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { outline: none; border-color: #2f80ed; box-shadow: 0 0 0 3px rgba(47,128,237,.15); }

.btn-primary, .btn { display: inline-block; background: #1f7a3d; color: #fff; border: none; padding: 11px 18px; border-radius: 6px; cursor: pointer; font-size: 14px; text-decoration: none; }
.btn-primary:hover, .btn:hover { opacity: .92; }
.btn.azul { background: #2f80ed; }
.btn.gris { background: #6c757d; }
.btn.rojo { background: #d9534f; }
.acciones { margin: 15px 0; display: flex; gap: 8px; flex-wrap: wrap; }
.ok { color: #1f7a3d; font-weight: bold; background: #eaf7ee; padding: 10px 14px; border-radius: 6px; }
.ayuda { font-size: 12px; color: #777; }
.checklist { list-style: none; padding: 0; }
.checklist li { padding: 4px 0; font-size: 14px; }
.checklist li.fail { color: #d9534f; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: bold; }
.badge.anulado { background: #f8d7da; color: #842029; }
.badge.activo { background: #d1e7dd; color: #0f5132; }

.tabla-listado, .detalle { width: 100%; border-collapse: collapse; margin-top: 12px; }
.tabla-listado th, .tabla-listado td, .detalle th, .detalle td { border: 1px solid #e6e9ec; padding: 8px 10px; font-size: 13px; text-align: left; }
.tabla-listado th { background: #eef3f8; }
.tabla-listado tr:hover td { background: #f7fafd; }
.detalle th { background: #eef3f8; width: 190px; }

.filtro { display: flex; align-items: end; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.filtro label { display: block; font-size: 12px; color: #555; }

@media print {
  .no-print { display: none !important; }
  .content { box-shadow: none; margin: 0; padding: 0; }
  body { background: #fff; }
}

@media (max-width: 700px) {
  .content { padding: 16px; margin: 10px; }
  .topbar { flex-direction: column; align-items: flex-start; }
}

/* QR: miniatura clicable y visor ampliado */
.qr-mini { width: 42px; height: 42px; border: 1px solid #ddd; border-radius: 4px; background: #fff; padding: 2px; }
.qr-grande { width: 200px; height: 200px; border: 1px solid #eee; border-radius: 6px; background: #fff; padding: 6px; }
.qr-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 999; align-items: center; justify-content: center; }
.qr-overlay.visible { display: flex; }
.qr-overlay-caja { background: #fff; padding: 20px; border-radius: 10px; text-align: center; }
.qr-overlay-caja img { width: 280px; height: 280px; }
.qr-overlay-caja button { margin-top: 12px; }
.logo-albaran { max-height: 190px; max-width: 480px; width: auto; height: auto; }

/* Buscador tipo combobox (clientes / destinatarios) */
.buscador-wrap { position: relative; }
.buscador-resultados { display: none; position: absolute; z-index: 50; top: 100%; left: 0; right: 0;
  background: #fff; border: 1px solid #ccc; border-top: none; border-radius: 0 0 5px 5px;
  max-height: 220px; overflow-y: auto; box-shadow: 0 4px 10px rgba(0,0,0,.1); }
.buscador-item { padding: 8px 10px; font-size: 13px; cursor: pointer; }
.buscador-item:hover { background: #eef3f8; }
.buscador-vacio { padding: 8px 10px; font-size: 13px; color: #999; }

.site-footer { text-align: center; font-size: 11px; color: #93a3b0; padding: 10px 8px; }
.site-footer-fixed { position: fixed; left: 0; right: 0; bottom: 0; color: #cfe0f0; }
