:root {
  --fondo: #f4f5f7; --panel: #ffffff; --texto: #1f2328; --suave: #5b6470; --borde: #dde1e6;
  --acento: #1d5fa8; --acento-osc: #164a83; --ok: #1a7f37; --error: #c62828; --aviso: #b26a00;
  --radio: 8px; --sombra: 0 1px 2px rgba(0,0,0,.06), 0 1px 6px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--fondo); color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; line-height: 1.45; }
a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.suave { color: var(--suave); }
.chico { font-size: .85rem; }

/* barra superior */
.barra { background: #15324f; color: #fff; }
.barra .cont { display: flex; align-items: center; gap: 1.25rem; padding: .6rem 1rem; max-width: 1200px; margin: auto; flex-wrap: wrap; }
.barra .marca { font-weight: 700; letter-spacing: .02em; color: #fff; }
.barra nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.barra nav a { color: #d6e2f0; padding: .35rem .65rem; border-radius: 6px; }
.barra nav a:hover, .barra nav a.activo { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.barra .usuario { font-size: .9rem; color: #c3d3e6; display: flex; gap: .75rem; align-items: center; }
.barra .usuario button { background: none; border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 6px; padding: .2rem .6rem; cursor: pointer; }
.modo { text-align: center; font-weight: 600; font-size: .85rem; padding: .3rem; }
.modo-simulado { background: #fde7e9; color: var(--error); }
.modo-homologacion { background: #fff4e0; color: var(--aviso); }

main { max-width: 1200px; margin: 1.25rem auto; padding: 0 1rem; }
.panel { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.grilla { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 800px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

.tarjeta { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: .9rem 1rem; box-shadow: var(--sombra); }
.tarjeta .valor { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tarjeta .etiqueta { color: var(--suave); font-size: .85rem; }

/* mensajes */
.mensajes { list-style: none; padding: 0; margin: 0 0 1rem; }
.mensajes li { padding: .7rem 1rem; border-radius: var(--radio); margin-bottom: .5rem; white-space: pre-line; border: 1px solid; }
.mensajes .success { background: #e8f5ec; border-color: #b7dfc3; color: #14532d; }
.mensajes .error { background: #fdecec; border-color: #f2b8b8; color: #7f1d1d; }
.mensajes .info, .mensajes .warning { background: #eef4fb; border-color: #c3d6ee; color: #163d66; }

/* tablas */
table.lista { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.lista th { text-align: left; font-weight: 600; color: var(--suave); border-bottom: 2px solid var(--borde); padding: .45rem .5rem; white-space: nowrap; }
table.lista td { border-bottom: 1px solid var(--borde); padding: .45rem .5rem; vertical-align: top; }
table.lista tr:hover td { background: #f8fafc; }
.tabla-scroll { overflow-x: auto; }

/* etiquetas de estado */
.est { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.est-autorizado, .est-ok { background: #e3f4e8; color: var(--ok); }
.est-rechazado, .est-error { background: #fdecec; color: var(--error); }
.est-a_verificar, .est-enviando, .est-pendiente { background: #fff4e0; color: var(--aviso); }
.est-borrador, .est-no_aplica { background: #eceff3; color: var(--suave); }

/* formularios */
label { display: block; font-size: .85rem; color: var(--suave); margin-bottom: .2rem; }
input, select, textarea { width: 100%; padding: .45rem .55rem; border: 1px solid #c8ced6; border-radius: 6px; font: inherit; background: #fff; color: var(--texto); }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc0ea; border-color: var(--acento); }
.campo { margin-bottom: .75rem; }
.campo .errorlist, .errorlist { color: var(--error); list-style: none; padding: 0; margin: .2rem 0 0; font-size: .85rem; }
.ayuda { font-size: .8rem; color: var(--suave); }
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .5rem 1rem; border-radius: 6px; border: 1px solid var(--borde); background: #fff; color: var(--texto); font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { background: #f1f3f6; text-decoration: none; }
.btn-primario { background: var(--acento); border-color: var(--acento); color: #fff; font-weight: 600; }
.btn-primario:hover { background: var(--acento-osc); }
.btn-peligro { color: var(--error); border-color: #f2b8b8; }
.btn-chico { padding: .25rem .6rem; font-size: .85rem; }
.acciones { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filtros { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; }
.filtros > div { min-width: 140px; }

/* formulario de factura */
.buscador { position: relative; }
.sugerencias { position: absolute; z-index: 20; left: 0; right: 0; background: #fff; border: 1px solid var(--borde); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.12); max-height: 320px; overflow-y: auto; }
.sugerencias div { padding: .45rem .6rem; cursor: pointer; border-bottom: 1px solid #f0f2f4; }
.sugerencias div:hover, .sugerencias div.sel { background: #eef4fb; }
.ficha-cliente { background: #f8fafc; border: 1px dashed var(--borde); border-radius: 6px; padding: .6rem .8rem; font-size: .9rem; }
.letra { display: inline-flex; width: 2.2rem; height: 2.2rem; align-items: center; justify-content: center; border: 2px solid var(--texto); border-radius: 4px; font-weight: 800; font-size: 1.3rem; margin-right: .5rem; }
table.items { width: 100%; border-collapse: collapse; }
table.items th { font-size: .8rem; color: var(--suave); text-align: left; padding: .3rem; border-bottom: 2px solid var(--borde); }
table.items td { padding: .25rem; border-bottom: 1px solid var(--borde); vertical-align: top; }
table.items td.num { padding-top: .6rem; }
table.items input, table.items select { padding: .35rem .4rem; }
.col-art { width: 16%; } .col-cant { width: 9%; } .col-precio { width: 14%; } .col-iva { width: 10%; } .col-sub { width: 13%; } .col-x { width: 2.2rem; }
.totales { margin-left: auto; min-width: 280px; }
.totales div { display: flex; justify-content: space-between; padding: .2rem 0; }
.totales .total { font-weight: 700; font-size: 1.2rem; border-top: 2px solid var(--borde); margin-top: .3rem; padding-top: .4rem; }
.oculto { display: none !important; }
.paginas { display: flex; gap: .5rem; align-items: center; margin-top: .75rem; }

/* login */
.login { max-width: 360px; margin: 10vh auto; }
.login .panel { padding: 1.5rem; }
pre.xml { white-space: pre-wrap; word-break: break-all; font-size: .75rem; background: #f6f8fa; padding: .6rem; border-radius: 6px; max-height: 260px; overflow: auto; }
