/* Portal OP — La Fabrik. Azul noche y dorado del logo, fondo claro para leer al sol desde el celular. */
:root {
  --azul: #12203a;
  --azul-2: #1d3157;
  --oro: #b8913a;
  --oro-claro: #f4ead2;
  --fondo: #f5f4f0;
  --tarjeta: #ffffff;
  --texto: #1b1f27;
  --sutil: #5d6573;
  --borde: #dedbd2;
  --verde: #2f7a4d;   --verde-f: #e3f2e8;
  --ambar: #9a6a00;   --ambar-f: #fff3cf;
  --rojo: #b3261e;    --rojo-f: #fbe6e4;
  --azul-f: #e6ecf7;
  --gris-f: #ecebe7;
  --radio: 10px;
  --sombra: 0 1px 2px rgba(18, 32, 58, .06), 0 2px 8px rgba(18, 32, 58, .05);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--azul-2); }
h1 { font-size: 1.45rem; line-height: 1.25; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--sutil); margin: .75rem 0 .35rem; }
code { background: var(--gris-f); padding: .05rem .35rem; border-radius: 4px; font-size: .92em; }
code.grande { font-size: 1.2rem; padding: .2rem .6rem; letter-spacing: .04em; }
small { color: var(--sutil); font-size: .82rem; }
.sutil { color: var(--sutil); margin: 0; }
.req { color: var(--rojo); }
.pre { white-space: pre-wrap; margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.inline { display: inline; }

/* Navegación */
.nav {
  background: var(--azul); color: #fff; display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; padding: .55rem 16px; position: sticky; top: 0; z-index: 5; flex-wrap: wrap;
}
.nav a, .nav .link { color: #e8e3d6; text-decoration: none; font-size: .95rem; }
.nav a:hover, .nav .link:hover { color: #fff; }
.marca { display: flex; align-items: center; gap: .55rem; font-weight: 600; }
.marca img { border-radius: 6px; }
.marca span { color: var(--oro); letter-spacing: .02em; }
.nav-links { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
@media (max-width: 560px) {
  .nav { position: static; flex-wrap: nowrap; padding: .45rem 12px; }
  .marca span { display: none; }
  .nav-links { gap: .7rem; flex-wrap: nowrap; }
  .nav a, .nav .link { font-size: .85rem; }
  .nav .btn-sm { padding: .25rem .6rem; min-height: 34px; }
}
@media (max-width: 380px) { .nav-cuenta { display: none; } }

.contenedor { max-width: 1080px; margin: 0 auto; padding: 1.25rem 16px 4rem; }
.cabecera { margin-bottom: 1rem; }
.fila-entre { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.volver { display: inline-block; margin-bottom: .5rem; text-decoration: none; color: var(--sutil); }

/* Tarjetas y formularios */
.tarjeta {
  background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 1rem 1.1rem; margin: 0 0 1rem; box-shadow: var(--sombra); min-width: 0;
}
fieldset.tarjeta { margin-bottom: 1rem; }
legend { font-weight: 700; padding: 0 .35rem; margin-left: -.35rem; color: var(--azul); }
label { display: block; font-weight: 600; font-size: .93rem; margin-bottom: .85rem; }
label > input, label > select, label > textarea { display: block; margin-top: .3rem; }
label small { font-weight: 400; }
label > input + small, label > select + small, label > textarea + small { display: block; margin-top: .3rem; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--texto); background: #fff; width: 100%;
  border: 1px solid #c9c5ba; border-radius: 8px; padding: .62rem .7rem; min-height: 44px;
}
textarea { resize: vertical; }
input[type="file"] { padding: .5rem; background: var(--fondo); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--oro); outline-offset: 1px; border-color: var(--oro); }
.check { display: flex; align-items: center; gap: .55rem; font-weight: 500; }
.check input { width: 1.2rem; height: 1.2rem; min-height: 0; accent-color: var(--azul); flex: none; }
.fila2 { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .fila2 { grid-template-columns: 1fr 1fr; } }
.pila { display: grid; gap: .25rem; }
.pila label { margin-bottom: .6rem; }

.opciones { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .9rem; }
.opcion {
  display: flex; align-items: center; gap: .45rem; margin: 0; font-weight: 500; cursor: pointer;
  border: 1px solid #c9c5ba; border-radius: 999px; padding: .45rem .9rem; background: #fff; min-height: 44px;
}
.opcion input { width: auto; min-height: 0; accent-color: var(--azul); }
.opcion:has(input:checked) { border-color: var(--azul); background: var(--azul-f); }

.pregunta { font-weight: 700; margin: 0 0 .5rem; }
.opciones .opcion { min-width: 5.5rem; justify-content: center; }
[data-si] { margin-top: .25rem; }
.opcional summary { cursor: pointer; font-weight: 700; color: var(--azul); }
.opcional[open] summary { margin-bottom: .85rem; }
.tarjeta-alerta { border-color: #ecd58e; background: var(--ambar-f); }
.alerta { color: var(--ambar); }
.estimado { margin: 0; font-weight: 600; padding: .55rem .75rem; border-radius: 8px; }
.estimado:empty { display: none; }
.estimado-ok { background: var(--verde-f); color: var(--verde); }
.estimado-justo { background: var(--ambar-f); color: var(--ambar); }
.estimado-vencido { background: var(--rojo-f); color: var(--rojo); }

.acciones-form { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; min-height: 44px;
  padding: .55rem 1.05rem; border-radius: 8px; border: 1px solid #c9c5ba; background: #fff; color: var(--texto);
}
.btn:hover { border-color: var(--azul-2); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primario { background: var(--azul); border-color: var(--azul); color: #fff; }
.btn-primario:hover { background: var(--azul-2); }
.btn-oro { background: var(--oro); border-color: var(--oro); color: #fff !important; }
.btn-peligro { color: var(--rojo); border-color: #e3b6b2; }
.btn-fantasma { background: transparent; }
.btn-sm { min-height: 36px; padding: .3rem .8rem; font-size: .9rem; }
.btn-grande { padding: .75rem 1.6rem; font-size: 1.05rem; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--azul-2); cursor: pointer; text-decoration: underline; }

/* Avisos */
.aviso { border-radius: var(--radio); padding: .8rem 1rem; margin-bottom: 1rem; border: 1px solid; }
.aviso p { margin: .35rem 0 0; }
.aviso ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.aviso-ok { background: var(--verde-f); border-color: #b9dcc6; color: #1f5435; }
.aviso-error { background: var(--rojo-f); border-color: #efc1bc; color: #7d1a14; }
.aviso-datos { background: var(--ambar-f); border-color: #ecd58e; color: #5c4100; }

/* Chips y plazos */
.chip { display: inline-block; font-size: .75rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.chip-cola { background: var(--azul-f); color: var(--azul-2); }
.chip-datos { background: var(--ambar-f); color: var(--ambar); }
.chip-emitida { background: var(--oro-claro); color: #7a5a14; }
.chip-entregada { background: var(--verde-f); color: var(--verde); }
.chip-desestimada { background: var(--gris-f); color: var(--sutil); }
.chip-urgente { background: var(--rojo); color: #fff; }
.plazo { font-size: .85rem; font-weight: 600; white-space: nowrap; }
.plazo-ok { color: var(--verde); }
.plazo-justo { color: var(--ambar); }
.plazo-vencido { color: var(--rojo); }
.plazo-neutro { color: var(--sutil); }

/* Listas de ventas */
.pestanas { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--borde); margin-bottom: 1rem; scrollbar-width: none; }
.pestanas a { padding: .55rem .85rem; text-decoration: none; color: var(--sutil); white-space: nowrap; border-bottom: 2px solid transparent; font-weight: 600; font-size: .93rem; }
.pestanas a.activa { color: var(--azul); border-bottom-color: var(--oro); }
.cuenta { background: var(--azul); color: #fff; border-radius: 999px; font-size: .72rem; padding: .05rem .45rem; margin-left: .2rem; }
.filtros { display: flex; gap: .5rem; flex-wrap: wrap; }
.filtros input { width: 190px; } .filtros select { width: auto; }
@media (max-width: 560px) { .filtros, .filtros input { width: 100%; } .filtros select { flex: 1; } }

.lista { display: grid; gap: .5rem; }
.fila-pedido {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap;
  background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: .8rem 1rem; text-decoration: none; color: inherit; box-shadow: var(--sombra);
}
.fila-pedido:hover { border-color: var(--oro); }
.fila-pedido.es-urgente { border-left: 4px solid var(--rojo); }
.fp-principal { display: grid; min-width: 0; }
.fp-empresa { font-weight: 700; overflow-wrap: anywhere; }
.fp-meta { color: var(--sutil); font-size: .85rem; }
.fp-lado { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
.bloque { margin-bottom: 1.5rem; }
.bloque h2 { color: var(--sutil); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.bloque-alerta h2 { color: var(--ambar); }
.vacio { color: var(--sutil); text-align: center; padding: 1.5rem; margin: 0; }
.vacio-grande { text-align: center; padding: 2.5rem 1rem; }

/* Detalle */
.columnas { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .columnas { grid-template-columns: 1.15fr 1fr; align-items: start; } }
.datos { margin: 0; display: grid; gap: .55rem; }
.dato { display: grid; grid-template-columns: 8.5rem 1fr; gap: .5rem; }
.dato dt { color: var(--sutil); font-size: .88rem; }
.dato dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .dato { grid-template-columns: 1fr; gap: 0; } }
.archivo {
  display: flex; justify-content: space-between; gap: .5rem; padding: .5rem .7rem; margin-bottom: .35rem;
  border: 1px solid var(--borde); border-radius: 8px; text-decoration: none; overflow-wrap: anywhere;
}
.archivo:hover { border-color: var(--oro); background: #fffdf7; }
.destacado-op { border-color: var(--oro); background: #fffcf3; }
.archivo-op { font-weight: 700; font-size: 1.05rem; border-color: var(--oro); background: #fff; }

.historial { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .55rem; max-height: 520px; overflow-y: auto; }
.historial li { border-radius: 8px; padding: .5rem .7rem; font-size: .93rem; }
.ev-cab { display: flex; justify-content: space-between; gap: .5rem; font-size: .82rem; color: var(--sutil); }
.ev-cab b { color: var(--texto); }
.ev-sistema { background: var(--gris-f); }
.ev-mensaje { background: var(--azul-f); }
.ev-solicitud { background: var(--ambar-f); }
.adjuntar { font-weight: 500; font-size: .88rem; }

.panel-admin { border-top: 3px solid var(--oro); }
.accion { border-top: 1px solid var(--borde); padding: .65rem 0; }
.accion:first-of-type { border-top: 0; }
.accion summary { cursor: pointer; font-weight: 700; color: var(--azul); }
.accion[open] summary { margin-bottom: .65rem; }
.copiable { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; background: var(--fondo); margin-bottom: .5rem; }

/* Acceso */
.acceso { max-width: 420px; margin: 3rem auto; text-align: center; }
.acceso form { text-align: left; margin-top: 1.25rem; }
.logo-acceso { border-radius: 14px; margin-bottom: .75rem; }

/* Tabla de usuarios */
.tabla { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tabla th, .tabla td { text-align: left; padding: .55rem .4rem; border-bottom: 1px solid var(--borde); vertical-align: top; }
.tabla th { font-size: .78rem; text-transform: uppercase; color: var(--sutil); letter-spacing: .04em; }
.tabla tr.inactivo td { color: var(--sutil); }
.definir-clave summary { list-style: none; display: inline; }
.definir-clave summary::-webkit-details-marker { display: none; }
.definir-clave[open] { flex-basis: 100%; }
.definir-clave form { margin-top: .5rem; max-width: 18rem; }
.contenedor-ancho { max-width: 1800px; }
/* Control: mismo orden de columnas y colores de status que el sheet */
.tabla-scroll { overflow-x: auto; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); }
.tabla-control { font-size: .88rem; min-width: 1050px; }
.tabla-control th { background: var(--azul); color: #fff; position: sticky; top: 0; white-space: nowrap; }
.tabla-control td { vertical-align: middle; padding: .4rem .5rem; }
.tabla-control tbody tr:nth-child(even) { background: #faf9f6; }
.tabla-control td.num { color: var(--sutil); text-align: right; width: 2.5rem; }
.tabla-control .mono { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; white-space: nowrap; }
.tabla-control input, .tabla-control select { min-height: 34px; padding: .25rem .4rem; font-size: .85rem; }
.tabla-control input[type="date"] { width: 9.5rem; }
.tabla-control td.com { display: flex; gap: .35rem; min-width: 16rem; }
.st { display: inline-block; font-weight: 700; font-size: .75rem; padding: .12rem .5rem; border-radius: 999px; white-space: nowrap; }
.st-PENDIENTE { background: #fff1b8; color: #6b5200; }
.st-ENTREGADA { background: #1e7d45; color: #fff; }
.st-DESESTIMADO { background: #b3261e; color: #fff; }
select.st-sel { font-weight: 700; border-radius: 999px; width: auto; border: 0; }
/* Status de la OP: azul = por hacer, ámbar = faltan datos, dorado = hecha */
.st-op-cola { background: var(--azul-f); color: var(--azul-2); }
.st-op-datos { background: var(--ambar-f); color: var(--ambar); border: 1px solid #ecd58e; }
.st-op-emitida { background: var(--oro-claro); color: #6b4f10; }
.tabla-control tr.sin-op td { background: #f3f6fc; }
.tabla-control tr.guardando { opacity: .55; pointer-events: none; }
.tabla-control input.corr { width: 10.5rem; font-size: .8rem; }
.op-celda { white-space: nowrap; }
.op-celda a { margin-right: .4rem; font-weight: 600; }
.subir-op { display: inline; }
.btn-archivo { position: relative; overflow: hidden; cursor: pointer; }
.btn-archivo input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; padding: 0; }
.estados-venta { display: flex; gap: .5rem; flex-wrap: wrap; margin: 0 0 .5rem; font-size: .85rem; color: var(--sutil); }
.estados-venta span { background: var(--gris-f); border-radius: 999px; padding: .1rem .6rem; }
.leyenda { margin-top: .6rem; font-size: .82rem; }
/* Facturación */
.tabla-facturacion td.docs { min-width: 12rem; }
.tabla-facturacion a.doc { display: block; font-size: .82rem; overflow-wrap: anywhere; margin-bottom: .2rem; }
.tabla-facturacion tr.falta-oc td { background: #fff8e6; }
.st-falta-oc { background: var(--ambar-f); color: var(--ambar); border: 1px solid #ecd58e; display: inline-block; margin-bottom: .3rem; }
.st-fac-por-facturar { background: var(--azul-f); color: var(--azul-2); }
.st-fac-facturada { background: #1e7d45; color: #fff; }
.tabla-facturacion td.com input[type="date"] { width: 9.5rem; }
.aviso-oc { color: var(--ambar) !important; font-weight: 600; }
.subir-oc { margin-top: .5rem; }
.st-nuevo { background: var(--azul-f); color: var(--azul-2); display: inline-block; margin-bottom: .3rem; }
.dato-fiscal { display: block; font-size: .82rem; overflow-wrap: anywhere; }
.bloque-fiscal { border-left: 3px solid var(--oro); padding-left: .8rem; margin-bottom: .5rem; }
.accion.fiscal { border-top: 0; padding: .3rem 0 0; }
.accion.fiscal .pila input { min-height: 34px; font-size: .85rem; }
.campo-precio { display: flex; align-items: center; gap: .4rem; margin-top: .3rem; max-width: 14rem; }
.campo-precio > span { font-weight: 700; color: var(--sutil); }
.campo-precio input { margin-top: 0; }
.precio { margin: .6rem 0 0; }
.sin-cot { display: grid; gap: .15rem; margin-top: .3rem; font-size: .82rem; }
.sin-cot span { white-space: pre-wrap; }
.resumen-control { display: flex; gap: .5rem; flex-wrap: wrap; margin: 0 0 .75rem; }
.cargo-form { display: flex; gap: .4rem; align-items: center; min-width: 13rem; }
.cargo-form input { min-height: 36px; padding: .3rem .5rem; }
.acciones-tabla { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) {
  .tabla thead { display: none; }
  .tabla tr { display: grid; padding: .5rem 0; border-bottom: 1px solid var(--borde); }
  .tabla td { border: 0; padding: .1rem 0; }
  .acciones-tabla { justify-content: flex-start; }
}
