:root {
  --bg: #f5f6f8;
  --panel: #fff;
  --linea: #e2e5ea;
  --texto: #1c2530;
  --suave: #6b7683;
  --acento: #1f5f8b;
  --ok: #1f7a4d;
  --warn: #9a6a00;
  --error: #b3261e;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--texto);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
}
.oculto { display: none !important; }

header {
  display: flex; align-items: center; gap: 24px;
  background: var(--panel); border-bottom: 1px solid var(--linea);
  padding: 12px 20px; position: sticky; top: 0; z-index: 10;
}
header strong { color: var(--acento); letter-spacing: .5px; }
header nav { display: flex; gap: 4px; flex: 1; }

button, .boton {
  font: inherit; padding: 7px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--acento); background: var(--acento); color: #fff;
  text-decoration: none; display: inline-block;
}
button:disabled { opacity: .45; cursor: default; }
.tab { background: transparent; color: var(--suave); border-color: transparent; }
.tab.activo { color: var(--acento); background: #e8f0f6; }
.link { background: none; border: none; color: var(--acento); padding: 4px; cursor: pointer; }

section { padding: 20px; max-width: 1500px; margin: 0 auto; }
.caja {
  background: var(--panel); border: 1px solid var(--linea); border-radius: 8px;
  padding: 16px 18px; margin-bottom: 16px;
}
h2 { margin: 0 0 4px; font-size: 17px; }
h3 { margin: 0 0 4px; font-size: 14px; }
.ayuda { color: var(--suave); margin: 0 0 10px; font-size: 13px; }
.fila-titulo { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.fila-titulo > div { display: flex; gap: 8px; align-items: center; }

form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input[type=text], input[type=search], input[type=password], select {
  font: inherit; padding: 6px 8px; border: 1px solid var(--linea); border-radius: 6px; background: #fff;
}

.procesos { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.proceso { border-right: 1px solid var(--linea); padding-right: 18px; }
.proceso:last-child { border-right: none; }
.barra { height: 6px; background: var(--linea); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.barra > div { height: 100%; background: var(--ok); transition: width .3s; }
.barra .txt { font-size: 12px; }
.estado-job { font-size: 12px; color: var(--suave); margin-top: 4px; display: block; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--linea); vertical-align: top; }
th { font-size: 12px; color: var(--suave); text-transform: uppercase; letter-spacing: .4px; position: sticky; top: 0; background: var(--panel); }
tbody tr:hover { background: #f9fafb; }
td input, td select { width: 100%; border: 1px solid transparent; background: transparent; padding: 3px 4px; font: inherit; border-radius: 4px; }
td input:focus, td select:focus { border-color: var(--acento); background: #fff; outline: none; }
tr.editado td { background: #fff8e1; }
.scroll { max-height: 65vh; overflow: auto; }
.num { text-align: right; }

.pill { font-size: 11px; padding: 2px 7px; border-radius: 10px; background: var(--linea); color: var(--suave); }
.pill.ia { background: #fde8c8; color: var(--warn); }
.pill.cache, .pill.regla { background: #dcefe3; color: var(--ok); }
.pill.similar { background: #fff3cd; color: var(--warn); }
.pill.manual { background: #dde8f3; color: var(--acento); }
.pill.error { background: #fbdedb; color: var(--error); }

.login { display: grid; place-items: center; height: 100vh; }
.login form { flex-direction: column; width: 280px; background: var(--panel); padding: 28px; border-radius: 10px; border: 1px solid var(--linea); }
.login input, .login button { width: 100%; }
.error { color: var(--error); font-size: 13px; }

.aviso {
  position: fixed; bottom: 18px; right: 18px; background: var(--texto); color: #fff;
  padding: 10px 16px; border-radius: 6px; z-index: 50; max-width: 380px;
}

/* La grilla de ítems necesita ancho real: con scroll horizontal las columnas
   editables (descripción y cuenta PUC) dejan de salir cortadas. */
#tabla-items { min-width: 1450px; }
#tabla-items th:nth-child(3), #tabla-items td:nth-child(3) { min-width: 320px; }
#tabla-items th:nth-child(8), #tabla-items td:nth-child(8) { min-width: 300px; }
#tabla-items th:nth-child(9), #tabla-items td:nth-child(9) { min-width: 110px; }
#tabla-items th:nth-child(4), #tabla-items th:nth-child(5),
#tabla-items th:nth-child(6), #tabla-items th:nth-child(7) { width: 90px; }
#tabla-cache { min-width: 1200px; }
#tabla-cache th:nth-child(3), #tabla-cache td:nth-child(3) { min-width: 300px; }
#tabla-cache th:nth-child(4), #tabla-cache td:nth-child(4) { min-width: 300px; }
.estado-job { max-height: 3.4em; overflow: hidden; cursor: pointer; }
.estado-job.abierto { max-height: none; }
.estado-job:not(.abierto)::after { content: " ▾"; color: var(--acento); }

.resumen { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.pill.pendiente { background: #eceff3; color: var(--suave); }
.barra.parcial > div { background: var(--warn); }
.barra.error > div { background: var(--error); }

button.secundario { background: transparent; color: var(--error); border-color: var(--error); }
.barra.cancelado > div, .barra.interrumpido > div { background: var(--suave); }

.param { display: grid; grid-template-columns: 220px 140px 1fr; gap: 12px; align-items: start;
         padding: 12px 0; border-bottom: 1px solid var(--linea); }
.param label { font-weight: 600; font-family: ui-monospace, monospace; font-size: 13px; }
.param small { color: var(--suave); }
.param code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
@media (max-width: 720px) { .param { grid-template-columns: 1fr; } }

tr.detalle > td { background: var(--bg); padding: 10px 14px; }
table.interna { font-size: 13px; background: var(--panel); border-radius: 6px; }
table.interna th { background: var(--panel); }

.modal { position: fixed; inset: 0; background: rgba(15, 22, 30, .45);
         display: grid; place-items: center; z-index: 40; padding: 20px; }
.modal-caja { background: var(--panel); border-radius: 10px; padding: 22px 26px;
              max-width: 1100px; width: 100%; max-height: 85vh; overflow: auto; position: relative; }
.modal-caja .cerrar { position: absolute; top: 10px; right: 12px; font-size: 18px; }
.modal-caja h3 { font-size: 16px; margin-right: 30px; }
code.cufe { font-size: 11px; word-break: break-all; }
tfoot td { border-top: 2px solid var(--linea); }

pre.xml { background: var(--bg); border: 1px solid var(--linea); border-radius: 6px;
          padding: 12px; max-height: 45vh; overflow: auto; font-size: 12px;
          white-space: pre-wrap; word-break: break-word; }
