.marca { display: flex; align-items: center; gap: .55rem; font-weight: 800; font-variation-settings: "wdth" 112; text-decoration: none; }
.marca-cuadro { width: 18px; height: 18px; background: linear-gradient(90deg, var(--tinta) 0 2px, transparent 2px 5px) 0 0/5px 100%, var(--cobalto); }

.login { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 20px; overflow: hidden; }
.login-campo { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .9; }
.login-caja { position: relative; width: min(400px, 100%); background: var(--papel); padding: 32px; display: grid; gap: 1rem; border-top: 10px solid var(--tinta); box-shadow: 0 30px 70px -30px rgba(25,30,42,.6); }
.login-caja h1 { margin: .4rem 0 0; font-weight: 900; font-variation-settings: "wdth" 120; font-size: 2rem; line-height: 1; letter-spacing: -.02em; }
.login-caja p { margin: 0; color: var(--gris); }
.login-error { color: var(--rojo) !important; min-height: 1.3em; font-size: .9rem; }
.login-volver { font-size: .88rem; color: var(--gris); text-align: center; }

.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.lateral { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1.6rem; padding: 22px 16px; background: var(--tinta); color: var(--papel); }
.lateral .marca-cuadro { background: linear-gradient(90deg, var(--papel) 0 2px, transparent 2px 5px) 0 0/5px 100%, var(--cobalto); }
.lateral nav { display: grid; gap: 2px; }
.lateral nav a { padding: .55em .8em; border-radius: var(--r); text-decoration: none; color: #c8ccd6; font-size: .94rem; border-left: 3px solid transparent; }
.lateral nav a:hover { background: rgba(255,255,255,.06); color: var(--papel); }
.lateral nav a[aria-current="page"] { background: rgba(255,255,255,.09); color: var(--papel); border-left-color: var(--amarillo); font-weight: 600; }
.lateral-usuario { margin-top: auto; display: grid; gap: .5rem; font-size: .88rem; }
.lateral-usuario p { margin: 0 0 .3rem; display: grid; }
.lateral-usuario span { color: #9aa0ad; }
.lateral .btn.sec { color: var(--papel); border-color: #4a5165; }
.lateral .btn.sec:hover { background: var(--papel); color: var(--tinta); }

.vista { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; outline: none; }
.vista-cab { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.vista-cab h1 { margin: 0; font-weight: 900; font-variation-settings: "wdth" 118; font-size: clamp(1.7rem, 3vw, 2.3rem); letter-spacing: -.02em; line-height: 1; }
.vista-cab p { margin: .35rem 0 0; color: var(--gris); }

.filtros { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.filtros input:not([type=checkbox]):not([type=radio]), .filtros select { padding: .55em .75em; border: 1.5px solid var(--linea); border-radius: var(--r); background: var(--papel); }
.filtros input:not([type=checkbox]):not([type=radio]) { flex: 1 1 260px; min-width: 0; }
.filtros select { flex: 0 1 auto; min-width: 0; max-width: 100%; }
.filtros .check { flex: 0 0 auto; white-space: nowrap; padding: .3em .2em; }
.filtros .check input { width: 1.05rem; height: 1.05rem; margin: 0; flex: none; }

.tabla-envoltura { overflow-x: auto; background: var(--papel); border: 1px solid var(--linea); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-weight: 600; color: var(--gris); font-size: .8rem; padding: .7em .8em; border-bottom: 2px solid var(--tinta); white-space: nowrap; position: sticky; top: 0; background: var(--papel); }
td { padding: .55em .8em; border-bottom: 1px solid #e3e6e3; vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f0f3f9; }
td.num { font-variant-numeric: tabular-nums; color: var(--gris); }
.mini-img { width: 38px; height: 46px; overflow: hidden; background: var(--pared); }
.mini-img img, .mini-img svg { width: 100%; height: 100%; object-fit: cover; }
.etiqueta { display: inline-block; padding: .12em .55em; border-radius: 999px; font-size: .78rem; background: var(--pared); white-space: nowrap; }
.etiqueta.alerta { background: #fdecc0; color: #6b4e00; }
.etiqueta.off { background: #f6d9dd; color: #8a1424; }
.paginacion { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; color: var(--gris); font-size: .9rem; }

/* Resumen */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.kpi { background: var(--papel); padding: 1rem 1.1rem; border-top: 4px solid var(--tinta); }
.kpi b { display: block; font-size: 2.1rem; font-weight: 800; font-variation-settings: "wdth" 110; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi span { color: var(--gris); font-size: .88rem; }
.kpi.aviso { border-top-color: var(--amarillo); }
.kpi a { font-size: .84rem; }
.paneles { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.panel { background: var(--papel); padding: 1.1rem 1.2rem; }
.panel h2 { margin: 0 0 .9rem; font-size: 1rem; }
.barras { display: grid; gap: .45rem; }
.barra-fila { display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: .6rem; font-size: .86rem; }
.barra-fila i { display: block; height: 12px; background: var(--cobalto); transform-origin: left; animation: crecer .7s cubic-bezier(.2,.7,.2,1) both; }
.barra-fila:nth-child(3n+2) i { background: var(--rojo); }
.barra-fila:nth-child(3n+3) i { background: var(--amarillo); }
.barra-fila em { font-style: normal; text-align: right; font-variant-numeric: tabular-nums; color: var(--gris); }
@keyframes crecer { from { transform: scaleX(0); } }

/* Catálogos agrupados */
.grupos { display: grid; gap: 1.4rem; }
.grupo h2 { font-size: 1rem; margin: 0 0 .6rem; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem; }
.item { all: unset; cursor: pointer; background: var(--papel); padding: .7rem .85rem; border-left: 3px solid var(--tinta); display: grid; gap: .1rem; }
.item:hover { background: #f0f3f9; }
.item:focus-visible { outline: 2px solid var(--cobalto); }
.item b { font-weight: 600; }
.item span { font-size: .8rem; color: var(--gris); }

/* Matriz de permisos */
.rol { background: var(--papel); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.rol-cab { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .8rem; align-items: center; margin-bottom: .8rem; }
.rol-cab h2 { margin: 0; font-size: 1.15rem; }
.rol-cab p { margin: .15rem 0 0; color: var(--gris); font-size: .88rem; }
.matriz th, .matriz td { text-align: center; }
.matriz th:first-child, .matriz td:first-child { text-align: left; }
.matriz tbody tr { cursor: default; }
.matriz input { width: 18px; height: 18px; accent-color: var(--cobalto); }

/* Modal */
.modal { border: 0; padding: 0; width: min(720px, 94vw); max-height: 92vh; background: var(--papel); color: var(--tinta); box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); }
.modal[open] { animation: fichaIn .25s cubic-bezier(.2,.7,.2,1); }
@keyframes fichaIn { from { opacity: 0; transform: translateY(10px); } }
.modal::backdrop { background: rgba(25,30,42,.6); }
.modal-cuerpo { display: grid; gap: 1rem; padding: 26px 28px; }
.modal-cuerpo h2 { margin: 0; font-size: 1.4rem; font-weight: 800; font-variation-settings: "wdth" 112; }
.modal-cuerpo .sub { margin: -.6rem 0 0; color: var(--gris); font-size: .9rem; }
.rejilla-form { display: grid; grid-template-columns: repeat(6, 1fr); gap: .9rem; }
.c2 { grid-column: span 2; } .c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c6 { grid-column: span 6; }
.acciones { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end; align-items: center; border-top: 1px solid var(--linea); padding-top: 1rem; }
.acciones .izq { margin-right: auto; }
.foto { display: grid; grid-template-columns: 140px 1fr; gap: 1rem; align-items: center; }
.foto-prev { width: 140px; aspect-ratio: 4/5; background: var(--pared); overflow: hidden; }
.foto-prev img, .foto-prev svg { width: 100%; height: 100%; object-fit: cover; }
.foto-botones { display: flex; flex-wrap: wrap; gap: .5rem; }
.solo-lectura { background: #fdecc0; color: #6b4e00; padding: .55em .8em; font-size: .88rem; border-radius: var(--r); }
.check { display: flex; align-items: center; gap: .5rem; font-size: .92rem; }
.vacio-vista { padding: 50px 20px; text-align: center; color: var(--gris); background: var(--papel); }
.auditoria td { cursor: default; font-size: .86rem; }
.auditoria code { font-size: .78rem; color: var(--gris); white-space: pre-wrap; word-break: break-word; }

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .lateral { min-width: 0; }
  .lateral { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: .8rem; }
  .lateral nav { display: flex; overflow-x: auto; width: 100%; order: 3; }
  .lateral nav a { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; }
  .lateral nav a[aria-current="page"] { border-bottom-color: var(--amarillo); }
  .lateral-usuario { margin: 0 0 0 auto; display: flex; flex-wrap: wrap; }
  .lateral-usuario p { display: none; }
  .rejilla-form { grid-template-columns: 1fr 1fr; }
  .c2, .c3 { grid-column: span 1; } .c4, .c6 { grid-column: span 2; }
  .foto { grid-template-columns: 100px 1fr; } .foto-prev { width: 100px; }
  .col-opc { display: none; }
}

.login-caja .logo-sm { height: 42px; }
.marca-lateral { flex-direction: column; align-items: flex-start; gap: .6rem; }
.logo-placa { background: var(--papel); padding: 8px 10px; border-radius: var(--r); display: block; }
.logo-placa .logo-sm { height: 40px; }
@media (max-width: 860px) { .marca-lateral { flex-direction: row; align-items: center; } .logo-placa { padding: 5px 7px; } .logo-placa .logo-sm { height: 26px; } }

.modal .toast-zona { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 5; }

/* Arte Sin Fronteras: ajustes de marca del panel */
.login-caja { border-top: 0; border-radius: 22px; box-shadow: 0 40px 90px -30px rgba(2,38,98,.55); }
.login-caja .marca { margin-bottom: .4rem; }
.modal { border-radius: 20px; }
.kpi { border-radius: 14px; border-top: 0; box-shadow: inset 0 4px 0 var(--coral); }
.tabla-envoltura { border-radius: 14px; }

/* Mensajes y boletín */
.aviso-panel { padding: .8rem 1rem; border-radius: 12px; background: #fdecc0; color: #4a3500; font-size: .92rem; }
.aviso-panel.ok { background: #dff3f5; color: #024550; } .aviso-panel.mal { background: #f6d9dd; color: #6b0d31; }
.pestanas { display: flex; gap: .3rem; border-bottom: 1px solid var(--linea); margin: .4rem 0 1rem; }
.pestanas button { border: 0; background: none; padding: .7em 1.1em; font: inherit; font-weight: 600; color: var(--gris); border-bottom: 3px solid transparent; cursor: pointer; margin-bottom: -1px; }
.pestanas button[aria-selected="true"] { color: var(--tinta); border-bottom-color: var(--coral); }
.lista-cand { display: grid; gap: .35rem; max-height: 260px; overflow-y: auto; border: 1px solid var(--linea); border-radius: 12px; padding: .6rem .8rem; margin-top: .35rem; background: var(--papel); }
.lista-cand .check { align-items: start; }
#b-acc { display: flex; gap: .5rem; flex-wrap: wrap; }
.etiqueta.ok { background: #dff3f5; color: #024550; }
.tarjeta-op { background: var(--papel); border: 1px solid var(--linea); border-radius: 14px; padding: .9rem 1.1rem; }
.tarjeta-op.oculta { opacity: .65; }

/* Tablas de la ficha de pedido: los importes no se parten */
.modal td.num { white-space: nowrap; }
.pestanas { overflow-x: auto; scrollbar-width: thin; } .pestanas button { white-space: nowrap; flex: none; }
@media (max-width: 560px) { .pestanas button { padding: .7em .8em; } }
.modal.ancho { width: min(1100px, 96vw); }

/* Indicador de proceso */
.reloj { display: inline-block; width: 1em; height: 1em; margin-right: .45em; vertical-align: -.15em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: girar .7s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
.btn[aria-busy="true"] { cursor: progress; opacity: 1; }
body.esperando, body.esperando * { cursor: progress !important; }
tr[aria-busy="true"] td { background: rgba(0, 0, 0, .04); }
@media (prefers-reduced-motion: reduce) { .reloj { animation-duration: 2s; } }

/* Selección múltiple en el archivo histórico */
.col-sel { width: 2.2rem; text-align: center; }
.col-sel input { width: 1.1rem; height: 1.1rem; cursor: pointer; }
.lote { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin: .6rem 0; padding: .6rem .9rem; border-radius: 10px; background: rgba(0,0,0,.04); color: var(--gris, #666); transition: background .15s; }
.lote #a-lote-n { font-weight: 500; }
.lote.activa { background: var(--tinta, #12203a); color: #fff; }
.lote.activa #a-lote-n { font-weight: 700; }
.lote .acciones { display: flex; gap: .4rem; margin: 0; }
.lote.activa .btn.sec { color: #fff; border-color: rgba(255,255,255,.5); }
.lote .btn:disabled { opacity: .45; cursor: default; }

.etiqueta.aviso { background: #fff1cc; color: #6b4b00; }
