:root {
  --marron: #4f2a0a; --marron2: #7a4a1f; --ambar: #d4860b; --rosa: #f29b9b; --rosa-suave: #fbe3e1;
  --oliva: #6b7a2a; --oliva-osc: #566321; --crema: #fbf6ee; --crema2: #f3e9da; --linea: #e3d6c1;
  --ok-bg: #e3f0d3; --ok-tx: #3b5a12; --av-bg: #ffefc2; --av-tx: #8a5600; --mal-bg: #fbd9d6; --mal-tx: #9b1c1c; --azul-bg: #dcebf7; --azul-tx: #1f4e78;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", system-ui, Arial, sans-serif; font-size: 17px; color: var(--marron); background: var(--crema); }
#app { display: flex; height: 100vh; }
#menu { width: 262px; flex: none; background: var(--crema2); border-right: 1px solid var(--linea); display: flex; flex-direction: column; overflow-y: auto; }
.marca { padding: 14px 18px 4px; text-align: center; }
.marca img { width: 100%; max-width: 200px; }
#nav { padding: 6px 12px 12px; flex: 1; }
.grupo { font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--marron2); margin: 16px 8px 5px; font-weight: 700; }
.nav-btn { display: flex; align-items: center; gap: 11px; width: 100%; border: 0; background: transparent; padding: 11px 12px; border-radius: 12px; font-size: 17px; color: var(--marron); text-align: left; cursor: pointer; font-family: inherit; }
.nav-btn .ic { font-size: 21px; width: 28px; text-align: center; }
.nav-btn:hover { background: #ead9bf; }
.nav-btn.activo { background: var(--oliva); color: #fff; font-weight: 700; }
.guardado { padding: 12px 16px; font-size: 14px; color: var(--oliva-osc); border-top: 1px solid var(--linea); text-align: center; }
.guardado.error { color: var(--mal-tx); font-weight: 700; }
#vista { flex: 1; overflow: auto; padding: 22px 28px 40px; }
.solo-imprimir { display: none; }

h1 { font-size: 28px; margin: 0; color: var(--marron); }
h2 { font-size: 21px; margin: 24px 0 10px; }
.encabezado { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.encabezado .acciones { display: flex; gap: 10px; flex-wrap: wrap; }
.nota { background: #fff; border: 1px solid var(--linea); border-left: 6px solid var(--ambar); border-radius: 12px; padding: 12px 16px; margin: 0 0 16px; line-height: 1.45; }

.btn { font-family: inherit; font-size: 17px; border-radius: 12px; border: 2px solid var(--oliva); background: #fff; color: var(--oliva-osc); padding: 10px 18px; cursor: pointer; font-weight: 600; }
.btn:hover { background: #f0f3e2; }
.btn.primario { background: var(--oliva); color: #fff; }
.btn.primario:hover { background: var(--oliva-osc); }
.btn.peligro { border-color: #c0504d; color: #9b1c1c; }
.btn.peligro:hover { background: var(--mal-bg); }
.btn.suave { border-color: var(--linea); color: var(--marron); }
.btn.suave:hover { background: var(--crema2); }
.btn.mini { font-size: 15px; padding: 6px 11px; border-radius: 9px; border-width: 1.5px; }
.btn.grande { font-size: 19px; padding: 14px 24px; }

.barra { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.barra label { font-weight: 600; }
input, select { font-family: inherit; font-size: 17px; color: var(--marron); background: #fff; border: 2px solid var(--linea); border-radius: 10px; padding: 9px 12px; }
input:focus, select:focus { outline: none; border-color: var(--ambar); box-shadow: 0 0 0 3px #f6dfae; }
input.buscar { width: 270px; }

.tabla-caja { background: #fff; border: 1px solid var(--linea); border-radius: 14px; overflow: auto; max-height: calc(100vh - 290px); }
table { border-collapse: collapse; width: 100%; font-size: 15.5px; }
th { position: sticky; top: 0; z-index: 2; background: var(--marron2); color: #fff; padding: 10px 10px; text-align: center; font-weight: 600; white-space: pre-line; line-height: 1.2; }
th.der, td.der { text-align: right; }
td { padding: 9px 10px; border-bottom: 1px solid #efe5d3; white-space: nowrap; }
td.ancho { white-space: normal; min-width: 150px; }
tbody tr:nth-child(even) td { background: #fdfaf4; }
tbody tr:hover td { background: #fbf0d9; }
td.calc { background: #f4f1ea; }
tbody tr:nth-child(even) td.calc { background: #efebe2; }
tr.totales td { background: var(--crema2) !important; font-weight: 700; border-top: 2px solid var(--marron2); position: sticky; bottom: 0; }
.acc { display: flex; gap: 6px; }
th.acc-col { right: 0; z-index: 4; }
td.acc-col { position: sticky; right: 0; background: #fff; box-shadow: -8px 0 8px -8px rgba(80, 40, 10, .35); }
tbody tr:hover td.acc-col { background: #fbf0d9; }
tr.totales td.acc-col { background: var(--crema2) !important; box-shadow: none; }
.vacio { text-align: center; padding: 38px 20px; color: var(--marron2); }
.vacio .grande { font-size: 20px; margin-bottom: 14px; }

.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-weight: 700; font-size: 14px; }
.badge.ok { background: var(--ok-bg); color: var(--ok-tx); }
.badge.av { background: var(--av-bg); color: var(--av-tx); }
.badge.mal { background: var(--mal-bg); color: var(--mal-tx); }
.badge.azul { background: var(--azul-bg); color: var(--azul-tx); }
.neg { color: var(--mal-tx); font-weight: 700; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 8px 0 8px; }
.kpi { background: #fff; border: 1px solid var(--linea); border-radius: 16px; padding: 14px 18px; }
.kpi .et { font-size: 14.5px; color: var(--marron2); }
.kpi .vl { font-size: 27px; font-weight: 700; margin-top: 4px; }
.kpi.verde { border-left: 6px solid var(--oliva); } .kpi.ambar { border-left: 6px solid var(--ambar); } .kpi.rosa { border-left: 6px solid var(--rosa); }
.pasos { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.paso { display: flex; gap: 14px; align-items: flex-start; text-align: left; background: #fff; border: 2px solid var(--linea); border-radius: 16px; padding: 14px 16px; cursor: pointer; font-family: inherit; font-size: 16px; color: var(--marron); }
.paso:hover { border-color: var(--oliva); background: #f8faee; }
.paso .num { flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--oliva); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; }
.paso b { display: block; font-size: 18px; margin-bottom: 3px; }
.alerta { background: var(--av-bg); border: 1px solid #ecd48b; border-radius: 14px; padding: 12px 18px; margin: 12px 0; }
.alerta ul { margin: 6px 0 0 18px; padding: 0; }
.cards-inf { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.card { background: #fff; border: 1px solid var(--linea); border-radius: 16px; padding: 18px 20px; }
.card h3 { margin: 0 0 6px; font-size: 20px; }
.card p { margin: 0 0 14px; color: var(--marron2); line-height: 1.4; }
.card .fila { display: flex; gap: 10px; flex-wrap: wrap; }

/* Ventanas de formulario */
.velo { position: fixed; inset: 0; background: rgba(60, 32, 8, .45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: var(--crema); border-radius: 18px; width: 100%; max-width: 640px; max-height: 94vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.modal header { padding: 18px 24px 8px; font-size: 23px; font-weight: 700; }
.modal .cuerpo { padding: 6px 24px 10px; }
.modal footer { padding: 14px 24px 20px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.campo { margin-bottom: 14px; }
.campo label { display: block; font-weight: 700; margin-bottom: 5px; }
.campo .req { color: #c0504d; }
.campo input, .campo select { width: 100%; }
.campo .fila-sel { display: flex; gap: 8px; }
.campo .fila-sel select { flex: 1; }
.campo .ayuda { font-size: 14px; color: var(--marron2); margin-top: 4px; }
.campo .error { font-size: 15px; color: var(--mal-tx); font-weight: 700; margin-top: 4px; }
.campo.con-error input, .campo.con-error select { border-color: #c0504d; }
.previo { background: #fff; border: 1px dashed var(--ambar); border-radius: 12px; padding: 10px 16px; margin: 4px 0 8px; line-height: 1.6; }
.error-general { background: var(--mal-bg); color: var(--mal-tx); font-weight: 700; padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }
.modal p { line-height: 1.5; }

#avisos { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.aviso { background: var(--marron); color: #fff; padding: 12px 20px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.3); display: flex; gap: 16px; align-items: center; }
.aviso button { background: #fff; color: var(--marron); border: 0; border-radius: 8px; padding: 6px 12px; font-weight: 700; cursor: pointer; font-family: inherit; font-size: 15px; }

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  html, body, #vista { background: #fff !important; }
  body { font-size: 11px; }
  td.der { white-space: nowrap; }
  #menu, .no-print, #avisos, .velo { display: none !important; }
  #app { display: block; height: auto; }
  #vista { overflow: visible; padding: 0; }
  .tabla-caja { max-height: none; overflow: visible; border: 0; }
  table { font-size: 9.5px; }
  th { position: static; padding: 5px 4px; }
  td { padding: 4px 4px; white-space: normal; }
  tr.totales td { position: static; }
  .solo-imprimir { display: flex; align-items: center; gap: 18px; border-bottom: 2px solid var(--marron2); padding-bottom: 8px; margin-bottom: 12px; }
  .solo-imprimir img { height: 60px; }
  .solo-imprimir .t { font-size: 20px; font-weight: 700; }
  .solo-imprimir .f { font-size: 11px; color: var(--marron2); }
  h1 { font-size: 20px; }
  .kpi .vl { font-size: 18px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .nota { display: none; }
}
