/* ═══════════ CotizaLab: componentes propios de esta app ═══════════
   Va en la capa «app»: siempre gana al sistema de diseño padre (packages/diseno), que se carga antes.
   Los colores salen siempre de los tokens (var(--…)); los tokens propios de la app van en tema.css. */
@layer app {
  /* Aviso fijo cuando el superadministrador está dentro de un negocio */
  .modo-super {
    background: var(--ink);
    color: var(--bg);
    font-size: 13px;
  }
  .modo-super .in {
    max-width: 1180px;
    margin: 0 auto;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px 12px;
    flex-wrap: wrap;
  }
  .modo-super a {
    color: inherit;
    font-weight: 600;
  }
  .modo-super .grow {
    flex: 1;
    min-width: 0;
  }
  /* Plataforma: tabla de negocios */
  table.t td.adms {
    color: var(--ink-2);
    overflow-wrap: anywhere;
  }
  @media (min-width: 720px) {
    /* En pantallas medianas la tabla se desliza de lado en vez de cortarse */
    .tw-negocios {
      overflow-x: auto;
    }
    table.t-negocios td:first-child {
      min-width: 170px;
    }
    table.t-negocios td.adms {
      min-width: 200px;
      overflow-wrap: normal;
      word-break: break-word;
    }
    table.t-negocios td,
    table.t-negocios th {
      vertical-align: middle;
    }
  }
  .acts-iconos {
    display: inline-flex;
    gap: 6px;
    justify-content: flex-end;
  }
  .acts-iconos .btn {
    margin: 0 !important;
  }
  /* Nombre de la acción al pasar el ratón o enfocar el botón (los íconos solos no se explican) */
  [data-tip] {
    position: relative;
  }
  [data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translate(-50%, 4px);
    padding: 5px 9px;
    border-radius: 6px;
    background: var(--ink);
    color: var(--bg);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s, transform 0.12s;
    z-index: 30;
  }
  [data-tip]:hover::after,
  [data-tip]:focus-visible::after {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  /* El último de la fila: el globo se alinea a la derecha para no salirse de la tabla */
  .acts-iconos > :last-child::after {
    left: auto;
    right: 0;
    transform: translate(0, 4px);
  }
  .acts-iconos > :last-child:hover::after,
  .acts-iconos > :last-child:focus-visible::after {
    transform: translate(0, 0);
  }

  /* ═══════════ App del paciente ═══════════ */
  .wrap {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 16px;
  }
  .top {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .top .wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 60px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
  }
  .brand img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 8px;
    background: var(--surface);
    flex: none;
  }
  .brand .mark {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-ink);
    display: grid;
    place-items: center;
    flex: none;
  }
  .brand .mark svg {
    width: 20px;
    height: 20px;
  }
  .brand strong {
    display: block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.01em;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .brand > div {
    min-width: 0;
  }
  .brand small {
    display: block;
    color: var(--ink-3);
    font-size: 12px;
  }
  .ratechip {
    text-align: right;
    font-size: 12px;
    line-height: 1.3;
    color: var(--ink-3);
    flex: none;
  }
  .ratechip b {
    display: block;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
  }
  .ratechip.stale b {
    color: var(--warn);
  }
  .ratebar {
    display: none;
    font-size: 12px;
    color: var(--ink-3);
  }
  .ratebar b {
    color: var(--ink);
    font-weight: 600;
  }
  .ratebar.stale b {
    color: var(--warn);
  }
  @media (max-width: 520px) {
    .ratechip {
      display: none;
    }
    .ratebar {
      display: block;
    }
  }
  main.patient {
    padding-top: 16px;
    padding-bottom: 110px;
  }

  /* Buscador del paciente: se queda pegado bajo la cabecera para agregar varios exámenes seguidos */
  .buscador {
    position: sticky;
    top: var(--alto-top, 61px);
    z-index: 15;
    margin-left: -16px;
    margin-right: -16px;
    padding: 8px 16px;
    background: var(--bg);
  }
  .buscador .search input {
    padding-right: 48px;
  }
  /* El buscador del navegador trae su propia «x» (solo en algunos): se usa la nuestra, más grande */
  .buscador .search input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
  }
  .buscador .limpiar {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-3);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
  }
  .buscador .limpiar[hidden] {
    display: none;
  }
  .buscador .limpiar:hover {
    color: var(--ink);
    background: var(--surface-2);
  }
  .qhint {
    margin: 0;
    font-size: 13px;
    color: var(--ink-2);
    display: flex;
    gap: 6px;
    align-items: flex-start;
  }
  .qhint:empty {
    display: none;
  }
  .qhint:not(:empty) {
    margin-top: 8px;
  }
  .qhint svg {
    flex: none;
    width: 16px;
    height: 16px;
    margin-top: 1px;
    color: var(--ok);
  }
  .stack > * + * {
    margin-top: 12px;
  }
  .stack > .tabs {
    margin-top: 16px;
  }
  /* «Ver promociones» lleva hasta las categorías sin que queden debajo de la cabecera fija */
  #chips {
    scroll-margin-top: calc(var(--alto-top, 61px) + 12px);
  }

  /* Anuncio de promociones al inicio. Grande: caja de superficie (blanca en claro) con sombra suave, «Ver promociones»
     en tinta (negro con letras blancas en claro) y una flecha para plegarlo. Compacto: una línea que se toca
     para desplegarlo otra vez. */
  .promo-anuncio {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 14px 52px 14px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--sombra-suave);
    font: inherit;
    text-align: left;
  }
  .promo-anuncio + .notice {
    margin-top: 12px;
  }
  .promo-anuncio .emoji {
    flex: none;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 28px;
    line-height: 1;
    background: var(--accent-bg);
  }
  .promo-anuncio .txt {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }
  .promo-anuncio .una {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
  }
  .promo-anuncio .una + .una {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line-2);
  }
  .promo-anuncio .una > b {
    font-family: var(--font-display);
    font-size: 17px;
    line-height: 1.25;
  }
  .promo-anuncio .una > span {
    font-size: 14px;
    line-height: 1.4;
  }
  .promo-anuncio strong {
    font-weight: 700;
  }
  .promo-anuncio small {
    font-size: 12px;
    color: var(--ink-3);
  }
  .promo-anuncio .ver {
    margin-top: 12px;
    border: 0;
    background: var(--ink);
    color: var(--surface);
    font-weight: 600;
  }
  .promo-anuncio .ver:hover {
    background: var(--ink-2);
  }
  .promo-anuncio .plegar {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-3);
    cursor: pointer;
    display: grid;
    place-items: center;
  }
  .promo-anuncio .plegar:hover {
    color: var(--ink);
    background: var(--surface-2);
  }
  /* «›» girado: hacia abajo para desplegar, hacia arriba para plegar */
  .promo-anuncio .flecha {
    flex: none;
    align-self: center;
    display: inline-block;
    font-size: 26px;
    line-height: 1;
    color: var(--ink-3);
  }
  .promo-anuncio .flecha.abajo {
    transform: rotate(90deg);
  }
  .promo-anuncio .flecha.arriba {
    transform: rotate(-90deg);
  }
  .promo-anuncio .sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  /* Compacto: una sola línea, cortada con «…» */
  .promo-anuncio.compacta {
    cursor: pointer;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 8px 10px 8px 8px;
    border-radius: 12px;
    box-shadow: none;
  }
  .promo-anuncio.compacta .emoji {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    font-size: 20px;
  }
  .promo-anuncio.compacta .linea {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .promo-anuncio.compacta:hover {
    border-color: var(--ink-3);
  }

  #lista {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  /* Tarjeta de examen/perfil: nombre y detalles a la izquierda; precio y botón en la misma fila a la derecha.
     En pantallas grandes toda la tarjeta alterna «Agregar» (enlace extendido del botón); en el celular, solo el
     botón (ver «Celular» más abajo). */
  .item {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 14px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    transition: border-color 0.12s, box-shadow 0.12s;
  }
  .item:hover {
    border-color: var(--ink-3);
  }
  .item.sel {
    border-color: var(--accent-text);
    box-shadow: inset 0 0 0 1px var(--accent-text);
  }
  .item.dis {
    background: var(--surface-2);
  }
  .item.dis h3 {
    color: var(--ink-3);
  }
  .item h3 {
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }
  .item .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    align-items: center;
    margin-top: 5px;
    font-size: 12px;
    color: var(--ink-3);
  }
  /* «También llamado glucemia»: cuando se encontró el examen por otro de sus nombres */
  .item .alias {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--ink-3);
  }
  .item .alias b {
    color: var(--ink-2);
    font-weight: 600;
  }
  /* Perfil: sus exámenes siempre a la vista, debajo de una línea gris */
  .item .incluye {
    position: relative;
    z-index: 1;
    grid-column: 1 / -1;
    margin: 2px 0 0;
    padding-top: 8px;
    border-top: 1px solid var(--line-2);
    font-size: 13px;
    line-height: 1.45;
    color: var(--ink-2);
  }
  .item .incluye b {
    font-weight: 600;
    color: var(--ink);
  }
  .item .desc {
    margin: 5px 0 0;
    font-size: 13px;
    color: var(--ink-2);
  }
  .item .side {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
  }
  .price {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
    letter-spacing: -0.01em;
    white-space: nowrap;
  }
  .item .side .btn {
    min-width: 100px;
  }
  .item .side .btn::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 10px;
  }
  /* Sin «filter» al pasar el ratón: convierte el botón en contenedor del ::after, que encoge al tamaño del botón
     y el cursor parpadea entre la flecha y la mano. Se oscurece con el color de fondo en su lugar. */
  .item .side .btn-primary:hover {
    filter: none;
    background: color-mix(in srgb, var(--accent) 88%, var(--surface));
  }
  .item:hover .side .btn-soft {
    border-color: var(--accent-text);
  }
  .item .side .contador .btn::after {
    content: none;
  }
  /* Precio en promoción: el de antes tachado, más chico (el nuevo, en el color normal) */
  .price.promo s {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-3);
    margin-right: 2px;
  }
  /* Chip de promoción: solo el descuento («−20 %»), en el color de información */
  .promo-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--info-bg);
    color: var(--info);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
    white-space: nowrap;
  }

  /* Indicaciones: ícono y texto en la misma línea; si el texto es largo, baja junto al ícono */
  .item .meta.ind {
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 5px;
  }
  .item .meta svg.i {
    flex: none;
    width: 14px;
    height: 14px;
    margin-top: 1px;
  }
  /* «✓ Incluido en <perfil>»: debajo del nombre, en verde */
  .item .meta.incluido {
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 5px;
    color: var(--ok);
    font-weight: 600;
  }
  /* En lugar del botón: un círculo con ✓ (no se puede tocar) */
  .ya-incluido {
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--ok-bg);
    color: var(--ok);
  }
  .ya-incluido svg.i {
    width: 18px;
    height: 18px;
  }
  @media (max-width: 480px) {
    .item .side .btn {
      min-width: 0;
    }
  }
  #lista > .empty {
    margin-top: 6px;
  }
  .price small {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-3);
  }
  /* Contador − n + (exámenes que se pueden pedir varias veces) */
  .contador {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    border: 1px solid var(--accent-text);
    border-radius: 8px;
    background: var(--accent-bg);
    padding: 2px;
    position: relative;
    z-index: 1;
  }
  .contador .btn {
    border: 0;
    background: transparent;
    color: var(--accent-text);
    font-size: 18px;
    font-weight: 600;
  }
  .contador .btn:hover:not(:disabled) {
    background: var(--surface);
  }
  .contador .btn:disabled {
    opacity: 0.35;
  }
  .contador span {
    min-width: 26px;
    text-align: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    color: var(--accent-text);
  }
  .lines .line.con-contador .contador {
    border-color: var(--line);
    background: var(--surface-2);
  }
  .lines .line.con-contador .contador .btn,
  .lines .line.con-contador .contador span {
    color: var(--ink);
  }

  /* Celular: la tarjeta no agrega (es fácil tocarla sin querer al deslizar); solo el botón «Agregar». */
  @media (max-width: 719px), (pointer: coarse) {
    .patient .item .side .btn::after {
      content: none;
    }
    .patient .item:hover {
      border-color: var(--line);
    }
    .patient .item.sel,
    .patient .item.sel:hover {
      border-color: var(--accent-text);
    }
    .patient .item:hover .side .btn-soft {
      border-color: transparent;
    }
    /* Buscando: se esconde todo lo que está arriba del buscador (cabecera, tasa y aviso) */
    body.buscando header.top,
    body.buscando #ratebar,
    body.buscando #aviso {
      display: none;
    }
    body.buscando .patient {
      padding-top: 0;
      padding-bottom: 0;
    }
    /* Y la página queda quieta: buscador, categorías y pestañas fijos arriba; solo la lista se desplaza.
       El alto sale del área visible (sin el teclado), que app.js pone en --alto-visible. */
    html:has(body.buscando),
    body.buscando {
      overflow: hidden;
      overscroll-behavior: none;
    }
    body.buscando #v-catalogo {
      display: flex;
      flex-direction: column;
      height: var(--alto-visible, 100dvh);
    }
    body.buscando #v-catalogo > * {
      flex: none;
    }
    body.buscando .buscador {
      position: static;
    }
    body.buscando #lista {
      flex: 1 1 auto;
      min-height: 0;
      overflow-y: auto;
      overscroll-behavior: contain;
      -webkit-overflow-scrolling: touch;
      margin: 8px -16px 0;
      padding: 4px 16px calc(96px + env(safe-area-inset-bottom));
    }
    body.buscando #lista > * {
      flex: none;
    }

    /* Tarjeta compacta: nombre a la izquierda; precio y botón redondo en la misma fila a la derecha */
    .patient .item {
      align-items: center;
      gap: 6px 12px;
      padding: 10px 10px 10px 14px;
    }
    .patient .item .side {
      flex-direction: row;
      align-items: center;
      gap: 10px;
    }
    .patient .item .price.promo {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      line-height: 1.2;
    }
    .patient .item .side .btn.agregar {
      width: 48px;
      min-width: 48px;
      height: 48px;
      min-height: 48px;
      padding: 0;
      border-radius: 999px;
      justify-content: center;
    }
    .patient .item .side .btn.agregar svg {
      width: 22px;
      height: 22px;
    }
    .patient .btn.agregar .txt {
      display: none;
    }
    .patient .ya-incluido {
      width: 48px;
      height: 48px;
    }
    .patient .ya-incluido svg.i {
      width: 22px;
      height: 22px;
    }

    /* Nada más chico que 44 px para el dedo */
    .patient .btn,
    .patient .chip,
    .modal .btn {
      min-height: 44px;
    }
    .patient .btn-icon,
    .patient .contador .btn {
      width: 44px;
      min-width: 44px;
      min-height: 44px;
    }
    .patient .tabs button {
      min-height: 44px;
    }
    .buscador .limpiar {
      width: 44px;
      height: 44px;
      right: 2px;
    }
    body.buscando .buscador {
      top: 0;
    }
  }

  /* Categorías en el celular: una sola línea que se desliza con el dedo, en vez de tres o cuatro filas.
     Llegan hasta el borde de la pantalla y se desvanecen a la derecha para que se note que hay más. */
  @media (max-width: 719px) {
    .patient #chips {
      flex-wrap: nowrap;
      overflow-x: auto;
      overscroll-behavior-x: contain;
      scroll-snap-type: x proximity;
      scroll-padding-inline: 16px;
      scrollbar-width: none;
      margin-left: -16px;
      margin-right: -16px;
      padding: 2px 16px;
      -webkit-mask-image: linear-gradient(to right, var(--ink) calc(100% - 40px), transparent);
      mask-image: linear-gradient(to right, var(--ink) calc(100% - 40px), transparent);
    }
    .patient #chips::-webkit-scrollbar {
      display: none;
    }
    .patient #chips .chip {
      flex: none;
      scroll-snap-align: start;
    }
    /* Al final de la línea ya no hay nada más: sin desvanecido */
    .patient #chips.al-final {
      -webkit-mask-image: none;
      mask-image: none;
    }
  }

  /* Barra inferior fija del carrito (catálogo) */
  .cartbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    padding: 14px 16px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg) 60%, transparent);
    pointer-events: none;
  }
  .cart-in {
    display: flex;
    gap: 8px;
    max-width: 728px;
    margin: 0 auto;
  }
  .cartbar .ir {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    width: 100%;
    max-width: 728px;
    margin: 0 auto;
    min-height: 52px;
    padding: 0 16px;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-pop);
  }
  .cartbar .ir:hover {
    filter: brightness(1.08);
  }
  .cartbar .ir > span:last-child {
    font-family: var(--font-display);
    font-size: 16px;
  }
  .cartbar .vaciar {
    pointer-events: auto;
    flex: none;
    width: 52px;
    min-height: 52px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink-2);
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow: var(--shadow-pop);
  }
  .cartbar .vaciar:hover {
    color: var(--danger);
    border-color: var(--danger);
  }
  .cartbar .count {
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--accent-ink);
    color: var(--accent);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
  }
  .cartbar .grow {
    flex: 1;
    text-align: left;
  }
  body:has(.cartbar:not([hidden])) #toasts {
    bottom: calc(86px + env(safe-area-inset-bottom));
  }
  /* Con una ventana abierta, los avisos van arriba para no tapar sus botones (gana a las reglas de las barras inferiores) */
  body:has(.overlay) #toasts {
    top: calc(12px + env(safe-area-inset-top)) !important;
    bottom: auto !important;
  }

  /* Resumen */
  .res-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
  }
  .res-head .back {
    margin-bottom: 0;
  }
  .vaciar-txt {
    color: var(--ink-3);
  }
  .vaciar-txt:hover {
    color: var(--danger);
  }
  .limite {
    display: flex;
    gap: 6px;
    align-items: center;
    margin: 2px 0 6px;
    font-size: 13px;
    color: var(--ink-2);
  }
  .limite svg.i {
    color: var(--accent-text);
  }
  /* Perfil que repite exámenes: los que faltan, como exámenes sueltos */
  .faltan {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    margin: 12px 0;
    background: var(--surface-2);
  }
  .faltan p {
    margin: 0 0 6px;
  }
  .faltan ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  .faltan li,
  .faltan .suma {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    font-size: 13px;
  }
  .faltan li + li {
    border-top: 1px solid var(--line-2);
  }
  .faltan .suma {
    border-top: 1px solid var(--line);
    margin: 6px 0 0;
    padding-top: 8px;
  }
  .faltan .suma b {
    font-family: var(--font-display);
    font-size: 15px;
  }
  /* Con tres botones, en el móvil van uno debajo de otro (el principal arriba) */
  /* ¿Cómo se enteró? (tarjeta opcional después de generar) */
  .origenes {
    display: grid;
    gap: 8px;
    margin: 4px 0 8px;
  }
  .origenes .btn {
    justify-content: flex-start;
    font-weight: 500;
  }
  .origenes .btn:hover {
    border-color: var(--accent-text);
    color: var(--accent-text);
  }
  .sin-origen {
    width: 100%;
  }
  .origenes .btn.on {
    border-color: var(--accent-text);
    color: var(--accent-text);
    background: var(--accent-bg);
  }
  .otro-detalle {
    display: grid;
    gap: 8px;
    margin: 0 0 8px;
  }
  .otro-detalle .field {
    margin: 0;
  }
  #v-resumen > h2 {
    font-size: 24px;
  }
  .back {
    margin: 0 0 4px -8px;
  }
  .lines .line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px 10px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--line-2);
  }
  .lines .line:first-child {
    padding-top: 0;
  }
  .lines .line:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }
  .lines .line b {
    font-weight: 600;
    overflow-wrap: anywhere;
  }
  .lines .line small {
    display: block;
    color: var(--ink-3);
    font-size: 12px;
    margin-top: 2px;
  }
  .totals .tr {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 2px 0;
    color: var(--ink-2);
  }
  .totals .big {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
    white-space: nowrap;
  }
  .totals .tr.main {
    border-top: 1px solid var(--line);
    margin-top: 10px;
    padding-top: 12px;
  }
  .totals .sub {
    font-size: 12px;
    color: var(--ink-3);
    margin-top: 6px;
  }

  /* Tu presupuesto: acciones (WhatsApp, descargar, copiar, compartir) */
  .actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin: 14px 0;
  }
  details.card > summary {
    font-weight: 600;
  }
  .paper {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 22px clamp(16px, 4vw, 32px);
    font-size: 13px;
  }
  .paper .ph {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--accent);
  }
  .paper .ph img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 6px;
  }
  .paper .ph h2 {
    font-size: 18px;
    font-weight: 700;
  }
  .paper .ph .code {
    margin-left: auto;
    text-align: right;
    flex: none;
  }
  .paper .ph .code span {
    letter-spacing: 0.07em;
    font-weight: 600;
    font-size: 11px;
  }
  .paper .ph .code b {
    display: block;
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 700;
    color: var(--accent-text);
  }
  .paper .meta2 {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 18px;
    margin: 12px 0;
    font-size: 12px;
    color: var(--ink-3);
  }
  .paper .meta2 b {
    color: var(--ink);
    font-weight: 600;
  }
  .paper .pac {
    background: var(--surface-2);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 10px;
    color: var(--ink-2);
  }
  .paper .pac b {
    color: var(--ink);
    font-weight: 600;
  }
  .paper table {
    width: 100%;
    border-collapse: collapse;
  }
  .paper th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
    color: var(--ink-3);
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
  }
  .paper td {
    padding: 9px 0;
    border-bottom: 1px solid var(--line-2);
    vertical-align: top;
  }
  .paper td b {
    font-weight: 600;
  }
  .paper td.p {
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
    padding-left: 10px;
  }
  .paper .inc {
    display: block;
    color: var(--ink-3);
    font-size: 12px;
    margin-top: 2px;
  }
  .paper .promo-pdf {
    display: inline-block;
    vertical-align: 1px;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--info-bg);
    color: var(--info);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }
  .paper td.p .antes {
    display: block;
    font-size: 11.5px;
    font-weight: 400;
    color: var(--ink-3);
  }
  .paper .nota-promo {
    margin-top: 10px;
    font-size: 11.5px;
  }
  .paper .tot {
    margin-top: 14px;
    text-align: right;
  }
  .paper .tot .big {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
  }
  .paper .note {
    margin-top: 14px;
    font-size: 11.5px;
    color: var(--ink-3);
  }

  /* Administración → Actividad: historial agrupado por día */
  .act-filtro {
    max-width: 320px;
    margin: 14px 0 4px;
  }
  .act-dia {
    margin: 18px 0 8px;
    font-size: 14px;
    color: var(--ink-2);
  }
  .act-lista {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
  }
  .act-item {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: start;
    padding: 12px 14px;
  }
  .act-item + .act-item {
    border-top: 1px solid var(--line-2);
  }
  .act-ico {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    color: var(--ink-2);
  }
  .act-ico svg.i {
    width: 16px;
    height: 16px;
  }
  .act-item.peligro .act-ico {
    background: var(--danger-bg);
    color: var(--danger);
  }
  .act-item.super .act-ico {
    background: var(--info-bg);
    color: var(--info);
  }
  .act-quien {
    font-size: 13px;
    overflow-wrap: anywhere;
  }
  .act-det {
    margin-top: 2px;
    font-size: 14px;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }
  .act-cuando {
    font-size: 13px;
    color: var(--ink-2);
    text-align: right;
    white-space: nowrap;
  }
  .act-cuando small {
    display: block;
    font-size: 11px;
    color: var(--ink-3);
  }
  .act-mas,
  .act-fin {
    margin-top: 14px;
    text-align: center;
  }
  @media (max-width: 560px) {
    .act-item {
      grid-template-columns: 28px minmax(0, 1fr);
    }
    .act-cuando {
      grid-column: 2;
      text-align: left;
    }
    .act-cuando small {
      display: inline;
      margin-left: 6px;
    }
  }

  /* Superadministrador: ventana de administradores de un negocio */
  .adm-lista {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
  }
  .adm-fila {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    padding: 10px 12px;
  }
  .adm-fila + .adm-fila {
    border-top: 1px solid var(--line-2);
  }
  .adm-fila.off .quien b,
  .adm-fila.off .quien > span:not(.badge) {
    color: var(--ink-3);
  }
  .adm-fila .quien {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .adm-fila .quien > span:not(.badge) {
    font-size: 13px;
    color: var(--ink-2);
    overflow-wrap: anywhere;
  }
  .adm-fila .quien .badge {
    align-self: flex-start;
    margin-top: 4px;
  }
  .adm-acciones {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .adm-form {
    margin-top: 8px;
  }
  .adm-form h3 {
    margin: 0 0 10px;
    overflow-wrap: anywhere;
  }
  .adm-botones {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
  }
  .clave-gen {
    display: flex;
    gap: 8px;
  }
  .clave-gen input {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  }
  .adm-aviso {
    margin-bottom: 12px;
  }
  .adm-aviso code {
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--surface);
    font-size: 14px;
    user-select: all;
  }

  /* Eslogan bajo el nombre, en el inicio de sesión */
  .login .eslogan {
    margin: -4px 0 10px;
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    color: var(--accent-text);
  }

  /* ═══════════ Panel de administración (y plataforma) ═══════════ */
  .adm-top {
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .adm-top .in {
    max-width: 1180px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px 10px;
    flex-wrap: wrap;
  }
  /* La marca cede espacio (su nombre se recorta) para que los botones quepan en la misma fila */
  .adm-top .brand {
    flex: 1 1 0 !important;
    min-width: 0;
  }
  /* Navegación: pestañas con subrayado en su propia fila, pegadas al borde de la cabecera */
  .adm-nav {
    order: 10;
    flex: 1 0 100%;
    display: flex;
    gap: 2px;
    overflow-x: auto;
    min-width: 0;
    scrollbar-width: none;
    margin: 2px 0 -13px;
  }
  .adm-nav::-webkit-scrollbar {
    display: none;
  }
  .adm-nav a {
    padding: 9px 12px;
    border-bottom: 2px solid transparent;
    font-weight: 500;
    text-decoration: none;
    color: var(--ink-2);
    white-space: nowrap;
  }
  .adm-nav a:hover {
    color: var(--ink);
  }
  .adm-nav a.on {
    color: var(--ink);
    border-bottom-color: var(--accent-text);
    font-weight: 600;
  }
  @media (max-width: 480px) {
    .adm-top .brand small {
      display: none;
    }
  }
  .page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px 16px 64px;
  }
  .page-head {
    display: flex;
    align-items: center;
    gap: 10px 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
  }
  .page-head h1 {
    flex: 1;
    min-width: 180px;
  }
  .page-head h1 .muted {
    font-family: var(--font-body);
  }
  .page > .vista > p.muted {
    margin-top: -6px;
  }
  .toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
  }
  .toolbar > * {
    flex: 1 1 200px;
    min-width: 0;
  }
  .toolbar .btn {
    flex: none;
  }
  @media (min-width: 720px) {
    .toolbar > input[type="search"] {
      max-width: 360px;
    }
    .toolbar > select {
      max-width: 260px;
    }
  }
  .picklist {
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
    padding: 4px 12px 8px;
  }
  .picklist h4 {
    margin: 12px 0 2px;
    font-family: var(--font-body);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
    color: var(--ink-3);
  }
  .logo-prev {
    width: 84px;
    height: 84px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--surface-2);
    color: var(--ink-3);
    font-size: 12px;
    text-align: center;
    flex: none;
  }
  .repetir {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .repetir select {
    flex: 1 1 240px;
  }
  .repetir .input-unit {
    flex: 0 1 160px;
  }
  .repetir .input-unit input {
    padding-right: 92px;
  }
  .origen-fila {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--line-2);
  }
  /* El nombre ocupa lo que quede; si no caben los botones, bajan a otra línea (a la derecha) */
  .origen-fila .nom {
    flex: 1 1 150px;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .origen-fila .nom + .btn {
    margin-left: auto;
  }
  /* Asa para arrastrar (ratón y dedo: touch-action none evita que la página se desplace al arrastrar) */
  .origen-fila .asa {
    flex: none;
    display: grid;
    place-items: center;
    width: 28px;
    height: 34px;
    margin-left: -6px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ink-3);
    cursor: grab;
    touch-action: none;
    user-select: none;
  }
  .origen-fila .asa:hover {
    background: var(--line-2);
    color: var(--ink);
  }
  .origen-fila.arrastrando {
    background: var(--accent-bg);
    border-radius: 8px;
    box-shadow: var(--shadow-pop);
    position: relative;
    z-index: 1;
  }
  .origen-fila.arrastrando .asa {
    cursor: grabbing;
    color: var(--accent-text);
  }
  #ol.ordenando,
  #ol.ordenando * {
    cursor: grabbing !important;
    user-select: none;
  }
  @media (pointer: coarse) {
    .origen-fila .asa {
      width: 36px;
      height: 40px;
    }
  }
  .detalles-otro {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line-2);
  }
  .detalles-otro ul {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
  }
  .detalles-otro li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    font-size: 13px;
  }
  .detalles-otro li span {
    overflow-wrap: anywhere;
  }
  .enlace {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  .enlace code {
    flex: 1 1 220px;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    font-size: 13px;
    overflow-wrap: anywhere;
  }
  .zona-peligro {
    border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  }
  .zona-peligro > h3 {
    color: var(--danger);
  }
  .borrar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 8px 12px;
    margin-top: 12px;
  }
  .borrar .field {
    flex: 0 1 200px;
  }
  /* Edición rápida de exámenes (tabla editable) */
  .rapida table.t.editable td {
    padding: 6px 8px;
  }
  .rapida table.t.editable input[type="text"],
  .rapida table.t.editable select {
    min-height: 34px;
    padding: 6px 8px;
  }
  .rapida table.t.editable .input-unit input {
    padding-right: 44px;
  }
  .rapida .centro-celda {
    text-align: center;
  }
  .rapida tr.cambiada td {
    background: var(--accent-bg);
  }
  .rapida tr.con-error td {
    background: var(--danger-bg);
  }
  .rapida tr.a-borrar td {
    background: var(--danger-bg);
  }
  .rapida tr.a-borrar input[type="text"],
  .rapida tr.a-borrar select {
    text-decoration: line-through;
    opacity: 0.6;
  }
  .rapida .btn-borrar[aria-pressed="true"] {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--surface);
  }
  .barra-lote {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 1px solid var(--line);
    margin-top: 12px;
  }
  @media (min-width: 720px) {
    .rapida table.t.editable td:first-child {
      min-width: 200px;
    }
    .rapida table.t.editable td:nth-child(5) {
      min-width: 200px;
    }
  }
  @media (max-width: 719px) {
    .rapida table.t.editable td {
      flex: 1 1 100%;
    }
    .rapida table.t.editable td.centro-celda {
      flex: 0 1 auto;
      text-align: left;
    }
  }

  /* Paleta de colores principales (Configuración) */
  .paleta {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
    gap: 8px;
    max-width: 420px;
  }
  .muestra {
    position: relative;
    display: block;
    cursor: pointer;
  }
  .muestra input {
    position: absolute;
    opacity: 0;
    inset: 0;
    margin: 0;
    cursor: pointer;
  }
  .muestra span {
    display: block;
    aspect-ratio: 1;
    border-radius: 8px;
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 1px var(--line);
  }
  .muestra input:checked + span {
    box-shadow: 0 0 0 2px var(--ink);
  }
  .muestra input:focus-visible + span {
    outline: 2px solid var(--accent-text);
    outline-offset: 3px;
  }
  /* Vista previa de descripción e indicaciones en las listas del administrador (dos líneas como máximo) */
  .vista-previa {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--ink-3);
    font-size: 12px;
    margin-top: 2px;
    max-width: 520px;
  }
  .vista-previa svg.i {
    width: 13px;
    height: 13px;
  }
  /* Editar perfil: suma por separado y descuento, debajo del precio */
  .suma-perfil {
    font-size: 12px;
    color: var(--ink-3);
    margin-top: 4px;
  }
  .suma-perfil b {
    color: var(--ok);
    font-weight: 600;
  }
  .logo-prev img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  /* Dashboard */
  .range {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 14px;
  }
  .range input[type="date"] {
    width: auto;
    flex: 1 1 140px;
    max-width: 180px;
  }
  .kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
    gap: 12px;
    margin-bottom: 12px;
  }
  @media (max-width: 479px) {
    .kpis {
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      gap: 8px;
    }
    .kpi-horas {
      grid-column: 1 / -1; /* la quinta tarjeta ocupa la fila entera */
    }
  }
  .kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    min-width: 0;
  }
  .kpi .l {
    font-size: 11px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ink-3);
    font-weight: 600;
  }
  .kpi .v {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-top: 6px;
    overflow-wrap: anywhere;
  }
  .kpi .s {
    color: var(--ink-3);
    font-size: 12px;
    margin-top: 2px;
  }
  .grid2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
    gap: 12px;
    margin: 12px 0;
  }
  .grid2 > .card {
    margin-top: 0;
    min-width: 0;
  }
  .grid2 + .card {
    margin-top: 0;
  }
  .bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .bars .br {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px;
    font-size: 13px;
  }
  .bars .br .nm {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .bars .br .vl {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }
  .bars .br .tr {
    grid-column: 1 / -1;
    height: 8px;
    border-radius: 4px;
    background: var(--line-2);
    overflow: hidden;
  }
  .bars .br .tr i {
    display: block;
    height: 100%;
    border-radius: 4px;
    background: var(--accent);
  }
  .bars .br .sub {
    grid-column: 1 / -1;
    font-size: 12px;
    color: var(--ink-3);
  }
  .chart svg {
    width: 100%;
    height: auto;
    display: block;
  }
  .chart text {
    font-size: 10px;
    fill: var(--ink-3);
    font-family: var(--font-body);
  }
  .legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 12px;
    color: var(--ink-2);
    margin-top: 8px;
  }
  .legend i {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 6px;
    vertical-align: -1px;
  }
  .heat {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 3px;
  }
  .heat div {
    aspect-ratio: 1;
    border-radius: 3px;
    background: color-mix(in srgb, var(--accent) calc(var(--a) * 100%), var(--line-2));
  }
  .heatlbl {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 3px;
    font-size: 10px;
    color: var(--ink-3);
    text-align: center;
    margin-top: 4px;
  }
  .wk {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    align-items: end;
    height: 120px;
  }
  .wk div {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
    font-size: 12px;
    color: var(--ink-3);
    gap: 4px;
  }
  .wk div span:first-child {
    color: var(--ink);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }
  .wk i {
    display: block;
    width: 100%;
    max-width: 40px;
    background: var(--accent);
    border-radius: 4px 4px 2px 2px;
    min-height: 2px;
  }
  .seg2 {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--line-2);
    margin: 8px 0;
    gap: 2px;
  }
  .seg2 i {
    display: block;
    height: 100%;
  }

  /* Impresión: solo el presupuesto */
  @media print {
    .top,
    .cartbar,
    .wa-fab,
    .actions,
    .back,
    #toasts,
    details.card {
      display: none !important;
    }
    .paper {
      border: 0;
      padding: 0;
    }
  }

  /* Panel → Presupuestos: buscar por código */
  .pb-buscar {
    display: flex;
    gap: 8px;
    max-width: 520px;
    margin: 12px 0 16px;
  }
  .pb-buscar input {
    flex: 1;
    min-width: 0;
    font-size: 18px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  .pb-buscar input::placeholder {
    text-transform: none;
    letter-spacing: 0;
  }
  .pb-buscar .btn {
    flex: none;
  }
  .pb-res {
    max-width: 640px;
  }
  .pb-cab {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
  }
  .pb-codigo {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.1;
    word-break: break-all;
  }
  .pb-estado {
    font-weight: 700;
    font-size: 13px;
    padding: 5px 12px;
    border-radius: 999px;
  }
  .pb-estado.vigente {
    background: var(--ok-bg);
    color: var(--ok);
  }
  .pb-estado.vencido {
    background: var(--danger-bg);
    color: var(--danger);
  }
  .pb-fechas {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 18px;
    margin: 10px 0 14px;
    color: var(--ink-2);
  }
  .pb-items {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--line);
  }
  .pb-items li,
  .pb-total,
  .pb-hoy {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
  }
  .pb-items li {
    padding: 9px 0;
    border-bottom: 1px solid var(--line-2);
  }
  .pb-nom {
    min-width: 0;
  }
  .pb-total b,
  .pb-hoy b {
    flex: none;
    white-space: nowrap;
  }
  .pb-precio {
    flex: none;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  .pb-promo {
    font-size: 12px;
    font-weight: 700;
    color: var(--ok);
  }
  .pb-total {
    padding-top: 12px;
    font-size: 17px;
  }
  .pb-total.sec {
    padding-top: 4px;
    font-size: 15px;
  }
  .pb-hoy {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--info-bg);
    font-size: 15px;
  }

  /* Vista previa «así lo ve el paciente» (?vista_previa=1) */
  .franja-vp {
    position: sticky;
    top: 0;
    z-index: 60;
    padding: 6px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    background: var(--warn-bg);
    color: var(--warn);
    border-bottom: 1px solid var(--line);
  }
  .nota-vp {
    margin: 12px 0 0;
    text-align: center;
    font-weight: 600;
    color: var(--warn);
  }
  .actions .btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
  }
  @media (max-width: 479px) {
    .vp-txt {
      display: none; /* en el celular, solo el ícono */
    }
  }
  /* Panel: la ventana con la página del paciente */
  .modal.vp-modal {
    width: min(480px, 100%);
    max-width: 480px;
  }
  .vp-marco {
    display: block;
    width: 100%;
    height: min(72vh, 760px);
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
  }

  /* Catálogo compartido: en la sede que usa el catálogo de otra, las páginas del catálogo son de solo lectura */
  .catalogo-ajeno .page-head button,
  .catalogo-ajeno td.acts {
    display: none;
  }
  .catalogo-ajeno [data-t] {
    pointer-events: none;
  }
  .catalogo-ajeno button.badge::after {
    display: none; /* sin la flechita: aquí no se puede cambiar */
  }
  .franja-catalogo {
    margin-bottom: 12px;
  }

  /* Configuración: estado del guardado automático */
  .estado-guardado {
    font-size: 13px;
    color: var(--ink-3);
  }
  .estado-guardado.ok {
    color: var(--ok);
  }
  .estado-guardado.bad {
    color: var(--danger);
    font-weight: 600;
  }
  #fc [aria-invalid="true"] {
    border-color: var(--danger);
  }

  /* Presupuesto generado: «¿Cómo se enteró?» opcional */
  .origen-card .gracias {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 600;
    color: var(--ok);
  }

  /* Tu presupuesto: código, WhatsApp y paneles plegables */
  .codigo-pres {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    margin: 0 0 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
  }
  .codigo-pres b {
    font-family: var(--font-display);
    font-size: 22px;
    letter-spacing: 0.02em;
  }
  .codigo-pres.cargando b {
    color: var(--ink-3);
  }
  /* En «Tu presupuesto» el código va dentro de la caja del total, debajo de una línea */
  .totals #pres-codigo:not(:empty) {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
  }
  .totals .codigo-pres {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
  }
  .totals #pres-codigo p {
    margin: 6px 0 0 !important;
  }
  .actions .btn-wa {
    grid-column: 1 / -1;
  }
  /* Enviar por WhatsApp: botón negro (en oscuro, claro) con el logo en verde */
  .btn-wa {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--bg);
  }
  .btn-wa:hover {
    filter: none;
    opacity: 0.88;
  }
  .btn-wa .wa-ico {
    width: 22px;
    height: 22px;
    color: var(--whatsapp-marca);
  }
  /* Botones de acción un poco más altos (más fáciles de tocar) */
  .actions .btn {
    min-height: 52px;
  }
  details.plegable {
    padding: 0 16px;
  }
  details.plegable > summary {
    cursor: pointer;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .plegable-in {
    padding-bottom: 6px;
  }
  details.plegable .paper {
    margin-bottom: 14px;
  }
  /* Botón flotante de WhatsApp: abre el chat de la sede. En el celular, solo el círculo; en pantallas grandes,
     con la etiqueta «Escríbenos por WhatsApp» */
  .wa-ico {
    width: 20px;
    height: 20px;
    flex: none;
  }
  .wa-fab {
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 35;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    text-decoration: none;
    transition: bottom 0.2s, transform 0.15s;
  }
  .wa-fab:hover {
    transform: translateY(-2px);
  }
  .wa-circulo {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--whatsapp-marca);
    color: var(--whatsapp-ink);
    box-shadow: var(--shadow-pop);
  }
  .wa-circulo .wa-ico {
    width: 30px;
    height: 30px;
  }
  .wa-txt {
    display: none;
  }
  @media (min-width: 720px) and (pointer: fine) {
    .wa-fab {
      padding: 5px 18px 5px 5px;
      border-radius: 999px;
      background: var(--surface);
      border: 1px solid var(--line);
      box-shadow: var(--shadow-pop);
      font-weight: 600;
      font-size: 15px;
    }
    .wa-circulo {
      width: 44px;
      height: 44px;
      box-shadow: none;
    }
    .wa-circulo .wa-ico {
      width: 24px;
      height: 24px;
    }
    .wa-txt {
      display: inline;
    }
  }
  /* Con la barra «Ver mi presupuesto» abajo, el botón sube para no taparla */
  body.con-barra .wa-fab {
    bottom: calc(92px + env(safe-area-inset-bottom));
  }
  /* En «Tu presupuesto» ya está el botón grande «Enviar al laboratorio por WhatsApp» */
  body.en-presupuesto .wa-fab {
    display: none;
  }

  /* Ventana «¿Cómo se enteró?»: × para saltarla sin buscar */
  .modal {
    position: relative;
  }
  .modal-x {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-3);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
  }
  .modal-x:hover {
    background: var(--surface-2);
    color: var(--ink);
  }
  /* Enviar al laboratorio: pasos para pegar la imagen */
  .pasos-wa {
    margin: 0;
    padding-left: 20px;
    display: grid;
    gap: 8px;
  }
}
