@font-face { font-family: "Barlow"; font-weight: 400; src: url("fonts/Barlow-Regular.ttf"); }
@font-face { font-family: "Barlow"; font-weight: 500; src: url("fonts/Barlow-Medium.ttf"); }
@font-face { font-family: "Barlow"; font-weight: 600; src: url("fonts/Barlow-SemiBold.ttf"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; src: url("fonts/BarlowCondensed-SemiBold.ttf"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; src: url("fonts/BarlowCondensed-Bold.ttf"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-style: italic; src: url("fonts/BarlowCondensed-BoldItalic.ttf"); }

:root {
  --navy: #013477; --navy-deep: #031B3C; --red: #BC1416; --ink: #0E1A2C; --muted: #56627A;
  --line: #DDE3ED; --mist: #F2F5FA; --bg: #F5F7FB; --card: #fff; --ok: #1F7A4D; --warn: #A15C00;
  --display: "Barlow Condensed", "Arial Narrow", Arial, sans-serif; --body: "Barlow", "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--body); }
a { color: var(--navy); }
/* Mayúscula itálica condensada solo en el título de página (h1) y en el login; secciones en Barlow normal (D19) */
h1, h2, h3 { color: var(--navy); margin: 0; }
h1 { font-family: var(--display); font-weight: 700; font-style: italic; text-transform: uppercase;
  font-size: clamp(24px, 1.6vw + 16px, 30px); line-height: 1.1; text-wrap: balance; }
h2, h3 { font-family: var(--body); font-weight: 600; line-height: 1.2; }
h2 { font-size: 19px; } h3 { font-size: 16px; }

/* Barra superior */
.top { background: var(--navy-deep); color: #fff; display: flex; align-items: center; gap: 22px; padding: 0 24px; height: 60px; position: sticky; top: 0; z-index: 20; }
.top img { height: 34px; }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { color: #C2D3EC; text-decoration: none; padding: 8px 12px; border-radius: 6px; font-weight: 500; }
.top nav a.on, .top nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.top .yo { font-size: 13px; color: #C2D3EC; display: flex; gap: 12px; align-items: center; }
.top .yo a { color: #fff; }
.stripe { height: 4px; background: linear-gradient(90deg, var(--red) 0 38%, var(--navy) 38% 60%, transparent 60%); }

main { max-width: 1240px; margin: 0 auto; padding: 24px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.sub { color: var(--muted); margin-top: 2px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  /* Teléfono: el menú baja a su propia fila y se desliza de lado */
  .top { flex-wrap: wrap; height: auto; padding: 8px 16px 0; gap: 4px 16px; }
  .top .yo { margin-left: auto; }
  .top nav { order: 3; flex: 1 0 100%; overflow-x: auto; padding-bottom: 6px; }
  .top nav a { white-space: nowrap; }
}

.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; }
.kpi small { display: block; font-family: var(--display); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; font-size: 12px; color: var(--muted); }
.kpi b { font-family: var(--display); font-weight: 700; font-size: 30px; color: var(--navy); }
a.kpi { display: block; color: inherit; text-decoration: none; }
a.kpi:hover { border-color: var(--navy); }
a.kpi:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.kpi .nota { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.kpi.alerta .nota { color: var(--red); }
.kpi.dark .nota { color: #fff; }
.head .acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.kpi.alerta b { color: var(--red); } .kpi.dark { background: var(--navy); border-color: var(--navy); } .kpi.dark b, .kpi.dark small { color: #fff; }

/* Formularios */
label, legend { display: block; font-family: var(--body); font-weight: 500; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid #CBD3E1; border-radius: 7px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 3px solid #5A86C8; outline-offset: 0; border-color: var(--navy); }
input[type=checkbox], input[type=radio] { width: auto; }
.radios { display: flex; gap: 16px; align-items: center; padding: 8px 0; }
.radios label { display: flex; gap: 6px; align-items: center; text-transform: none; letter-spacing: 0; font-family: var(--body); font-size: 14px; color: var(--ink); margin: 0; font-weight: 500; }
.campo { min-width: 0; }
.ayuda { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.pista { font-size: 13px; color: var(--navy); background: var(--mist); border-radius: 6px; padding: 5px 9px; margin-top: 6px; }
.pista button { margin-left: 6px; }
.aviso-monto { font-size: 13px; color: #7A4A00; background: #FFF4DC; border-left: 3px solid #E0A100; border-radius: 6px; padding: 5px 9px; margin-top: 6px; }
.placa { font-size: 12.5px; color: var(--ok); margin-top: 4px; font-weight: 600; }

/* Botones */
.btn, .mas, .seg label { transition: background-color 120ms ease-out, transform 100ms ease-out; }
.btn:active, .mas:active { transform: scale(.97); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--navy); background: var(--navy); color: #fff; padding: 9px 16px; border-radius: 7px; font: 600 14px var(--body); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--navy-deep); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .6; cursor: progress; }
.btn.sec { background: #fff; color: var(--navy); } .btn.sec:hover { background: var(--mist); }
.btn.rojo { background: var(--red); border-color: var(--red); } .btn.peq { padding: 5px 10px; font-size: 13px; }
.btn.link { background: none; border: 0; color: var(--navy); padding: 4px 6px; text-decoration: underline; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; }

/* Tablas */
table.t { width: 100%; border-collapse: collapse; background: #fff; }
table.t th { text-align: left; font-family: var(--display); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: 12px; color: #fff; background: var(--navy); padding: 9px 10px; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
table.t tr:hover td { background: #FAFCFE; }
table.t .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cod { white-space: nowrap; }
table.t td.cod, table.t td.nw, table.t td.col-editar, table.t td.num { white-space: nowrap; overflow-wrap: normal; }
table.t td.det { min-width: 16em; }
.resumen { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 380px; }
.srv { display: flex; justify-content: space-between; gap: 12px; }
.srv + .srv { border-top: 1px dotted var(--line); margin-top: 3px; padding-top: 3px; }
.srv .m { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.desliza { overflow-x: auto; }
.paginas { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 16px 0 4px; flex-wrap: wrap; }
.paginas .donde { color: var(--muted); font-variant-numeric: tabular-nums; }
.paginas [aria-disabled="true"] { opacity: .45; cursor: default; pointer-events: none; }
.wrap-t { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }

.chip { display: inline-block; white-space: nowrap; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.chip.borrador { background: #FFF3DC; color: var(--warn); } .chip.emitida { background: #E6F3EC; color: var(--ok); }
.chip.anulada { background: #FBE7E7; color: var(--red); } .chip.vencida { background: #FBE7E7; color: var(--red); }
.chip.pendiente { background: #E6EEF9; color: var(--navy); } .chip.pagada { background: #E6F3EC; color: var(--ok); }
.chip.abonada { background: #FFF3DC; color: var(--warn); }
.dias-v { color: var(--red); font-weight: 700; }

/* Selector segmentado: radios nativos visibles como botones (guía forms/forms.md: 2 a 5 opciones excluyentes) */
.seg { display: inline-flex; border: 1px solid #CBD3E1; border-radius: 8px; overflow: hidden; background: #fff; vertical-align: middle; }
.seg label { position: relative; margin: 0; padding: 8px 16px; cursor: pointer; font: 600 14px var(--body); text-transform: none;
  letter-spacing: 0; color: var(--navy); border-right: 1px solid #CBD3E1; white-space: nowrap; }
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--navy); color: #fff; }
.seg label:has(input:focus-visible) { outline: 3px solid var(--navy); outline-offset: -3px; }
.seg label:has(input:checked):has(input:focus-visible) { outline-color: #5A86C8; }
.seg.peq label { padding: 5px 11px; font-size: 13px; }
.condicion { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.condicion .dias { width: 110px; }

.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; margin: 0; padding: 0; }

/* Pestañas de una sección */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 9px 16px; text-decoration: none; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a[aria-current=page] { color: var(--navy); border-bottom-color: var(--red); }

/* Historial: mostrar solo los campos del período elegido (sin JS) */
.filtro-historial:has(input[name=modo][value=mes]:checked) .solo-rango,
.filtro-historial:has(input[name=modo][value=rango]:checked) .solo-mes { display: none; }

/* Pagos: monto por factura */
.aplicar { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.aplicar .slot { width: 130px; flex: none; text-align: right; }
.aplicar .slot input { width: 130px; }
.aplicar .fijo { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ok); }
.seg label:has(input[value=no]:checked) { background: var(--mist); color: var(--muted); }

.flash { padding: 11px 15px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.flash.ok { background: #E6F3EC; color: var(--ok); } .flash.error { background: #FBE7E7; color: var(--red); }

/* Factura: líneas */
.linea { border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; background: #fff; }
.linea.adicional { border-left-color: var(--red); } .linea.alquiler { border-left-color: #3D78C2; }
.linea-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.linea-head .tag { font-weight: 600; color: var(--navy); font-size: 16px; }
.linea-total { font-family: var(--display); font-weight: 700; font-size: 20px; color: var(--navy); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* #12: la cabeza del traslado es un botón que contrae la línea a un resumen de una fila (guía ui-components/accordion.md:
   flecha antes del rótulo, girada cuando está contraída). */
.linea-abrir { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; margin: -6px -8px; padding: 6px 8px;
  border: 0; border-radius: 7px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.linea-abrir:hover { background: var(--mist); }
.linea-abrir::before { content: ""; flex: none; width: 12px; height: 12px; background: var(--navy);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23000' stroke-width='1.8'/%3E%3C/svg%3E") no-repeat center / contain; }
.linea-abrir[aria-expanded="false"]::before { rotate: -90deg; }
.linea-abrir .tag { flex: none; }
.linea-resumen { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.linea-abrir[aria-expanded="true"] .linea-resumen { display: none; }
.linea-abrir .linea-total { margin-left: auto; }
/* D5: "Quitar" discreto y separado del total; la línea quitada deja un aviso con "Deshacer" */
.linea-head [data-quitar] { margin-left: 16px; color: var(--muted); flex: none; }
.linea-head [data-quitar]:hover { color: var(--red); }
.linea-quitada { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 1px dashed #CBD3E1;
  border-radius: 10px; padding: 8px 16px; margin-bottom: 12px; color: var(--muted); overflow-wrap: anywhere; }
.linea-quitada .btn.link { flex: none; font-weight: 600; }
.linea.contraida { padding-block: 10px; }
.linea.contraida .linea-head { margin-bottom: 0; }
@media (max-width: 600px) {
  /* Teléfono: el resumen baja a su propio renglón (hasta dos) para que se lean el origen y el destino. */
  .linea-abrir { flex-wrap: wrap; row-gap: 2px; }
  .linea.contraida .linea-head { align-items: flex-start; }
  .linea-resumen { order: 1; flex-basis: 100%; padding-left: 22px; white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
}
.fila { display: grid; gap: 12px; margin-bottom: 10px; }
.f-traslado1 { grid-template-columns: 190px minmax(0, 1fr) minmax(0, 1fr); }
/* D20: el conductor va en la fila del equipo y la carta porte en la de la carga; las columnas ocultas
   (furgón, temperatura) no dejan hueco porque la fila reparte el ancho entre las que se ven. */
.f-equipo, .f-carga { display: flex; gap: 12px; }
.f-equipo > *, .f-carga > * { flex: 1 1 0; min-width: 0; }
.f-carga > .c-tipo { flex: 0 0 160px; }
.sub-contenedor { grid-template-columns: 120px minmax(0, 1fr); margin: 8px 0 0; }
.cp { display: flex; gap: 10px; align-items: center; }
.cp .radios { flex: none; }
.cp input { flex: 1; min-width: 0; }
.f-final { grid-template-columns: minmax(0, 1fr) 180px auto; margin-bottom: 0; }
.f-final [name=precio] { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
/* D12: "Siguiente tramo desde aquí" en la última fila (pie de la línea), lejos de "Quitar" */
.linea-pie { display: flex; align-items: flex-end; }
.linea-pie .btn { min-height: 42px; }
.f-simple { grid-template-columns: 170px minmax(0, 1fr) minmax(0, 1fr) 110px 150px; }
@media (max-width: 900px) {
  .f-traslado1, .f-final, .f-simple { grid-template-columns: minmax(0, 1fr); }
  .f-equipo, .f-carga { flex-direction: column; }
  .f-equipo > *, .f-carga > *, .f-carga > .c-tipo { flex: none; }
}
.con-boton { display: flex; gap: 6px; } .con-boton select { flex: 1; min-width: 0; }
.mas { border: 1px dashed var(--navy); background: #fff; color: var(--navy); border-radius: 7px; padding: 0 10px; cursor: pointer; font-weight: 700; font-size: 16px; }
.mas:hover { background: var(--mist); }
.barra-total { position: sticky; bottom: 0; background: var(--navy-deep); color: #fff; border-radius: 10px; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 10px; }
.barra-total b { font-family: var(--display); font-weight: 700; font-size: 28px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.barra-total .conteo { color: #C2D3EC; white-space: nowrap; }
.barra-total .suma { min-width: 0; }
/* El resto del texto del botón sigue al "Guardar" como un solo texto (el botón es flex: sin esto quedaría como otro elemento). */
.solo-ancho { display: contents; }
/* D13: en el teléfono la barra superior se va con la página y la barra del total es una franja compacta pegada abajo,
   con el área segura del equipo; el botón dice solo "Guardar". */
@media (max-width: 900px) {
  .top { position: static; }
  .barra-total { margin: 10px -24px 0; border-radius: 0; gap: 10px; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); }
  .barra-total .suma { line-height: 1.1; }
  .barra-total b { font-size: 22px; }
  .barra-total .conteo { display: block; font-size: 12.5px; }
  .barra-total .acciones { flex-wrap: nowrap; }
  .barra-total .btn { padding-inline: 12px; }
  .solo-ancho { display: none; }
}
.barra-total .btn { background: #fff; color: var(--navy); border-color: #fff; } .barra-total .btn.sec { background: transparent; color: #fff; }
.agregar { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }

/* Ventana modal (+ agregar) */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(3,27,60,.3); }
dialog::backdrop { background: rgba(3,27,60,.45); }
dialog form { padding: 20px 22px; }
dialog h3 { margin-bottom: 14px; }
dialog .grid { margin-bottom: 14px; }
.error-modal { color: var(--red); font-weight: 500; margin-bottom: 10px; }

.vista { width: 100%; height: 1100px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.login { max-width: 380px; margin: 9vh auto; }
.login .card { padding: 28px; }
.login img { height: 46px; display: block; margin: 0 auto 12px; }
.login h1 { color: #fff; text-align: center; margin-bottom: 18px; }
.muted { color: var(--muted); }

/* Accesibilidad (guías: references/modern-web/accessibility/accessibility.md y forms/required-field-feedback.md) */
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
:where(a, button, summary, [tabindex]:not([tabindex="-1"])):focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
:where(.top, .barra-total, .login .card) :where(a, button):focus-visible { outline-color: #fff; }
input:is([type=checkbox], [type=radio]):focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }

/* Errores junto al campo: borde, fondo y texto (no solo color) */
:is(input, select, textarea):is(:user-invalid, [aria-invalid="true"]) { border-color: var(--red); background: #FFF6F6; }
.error-campo { display: flex; gap: 6px; align-items: baseline; color: var(--red); font-size: 13px; font-weight: 500; margin-top: 4px; }
.error-campo::before { content: "!" / ""; flex: none; display: inline-grid; place-items: center; width: 16px; height: 16px;
  border-radius: 50%; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; }
.linea.con-error { border-left-color: var(--red); box-shadow: 0 0 0 1px var(--red); }

/* P1-seguridad */
.top .yo .salir { display: inline; margin: 0; }
.top .yo .salir button { all: unset; cursor: pointer; color: #fff; text-decoration: underline; font-size: 13px; }
.top .yo .salir button:hover { text-decoration: none; }
.top .yo .salir button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.login .recordarme { display: flex; gap: 8px; align-items: center; color: #C2D3EC; font-size: 13px; letter-spacing: normal; text-transform: none; font-weight: 500; }

/* P4-estilo */
.card.grid > .btn { justify-self: start; }
.chip::first-letter { text-transform: uppercase; }

/* Tablas apiladas en el teléfono (D6): cada fila es una tarjeta con el dinero a la vista */
@media (max-width: 600px) {
  .t.apilada thead { display: none; }
  .t.apilada, .t.apilada tbody { display: block; }
  .t.apilada tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .t.apilada td { display: block; padding: 0; border: 0; min-width: 0; }
  .t.apilada td:empty { display: none; }
  .t.apilada td.num { text-align: right; }
  .t.apilada td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12.5px; font-weight: 400; }
  .t.apilada .resumen { max-width: none; }
  .t.f-lista tbody tr { grid-template-areas: "fac est" "cli saldo" "fecha total" "srv srv"; }
  .t.f-pagos tbody tr { grid-template-areas: "fecha monto" "cli sin" "met met" "apl apl" "del del"; }
  .a-fac { grid-area: fac; } .a-estado { grid-area: est; text-align: right; } .a-cli { grid-area: cli; } .a-saldo { grid-area: saldo; }
  .a-fecha { grid-area: fecha; color: var(--muted); } .a-total { grid-area: total; } .a-srv { grid-area: srv; }
  .a-monto { grid-area: monto; } .a-sin { grid-area: sin; } .a-met { grid-area: met; } .a-apl { grid-area: apl; } .a-del { grid-area: del; }
  .col-editar { display: none; }
}

/* Teléfono: indicadores de dos en dos y menú con borde que sugiere que se desliza (D10, D11) */
@media (max-width: 900px) {
  .grid:has(> .kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi b { font-size: 24px; }
  .top nav.desborda { mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
}

/* Listas y detalles (#10, #14) */
.filtros { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.suma-filtro { margin: 10px 2px 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.suma-filtro b { color: var(--navy); }
.kpi.enlace { transition: border-color 120ms ease-out, box-shadow 120ms ease-out; }
.kpi.enlace::after { content: "Abrir ›"; display: block; margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--navy); }
.kpi.enlace:hover { border-color: var(--navy); box-shadow: 0 2px 10px rgba(1,52,119,.14); }
.btn.sec.peligro { color: var(--red); border-color: var(--red); }
.btn.sec.peligro:hover { background: #FBE7E7; }

/* P5-formulario */
/* Campo que ocupa dos columnas en escritorio y una sola cuando la cuadrícula se apila (D1). */
.ancho-2 { grid-column: span 2; }
@media (max-width: 900px) {
  .ancho-2 { grid-column: auto; }
}
/* Búsqueda en ubicaciones y conductores (#11): campo con lista filtrada (combobox) */
.busca { position: relative; flex: 1; min-width: 0; }
.busca input[data-busca] { padding-right: 32px; background-repeat: no-repeat; background-position: right 11px center; background-size: 12px 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23291A6B' stroke-width='1.6'/%3E%3C/svg%3E"); }
.opciones { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; max-height: min(264px, 50vh); overflow-y: auto;
  overscroll-behavior: contain; margin: 0; padding: 4px; list-style: none; background: #fff; border: 1px solid #CBD3E1; border-radius: 8px;
  box-shadow: 0 10px 30px rgba(3,27,60,.18); }
.opciones li { padding: 8px 10px; border-radius: 6px; cursor: pointer; overflow-wrap: anywhere; }
.opciones li:hover { background: var(--mist); }
.opciones li.actual { font-weight: 600; }
.opciones li[aria-selected="true"] { background: var(--navy); color: #fff; }
/* "Sin coincidencias": región de estado siempre presente (lector de pantalla); vacía no ocupa lugar. */
.sin-coincidencias { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; padding: 10px 12px; color: var(--muted);
  background: #fff; border: 1px solid #CBD3E1; border-radius: 8px; box-shadow: 0 10px 30px rgba(3,27,60,.18); overflow-wrap: anywhere; }
.sin-coincidencias:empty { padding: 0; border: 0; box-shadow: none; }
@media (pointer: coarse) { .opciones li { padding: 11px 12px; } }
@media (forced-colors: active) { .opciones li[aria-selected="true"] { outline: 2px solid Highlight; } }

/* P6-deshacer */
/* Aviso con acción: "Borrador #13 eliminado · Deshacer" (el botón es un formulario POST con CSRF) */
.flash.con-accion form { display: inline-flex; align-items: baseline; gap: 6px; margin: 0 0 0 6px; white-space: nowrap; }
.flash.con-accion .sep { font-weight: 400; }
.flash.con-accion .btn.link { padding: 0 2px; color: inherit; font-weight: 700; }
/* Facturas > Eliminados en el teléfono */
@media (max-width: 600px) {
  .t.f-eliminados tbody tr { grid-template-areas: "fac total" "cli cli" "srv srv" "fecha purga" "del del"; }
  .a-purga { grid-area: purga; text-align: right; }
}
/* Ventanas de confirmar: emitir y anular */
dialog.confirmar { width: min(520px, 94vw); }
dialog.confirmar h2 { margin-bottom: 10px; }
dialog.confirmar p { margin: 0 0 10px; }
dialog.confirmar .botones { justify-content: flex-end; margin-top: 16px; }
.anular-zona { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 16px; }
.anular-zona .ayuda { margin: 0; }
/* D18: en el borrador, Eliminar va separado de Editar · Emitir y como enlace discreto */
.acciones .aparte { display: flex; align-items: center; margin: 0 0 0 8px; padding-left: 14px; border-left: 1px solid var(--line); }
.btn.link.discreto { color: var(--muted); font-weight: 500; }
.btn.link.discreto:hover { color: var(--red); }
/* D16: todas las ventanas (<dialog>, incluida "+ agregar" del formulario) entran y salen con un movimiento sutil.
   Guía ui-behaviors/animate-to-from-top-layer.md: display y overlay con allow-discrete; escala .96 solo sin
   reduced-motion; con reduced-motion, instantáneo (decisión de Justyn 2026-11-18). */
dialog {
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 180ms;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}
dialog[open] { opacity: 1; }
@starting-style { dialog[open] { opacity: 0; } }
dialog::backdrop {
  background-color: rgba(3,27,60,0);
  transition-property: background-color, display, overlay;
  transition-duration: 180ms;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}
dialog[open]::backdrop { background-color: rgba(3,27,60,.45); }
@starting-style { dialog[open]::backdrop { background-color: rgba(3,27,60,0); } }
@media (prefers-reduced-motion: no-preference) {
  dialog { transform: scale(.96); }
  dialog[open] { transform: scale(1); }
  @starting-style { dialog[open] { transform: scale(.96); } }
}
@media (prefers-reduced-motion: reduce) {
  dialog, dialog::backdrop { transition-duration: 0s; }
}
/* Guía ui-behaviors/prevent-page-scroll-under-modal-dialog.md: la página de atrás no se desliza */
dialog:modal, dialog::backdrop { overscroll-behavior: contain; }
dialog::backdrop { overflow: hidden; }
/* Vista previa del borrador: la plantilla del PDF mide una carta de ancho. En pantallas angostas se desliza
   de lado DENTRO de su caja (la página no se desborda); en escritorio ocupa el ancho como siempre. */
.vista-caja { overflow-x: auto; overscroll-behavior-x: contain; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.vista-caja .vista { display: block; border: 0; border-radius: 0; }
.vista.doc { min-width: 8.5in; }
/* Avisos con nombres largos sin espacios (cliente de 60 caracteres): parten dentro de su caja, no desbordan la página */
.flash { overflow-wrap: anywhere; }
dialog.confirmar textarea { resize: vertical; min-height: calc(3lh + 20px); }

/* P7-linea */
/* D14: la línea nueva entra con un fundido y 8 px de subida (guía ui-behaviors/animate-element-entry-exit.md).
   Solo sin preferencia de movimiento reducido: con prefers-reduced-motion aparece al instante (decisión de Justyn). */
@media (prefers-reduced-motion: no-preference) {
  .linea { transition: opacity 180ms ease-out, translate 220ms ease-out; }
  @starting-style {
    .linea { opacity: 0; translate: 0 8px; }
  }
}
