:root {
  --fondo: #f3f4f6;
  --tarjeta: #ffffff;
  --texto: #1f2933;
  --suave: #616e7c;
  --borde: #d9dee5;
  --pri: #e8590c;
  --pri-osc: #c2410c;
  --pri-claro: #fff1e6;
  --oscuro: #1f2933;
  --verde: #2f855a;
  --rojo: #c53030;
  --azul: #2b6cb0;
  --radio: 12px;
  --sombra: 0 1px 3px rgba(16, 42, 67, .08), 0 1px 2px rgba(16, 42, 67, .06);
  --nav-h: 64px;
  --badge-h: 0px; /* hueco para la marca del hosting gratuito (Netlify) */
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
body.con-modal { overflow: hidden; }
a { color: var(--pri-osc); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- barra superior */
.barra {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  background: var(--oscuro); color: #fff; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  min-height: 56px;
}
.barra h1 { font-size: 20px; flex: 1; }
.marca { display: flex; gap: 8px; align-items: center; font-size: 22px; flex: 1; }
.atras { color: #fff; text-decoration: none; font-size: 24px; padding: 4px 8px 4px 0; }
.barra-tit { flex: 1; min-width: 0; }
.barra-tit h1 { font-size: 17px; }
.barra-tit small { display: block; color: #cbd2d9; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra-total { text-align: right; font-weight: 700; font-size: 18px; }
.barra-total small { display: block; font-weight: 400; font-size: 11px; color: #cbd2d9; }

.tabs {
  position: sticky; top: 56px; z-index: 19; display: flex; background: #fff; border-bottom: 1px solid var(--borde);
}
.tabs a {
  flex: 1; text-align: center; padding: 12px 4px; text-decoration: none; color: var(--suave); font-weight: 600; font-size: 14px;
  border-bottom: 3px solid transparent;
}
.tabs a i { font-style: normal; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--borde); color: var(--texto); font-size: 12px; margin-right: 4px; }
.tabs a.on { color: var(--pri-osc); border-color: var(--pri); }
.tabs a.on i { background: var(--pri); color: #fff; }

.contenido { max-width: 820px; margin: 0 auto; padding: 16px; }

/* ---------- navegación inferior */
#nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; background: #fff; border-top: 1px solid var(--borde);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
}
#nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: var(--suave); font-size: 12px; font-weight: 600; }
#nav a span { font-size: 22px; line-height: 1.1; }
#nav a.activo { color: var(--pri-osc); }
body:has(#nav[hidden]) { padding-bottom: 24px; }

/* Con la marca del hosting: la barra sube y el hueco de abajo queda para la marca */
body.con-marca { padding-bottom: calc(var(--nav-h) + var(--badge-h) + env(safe-area-inset-bottom)); }
body.con-marca:has(#nav[hidden]) { padding-bottom: calc(var(--badge-h) + 24px); }
body.con-marca #nav {
  bottom: var(--badge-h); height: var(--nav-h); padding-bottom: 0;
  box-shadow: 0 var(--badge-h) 0 #fff; /* rellena de blanco la franja de la marca */
}
body.con-marca .fab { bottom: calc(var(--nav-h) + var(--badge-h) + 16px); }
body.con-marca #toast { bottom: calc(var(--nav-h) + var(--badge-h) + 80px); }
body.con-marca #modal { padding-bottom: var(--badge-h); }

/* ---------- tarjetas */
.tarjeta { background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); padding: 16px; margin-bottom: 14px; }
.tarjeta h2 { font-size: 17px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.tarjeta.ok { color: var(--verde); font-weight: 600; }
.tarjeta.interno { border: 2px dashed var(--borde); box-shadow: none; }
.banner { display: block; background: var(--pri-claro); border: 1px solid #fdc9a6; color: var(--texto); padding: 12px 14px; border-radius: var(--radio); margin-bottom: 14px; text-decoration: none; }

/* ---------- formularios */
.campo { display: block; margin-bottom: 12px; }
.campo > span { display: block; font-size: 13px; font-weight: 600; color: var(--suave); margin-bottom: 4px; }
.campo > em { display: block; font-size: 12px; color: var(--suave); font-style: normal; margin-top: 4px; }
input:not([type=checkbox]), select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 10px; background: #fff;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pri); outline-offset: 0; border-color: var(--pri); }
.fila2, .fila3, .fila4 { display: grid; gap: 10px; }
.fila2 { grid-template-columns: 1fr 1fr; }
.fila3 { grid-template-columns: repeat(3, 1fr); }
.fila4 { grid-template-columns: repeat(4, 1fr); }
.fila2 .campo, .fila3 .campo, .fila4 .campo { min-width: 0; }
.buscar { margin-bottom: 12px; }
.ayuda { font-size: 14px; color: var(--suave); margin: 4px 0 12px; }
.ayuda.centro { text-align: center; }
.aviso-t { color: var(--pri-osc); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 10px 16px;
  border-radius: 10px; border: 1px solid var(--pri); background: var(--pri); color: #fff; font-weight: 700; text-decoration: none; text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.sec { background: #fff; color: var(--pri-osc); }
.btn.peligro { border-color: var(--rojo); }
.btn.sec.peligro { color: var(--rojo); }
.btn.mini { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.grande { width: 100%; min-height: 54px; font-size: 17px; margin-top: 4px; }
.siguiente { margin: 8px 0 24px; }
.botones { display: grid; gap: 10px; }
.botones.fila { display: flex; flex-wrap: wrap; gap: 8px; }
.link { background: none; border: 0; padding: 0; color: var(--pri-osc); text-decoration: underline; font-size: inherit; }
.link.peligro, .peligro { color: var(--rojo); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip { border: 1px solid var(--borde); background: #fff; border-radius: 999px; padding: 8px 14px; font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--oscuro); color: #fff; border-color: var(--oscuro); }

.seg { display: flex; border: 1px solid var(--borde); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { flex: 1; border: 0; background: none; padding: 12px 6px; font-weight: 600; min-height: 46px; }
.seg button + button { border-left: 1px solid var(--borde); }
.seg button.on { background: var(--pri); color: #fff; }

.fila-campo { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.fila-campo > span { font-weight: 600; }
.fila-campo .seg { min-width: 160px; }
.fila-campo.col { flex-direction: column; align-items: stretch; }
.fila-campo.col .seg { min-width: 0; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 46px; height: 46px; border-radius: 10px; border: 1px solid var(--borde); background: #fff; font-size: 22px; }
.stepper b { min-width: 56px; text-align: center; }

.switch { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .sl { flex: none; width: 50px; height: 30px; border-radius: 15px; background: #cbd2d9; position: relative; transition: .2s; }
.switch .sl::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: var(--sombra); }
.switch input:checked + .sl { background: var(--pri); }
.switch input:checked + .sl::after { transform: translateX(20px); }
.switch input:focus-visible + .sl { outline: 2px solid var(--pri); outline-offset: 2px; }
.sw-t b { display: block; font-weight: 600; }
.sw-t em { display: block; font-style: normal; font-size: 13px; color: var(--suave); }

/* ---------- lista de presupuestos */
.pres { display: block; text-decoration: none; color: inherit; }
.pres-top, .pres-bot { display: flex; justify-content: space-between; align-items: center; }
.num { font-weight: 700; color: var(--suave); font-size: 14px; }
.pres-cli { font-size: 18px; font-weight: 700; margin-top: 4px; }
.pres-obra { color: var(--suave); font-size: 14px; margin: 2px 0 8px; }
.pres-bot span { color: var(--suave); font-size: 14px; }
.pres-bot b { font-size: 18px; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.badge.gris { background: #e4e7eb; color: #3e4c59; }
.badge.azul { background: #dbeafe; color: var(--azul); }
.badge.verde { background: #dcfce7; color: var(--verde); }
.badge.rojo { background: #fee2e2; color: var(--rojo); }
.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 25;
  border: 0; background: var(--pri); color: #fff; font-weight: 700; font-size: 16px; padding: 16px 22px; border-radius: 999px;
  box-shadow: 0 6px 16px rgba(232, 89, 12, .4);
}
.vacio { text-align: center; color: var(--suave); padding: 40px 16px; }
.vacio-ico { font-size: 48px; }
.vacio-mini { color: var(--suave); font-size: 14px; text-align: center; margin: 8px 0; }

/* ---------- estancias */
.est-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.est-nombre { font-weight: 700; font-size: 18px !important; border-color: transparent !important; padding-left: 4px !important; background: transparent !important; }
.est-nombre:focus { border-color: var(--pri) !important; background: #fff !important; }
.est-sub { font-weight: 700; white-space: nowrap; }
.menu { position: relative; }
.menu summary { list-style: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; font-size: 22px; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: var(--fondo); }
.menu > div { position: absolute; right: 0; top: 44px; z-index: 10; background: #fff; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .15); min-width: 180px; padding: 6px; }
.menu > div button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 12px; border-radius: 8px; }
.menu > div button:hover { background: var(--fondo); }
.menu > div .ayuda { display: block; padding: 8px; margin: 0; }
.medidas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.medidas label span { display: block; font-size: 12px; color: var(--suave); font-weight: 600; margin-bottom: 2px; }
.medidas input { text-align: center; font-weight: 700; padding: 8px 4px !important; }
.calc-med { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--suave); background: var(--fondo); border-radius: 8px; padding: 8px 10px; margin: 10px 0 12px; }
.calc-med b { color: var(--texto); }

.partidas { border-top: 1px solid var(--borde); }
.partida { border-bottom: 1px solid var(--borde); }
.partida.abierta { background: #fafbfc; margin: 0 -16px; padding: 0 16px; }
.p-fila { display: grid; grid-template-columns: 1fr 104px 86px; gap: 8px; align-items: center; padding: 10px 0; }
.p-nombre { text-align: left; background: none; border: 0; padding: 0; min-width: 0; }
.p-nombre span { display: block; font-weight: 600; font-size: 15px; }
.p-nombre small { display: block; color: var(--suave); font-size: 12px; }
.fac { font-style: normal; color: var(--pri-osc); font-weight: 600; }
.p-cant { display: flex; flex-direction: column; align-items: stretch; }
.p-cant input { text-align: center; font-weight: 700; min-height: 42px; padding: 6px 4px !important; }
.p-cant span { text-align: center; font-size: 11px; color: var(--suave); }
.p-cant.auto input { background: #eff6ff; border-color: #bfdbfe; color: var(--azul); }
.p-imp { text-align: right; font-weight: 700; font-size: 15px; }
.p-det { padding: 4px 0 14px; }
.desc { font-size: 14px; color: var(--suave); margin: 0 0 8px; }
.desg { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; background: #fff; border-radius: 8px; overflow: hidden; }
.desg td { padding: 6px 8px; border-bottom: 1px solid #eef0f3; }
.desg td:nth-child(2) { color: var(--suave); white-space: nowrap; }
.desg td:last-child { text-align: right; white-space: nowrap; }
.desg tr.tot td { font-weight: 700; }
.p-acc { margin-top: 6px; }
.acc-est { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }

.fotos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.foto { position: relative; width: 76px; height: 76px; }
.foto img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.foto button { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--oscuro); color: #fff; font-size: 12px; }
.foto-add { width: 76px; height: 76px; border: 2px dashed var(--borde); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 24px; color: var(--suave); cursor: pointer; }
.foto-add span { font-size: 12px; }

/* ---------- resumen */
.linea { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid #eef0f3; }
.linea:last-child { border-bottom: 0; }
.linea span { color: var(--suave); }
.linea.destacado { font-size: 17px; }
.total-gr { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; padding-top: 10px; border-top: 2px solid var(--texto); }
.total-gr span { font-weight: 700; }
.total-gr b { font-size: 28px; color: var(--pri-osc); }
.verde { color: var(--verde); }
.rojo { color: var(--rojo); }
.cuenta { background: var(--pri); color: #fff; border-radius: 999px; font-size: 13px; padding: 1px 9px; }
.sug { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; font-size: 14px; }
.sug.sug { background: #fffbeb; border: 1px solid #fde68a; }
.sug.aviso { background: #fef2f2; border: 1px solid #fecaca; }
.sug.info { background: #eff6ff; border: 1px solid #bfdbfe; }
.sug .btn { flex: none; }
.comp { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.comp button { border: 1px solid var(--borde); background: #fff; border-radius: 10px; padding: 10px 6px; }
.comp button small { display: block; color: var(--suave); font-size: 13px; }
.comp button b { font-size: 15px; }
.comp button.on { border: 2px solid var(--pri); background: var(--pri-claro); }
.firma-ok { display: flex; gap: 12px; align-items: center; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; padding: 10px; margin-bottom: 12px; }
.firma-ok img { width: 110px; height: 50px; object-fit: contain; background: #fff; border-radius: 6px; }
.firma-ok div { flex: 1; font-size: 14px; }

/* ---------- clientes y precios */
.cliente { display: flex; flex-direction: column; gap: 10px; }
.cliente small { display: block; color: var(--suave); font-size: 13px; }
.mini-res { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; align-items: center; }
.grupo { font-size: 15px; color: var(--suave); margin: 18px 0 8px; }
.plantilla { padding: 0; overflow: hidden; }
.pl-cab { width: 100%; display: flex; justify-content: space-between; gap: 10px; align-items: center; border: 0; background: none; padding: 14px 16px; text-align: left; }
.pl-cab span { font-weight: 600; }
.pl-cab b { white-space: nowrap; }
.pl-cab b small { font-weight: 400; color: var(--suave); }
.plantilla.abierta .pl-cab { background: var(--pri-claro); }
.pl-form { padding: 14px 16px; }
.pl-form h4 { font-size: 14px; margin: 14px 0 8px; }
.mat-fila { background: var(--fondo); border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.mat-fila .campo { margin-bottom: 6px; }
.mat-pie { display: flex; justify-content: space-between; align-items: center; }
.mat-pie .switch { padding: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.logo-box { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.logo-box img { max-height: 60px; max-width: 160px; }

/* ---------- modal */
#modal { position: fixed; inset: 0; z-index: 50; background: rgba(16, 24, 32, .55); display: none; align-items: flex-end; justify-content: center; }
#modal.on { display: flex; }
#modal .caja { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; animation: sube .2s ease-out; }
@keyframes sube { from { transform: translateY(40px); opacity: .5; } }
@media (min-width: 700px) { #modal { align-items: center; } #modal .caja { border-radius: 16px; } }
.modal-cab { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid var(--borde); }
.modal-cab h2 { font-size: 18px; }
.x { border: 0; background: var(--fondo); width: 38px; height: 38px; border-radius: 50%; font-size: 16px; }
.modal-fijo { padding: 12px 16px 0; }
.modal-cuerpo { padding: 12px 16px; overflow-y: auto; flex: 1; }
.modal-pie { display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--borde); }
.modal-pie .btn { flex: 1; }
.cat-item { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--borde); background: #fff; border-radius: 10px; padding: 12px; margin-bottom: 8px; }
.cat-item span { font-weight: 600; }
.cat-item small { display: block; font-weight: 400; color: var(--suave); font-size: 13px; }
.cat-item b { font-size: 22px; color: var(--pri); }
.cat-item.ya { border-color: #bbf7d0; background: #f0fdf4; }
.kits { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kit { border: 1px solid var(--borde); background: #fff; border-radius: 12px; padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.kit-ico { font-size: 30px; }
.kit small { color: var(--suave); }
#firma-cv { width: 100%; border: 2px dashed var(--borde); border-radius: 10px; touch-action: none; background: #fff; display: block; margin-bottom: 12px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 80px); transform: translateX(-50%) translateY(20px); z-index: 60;
  background: var(--oscuro); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s;
  max-width: calc(100% - 32px);
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 420px) {
  .fila3 { grid-template-columns: 1fr 1fr; }
  .fila4 { grid-template-columns: 1fr 1fr; }
  .medidas { grid-template-columns: 1fr 1fr; }
  .p-fila { grid-template-columns: 1fr 88px 78px; }
  .total-gr b { font-size: 24px; }
}

/* ---------- documento / PDF */
.print-bar { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; justify-content: space-between; padding: 12px 16px; background: var(--oscuro); }
.print-tip { max-width: 820px; margin: 10px auto 0; padding: 0 16px; }
.doc { background: #fff; max-width: 820px; margin: 16px auto; padding: 32px; box-shadow: var(--sombra); font-size: 13px; color: #111; }
.doc h1 { font-size: 22px; color: var(--pri-osc); letter-spacing: 1px; }
.doc h3 { font-size: 15px; margin: 18px 0 8px; }
.doc-cab { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--pri); padding-bottom: 14px; }
.doc-emp { display: flex; gap: 14px; align-items: flex-start; }
.doc-emp .logo { max-height: 70px; max-width: 150px; }
.doc-num { text-align: right; }
.doc-cli { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0; }
.doc-cli > div { background: #f7f7f8; padding: 10px 12px; border-radius: 6px; }
.doc-cli small { display: block; color: #666; font-size: 11px; letter-spacing: 1px; }
.doc-notas { background: #fff8f2; border-left: 3px solid var(--pri); padding: 8px 12px; }
.cap { color: var(--oscuro); border-bottom: 1px solid #ddd; padding-bottom: 4px; }
.doc-t { width: 100%; border-collapse: collapse; }
.doc-t th { text-align: left; font-size: 11px; text-transform: uppercase; color: #666; border-bottom: 1px solid #ccc; padding: 6px 4px; }
.doc-t td { padding: 7px 4px; border-bottom: 1px solid #eee; vertical-align: top; }
.doc-t .n { text-align: right; white-space: nowrap; }
.doc-t td:first-child { color: #666; white-space: nowrap; }
.doc-t .d { color: #555; font-size: 12px; margin-top: 2px; }
.doc-t .d.nota { color: var(--pri-osc); }
.doc-t tfoot td { font-weight: 700; border-bottom: 0; text-align: right; color: #111; }
.doc-t.res td:first-child { color: #111; }
.doc-t.res tr.sep td { border-top: 1px solid #999; font-weight: 600; }
.doc-t.res tr.total td { font-size: 17px; font-weight: 800; border-top: 2px solid #111; color: var(--pri-osc); }
.doc-res { margin-left: auto; max-width: 420px; }
.comp-doc { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.comp-doc div { border: 1px solid #ddd; border-radius: 6px; padding: 10px; text-align: center; }
.comp-doc div.on { border: 2px solid var(--pri); }
.comp-doc small { display: block; color: #666; }
.comp-doc b { font-size: 16px; }
.doc-cond p { white-space: normal; color: #333; }
.doc-firmas { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 24px; break-inside: avoid; }
.doc-firmas small { color: #666; }
.firma-esp { height: 80px; border-bottom: 1px solid #999; margin-bottom: 6px; display: flex; align-items: flex-end; }
.firma-esp img { max-height: 78px; max-width: 100%; }
.grid-fotos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid-fotos figure { margin: 0; break-inside: avoid; }
.grid-fotos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 4px; }
.grid-fotos figcaption { font-size: 11px; color: #666; }

body.print-mode { background: #e5e7eb; }
@media (max-width: 600px) {
  .doc { padding: 16px; margin: 8px; }
  .doc-cab, .doc-cli { display: block; }
  .doc-num { text-align: left; margin-top: 12px; }
  .doc-cli > div { margin-bottom: 8px; }
  .grid-fotos { grid-template-columns: 1fr 1fr; }
}

@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body, body.print-mode { background: #fff; padding: 0; }
  .no-print, #nav, #toast, #modal { display: none !important; }
  .doc { box-shadow: none; margin: 0; padding: 0; max-width: none; font-size: 11.5px; }
  .doc-cab { display: flex; }
  .doc-cli { display: grid; }
  .doc-num { text-align: right; margin: 0; }
  .grid-fotos { grid-template-columns: repeat(3, 1fr); }
  .doc-t tr { break-inside: avoid; }
  .cap { break-after: avoid; }
  .doc-fotos { break-before: page; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
