/* ===================================================================
   Licencia AMG — capa de presentación
   Dirección de Claude Design (papel de periódico: filetes, sin
   tarjetas, sin degradados, jerarquía por escala y aire) con la
   identidad de CEM: azul petróleo #214e62 y gris corporativo #434141,
   los mismos de cemlegal.com.mx.

   El color con significado (dentro del base / paga contribución /
   no autorizable) es el único énfasis cromático fuerte.
   Autocontenido: ninguna petición externa.
   =================================================================== */

:root {
  /* Tinta y papel */
  --paper: #f3f2f2;
  --surface: #eae9e9;
  --ink: #201e1d;
  --corp: #434141;                                     /* gris corporativo CEM, 9.07:1 */
  --muted: color-mix(in srgb, #201e1d 72%, #f3f2f2);   /* 5.7:1 sobre papel */
  --faint: color-mix(in srgb, #201e1d 66%, #f3f2f2);   /* 4.7:1 sobre papel */
  --line: color-mix(in srgb, #201e1d 16%, transparent);
  --line-firme: color-mix(in srgb, #201e1d 45%, transparent);

  /* Tintas. Azul CEM para interfaz; ladrillo como segunda tinta de alarma. */
  --cy: #214e62;          /* 8.06:1 — azul CEM del sitio */
  --cy-tinta: #1a3d4d;    /* 10.33:1 — texto de cuerpo en azul */
  --cy-suave: #e3ecf0;
  --mg: #a8322a;          /* 5.96:1 — ladrillo, no rosa: acompaña al petróleo */
  --mg-tinta: #8c2f22;    /* 7.39:1 */
  --mg-suave: #f8ecea;
  --yellow: #c08a1e;      /* solo tratamiento de plancha, nunca texto */

  /* Escala tipográfica: seis escalones. Los campos van pinchados a 16 px
     porque por debajo iOS hace zoom al enfocar y desmonta el diseño. */
  --t-xs: 11px;
  --t-sm: 13px;
  --t-md: 15px;
  --t-lg: 20px;
  --t-xl: 25px;
  --t-2xl: 42px;

  --s1: 5px; --s2: 10px; --s3: 15px; --s4: 20px; --s6: 30px; --s8: 40px;
  --r: 2px;

  --serif: ui-serif, "Iowan Old Style", "Source Serif 4", Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #171a1c;
    --surface: #202528;
    --ink: #eceae8;
    --corp: #c9cccе;
    --muted: color-mix(in srgb, #eceae8 74%, #171a1c);
    --faint: color-mix(in srgb, #eceae8 64%, #171a1c);
    --line: color-mix(in srgb, #eceae8 22%, transparent);
    --line-firme: color-mix(in srgb, #eceae8 48%, transparent);
    --cy: #7fb3ca;        /* 7.77:1 */
    --cy-tinta: #a9c6d4;
    --cy-suave: #1c3440;
    --mg: #e08072;        /* 6.33:1 */
    --mg-tinta: #e89486;
    --mg-suave: #3a2422;
  }
}
:root[data-theme="dark"] {
  --paper: #171a1c;
  --surface: #202528;
  --ink: #eceae8;
  --corp: #c9ccce;
  --muted: color-mix(in srgb, #eceae8 74%, #171a1c);
  --faint: color-mix(in srgb, #eceae8 64%, #171a1c);
  --line: color-mix(in srgb, #eceae8 22%, transparent);
  --line-firme: color-mix(in srgb, #eceae8 48%, transparent);
  --cy: #7fb3ca; --cy-tinta: #a9c6d4; --cy-suave: #1c3440;
  --mg: #e08072; --mg-tinta: #e89486; --mg-suave: #3a2422;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--t-md)/1.55 var(--serif);
  overscroll-behavior-y: none;
}
body.hoja-abierta { overflow: hidden; }
::selection { background: color-mix(in srgb, var(--cy) 30%, transparent); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--cy); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 1180px; margin: 0 auto; padding: var(--s6) var(--s4) 90px; }

/* ── Cabecera: furniture de primera plana, con la marca de CEM ─── */
.topbar { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.marca { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.marca img { height: 42px; width: auto; display: block; flex: none; }
.wordmark { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.wordmark .nm { font-size: var(--t-lg); font-weight: 600; letter-spacing: -.015em; line-height: 1.1; }
.wordmark .yr {
  font-size: var(--t-xs); font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
}
.topbar-actions { margin-left: auto; display: flex; gap: var(--s1); }
.icon-btn {
  background: none; border: 1px solid var(--line); border-radius: var(--r); color: var(--muted);
  min-width: 44px; min-height: 44px; cursor: pointer; font: inherit; font-size: var(--t-md);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--cy); color: var(--cy-tinta); }
.icon-btn:active { background: color-mix(in srgb, var(--cy) 12%, transparent); }

/* El filete grueso es el de la hoja membretada: azul CEM, no tinta negra. */
.filete-grueso { height: 4px; background: var(--cy); margin-top: var(--s2); }
.filete-fino { height: 1px; background: var(--ink); }
.dateline {
  display: flex; justify-content: space-between; gap: var(--s3); flex-wrap: wrap;
  padding: 5px 0; font-size: var(--t-xs); letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}

header.doc { padding: var(--s4) 0 var(--s3); }
h1 { font-size: var(--t-xl); font-weight: 600; letter-spacing: -.015em; margin: 0 0 var(--s2); text-wrap: balance; }
.source { font-size: var(--t-sm); color: var(--muted); max-width: 78ch; margin: 0; }
.source strong { color: var(--ink); font-weight: 600; }

/* ── Selector de municipio ─────────────────────────────────── */
.muni-picker { display: flex; gap: var(--s1); flex-wrap: wrap; margin-bottom: var(--s4); }
.muni-btn {
  flex: 1 1 180px; min-height: 48px; padding: 6px 14px; cursor: pointer; text-align: left;
  background: none; border: 1px solid var(--line); border-radius: var(--r); color: var(--ink);
  font: inherit; display: flex; flex-direction: column; justify-content: center;
}
.muni-btn .mn { font-weight: 600; font-size: var(--t-md); }
.muni-btn .ms { font-size: var(--t-xs); color: var(--muted); }
.muni-btn:hover { border-color: var(--cy); }
.muni-btn[aria-pressed="true"] { background: var(--cy); border-color: var(--cy); }
.muni-btn[aria-pressed="true"] .mn { color: var(--paper); }
.muni-btn[aria-pressed="true"] .ms { color: color-mix(in srgb, var(--paper) 82%, var(--cy)); }
:root[data-theme="dark"] .muni-btn[aria-pressed="true"] .mn,
:root[data-theme="dark"] .muni-btn[aria-pressed="true"] .ms { color: #14181b; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .muni-btn[aria-pressed="true"] .mn,
  :root:not([data-theme="light"]) .muni-btn[aria-pressed="true"] .ms { color: #14181b; }
}

/* ── Aviso de cambio de ley ────────────────────────────────── */
.ley-cambio {
  display: none; gap: var(--s3); align-items: flex-start; flex-wrap: wrap;
  padding: var(--s2) 0 var(--s3) var(--s3);
  border-left: 3px solid var(--cy); margin-bottom: var(--s4);
}
.ley-cambio.visible { display: flex; }
.ley-cambio .lc-txt { flex: 1 1 320px; }
.ley-cambio .lc-tit { font-weight: 600; font-size: var(--t-md); }
.ley-cambio .lc-sub { font-size: var(--t-sm); color: var(--muted); }
.ley-cambio .lc-campos { font-size: var(--t-sm); color: var(--muted); margin-top: 3px; }

/* ── Reanudar ──────────────────────────────────────────────── */
.reanudar {
  display: none; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s2) 0 var(--s3) var(--s3);
  border-left: 3px solid var(--ink); margin-bottom: var(--s4); font-size: var(--t-sm);
}
.reanudar.visible { display: flex; }
.reanudar .r-txt { flex: 1 1 240px; }
.reanudar .r-when { color: var(--muted); font-size: var(--t-xs); }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: var(--s8); align-items: start; }

/* ══ Formulario ═══════════════════════════════════════════════
   Sin tarjetas: cada bloque es una sección separada por filete fino.
   ══════════════════════════════════════════════════════════ */
fieldset { border: 0; border-top: 1px solid var(--line); padding: var(--s3) 0 var(--s4); margin: 0; }
fieldset:first-of-type { border-top: 0; padding-top: 0; }
legend { font-size: var(--t-lg); font-weight: 600; padding: 0; margin-bottom: var(--s1); }

/* La ruta mínima: lo esencial pesa más que todo lo demás. */
fieldset.esencial { border-top: 0; padding-top: 0; }
fieldset.esencial > legend { font-size: var(--t-xl); }
fieldset.esencial .field > label { font-size: var(--t-sm); }
fieldset.esencial input, fieldset.esencial select { font-size: 17px; }

legend .art, summary .art {
  font-size: var(--t-xs); font-weight: 400; color: var(--muted);
  letter-spacing: .08em; text-transform: uppercase; margin-left: var(--s2);
}
.row { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s4); margin-bottom: var(--s3); }
.row:last-child { margin-bottom: 0; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; min-width: 0; }
.field.small { flex: 0 1 180px; }
.field.wide { flex: 1 1 100%; }
.field > label { font-size: var(--t-sm); color: var(--muted); display: flex; align-items: center; gap: 6px; }

select, input[type="number"], input[type="text"] {
  font: inherit; font-size: 16px;      /* piso de iOS: por debajo hace zoom al enfocar */
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 11px; width: 100%; min-height: 48px;
  font-variant-numeric: tabular-nums;
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 22px, calc(100% - 12px) 22px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
input:hover, select:hover { border-color: var(--line-firme); }
input:focus-visible, select:focus-visible { border-color: var(--cy); outline-offset: 0; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Un campo apagado por ley NO es un campo roto: no se atenúa, se
   convierte en renglón de lectura y la regla se enuncia debajo. */
input:disabled, select:disabled {
  opacity: 1; cursor: default;
  background: none; color: var(--muted);
  border-color: transparent; border-bottom: 1px dashed var(--line-firme);
  border-radius: 0; padding-left: 0;
}
select:disabled { background-image: none; }

/* Valor precargado por regla: cursiva y procedencia al lado.
   Al capturarlo pasa a redonda y la marca desaparece. */
input.sugerido, select.sugerido { font-style: italic; color: var(--cy-tinta); }
.origen {
  display: none; font-size: var(--t-xs); letter-spacing: .04em; text-transform: uppercase;
  color: var(--cy-tinta);
}
input.sugerido ~ .origen, select.sugerido ~ .origen { display: block; }

.hint { font-size: var(--t-xs); color: var(--muted); }
.hint.warn { color: var(--mg-tinta); font-weight: 600; }
/* Regla legal enunciada en una línea, con su filete de tinta */
.hint.regla {
  font-size: var(--t-sm); color: var(--ink);
  border-left: 2px solid var(--cy); padding: 2px 0 2px var(--s2); margin-top: 2px;
}

.help-btn {
  width: 22px; height: 22px; flex: none; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line-firme); background: none; color: var(--muted);
  font: inherit; font-size: 11px; line-height: 1; padding: 0;
}
.help-btn[aria-expanded="true"] { background: var(--cy); border-color: var(--cy); color: var(--paper); }
.hint.ondemand { display: none; }
.hint.ondemand.open { display: block; }

label.check {
  display: flex; align-items: center; gap: var(--s2); min-height: 48px;
  padding: 4px 0; font-size: var(--t-md); cursor: pointer;
  border-bottom: 1px solid var(--line);
}
label.check:last-of-type { border-bottom: 0; }
label.check input { flex: none; width: 20px; height: 20px; accent-color: var(--cy); }
label.check.disabled { cursor: default; color: var(--muted); }
label.check.disabled input { opacity: .4; }
.check-label { font-size: var(--t-md); }
.check .art-ref { color: var(--muted); font-size: var(--t-xs); display: block; }
.check .art-ref.regla {
  font-size: var(--t-sm); color: var(--ink);
  border-left: 2px solid var(--cy); padding: 2px 0 2px var(--s2); margin-top: 2px;
}

.subhead {
  font-size: var(--t-xs); font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin: var(--s3) 0 var(--s2);
}
.subhead:first-of-type { margin-top: 0; }

/* Secciones plegadas con etiqueta de estado */
details.extras { border-top: 1px solid var(--line); }
fieldset > details.extras:first-child { border-top: 0; }
details.extras > summary {
  cursor: pointer; font-size: var(--t-lg); font-weight: 600;
  padding: var(--s3) 0; min-height: 48px;
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px;
  list-style: none;
}
details.extras > summary::-webkit-details-marker { display: none; }
details.extras > summary::after {
  content: "+"; margin-left: var(--s2); color: var(--muted); font-size: var(--t-md); width: 1em; text-align: right;
}
details.extras[open] > summary::after { content: "–"; }
details.extras[open] > summary { margin-bottom: var(--s1); }
.chip {
  margin-left: auto; font-size: var(--t-sm); font-weight: 400; color: var(--muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chip.on { color: var(--ink); }
fieldset.off .row, fieldset.off .apro-box, fieldset.off label.check ~ .row { opacity: .55; }

/* Confirmación de la ruta esencial */
.listo {
  display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap;
  margin-top: var(--s3); padding: var(--s2) 0; font-size: var(--t-sm);
  border-top: 1px solid var(--line);
}
.listo .ok-mark { color: var(--cy-tinta); font-weight: 600; }
.listo .cifra { font-weight: 600; font-size: var(--t-lg); font-variant-numeric: tabular-nums; margin-left: auto; }
.listo.pendiente { color: var(--muted); }

/* ── Aprovechamiento: la regla de tramos ───────────────────── */
.apro-box { margin-top: var(--s3); font-size: var(--t-sm); display: grid; gap: var(--s1); }
.apro-line { display: flex; justify-content: space-between; gap: var(--s3); }
.apro-line .v { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.apro-line .v.ok { color: var(--ink); }
.apro-line .v.bad { color: var(--mg-tinta); }
.apro-warn {
  color: var(--mg-tinta); font-weight: 600;
  border-left: 2px solid var(--mg); padding: 2px 0 2px var(--s2);
}

.regla-tramos { margin: var(--s2) 0 var(--s1); }
.regla-marca { display: flex; height: 20px; }
.regla-marca span {
  min-width: fit-content; max-width: 100%;
  display: flex; justify-content: flex-end; white-space: nowrap;
  font-size: var(--t-xs); font-weight: 600; font-variant-numeric: tabular-nums;
}
.regla-barra {
  position: relative; display: flex; height: 26px;
  border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink);
}
.regla-barra > span { display: block; height: 100%; }
/* Distinción por forma antes que por tinta: sobrevive al monocromo. */
.t-base { background: var(--ink); }
.t-inc  { background: repeating-linear-gradient(45deg, var(--cy) 0 4px, var(--cy-suave) 4px 8px); }
.t-no   { background: repeating-linear-gradient(-45deg, var(--mg) 0 3px, var(--mg-suave) 3px 6px); }
.regla-tope { position: absolute; top: -1px; bottom: -1px; width: 2px; background: var(--ink); transform: translateX(-1px); }
.regla-eje {
  display: flex; justify-content: space-between; gap: var(--s3);
  font-size: var(--t-xs); letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); margin-top: 4px;
}
.tramos-key { display: flex; gap: var(--s3); flex-wrap: wrap; font-size: var(--t-xs); color: var(--muted); }
.tramos-key i {
  display: inline-block; width: 22px; height: 10px; margin-right: 5px; vertical-align: -1px;
  border: 1px solid var(--line-firme);
}

/* ══ Panel de desglose ════════════════════════════════════════ */
.receipt { position: sticky; top: var(--s4); }
.receipt-head { display: flex; align-items: baseline; gap: var(--s2); border-bottom: 1px solid var(--ink); padding-bottom: 4px; }
.receipt-head h2 { font-size: var(--t-xs); letter-spacing: .1em; text-transform: uppercase; font-weight: 600; margin: 0; }
.receipt-head .sub { margin-left: auto; font-size: var(--t-xs); color: var(--muted); }

/* La alarma: los metros que no son autorizables, antes que cualquier cifra */
.alerta-noaut {
  display: flex; gap: var(--s3); align-items: center;
  border-top: 3px solid var(--mg); border-bottom: 1px solid var(--line);
  padding: var(--s3) 0; margin-bottom: var(--s3);
}
.alerta-noaut[hidden] { display: none; }
.alerta-noaut .an-txt { font-size: var(--t-sm); color: var(--muted); }
.alerta-noaut .an-tit { font-size: var(--t-md); font-weight: 600; color: var(--ink); line-height: 1.2; }
/* Cifra impresa como planchas de proceso desalineadas: el error de
   registro comunica el error. El número real vive en .paper; las
   planchas son repeticiones ocultas al lector de pantalla. */
.cifra-plancha {
  position: relative; flex: none; width: fit-content; line-height: .9;
  font-weight: 600; font-size: clamp(34px, 11vw, 54px); letter-spacing: -.02em;
  font-variant-numeric: tabular-nums lining-nums;
  background: var(--ground); padding: .12em; margin: -.12em;
}
.cifra-plancha .paper {
  color: var(--ground);
  text-shadow: .036em .025em 0 var(--ground), -.031em -.023em 0 var(--ground);
}
.cifra-plancha .plate { position: absolute; inset: .12em; mix-blend-mode: multiply; }
.cifra-plancha .plate-c { color: #214e62; }
.cifra-plancha .plate-m { color: #a8322a; translate: .036em .025em; }
.cifra-plancha .plate-y { color: #c08a1e; translate: -.031em -.023em; }
/* La plancha se imprime siempre sobre papel, también en tema oscuro:
   las tintas de proceso multiplican, y sobre tinta negra desaparecen. */
.cifra-plancha { --ground: #f3f2f2; }

.receipt-total {
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3);
  border-bottom: 2px solid var(--ink); padding: var(--s2) 0;
}
.receipt-total .t-label { font-size: var(--t-xs); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.receipt-total .t-amount { font-size: 32px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.por-m2 { display: flex; justify-content: space-between; gap: var(--s2); font-size: var(--t-xs); color: var(--muted); padding: 4px 0 var(--s3); }
.por-m2 b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Composición: qué pesa más, antes del detalle */
.composicion { display: grid; gap: 5px; font-size: var(--t-sm); padding-bottom: var(--s3); }
.comp-bar { display: flex; height: 12px; }
.comp-bar .b1 { background: var(--ink); }
.comp-bar .b2 { background: repeating-linear-gradient(45deg, var(--cy) 0 4px, var(--cy-suave) 4px 8px); }
.comp-row { display: flex; justify-content: space-between; gap: var(--s2); }
.comp-row .cv { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

.receipt-body { max-height: 42vh; overflow-y: auto; overscroll-behavior: contain; }
.rgroup {
  display: flex; align-items: baseline; gap: var(--s2);
  font-size: var(--t-xs); font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  border-bottom: 1px solid var(--ink); padding-bottom: 3px; margin-top: var(--s4);
}
.rline {
  display: grid; grid-template-columns: 1fr auto; gap: 0 var(--s3);
  padding: var(--s2) 0; border-bottom: 1px solid color-mix(in srgb, var(--ink) 8%, transparent);
}
.rline .c { font-size: var(--t-sm); }
.rline .f { font-size: var(--t-xs); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); text-align: right; white-space: nowrap; }
.rline .m { font-variant-numeric: tabular-nums; text-align: right; font-size: var(--t-sm); white-space: nowrap; }
/* El volado es la misma marca del mismo aparato, viva donde viva. */
.volado { font-size: .7em; vertical-align: super; color: var(--cy-tinta); font-weight: 600; }
.rline.rsub { border-bottom: 0; }
.rline.rsub .c, .rline.rsub .m { font-size: var(--t-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.empty { color: var(--muted); font-size: var(--t-sm); padding: var(--s4) 0; }

/* Salvedades: aparato de notas del documento */
.notas-aparato { margin-top: var(--s4); }
.notas-aparato[hidden] { display: none; }
.notas-aparato h3 {
  font-size: var(--t-xs); font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  border-bottom: 1px solid var(--ink); padding-bottom: 3px; margin: 0 0 var(--s1);
}
.notas-aparato ol { list-style: none; margin: 0; padding: 0; counter-reset: nota; }
.notas-aparato li {
  display: grid; grid-template-columns: 1.8em 1fr; gap: var(--s1);
  padding: 6px 0; font-size: var(--t-xs); line-height: 1.5; color: var(--muted);
  counter-increment: nota;
}
.notas-aparato li::before { content: counter(nota) "."; font-weight: 600; color: var(--ink); }

.receipt-foot { padding-top: var(--s3); font-size: var(--t-xs); color: var(--muted); }
.btnrow { display: flex; flex-wrap: wrap; gap: var(--s1); margin-top: var(--s2); }
button.act {
  font: inherit; font-size: var(--t-sm); font-weight: 600;
  color: var(--ink); background: none; border: 1px solid var(--line);
  border-radius: var(--r); padding: 0 var(--s3); min-height: 44px; cursor: pointer;
}
button.act:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 7%, transparent); }
button.act:active:not(:disabled) { background: color-mix(in srgb, var(--ink) 14%, transparent); }
button.act.primary { background: var(--cy); border-color: var(--cy); color: var(--paper); }
:root[data-theme="dark"] button.act.primary { color: #14181b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) button.act.primary { color: #14181b; } }
button.act.primary:hover:not(:disabled) { background: var(--cy-tinta); border-color: var(--cy-tinta); }
button.act:disabled { opacity: .45; cursor: not-allowed; }
.guardado { font-size: var(--t-xs); color: var(--faint); padding-top: var(--s2); }

/* ── Notas al pie del municipio ────────────────────────────── */
.notes { margin-top: var(--s6); border-top: 1px solid var(--line); }
.notes > summary { cursor: pointer; font-size: var(--t-sm); font-weight: 600; min-height: 48px; display: flex; align-items: center; list-style: none; }
.notes > summary::-webkit-details-marker { display: none; }
.notes > summary::after { content: "+"; margin-left: var(--s2); color: var(--muted); }
.notes[open] > summary::after { content: "–"; }
.notes ul { margin: 0 0 var(--s3); padding-left: var(--s4); font-size: var(--t-xs); color: var(--muted); }
.notes li { margin-bottom: 6px; }
.notes li strong { color: var(--ink); font-weight: 600; }

/* Pie con la firma corporativa de CEM */
footer.pie {
  margin-top: var(--s8); padding-top: var(--s3); border-top: 1px solid var(--line);
  font-size: var(--t-xs); color: var(--faint); display: grid; gap: 3px; text-align: center;
}
footer.pie .cl {
  font-weight: 700; letter-spacing: .24em; text-transform: uppercase; color: var(--corp);
  font-size: var(--t-xs);
}
footer.pie a { color: var(--cy-tinta); text-underline-offset: 3px; letter-spacing: .1em; }
footer.pie a:hover { color: var(--cy); }

/* ══ Celular ══════════════════════════════════════════════════
   375–430 px, de pie, con una mano ocupada.
   ══════════════════════════════════════════════════════════ */
.sheet-handle { display: none; }
.backdrop { display: none; }

@media (max-width: 900px) {
  /* El documento libera exactamente lo que mide la hoja en reposo,
     que la publica el motor: su altura la dicta su contenido. */
  .wrap { padding: var(--s4) var(--s4) calc(var(--alto-hoja, 340px) + var(--s4)); }
  .grid { grid-template-columns: 1fr; gap: 0; }
  .field, .field.small { flex: 1 1 100%; }
  .row { gap: var(--s3); }
  .marca img { height: 34px; }

  /* El desglose deja de vivir al final del documento: hoja inferior. */
  .receipt {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 40;
    background: var(--paper); border-top: 4px solid var(--cy);
    box-shadow: 0 -6px 28px rgba(0, 0, 0, .18);
    max-height: 94vh; display: flex; flex-direction: column;
    transform: translateY(var(--baja, 0));
    transition: transform .26s cubic-bezier(.32, .72, 0, 1);
    padding: 0 var(--s4) max(var(--s4), env(safe-area-inset-bottom));
  }
  .receipt.media { max-height: 62vh; }
  .receipt.full { max-height: 94vh; }
  /* Con el teclado abierto la hoja se aparta y deja ver el campo. */
  .receipt.teclado { --baja: 120%; }

  .sheet-handle {
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    padding: 8px 0 4px; cursor: grab; touch-action: none; flex: none;
    background: none; border: 0; width: 100%; font: inherit; color: inherit;
  }
  .sheet-handle .bar { width: 44px; height: 4px; border-radius: 2px; background: var(--line-firme); }
  .sheet-handle .lbl { font-size: var(--t-xs); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }

  .receipt-head { display: none; }
  .receipt.media .receipt-head, .receipt.full .receipt-head { display: flex; }
  .receipt-total { padding-top: 0; }
  .receipt-body { max-height: none; flex: 1 1 auto; }
  .receipt:not(.media):not(.full) .receipt-body,
  .receipt:not(.media):not(.full) .composicion,
  .receipt:not(.media):not(.full) .notas-aparato,
  .receipt:not(.media):not(.full) .receipt-foot .desc,
  .receipt:not(.media):not(.full) .guardado { display: none; }
  /* Los metros no autorizables viajan también en la posición asomada. */
  .receipt .alerta-noaut { border-top: 0; padding: var(--s1) 0; margin-bottom: var(--s2); }
  .receipt .alerta-noaut .cifra-plancha { font-size: clamp(30px, 9vw, 40px); }
  .receipt .alerta-noaut .an-txt { display: none; }
  .receipt.media .alerta-noaut .an-txt, .receipt.full .alerta-noaut .an-txt { display: block; }

  .btnrow { display: grid; grid-template-columns: 1fr 1fr; }
  .btnrow button.act { min-height: 48px; font-size: var(--t-md); }
  #shareBtn { grid-column: 1 / -1; }
  #shareBtn:not([hidden]) ~ #pdfBtn { grid-column: auto; }

  .backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .38); z-index: 39;
    opacity: 0; pointer-events: none; transition: opacity .26s; border: 0; padding: 0;
  }
  .backdrop.on { opacity: 1; pointer-events: auto; }

  .alerta-noaut { gap: var(--s2); }
  h1 { font-size: var(--t-lg); }
  .receipt-total .t-amount { font-size: var(--t-xl); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .receipt, .backdrop, .muni-picker, .topbar-actions, .reanudar, .ley-cambio { display: none !important; }
  body { background: #fff; color: #000; }
}
