:root {
  --azul: #0b6fa4;
  --azul-claro: #e6f3fa;
  --texto: #1d2733;
  --gris: #6b7785;
  --borde: #d6dde4;
  --fondo: #f4f7fa;
  --ok: #1e8e4e;
  --warn: #c98a00;
  --info: #2b6cd6;
  --ko: #b3261e;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, sans-serif; color: var(--texto); background: var(--fondo); font-size: 14px; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--azul); color: #fff; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; }
.brand span { font-weight: 400; opacity: .8; font-size: 13px; margin-left: 6px; }
.topbar nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.topbar nav button { background: transparent; color: #fff; border: 1px solid transparent; }
.topbar nav button.active, .topbar nav button:hover { background: rgba(255,255,255,.18); }

main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar h2 { margin: 0; }
.spacer { flex: 1; }

button, .btn { font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--borde); background: #fff; cursor: pointer; color: var(--texto); display: inline-block; }
button:hover, .btn:hover { border-color: var(--azul); }
button.primary { background: var(--azul); color: #fff; border-color: var(--azul); }
button.danger { color: var(--ko); }
button.small { padding: 3px 8px; font-size: 12px; }

input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--borde); border-radius: 6px; background: #fff; width: 100%; }
input[readonly] { background: #eef1f4; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--gris); min-width: 140px; }
label.grow { flex: 1; }

.card { background: #fff; border: 1px solid var(--borde); border-radius: 10px; padding: 16px; }
.card h3 { margin: 18px 0 8px; color: var(--azul); }
.row { display: flex; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; align-items: flex-end; }

table.grid { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--borde); border-radius: 8px; overflow: hidden; }
table.grid th { background: var(--azul-claro); text-align: left; padding: 8px; font-size: 12px; color: var(--azul); }
table.grid td { padding: 6px 8px; border-top: 1px solid var(--borde); }
table.grid tr:hover td { background: #fafcfd; }
.num { text-align: right; }
table.lineas input { padding: 4px 6px; }
table.lineas td:nth-child(1) { width: 90px; }
table.lineas td:nth-child(3), table.lineas td:nth-child(5), table.lineas td:nth-child(6), table.lineas td:nth-child(7) { width: 85px; }
table.lineas td:nth-child(4) { width: 70px; }
table.lineas td:nth-child(8) { width: 100px; }
.acciones { white-space: nowrap; text-align: right; }
.acciones button { margin-left: 4px; }

.badge { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; color: #fff; }
.badge.pendiente { background: var(--warn); }
.badge.en_reparto { background: var(--info); }
.badge.entregado { background: var(--ok); }
.badge.anulado { background: var(--ko); }
.badge.facturado { background: #6a4fb3; }
details summary { cursor: pointer; font-weight: 600; color: var(--azul); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: #fff; border: 1px solid var(--borde); border-radius: 8px; padding: 10px 14px; }
.stat b { display: block; font-size: 22px; color: var(--azul); }
.stat span { color: var(--gris); font-size: 12px; }

.totals-row { align-items: flex-start; }
.totales { min-width: 260px; background: var(--azul-claro); border-radius: 8px; padding: 10px 14px; }
.totales div { display: flex; justify-content: space-between; padding: 2px 0; }
.totales .total { font-weight: 700; font-size: 16px; border-top: 1px solid var(--borde); margin-top: 4px; padding-top: 6px; }

[hidden] { display: none !important; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--texto); margin: 10px 0 4px; }
label.check input { width: auto; }
.nota { font-size: 12px; color: var(--gris); margin: 4px 0 10px; }
.aviso { padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 10px; background: var(--azul-claro); }
.aviso.aplica { background: #e7f6ec; }
.aviso.excluido { background: #fff4dc; }
fieldset#ped-campos, fieldset#ped-campos-firma { border: 0; padding: 0; margin: 0; min-width: 0; }
.ped-firma-doc img { max-height: 70px; }
.ped-sello { font-size: 8.5px; color: #4a5562; word-break: break-all; }
.ped-senal-box { border: 2px solid #123; }
.dlg-importar { width: min(980px, 96vw); }
.ficha-datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 16px; margin-bottom: 12px; }
.ficha-datos small { display: block; color: var(--gris); font-size: 11px; text-transform: uppercase; }
.ficha-datos .ancho { grid-column: span 2; }
.ficha-nuevos { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
#ficha-equipos, #form-intervencion { margin-bottom: 12px; }
#ficha-equipos h3, #form-intervencion h3 { margin-top: 0; }
#ficha-equipos ul { margin: 0; padding-left: 18px; }
.historial { list-style: none; margin: 0; padding: 0; border-left: 3px solid var(--borde); }
.historial li { display: flex; gap: 12px; align-items: flex-start; background: #fff; border: 1px solid var(--borde); border-radius: 8px; padding: 10px 12px; margin: 0 0 8px 14px; position: relative; }
.historial li::before { content: ''; position: absolute; left: -22px; top: 14px; width: 11px; height: 11px; border-radius: 50%; background: var(--azul); border: 2px solid #fff; }
.historial li.hist-intervencion::before { background: #e08a00; }
.historial li.hist-servicio::before { background: #7a4fd1; }
.historial li.hist-factura::before { background: #1f9254; }
.historial li.empty { display: block; border: 0; background: none; }
.historial li.empty::before { display: none; }
.hist-fecha { min-width: 82px; font-weight: 600; color: var(--gris); }
.hist-cuerpo { flex: 1; min-width: 0; }
.hist-titulo { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hist-importe { margin-left: auto; font-weight: 600; }
.hist-detalle { margin: 4px 0; white-space: normal; }
.buscar-clientes { width: min(360px, 100%); }
input.buscar-cliente { margin-bottom: 4px; }
.buscar-cliente-info { color: var(--gris); font-size: 11px; min-height: 0; }
#form-correo { margin-top: 16px; }
/* Protección frente a copias */
body.sin-copiar main, body.sin-copiar .view { -webkit-user-select: none; user-select: none; }
body.sin-copiar input, body.sin-copiar textarea, body.sin-copiar select, body.sin-copiar [contenteditable] { -webkit-user-select: text; user-select: text; }
.bloqueado-exp { opacity: .6; }
.bloqueado-exp::before { content: '🔒 '; }
.aviso-seguridad { position: fixed; z-index: 9999; left: 50%; top: 20px; transform: translateX(-50%); width: min(560px, calc(100vw - 32px));
  background: #fff; border: 2px solid #c62828; border-left: 8px solid #c62828; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.aviso-seguridad b { color: #c62828; font-size: 16px; }
.aviso-seguridad small { color: var(--gris); }
.aviso-seguridad[hidden] { display: none; }
/* Fotos y documentos adjuntos */
.adjuntos { margin-top: 12px; }
.adjuntos h3 { margin-top: 0; }
.adj-subir { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.adj-subir select, .adj-subir input { width: auto; min-width: 160px; }
.adj-estado { color: var(--gris); }
.adj-galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.adj-item { margin: 0; border: 1px solid var(--borde); border-radius: 8px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.adj-mini { padding: 0; border: 0; border-radius: 0; height: 120px; background: #f2f5f8; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.adj-mini img { width: 100%; height: 100%; object-fit: cover; }
.adj-pdf { font-weight: 700; color: #c62828; border: 2px solid #c62828; border-radius: 6px; padding: 10px 12px; }
.adj-item figcaption { padding: 6px 8px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.adj-item figcaption small { color: var(--gris); }
.adj-nota { white-space: normal; }
.adj-botones { display: flex; gap: 4px; justify-content: flex-end; margin-top: 2px; }
.adj-img { -webkit-user-drag: none; }
.dlg-adjunto { width: min(1000px, 96vw); }
.adj-visor { display: flex; justify-content: center; background: #111; border-radius: 8px; min-height: 200px; }
.adj-visor img { max-width: 100%; max-height: 70vh; object-fit: contain; }
.adj-visor iframe { width: 100%; height: 70vh; border: 0; background: #fff; }
.dlg-adjunto menu { display: flex; gap: 8px; align-items: center; }
/* Agenda */
.age-navegar { display: inline-flex; gap: 4px; }
.age-titulo { display: inline-block; }
.age-titulo::first-letter { text-transform: uppercase; }
#view-agenda .toolbar select { width: auto; }
.stat-boton { text-align: left; font: inherit; cursor: pointer; }
.stat-boton.alerta b { color: #c62828; }
.agenda { margin-top: 12px; }
.age-cabecera, .age-rejilla { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.age-cab { font-size: 12px; color: var(--gris); text-align: center; font-weight: 600; }
.age-dia { background: #fff; border: 1px solid var(--borde); border-radius: 8px; padding: 6px; min-height: 150px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.agenda-mes .age-dia { min-height: 96px; }
.age-dia.hoy { border: 2px solid var(--azul); background: var(--azul-claro); }
.age-dia.finde { background: #fafbfc; }
.age-dia.fuera { opacity: .45; }
.age-dia-cab { display: flex; justify-content: space-between; align-items: center; font-size: 12px; text-transform: capitalize; }
button.enlace { background: none; border: 0; padding: 0; color: var(--azul); font-weight: 600; cursor: pointer; text-transform: inherit; }
.age-mas { padding: 0 7px; line-height: 18px; }
.age-visita, .age-alarma { display: block; width: 100%; text-align: left; font-size: 12px; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--borde); border-left: 4px solid var(--azul); background: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.age-visita small, .age-alarma small { display: block; color: var(--gris); overflow: hidden; text-overflow: ellipsis; }
.age-visita.est-realizada { border-left-color: #1f9254; background: #f1faf4; }
.age-visita.est-no_realizada { border-left-color: #e08a00; }
.age-visita.est-cancelada { border-left-color: #999; text-decoration: line-through; opacity: .6; }
.age-visita.sin-resultado { border-left-color: #c62828; background: #fdf1f1; }
.age-alarma { border-style: dashed; border-left: 4px dashed #e08a00; background: #fffaf0; }
.age-mas-n { font-size: 12px; text-align: left; }
.age-lista { list-style: none; margin: 0; padding: 0; }
.age-lista li { display: flex; gap: 12px; background: #fff; border: 1px solid var(--borde); border-left: 5px solid var(--azul); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.age-lista li.est-realizada { border-left-color: #1f9254; }
.age-lista li.est-no_realizada { border-left-color: #e08a00; }
.age-lista li.est-cancelada { border-left-color: #999; opacity: .7; }
.age-lista li.sin-resultado { border-left-color: #c62828; }
.age-lista li.age-li-alarma { border-style: dashed; border-left: 5px dashed #e08a00; }
.age-hora { min-width: 64px; display: flex; flex-direction: column; }
.age-hora small { color: var(--gris); }
.age-cuerpo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.age-obs, .age-res { font-size: 13px; }
.age-res { background: #f1faf4; border-radius: 6px; padding: 4px 8px; }
.age-acciones { display: flex; align-items: flex-start; }
.dlg-visita { width: min(720px, 96vw); }
.dlg-visita menu { display: flex; gap: 8px; align-items: center; }
.dlg-visita .row { align-items: flex-end; }
.vis-resultado { border: 1px solid var(--borde); border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.vis-resultado.activo { border-color: #1f9254; background: #f6fcf8; }
.vis-resultado legend { font-weight: 600; color: var(--azul); padding: 0 4px; }
.age-tabla-ruta td { vertical-align: top; font-size: 11px; }
.age-hueco { min-height: 48px; }
@media (max-width: 800px) {
  .age-rejilla, .age-cabecera { grid-template-columns: 1fr; }
  .age-cabecera { display: none; }
  .agenda-mes .age-rejilla { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .agenda-mes .age-visita small { display: none; }
  .age-dia { min-height: 0; }
}
#form-correo h3 { margin-top: 0; }
#ficha-alarmas { margin-bottom: 12px; }
#ficha-alarmas h3 { margin-top: 0; }
#form-alarma { border-top: 1px solid var(--borde); padding-top: 10px; margin-top: 8px; }
#form-alarma .row { align-items: flex-end; }
.atajos-fecha { display: flex; gap: 4px; flex-wrap: wrap; padding-bottom: 2px; }
.lista-alarmas { list-style: none; margin: 0; padding: 0; }
.lista-alarmas li { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--borde); }
.lista-alarmas li.empty { color: var(--gris); border: 0; }
.lista-alarmas li.ala-hecha { opacity: .6; }
.lista-alarmas .ala-texto { color: var(--gris); }
.lista-alarmas .ala-acciones { margin-left: auto; display: flex; gap: 4px; }
tr.ala-vencida td:first-child { color: #c62828; }
tr.ala-hoy td:first-child { color: #e08a00; }
@media (max-width: 600px) { .historial li { flex-wrap: wrap; } .ficha-datos .ancho { grid-column: auto; } }
.imp-mapeo { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 12px; }
.imp-vista { overflow: auto; max-height: 260px; margin-bottom: 10px; }
#btn-importar-clientes { cursor: pointer; }
.rep-lista { overflow: auto; max-height: 55vh; margin-bottom: 10px; }
.rep-grupo { border: 1px solid #ddd; border-radius: 6px; padding: 6px 8px; margin-bottom: 8px; }
.rep-grupo.rep-off { opacity: .55; }
.rep-grupo .grid td:first-child { text-align: center; }
tr.bloqueado td { color: var(--gris); background: #f7f7f7; }

/* ===== Catálogo ===== */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.chip small { color: var(--gris); margin-left: 2px; }
.chip.activo { background: var(--azul); color: #fff; border-color: var(--azul); }
.chip.activo small { color: rgba(255,255,255,.8); }
.segmentado { display: inline-flex; }
.segmentado button { border-radius: 0; padding: 5px 12px; }
.segmentado button:first-child { border-radius: 6px 0 0 6px; }
.segmentado button:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }
.segmentado button.activo { background: var(--azul-claro); color: var(--azul); border-color: var(--azul); }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.prod-card { background: #fff; border: 1px solid var(--borde); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.prod-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.prod-card.inactivo { opacity: .6; }
.prod-foto { aspect-ratio: 4 / 3; background: #f0f4f7; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.prod-foto img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.sin-foto { color: var(--azul); font-size: 32px; font-weight: 700; background: linear-gradient(135deg, var(--azul-claro), #f7fbfd); }
.prod-info { padding: 10px 12px; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.prod-meta { font-size: 11px; color: var(--gris); }
.tag { background: var(--azul-claro); color: var(--azul); border-radius: 4px; padding: 1px 6px; font-weight: 600; }
.prod-marca { font-size: 12px; color: var(--gris); }
.prod-detalle { font-size: 12px; color: #4a5562; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.prod-precio { margin-top: auto; padding-top: 6px; font-size: 18px; font-weight: 700; color: var(--azul); }
.prod-precio small { font-size: 11px; font-weight: 400; color: var(--gris); }
.prod-acciones { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 12px; border-top: 1px solid var(--borde); background: #fafcfd; }
.prod-mini { width: 44px; height: 44px; border-radius: 6px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #f0f4f7; }
.prod-mini img { width: 100%; height: 100%; object-fit: cover; }
.prod-mini.sin-foto { font-size: 14px; }
dialog.dlg-ancho { width: min(820px, 94vw); }
.prod-ficha { display: flex; gap: 16px; flex-wrap: wrap; }
.prod-imagen { width: 200px; display: flex; flex-direction: column; gap: 6px; align-items: stretch; text-align: center; }
.prod-imagen .prod-foto { border: 1px dashed var(--borde); border-radius: 8px; color: var(--gris); font-size: 12px; }
.prod-campos { flex: 1; min-width: 280px; }

/* Catálogo imprimible */
.cat-titulo { color: var(--azul); font-size: 15px; border-bottom: 2px solid var(--azul); padding-bottom: 3px; margin: 18px 0 8px; break-after: avoid; }
.cat-print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cat-print-item { display: flex; gap: 10px; border: 1px solid var(--borde); border-radius: 6px; padding: 8px; break-inside: avoid; }
.cat-print-foto { width: 80px; height: 80px; flex: none; border-radius: 4px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #f0f4f7; }
.cat-print-foto img { width: 100%; height: 100%; object-fit: contain; }
.cat-print-foto.sin-foto { font-size: 20px; }
.cat-print-item .prod-precio { font-size: 14px; }

.firma-box canvas { border: 1px dashed var(--gris); border-radius: 6px; background: #fff; touch-action: none; max-width: 100%; }
.empty { text-align: center; color: var(--gris); padding: 30px; }

dialog { border: none; border-radius: 10px; padding: 20px; width: min(520px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog label { margin-bottom: 10px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 10px 0 0; }

/* ===== Documento imprimible ===== */
.documento { background: #fff; width: 210mm; min-height: 297mm; margin: 0 auto; padding: 14mm; box-shadow: 0 2px 12px rgba(0,0,0,.12); font-size: 12px; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--azul); padding-bottom: 10px; }
.doc-head img { max-height: 60px; max-width: 180px; display: block; margin-bottom: 6px; }
.doc-head h1 { margin: 0; color: var(--azul); font-size: 24px; letter-spacing: 1px; text-align: right; }
.doc-meta { text-align: right; }
.doc-boxes { display: flex; gap: 12px; margin: 14px 0; }
.doc-box { flex: 1; border: 1px solid var(--borde); border-radius: 6px; padding: 8px 10px; }
.doc-box h4 { margin: 0 0 4px; font-size: 10px; text-transform: uppercase; color: var(--gris); }
.documento table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.documento th { background: var(--azul); color: #fff; padding: 6px; font-size: 11px; text-align: left; }
.documento td { padding: 5px 6px; border-bottom: 1px solid var(--borde); }
.doc-foot { display: flex; gap: 16px; margin-top: 14px; align-items: flex-start; }
.doc-firma { flex: 1; border: 1px solid var(--borde); border-radius: 6px; padding: 8px; min-height: 110px; }
.doc-firma img { max-height: 80px; }
.doc-legal { margin-top: 16px; font-size: 10px; color: var(--gris); border-top: 1px solid var(--borde); padding-top: 6px; }
.doc-seccion { margin-top: 10px; font-size: 9.5px; line-height: 1.4; color: #333; border: 1px solid var(--borde); border-radius: 6px; padding: 6px 10px; }
.doc-seccion h4 { margin: 0 0 4px; font-size: 10px; text-transform: uppercase; color: var(--azul); }
.doc-seccion p { margin: 3px 0; }
.documento .doc-rgpd table { margin: 0; }
.documento .doc-rgpd th { background: none; color: var(--texto); width: 95px; padding: 2px 6px 2px 0; font-size: 9.5px; vertical-align: top; }
.documento .doc-rgpd td { padding: 2px 0; border: none; }
.page-break { break-before: page; border-top: 2px dashed var(--borde); margin: 24px 0; }
.formulario { font-size: 12px; border: none; padding: 0; }
.formulario h3 { text-align: center; color: var(--azul); }
.formulario p { margin: 12px 0; }
.hueco { display: inline-block; min-width: 260px; border-bottom: 1px dotted #555; }
.linea-relleno { border-bottom: 1px dotted #555; padding: 4px 0; min-height: 40px; }
.firma-hueco { border: 1px solid var(--borde); height: 80px; border-radius: 6px; }
.documento h4.doc-h { margin: 12px 0 0; font-size: 11px; color: var(--azul); text-transform: uppercase; }
.documento .doc-boxes .doc-box { margin: 0; }
.documento > .doc-box { margin-top: 10px; }
.doc-garantia { margin-top: 10px; padding: 6px 10px; border: 2px solid var(--ok); border-radius: 6px; color: var(--ok); font-weight: 600; text-align: center; }
.firmas-sat .firma-box { flex: 1; min-width: 280px; }
.doc-anulado { color: var(--ko); font-weight: 700; font-size: 18px; text-align: center; border: 2px solid var(--ko); padding: 4px; margin: 8px 0; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  .documento { box-shadow: none; width: auto; min-height: 0; padding: 0; }
  .page-break { border: none; margin: 0; }
  @page { size: A4; margin: 10mm; }
}
/* ===== Documentos en una sola hoja A4 (el zoom lo calcula ajustarAUnaHoja en app.js) ===== */
@media screen { .documento { padding: 10mm; overflow-x: auto; } }
.hoja { font-size: 11px; line-height: 1.35; }
.hoja .doc-head { padding-bottom: 6px; }
.hoja .doc-head img { max-height: 48px; }
.hoja .doc-head h1 { font-size: 20px; }
.hoja .doc-boxes { margin: 8px 0; }
.hoja .doc-foot { margin-top: 8px; }
.hoja .doc-firma { min-height: 0; }
.hoja .doc-firma h4 { margin: 0 0 4px; font-size: 9px; color: var(--gris); text-transform: uppercase; }
.hoja .doc-firma img { max-height: 60px; }
.hoja .doc-legal { margin-top: 8px; font-size: 8.5px; }
.doc-legales { column-count: 2; column-gap: 5mm; margin-top: 8px; }
.doc-legales .doc-seccion { break-inside: avoid; margin: 0 0 5px; font-size: 8.3px; line-height: 1.3; padding: 4px 7px; }
.documento .doc-legales .doc-rgpd th { font-size: 8.3px; width: 68px; }
.corte { margin: 12px 0 6px; border-top: 1px dashed #888; text-align: center; font-size: 8.5px; color: var(--gris); }
.corte span { position: relative; top: -7px; background: #fff; padding: 0 6px; }
.hoja .formulario { font-size: 9.5px; }
.hoja .hueco, .hoja .linea-relleno { border-bottom-color: #aaa; }
.hoja .formulario h3 { margin: 0 0 2px; font-size: 12px; }
.hoja .formulario p { margin: 3px 0; }
.hoja .formulario .linea-relleno { min-height: 16px; padding: 2px 0; }
.hoja .formulario .firma-hueco { height: 40px; }
/* Información precontractual */
.tra-intro { margin: 8px 0 0; font-size: 10px; }
.documento table.tra-ficha { margin-top: 8px; font-size: 9.5px; }
.documento table.tra-ficha th { background: var(--azul-claro); color: var(--azul); width: 120px; vertical-align: top; font-size: 9.5px; }
.documento table.tra-ficha td { line-height: 1.35; }
.tra-ficha p { margin: 0; }
.tra-n { display: inline-block; width: 14px; height: 14px; line-height: 14px; border-radius: 50%; background: var(--azul); color: #fff; text-align: center; font-size: 8.5px; margin-right: 4px; }
.tra-acuse { font-size: 9.5px; margin-top: 8px; }
.tra-acuse .hueco { min-width: 200px; }
.tra-acuse .hueco.corto { min-width: 90px; }
.tra-hueco-firma { height: 45px; }

@media (max-width: 700px) {
  table.grid { font-size: 12px; display: block; overflow-x: auto; }
  .documento { width: 100%; padding: 12px; }
}

/* ===== Versión con servidor: usuario, sincronización, permisos ===== */
.brand a { text-decoration: none; }
#estado-sync { font-size: 12px; font-weight: 400; opacity: .85; margin-left: 8px; }
#estado-sync.error { color: #ffd2cc; font-weight: 600; opacity: 1; }
.contador { background: #e5484d; color: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px; font-weight: 700; margin-left: 2px; }
.usuario-menu { position: relative; }
.usuario-btn { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); }
.usuario-btn small { display: block; font-size: 10px; opacity: .8; text-align: left; }
.usuario-btn b { display: block; font-size: 13px; text-align: left; }
.menu-desplegable { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--borde); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); min-width: 230px; z-index: 50; padding: 4px; }
.menu-desplegable a, .menu-desplegable button { display: block; width: 100%; text-align: left; border: none; padding: 8px 12px; color: var(--texto); text-decoration: none; border-radius: 6px; background: none; font: inherit; cursor: pointer; }
.menu-desplegable a:hover, .menu-desplegable button:hover { background: var(--azul-claro); }
.img-preview { width: 120px; height: 70px; border: 1px dashed var(--borde); border-radius: 6px; display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--gris); font-size: 11px; text-align: center; background: #fff; }
.img-preview.ancho { width: 220px; height: 90px; }
.img-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.solo-admin { border-top: 1px solid var(--borde); margin-top: 16px; padding-top: 4px; }
.tag.editar { background: #e7f6ec; color: var(--ok); }
.permisos-resumen .tag { display: inline-block; margin: 1px 0; }
table.permisos td:not(:first-child), table.permisos th:not(:first-child) { text-align: center; }
label.radio { flex-direction: row; align-items: center; justify-content: center; gap: 4px; min-width: 0; color: var(--texto); }
label.radio input { width: auto; }
dialog { max-height: 92vh; overflow-y: auto; }
dialog form { display: flex; flex-direction: column; }
.dlg-seccion { margin: 16px 0 8px; color: var(--azul); border-bottom: 1px solid var(--borde); padding-bottom: 4px; }
.prod-fotos { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.prod-foto-item { position: relative; width: 130px; height: 110px; border: 1px solid var(--borde); border-radius: 8px; overflow: hidden; background: #fff; }
.prod-foto-item.principal { border: 2px solid var(--azul); }
.prod-foto-item img { width: 100%; height: 100%; object-fit: contain; }
.prod-foto-etq { position: absolute; top: 4px; left: 4px; background: var(--azul); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 4px; }
.prod-foto-botones { position: absolute; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; gap: 2px; padding: 3px; background: rgba(255,255,255,.9); }
.prod-foto-botones button { padding: 1px 6px; }
table.ficha-edit input { padding: 4px 6px; }
table.ficha-edit td:last-child { width: 40px; }

/* ===== Catálogo imprimible para clientes ===== */
.catp-portada { text-align: center; padding: 30px 0 20px; border-bottom: 3px solid var(--azul); margin-bottom: 10px; }
.catp-portada h1 { color: var(--azul); font-size: 30px; margin: 10px 0 4px; }
.catp-logo { max-height: 80px; max-width: 240px; }
.catp-eslogan { font-size: 15px; color: var(--gris); font-style: italic; }
.catp-item { display: flex; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--borde); break-inside: avoid; }
.catp-fotos { width: 42%; flex: none; }
.catp-foto { width: 100%; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #f0f4f7; border: 1px solid var(--borde); }
.catp-foto img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.catp-foto.sin-foto { font-size: 40px; }
.catp-miniaturas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 4px; }
.catp-mini { aspect-ratio: 1; border: 1px solid var(--borde); border-radius: 4px; overflow: hidden; background: #fff; }
.catp-mini img { width: 100%; height: 100%; object-fit: contain; }
.catp-texto { flex: 1; font-size: 12px; }
.catp-texto h3 { margin: 2px 0 6px; font-size: 16px; color: var(--texto); }
.catp-texto p { margin: 0 0 8px; color: #333; line-height: 1.45; }
.documento table.catp-ficha { width: 100%; margin: 6px 0; border-collapse: collapse; }
.documento table.catp-ficha th { background: var(--azul-claro); color: var(--azul); width: 42%; font-size: 10.5px; padding: 3px 6px; text-align: left; border-bottom: 1px solid #fff; }
.documento table.catp-ficha td { padding: 3px 6px; font-size: 10.5px; border-bottom: 1px solid var(--borde); }
@media (max-width: 700px) {
  .catp-item { flex-direction: column; }
  .catp-fotos { width: 100%; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
}
