/* Arancel México — hoja de estilos principal
   Paleta: azul aduanal + acento ámbar de sello. Sin dependencias externas. */

:root {
  --sello: #1e3a5f;
  --sello-dark: #16304f;
  --sello-mid: #2c5282;
  --sello-light: #eef2f7;
  --sello-border: #c3d3e5;
  --acento: #e07b39;

  --grafito: #17202c;
  --grafito-2: #4a5568;
  --grafito-3: #6b7280;

  --lienzo: #ffffff;
  --lienzo-2: #f7f9fb;
  --lienzo-3: #eef2f6;
  --borde: #dfe6ee;
  --borde-2: #cbd5e1;

  --verde: #15803d;
  --verde-bg: #f0fdf4;
  --verde-border: #bbf7d0;

  --azul: #1d4ed8;
  --azul-bg: #eff6ff;
  --azul-border: #bfdbfe;

  --ambar-bg: #fff8ef;
  --ambar-border: #f6d5b0;
  --ambar-ink: #8a4b12;

  --radio: 8px;
  --radio-lg: 12px;
  --ancho: 1120px;
  --lectura: 74ch;

  --letra: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --titulares: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --monoespaciada: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--letra);
  font-size: 16px;
  line-height: 1.65;
  color: var(--grafito);
  background: var(--lienzo);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.28; margin: 0 0 .5em; font-weight: 600; letter-spacing: -.005em; font-family: var(--titulares); }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; margin-top: 2em; }
h3 { font-size: 1.1rem; margin-top: 1.6em; }
p { margin: 0 0 1em; }

.recinto { width: 100%; max-width: var(--ancho); margin: 0 auto; padding: 0 20px; }

.brinca {
  position: absolute; left: -9999px; top: 0; background: var(--sello); color: #fff;
  padding: 10px 16px; z-index: 100; border-radius: 0 0 var(--radio) 0;
}
.brinca:focus { left: 0; }

/* ---------- Cabecera ----------
   Escritorio: marca + fila horizontal de secciones.
   Móvil con JS: botón hamburguesa + panel desplegable a pantalla completa.
   Móvil sin JS: la fila se envuelve (nunca queda inaccesible). */
.frontis {
  border-bottom: 1px solid var(--borde);
  background: var(--lienzo);
  position: sticky; top: 0; z-index: 60;
}
.frontis > .recinto { display: flex; align-items: center; gap: 12px; min-height: 60px; position: relative; }

.firma { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.06rem; color: var(--grafito); letter-spacing: -.02em; flex: none; }
.firma:hover { text-decoration: none; }
.firma-impronta {
  width: 26px; height: 26px; border-radius: 6px; background: var(--sello);
  display: grid; place-items: center; flex: none;
}
.firma-impronta span { width: 12px; height: 12px; border: 2px solid #fff; border-radius: 2px; display: block; }
.firma b { color: var(--sello-dark); }

/* --- Botón hamburguesa: solo existe si hay JS y la pantalla es angosta --- */
.pulsador-cuadricula {
  display: none; margin-left: auto; padding: 0; flex: none;
  width: 42px; height: 42px;
  align-items: center; justify-content: center;
  border: 1px solid var(--borde-2); border-radius: 9px;
  background: var(--lienzo); color: var(--grafito); cursor: pointer;
}
.pulsador-cuadricula:hover { background: var(--lienzo-3); }
.pulsador-cuadricula:focus-visible { outline: 2px solid var(--sello-mid); outline-offset: 2px; }
.cuadricula-icono { display: block; position: relative; width: 20px; height: 14px; }
.cuadricula-icono i {
  position: absolute; left: 0; right: 0; height: 2px; border-radius: 2px;
  background: currentColor; transition: transform .18s ease, opacity .18s ease;
}
.cuadricula-icono i:nth-child(1) { top: 0; }
.cuadricula-icono i:nth-child(2) { top: 6px; }
.cuadricula-icono i:nth-child(3) { top: 12px; }
.pulsador-cuadricula[aria-expanded="true"] .cuadricula-icono i:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.pulsador-cuadricula[aria-expanded="true"] .cuadricula-icono i:nth-child(2) { opacity: 0; }
.pulsador-cuadricula[aria-expanded="true"] .cuadricula-icono i:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Velo que cubre la página mientras el panel está abierto */
.cortina {
  display: none; position: absolute; top: 100%; left: 0; right: 0;
  height: 100vh; height: 100dvh;
  background: rgba(28, 25, 23, .42); z-index: 1;
}

.ruta { margin-left: auto; }
.ruta-lista { list-style: none; display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin: 0; padding: 0; }
.ruta-lista a {
  display: block; color: var(--grafito-2); font-size: .9rem;
  padding: 7px 11px; border-radius: 7px; white-space: nowrap;
}
.ruta-lista a:hover { background: var(--lienzo-3); color: var(--grafito); text-decoration: none; }
.ruta-lista a[aria-current] { color: var(--sello-dark); background: var(--sello-light); font-weight: 600; }

@media (max-width: 899px) {
  .js .pulsador-cuadricula { display: inline-flex; }

  /* El panel se ancla al borde inferior de la cabecera y ocupa todo el ancho */
  .js .ruta {
    display: none; position: absolute; top: 100%; left: -20px; right: -20px;
    z-index: 2; margin-left: 0;
    padding: 8px 12px 14px;
    background: var(--lienzo);
    border-top: 1px solid var(--borde);
    border-bottom: 1px solid var(--borde);
    box-shadow: 0 20px 34px -20px rgba(28, 25, 23, .5), 0 1px 3px rgba(28, 25, 23, .1);
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .js .ruta.abierto { display: block; }
  .js.menu-abierto .cortina { display: block; }
  .js.menu-abierto body { overflow: hidden; }

  .js .ruta-lista { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 0; }
  .js .ruta-lista li:not(:last-child) { border-bottom: 1px solid var(--borde); }
  .js .ruta-lista a {
    display: flex; align-items: center; min-height: 48px;
    padding: 11px 14px; font-size: .98rem; border-radius: 8px;
    white-space: normal;
  }
  .js .ruta-lista a[aria-current] { background: var(--sello-light); box-shadow: inset 3px 0 0 var(--sello); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cuadricula-icono i { transition: none; }
}

/* Los enlaces a anclas no deben quedar tapados por la cabecera fija */
[id] { scroll-margin-top: 74px; }

/* ---------- Miga de pan ---------- */
.estela { font-size: .82rem; color: var(--grafito-3); padding: 14px 0 0; }
.estela ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.estela li::after { content: "/"; margin-left: 6px; color: var(--borde-2); }
.estela li:last-child::after { content: ""; }
.estela a { color: var(--grafito-3); }

/* ---------- Hero ---------- */
.vitrina { padding: 42px 0 30px; border-bottom: 1px solid var(--borde); background: linear-gradient(180deg, var(--sello-light), var(--lienzo)); }
.vitrina h1 { font-size: 2.15rem; max-width: 22ch; }
.vitrina .entradilla { font-size: 1.08rem; color: var(--grafito-2); max-width: 62ch; margin-bottom: 0; }
.vitrina-marbetes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.marbete {
  font-size: .8rem; color: var(--sello-dark); background: var(--lienzo);
  border: 1px solid var(--sello-border); padding: 4px 11px; border-radius: 999px; font-weight: 500;
}

/* ---------- Secciones ---------- */
.tramo { padding: 40px 0; }
.tramo > .recinto > h2:first-child { margin-top: 0; }
.tramo-titulo { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.tramo-titulo h2 { margin: 0; }
.tramo-titulo p { margin: 0; color: var(--grafito-2); font-size: .92rem; }

/* ---------- Rejilla de herramientas ---------- */
.cuadricula { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .cuadricula { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 940px) { .cuadricula { grid-template-columns: repeat(3, 1fr); } }

.partida {
  display: block; border: 1px solid var(--borde); border-radius: var(--radio-lg);
  padding: 18px; background: var(--lienzo); color: inherit; transition: border-color .15s, transform .15s;
}
.partida:hover { text-decoration: none; border-color: var(--sello-border); transform: translateY(-2px); }
.partida h3 { margin: 0 0 6px; font-size: 1.02rem; color: var(--sello-dark); }
.partida p { margin: 0; font-size: .89rem; color: var(--grafito-2); line-height: 1.55; }
.partida .ruta-url { margin-top: 10px; font-size: .77rem; color: var(--grafito-3); font-family: var(--monoespaciada); }

/* ---------- Panel calculadora ---------- */
.despacho {
  border: 1px solid var(--borde-2); border-radius: var(--radio-lg); overflow: hidden;
  background: var(--lienzo); margin: 26px 0 8px;
}
.despacho-titulo {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  background: var(--lienzo-3); border-bottom: 1px solid var(--borde);
  font-size: .88rem; font-weight: 600; color: var(--grafito-2);
}
.despacho-titulo .senal { width: 8px; height: 8px; border-radius: 50%; background: var(--sello-mid); flex: none; }
.despacho-cuerpo { display: grid; grid-template-columns: 1fr; }
@media (min-width: 840px) { .despacho-cuerpo { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

.despacho-capturas { padding: 20px 18px; border-bottom: 1px solid var(--borde); }
@media (min-width: 840px) { .despacho-capturas { border-bottom: 0; border-right: 1px solid var(--borde); } }

.casilla { margin-bottom: 15px; }
.casilla:last-child { margin-bottom: 0; }
.casilla label { display: block; font-size: .84rem; font-weight: 600; color: var(--grafito-2); margin-bottom: 5px; }
.casilla .nota { font-size: .76rem; color: var(--grafito-3); font-weight: 400; display: block; margin-top: 5px; }

.casilla-grupo { border: 0; padding: 0; margin: 0 0 15px; }
.casilla-grupo legend { display: block; font-size: .84rem; font-weight: 600; color: var(--grafito-2); margin-bottom: 5px; padding: 0; }
.casilla-grupo .nota { font-size: .76rem; color: var(--grafito-3); display: block; margin-top: 5px; }

.captura, .lista {
  width: 100%; padding: 9px 11px; font-family: inherit; font-size: .95rem;
  border: 1px solid var(--borde-2); border-radius: 8px; background: var(--lienzo); color: var(--grafito);
}
.captura:focus, .lista:focus { outline: 2px solid var(--sello-mid); outline-offset: -1px; border-color: var(--sello-mid); }

.dos-columnas { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.verifica { display: flex; align-items: flex-start; gap: 9px; font-size: .87rem; color: var(--grafito-2); margin-bottom: 11px; }
.verifica:last-child { margin-bottom: 0; }
.verifica input { margin: 3px 0 0; width: 16px; height: 16px; flex: none; accent-color: var(--sello); }

.despacho-salida { padding: 20px 18px; background: var(--lienzo-2); }
.resultado {
  background: var(--lienzo); border: 1px solid var(--verde-border); border-radius: var(--radio);
  padding: 15px 16px; margin-bottom: 16px;
}
.resultado .leyenda { font-size: .77rem; text-transform: uppercase; letter-spacing: .05em; color: var(--grafito-3); font-weight: 600; }
.resultado .importe { font-size: 1.85rem; font-weight: 700; color: var(--verde); line-height: 1.15; margin-top: 3px; }
.resultado .pormenor { font-size: .84rem; color: var(--grafito-2); margin-top: 3px; }

.liquidacion { width: 100%; border-collapse: collapse; font-size: .88rem; background: var(--lienzo); }
.liquidacion caption { text-align: left; font-size: .77rem; text-transform: uppercase; letter-spacing: .05em; color: var(--grafito-3); font-weight: 600; padding-bottom: 7px; }
.liquidacion th, .liquidacion td { padding: 8px 10px; border-bottom: 1px solid var(--borde); text-align: left; }
.liquidacion th { font-size: .78rem; color: var(--grafito-3); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.liquidacion td:last-child, .liquidacion th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.liquidacion tbody tr:last-child td { border-bottom: 0; }
.liquidacion .concepto { font-weight: 600; color: var(--grafito); }
.liquidacion .acotacion { display: block; font-size: .76rem; color: var(--grafito-3); font-weight: 400; }

.acciones { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.pulsador {
  font: inherit; font-size: .87rem; font-weight: 600; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--borde-2); background: var(--lienzo); color: var(--grafito-2); cursor: pointer;
}
.pulsador:hover { background: var(--lienzo-3); }
.pulsador-principal { background: var(--sello); border-color: var(--sello); color: #fff; }
.pulsador-principal:hover { background: var(--sello-dark); }

/* ---------- Prosa ---------- */
.redaccion { max-width: var(--lectura); }
.redaccion h2 + p, .redaccion h3 + p { margin-top: .2em; }
.redaccion ul, .redaccion ol { padding-left: 1.3em; margin: 0 0 1em; }
.redaccion li { margin-bottom: .35em; }
.redaccion strong { font-weight: 650; }

.comprobante {
  font-family: var(--monoespaciada); font-size: .86rem; background: var(--lienzo-3);
  border-left: 3px solid var(--sello-mid); border-radius: 0 8px 8px 0;
  padding: 12px 15px; margin: 0 0 1.2em; overflow-x: auto; line-height: 1.7;
}

/* ---------- Tablas de datos ---------- */
.tabla-fracciones { width: 100%; border-collapse: collapse; font-size: .88rem; margin: 0 0 1.4em; }
.tabla-fracciones caption { text-align: left; font-size: .82rem; color: var(--grafito-3); padding-bottom: 8px; }
.tabla-fracciones th, .tabla-fracciones td { padding: 9px 11px; border: 1px solid var(--borde); text-align: left; vertical-align: top; }
.tabla-fracciones thead th { background: var(--lienzo-3); font-size: .8rem; color: var(--grafito-2); font-weight: 650; }
.tabla-fracciones tbody tr:nth-child(even) { background: var(--lienzo-2); }
.tabla-fracciones td.numerico { font-variant-numeric: tabular-nums; white-space: nowrap; }
.desliza-tabla { overflow-x: auto; margin-bottom: 1.4em; }
.desliza-tabla .tabla-fracciones { margin-bottom: 0; min-width: 520px; }

/* ---------- Avisos ---------- */
.advertencia {
  border: 1px solid var(--azul-border); background: var(--azul-bg);
  border-radius: var(--radio); padding: 14px 16px; margin: 0 0 1.4em; font-size: .91rem; color: #1e3a8a;
}
.advertencia p:last-child { margin-bottom: 0; }
.advertencia strong { font-weight: 650; }
.advertencia.alerta { border-color: var(--ambar-border); background: var(--ambar-bg); color: var(--ambar-ink); }
.advertencia.confirmado { border-color: var(--verde-border); background: var(--verde-bg); color: #14532d; }

/* ---------- FAQ ---------- */
.dudas-arancel { max-width: var(--lectura); }
.dudas-arancel details { border-bottom: 1px solid var(--borde); }
.dudas-arancel summary {
  cursor: pointer; padding: 14px 30px 14px 0; font-weight: 600; font-size: .97rem;
  list-style: none; position: relative; color: var(--grafito);
}
.dudas-arancel summary::-webkit-details-marker { display: none; }
.dudas-arancel summary::after {
  content: "+"; position: absolute; right: 4px; top: 12px; font-size: 1.25rem;
  font-weight: 400; color: var(--sello-mid); line-height: 1;
}
.dudas-arancel details[open] summary::after { content: "\2212"; }
.dudas-arancel .contestacion { padding: 0 0 16px; font-size: .93rem; color: var(--grafito-2); max-width: 68ch; }
.dudas-arancel .contestacion p:last-child { margin-bottom: 0; }

/* ---------- Enlaces relacionados ---------- */
.anexos { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .anexos { grid-template-columns: repeat(2, 1fr); } }
.anexo {
  display: block; border: 1px solid var(--borde); border-left: 3px solid var(--sello-mid);
  border-radius: 8px; padding: 13px 15px; color: inherit; background: var(--lienzo-2);
}
.anexo:hover { text-decoration: none; background: var(--sello-light); border-color: var(--sello-border); border-left-color: var(--sello); }
.anexo b { display: block; font-size: .93rem; color: var(--sello-dark); }
.anexo span { font-size: .82rem; color: var(--grafito-3); }

/* ---------- Espacios publicitarios (marcadores) ---------- */
.banda-proveedor {
  border: 1px dashed var(--borde-2); border-radius: var(--radio); background: var(--lienzo-2);
  padding: 18px; text-align: center; color: var(--grafito-3); font-size: .8rem; margin: 28px 0;
}
.banda-proveedor b { display: block; font-size: .85rem; color: var(--grafito-2); font-weight: 600; margin-bottom: 3px; }

/* ---------- Pie ---------- */
.cierre { border-top: 1px solid var(--borde); background: var(--lienzo-2); margin-top: 50px; padding: 40px 0 26px; font-size: .87rem; }
.cierre-rejilla { display: grid; gap: 26px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .cierre-rejilla { grid-template-columns: 1.4fr 1fr 1fr; } }
.cierre h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--grafito-3); margin-bottom: 10px; }
.cierre ul { list-style: none; margin: 0; padding: 0; }
.cierre li { margin-bottom: 6px; }
.cierre a { color: var(--grafito-2); }
.cierre-nota { border-top: 1px solid var(--borde); margin-top: 28px; padding-top: 18px; color: var(--grafito-3); font-size: .8rem; }
.cierre-nota p { margin-bottom: .6em; }

/* ---------- Utilidades ---------- */
.fecha-revision { font-size: .82rem; color: var(--grafito-3); border-top: 1px solid var(--borde); padding-top: 12px; margin-top: 34px; }
.fecha-revision b { color: var(--grafito-2); font-weight: 600; }
.texto-oculto {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
main { display: block; }
