/* LOSEN · estilos. Paleta: tinta #1E2422, papel #F6F2EA, acento #A84A22, gris #575E5A, arena #E4DACA */
:root {
  --tinta: #1E2422; --papel: #F6F2EA; --acento: #A84A22; --gris: #575E5A; --arena: #E4DACA; --linea: #D8CDBB;
  --fondo: #E9E4DA; --blanco: #fff; --ok: #2E7D32; --mal: #B3261E;
  --fuente: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--fuente); color: var(--tinta); background: var(--fondo); font-size: 15px; }
a { color: inherit; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 11.5px; letter-spacing: 1.5px; color: var(--acento); margin: 22px 0 8px; text-transform: uppercase; }
small { color: var(--gris); }
[hidden] { display: none !important; }

/* ---------- barra superior ---------- */
#modo-demo { background: #FFF3CD; color: #5C4400; text-align: center; font-size: 13px; padding: 6px 12px; }
#barra { background: var(--tinta); color: var(--papel); display: flex; align-items: center; gap: 18px; padding: 10px 20px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
#barra .marca { display: flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 800; letter-spacing: 3px; font-size: 18px; }
#barra nav { display: flex; gap: 4px; flex: 1; }
#barra nav a { color: #CFC6B6; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 700; font-size: 14px; }
#barra nav a.activo, #barra nav a:hover { background: rgba(246, 242, 234, .1); color: var(--papel); }
#barra .cuenta { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #CFC6B6; }
.btn-salir { background: transparent; color: var(--papel); border: 1px solid #575E5A; border-radius: 8px; padding: 6px 12px; font: inherit; cursor: pointer; }

/* ---------- controles ---------- */
label { display: block; font-size: 12px; font-weight: 700; color: var(--gris); margin: 9px 0 0; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid var(--linea); border-radius: 8px; font: inherit; font-size: 15px; background: var(--blanco); color: var(--tinta); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--acento); outline-offset: -1px; border-color: transparent; }
input:disabled { background: var(--papel); color: var(--gris); }
textarea { resize: vertical; }
.fila { display: flex; gap: 10px; } .fila > * { flex: 1; min-width: 0; }
.chk { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--tinta); font-weight: 400; margin: 10px 0; cursor: pointer; }
.chk input { width: 20px; height: 20px; margin: 0; accent-color: var(--acento); flex-shrink: 0; }
.ayuda { font-size: 12.5px; color: var(--gris); margin: 4px 0 8px; line-height: 1.4; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--tinta); color: #fff; border: none; border-radius: 10px; padding: 11px 16px; font: inherit; font-weight: 800; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.acento { background: var(--acento); }
.btn.sec { background: var(--arena); color: var(--tinta); }
.btn.chico { padding: 7px 11px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: wait; }
.enlace { background: none; border: none; color: var(--acento); font: inherit; font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; }
.alerta { background: #FBE9E7; color: var(--mal); border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 8px 0; }
.cargando, .vacia { padding: 50px 20px; text-align: center; color: var(--gris); }

/* ---------- avisos flotantes ---------- */
#avisos-globales { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: min(92vw, 460px); }
.aviso { background: var(--tinta); color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.aviso.error { background: var(--mal); }

/* ---------- entrar ---------- */
.entrar { max-width: 380px; margin: 8vh auto; background: #fff; border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 10px; }
.logo-entrar { display: flex; align-items: center; gap: 12px; background: var(--tinta); color: var(--papel); border-radius: 12px; padding: 14px 18px; font-weight: 800; font-size: 26px; letter-spacing: 4px; margin-bottom: 8px; }
.entrar .btn { width: 100%; margin-top: 6px; }

/* ---------- editor ---------- */
.editor { display: flex; gap: 24px; padding: 20px; align-items: flex-start; }
.formulario { width: 460px; flex-shrink: 0; background: #fff; border-radius: 14px; padding: 18px 20px 0; }
.enc-form { margin-bottom: 4px; }
.grupo { font-size: 12.5px; font-weight: 800; margin: 12px 0 2px; }
.item { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #F0EBE2; font-size: 14px; }
.item .n { flex: 1; } .item .n small { display: block; font-size: 12px; }
.item input { width: 80px; margin: 0; text-align: right; padding: 7px 8px; }
.item input.esp, .pm input.esp { width: 92px; border-style: dashed; border-color: var(--acento); }
.esp-fijo { font-size: 12px; color: var(--acento); font-weight: 700; white-space: nowrap; }
.pm { display: grid; grid-template-columns: 82px 1fr 92px 26px; gap: 6px 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid #F0EBE2; }
.pm select, .pm input { margin: 0; padding: 7px 8px; }
.pm .medidas, .pm .m2 { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.pm .medidas input { width: 100%; min-width: 0; text-align: center; }
.pm .m2 input { text-align: right; }
.pm select[name=formato] { grid-column: 1 / 3; }
.pm > .esp, .pm > .esp-fijo { grid-column: 3 / 4; }
.pm .quitar { grid-column: 4; grid-row: 1; }
.formato-info { grid-column: 1 / -1; font-size: 12.5px; color: var(--gris); }
.formato-info:empty { display: none; }
.formato-info.alerta { margin: 0; }
.mat { display: grid; grid-template-columns: 1fr 64px 92px 26px; gap: 6px; margin-bottom: 6px; }
.mat input { margin: 0; padding: 7px 8px; font-size: 14px; }
.quitar { background: transparent; border: none; color: var(--gris); font-size: 20px; cursor: pointer; padding: 0; line-height: 1; }
.acciones { position: sticky; bottom: 0; background: #fff; padding: 12px 0 calc(16px + env(safe-area-inset-bottom, 0px)); margin-top: 14px; border-top: 1px solid var(--arena); display: flex; flex-wrap: wrap; gap: 8px; }
.acciones .btn { flex: 1; }
.total-movil { width: 100%; font-size: 14px; color: var(--gris); display: none; }
.total-movil b { color: var(--tinta); font-size: 17px; }
.previa { flex: 1; min-width: 0; position: sticky; top: 76px; }
.etiqueta-previa { display: none; }

/* ---------- ver cotización ---------- */
.ver { padding: 20px; display: flex; gap: 24px; align-items: flex-start; }
.ficha { width: 340px; flex-shrink: 0; background: #fff; border-radius: 14px; padding: 18px 20px; position: sticky; top: 76px; }
.ficha-titulo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ficha-datos { margin: 14px 0; display: flex; flex-direction: column; gap: 7px; font-size: 14px; }
.ficha-datos div { display: flex; gap: 10px; } .ficha-datos span { width: 80px; color: var(--gris); font-weight: 700; font-size: 12.5px; flex-shrink: 0; padding-top: 1px; }
.ficha-acciones { display: flex; flex-direction: column; gap: 8px; }
.ver .marco { flex: 1; min-width: 0; }

/* ---------- estados ---------- */
.estado { display: inline-block; border-radius: 20px; padding: 3px 10px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.e-borrador { background: #ECEAE6; color: var(--gris); }
.e-enviada { background: #E3ECF7; color: #1F4E8C; }
.e-seguimiento { background: #FFF1D6; color: #7A4F00; }
.e-aceptada { background: #E2F2E3; color: var(--ok); }
.e-rechazada { background: #FBE3E0; color: var(--mal); }
.e-vencida { background: #EDE7E0; color: #6D5A45; }

/* ---------- historial ---------- */
.historial { padding: 20px; max-width: 1200px; margin: 0 auto; }
.enc-historial { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.filtros { background: #fff; border-radius: 14px; padding: 6px 16px 14px; display: grid; grid-template-columns: 2fr repeat(6, 1fr) auto; gap: 0 10px; align-items: end; }
.filtros .btn { margin-bottom: 1px; }
.resumen { margin: 12px 2px; font-size: 13px; color: var(--gris); }
.tabla-hist { width: 100%; border-collapse: collapse; background: #fff; border-radius: 14px; overflow: hidden; }
.tabla-hist th { background: var(--tinta); color: var(--papel); font-size: 11.5px; letter-spacing: .8px; text-align: left; padding: 10px 12px; }
.tabla-hist td { padding: 10px 12px; border-bottom: 1px solid #F0EBE2; font-size: 14px; vertical-align: middle; }
.tabla-hist td small { display: block; }
.tabla-hist .der { text-align: right; }
.tabla-hist .acc { white-space: nowrap; text-align: right; }
.tabla-hist .acc .btn { margin-left: 4px; }
.tabla-hist tbody tr:hover { background: #FBF9F5; }
.ejemplos { margin-top: 26px; font-size: 13px; color: var(--gris); }

/* ---------- hoja de cotización (vista previa, 816 px = carta) ---------- */
.marco { overflow: hidden; }
.hoja { width: 816px; min-height: 1056px; background: #fff; box-shadow: 0 4px 18px rgba(0,0,0,.12); display: flex; flex-direction: column; transform-origin: top left; font-family: Arial, Helvetica, sans-serif; color: var(--tinta); font-size: 13px; }
.hoja .hd { background: var(--tinta); color: var(--papel); padding: 26px 46px 26px 52px; display: flex; justify-content: space-between; align-items: center; border-left: 8px solid var(--acento); }
.hoja .marca { display: flex; align-items: center; gap: 14px; }
.hoja .marca > div, .hoja .titulo { display: flex; flex-direction: column; gap: 4px; }
.hoja .palabra { font-size: 30px; font-weight: 800; letter-spacing: 4px; line-height: 1; }
.hoja .lema { font-size: 10px; font-weight: 700; letter-spacing: 2px; color: #CFC6B6; }
.hoja .titulo { text-align: right; } .hoja .titulo span:first-child { font-size: 22px; font-weight: 800; letter-spacing: 1px; } .hoja .titulo span:last-child { font-size: 12px; color: #CFC6B6; }
.hoja .cajas { padding: 22px 46px 0; display: flex; gap: 22px; }
.hoja .cliente { flex: 1.36; background: var(--papel); border-radius: 12px; padding: 14px 17px; display: flex; flex-direction: column; gap: 5px; }
.hoja .lbl { font-size: 10px; font-weight: 800; letter-spacing: 1.6px; color: var(--acento); }
.hoja .kv { display: flex; gap: 8px; font-size: 13px; } .hoja .kv span:first-child { width: 80px; color: var(--gris); font-weight: 700; flex-shrink: 0; }
.hoja .ahorro { flex: 1; background: var(--acento); color: #fff; border-radius: 12px; padding: 14px 17px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.hoja .ahorro .mini { font-size: 9.5px; font-weight: 800; letter-spacing: 1.6px; opacity: .85; }
.hoja .ahorro .grande { font-size: 28px; font-weight: 800; line-height: 1.1; }
.hoja .ahorro .sub { font-size: 11.5px; opacity: .9; }
.hoja .bloque { padding: 18px 46px 0; }
.hoja table.t { width: 100%; border-collapse: collapse; }
.hoja table.t th { background: var(--tinta); color: var(--papel); font-size: 10px; letter-spacing: 1px; padding: 9px 12px; text-align: right; white-space: nowrap; }
.hoja table.t th:first-child { text-align: left; border-radius: 8px 0 0 0; } .hoja table.t th:last-child { border-radius: 0 8px 0 0; }
.hoja table.t td { padding: 12px; border-bottom: 1px solid var(--linea); text-align: right; vertical-align: middle; font-size: 13px; }
.hoja table.t td:first-child { text-align: left; }
.hoja table.t .c { text-align: center; }
.hoja table.t tr.sec td { border: none; padding: 14px 12px 4px; font-size: 10px; font-weight: 800; letter-spacing: 1.6px; color: var(--acento); }
.hoja .chico { font-size: 10.5px; color: var(--gris); }
.hoja .tachado { color: var(--gris); text-decoration: line-through; font-size: 11px; }
.hoja .totales { width: 330px; margin: 12px 0 0 auto; font-size: 13px; }
.hoja .totales > div { display: flex; justify-content: space-between; padding: 3px 0; }
.hoja .totales .gris { color: var(--gris); } .hoja .tachado2 { text-decoration: line-through; }
.hoja .totales .desc { color: var(--acento); font-weight: 800; }
.hoja .totales hr { border: none; border-top: 1px solid var(--linea); margin: 5px 0; }
.hoja .totales .total { background: var(--tinta); color: var(--papel); border-radius: 10px; padding: 12px 16px; margin-top: 8px; align-items: center; font-weight: 800; }
.hoja .totales .total span:last-child { font-size: 24px; }
.hoja .pagos { display: flex; gap: 9px; margin-top: 8px; flex-wrap: wrap; }
.hoja .pagos span { background: var(--papel); border: 1px solid var(--linea); border-radius: 20px; padding: 4px 13px; font-size: 12px; font-weight: 700; }
.hoja .notas { margin-top: 7px; display: flex; flex-direction: column; gap: 6px; }
.hoja .notas div { display: flex; gap: 9px; font-size: 12px; line-height: 1.45; }
.hoja .notas i { width: 6px; height: 6px; background: var(--acento); border-radius: 3px; margin-top: 6px; flex-shrink: 0; }
.hoja .vacia { padding: 60px 46px; }
.hoja .pie { margin-top: auto; padding: 22px 46px 24px; }
.hoja .vigencia { background: var(--papel); border-radius: 12px; padding: 12px 18px; font-size: 12.5px; }
.hoja .contacto { margin-top: 12px; font-size: 12px; color: var(--gris); } .hoja .contacto b { color: var(--tinta); }

/* ---------- pantallas medianas y celular ---------- */
@media (max-width: 1250px) {
  .filtros { grid-template-columns: repeat(4, 1fr); }
  .filtros .ancho { grid-column: 1 / -1; }
  .filtros .btn { grid-column: 1 / -1; justify-self: start; margin-top: 10px; }
}
@media (max-width: 1100px) {
  .editor, .ver { flex-direction: column; padding: 12px; gap: 14px; }
  .formulario, .ficha { width: 100%; position: static; }
  .previa { position: static; width: 100%; }
  .etiqueta-previa { display: block; font-size: 11.5px; letter-spacing: 1.5px; color: var(--acento); font-weight: 800; margin: 6px 0 8px; }
  .ver .marco { width: 100%; }
  .total-movil { display: block; }
}
@media (max-width: 700px) {
  body { font-size: 16px; }
  #barra { padding: 8px 12px; gap: 6px 12px; }
  #barra nav { order: 3; flex-basis: 100%; }
  #barra nav a { flex: 1; text-align: center; background: rgba(246,242,234,.06); }
  #barra .cuenta { margin-left: auto; } #usuario { display: none; }
  .historial { padding: 12px; }
  .filtros { grid-template-columns: 1fr 1fr; }
  .formulario { padding: 14px 14px 0; }
  .fila { flex-direction: column; gap: 0; }
  .ficha-acciones { flex-direction: row; flex-wrap: wrap; } .ficha-acciones .btn { flex: 1 1 45%; }
  /* tabla → tarjetas */
  .tabla-hist, .tabla-hist tbody, .tabla-hist tr, .tabla-hist td { display: block; width: 100%; }
  .tabla-hist { background: transparent; }
  .tabla-hist thead { display: none; }
  .tabla-hist tr { background: #fff; border-radius: 12px; margin-bottom: 10px; padding: 8px 12px; }
  .tabla-hist td { border: none; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .tabla-hist td::before { content: attr(data-k); color: var(--gris); font-size: 12.5px; font-weight: 700; text-align: left; }
  .tabla-hist td small { display: inline; margin-left: 6px; }
  .tabla-hist .acc { justify-content: flex-end; padding-top: 8px; } .tabla-hist .acc::before { content: none; }
}

/* precio especial (solo administradores) */
.pm .esp-lbl { grid-column: 2 / 4; display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: 0; font-size: 12px; color: var(--acento); }
.pm .esp-lbl input { width: 92px; }
.item.cab { font-size: 11.5px; color: var(--gris); font-weight: 700; border: none; padding-bottom: 0; }
.item.cab span:not(.n) { width: 80px; text-align: center; } .item.cab span:last-child { width: 92px; }
@media (max-width: 700px) {
  .pm { grid-template-columns: 1fr 1.4fr 26px; }
  .pm select[name=tipo] { grid-column: 1; } .pm .medidas { grid-column: 2; } .pm .quitar { grid-column: 3; grid-row: 1; }
  .pm .m2 { grid-column: 1; } .pm select[name=formato] { grid-column: 2 / 4; }
  .pm .esp-lbl { grid-column: 1 / -1; justify-content: flex-start; }
}

/* renglones «Por cotizar» en la hoja */
.hoja .por-cotizar { color: var(--acento); font-weight: 800; font-size: 11.5px; }
.hoja .totales .nota-total { justify-content: flex-end; font-size: 11px; color: var(--gris); padding-top: 6px; }

/* venta pagada y botones del historial */
.pagada { color: var(--ok); }
.tabla-hist td small { color: var(--gris); }
.enc-historial .botones { display: flex; gap: 8px; flex-wrap: wrap; }

/* casilla de mosaico */
.pm .mosaico { grid-column: 1 / -1; margin: 0; font-size: 13px; color: var(--gris); }
.pm .mosaico input { width: 18px; height: 18px; }

/* lista de precio (regular o con descuento) */
.pm .esp-lbl { color: var(--gris); }
.pm .esp-lbl select { width: auto; min-width: 170px; margin: 0; padding: 7px 8px; font-size: 14px; }
.item select.precio { width: 150px; margin: 0; padding: 7px 6px; font-size: 13px; }
