*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
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; }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 .6rem; }
a { color: inherit; }

/* Barra superior */
.barra { background: var(--marca); color: var(--marca-texto); border-bottom: 3px solid var(--acento); display: flex; align-items: center; gap: 1rem; padding: .5rem 1.25rem; flex-wrap: wrap; }
.barra .logo { height: 34px; background: #fff; padding: 3px 10px; border-radius: 4px; display: block; }
.barra .titulo { font-weight: 600; margin-right: .5rem; }
.barra nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.barra nav button { background: none; border: 0; color: inherit; opacity: .8; padding: .5rem .8rem; border-radius: 4px; font: inherit; cursor: pointer; }
.barra nav button:hover { opacity: 1; background: var(--marca-oscuro); }
.barra nav button[aria-current="page"] { opacity: 1; background: var(--marca-oscuro); box-shadow: inset 0 -2px 0 var(--marca-texto); }
.barra .quien { font-size: .9rem; opacity: .9; }

main { padding: 1.25rem; max-width: 1500px; margin: 0 auto; }
.encabezado { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* Botones y campos */
.boton { font: inherit; padding: .45rem .9rem; border-radius: 4px; border: 1px solid var(--borde); background: var(--superficie); color: var(--texto); cursor: pointer; text-decoration: none; display: inline-block; }
.boton:hover { border-color: var(--acento); }
.boton.principal { background: var(--marca); border-color: var(--marca); color: var(--marca-texto); }
.boton.principal:hover { background: var(--marca-oscuro); }
.boton.chico { padding: .25rem .6rem; font-size: .88rem; }
.boton.claro { background: transparent; border-color: currentColor; color: inherit; }
.boton:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; padding: .4rem .55rem; border: 1px solid var(--borde); border-radius: 4px; background: var(--superficie); color: var(--texto); width: 100%; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 1px; }
label { display: block; font-size: .85rem; color: var(--texto-suave); margin-bottom: .15rem; }

/* Tarjetas del panel */
.tarjetas { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem; }
.tarjeta { background: var(--superficie); border: 1px solid var(--borde); border-left: 5px solid var(--acento); border-radius: 6px; padding: .7rem .9rem; }
.tarjeta .rotulo { font-size: .82rem; color: var(--texto-suave); }
.tarjeta .valor { font-size: 1.25rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tarjeta .detalle { font-size: .82rem; color: var(--texto-suave); }
.tarjeta.peligro { border-left-color: var(--peligro); }
.tarjeta.alerta { border-left-color: var(--alerta); }
.tarjeta.ok { border-left-color: var(--ok); }
.tarjeta.marca { border-left-color: var(--marca); }

.dos-columnas { display: grid; grid-template-columns: 7fr 5fr; gap: 1.25rem; }
@media (max-width: 900px) { .dos-columnas { grid-template-columns: 1fr; } }

/* Tablas */
.tabla-caja { background: var(--superficie); border: 1px solid var(--borde); border-radius: 6px; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: .4rem .65rem; text-align: left; border-bottom: 1px solid var(--borde); vertical-align: middle; }
th { background: var(--fondo); font-weight: 600; white-space: nowrap; font-size: .85rem; color: var(--texto-suave); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--fondo); }
td.numero, th.numero { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.fuerte { font-weight: 600; }
td select { min-width: 9.5rem; padding: .2rem .4rem; }
.vacio { padding: 1.2rem; text-align: center; color: var(--texto-suave); }

.texto-peligro { color: var(--peligro); font-weight: 600; }
.texto-alerta { color: var(--alerta); }
.texto-ok { color: var(--ok); }
.etiqueta { display: inline-block; padding: .1rem .5rem; border-radius: 999px; background: var(--fondo); border: 1px solid var(--borde); font-size: .78rem; white-space: nowrap; }
.etiqueta.ok { background: var(--ok-fondo); border-color: transparent; color: var(--ok); }
.etiqueta.peligro { background: var(--peligro-fondo); border-color: transparent; color: var(--peligro); }

/* Avisos */
.aviso { border-radius: 6px; padding: .7rem .9rem; margin: .75rem 0; border: 1px solid var(--borde); background: var(--superficie); }
.aviso.alerta { background: var(--alerta-fondo); border-color: transparent; color: var(--alerta); }
.aviso.peligro { background: var(--peligro-fondo); border-color: transparent; color: var(--peligro); }
.aviso.ok { background: var(--ok-fondo); border-color: transparent; color: var(--ok); }
#mensajes { position: fixed; right: 1rem; bottom: 1rem; z-index: 20; max-width: 28rem; }

/* Filtros de la grilla */
.filtros { background: var(--superficie); border: 1px solid var(--borde); border-radius: 6px; padding: .8rem; margin-bottom: .9rem; }
.segmentos { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .7rem; }
.segmentos button[aria-pressed="true"] { background: var(--marca); border-color: var(--marca); color: var(--marca-texto); }
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .7rem; }
.pie-grilla { display: flex; justify-content: space-between; align-items: center; padding: .6rem .2rem; color: var(--texto-suave); font-size: .88rem; }

/* Ventana del comprobante */
dialog { border: 0; border-radius: 8px; padding: 0; width: min(960px, 94vw); box-shadow: 0 12px 40px rgba(0, 0, 0, .3); color: var(--texto); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog header { background: var(--marca); color: var(--marca-texto); padding: .7rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
dialog .cuerpo { display: grid; grid-template-columns: 7fr 5fr; gap: 1rem; padding: 1rem; }
@media (max-width: 760px) { dialog .cuerpo { grid-template-columns: 1fr; } }
dialog .historial { max-height: 320px; overflow-y: auto; border: 1px solid var(--borde); border-radius: 6px; }
dialog form > div { margin-bottom: .7rem; }

/* Importar y usuarios */
.panel-simple { background: var(--superficie); border: 1px solid var(--borde); border-radius: 6px; padding: 1rem; max-width: 760px; }
.resumen { margin: .5rem 0 1rem; padding: 0; list-style: none; }
.resumen li { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid var(--borde); }
.resumen li strong { font-variant-numeric: tabular-nums; }
.fila-botones { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.casilla { display: flex; gap: .5rem; align-items: flex-start; margin: .75rem 0; color: var(--texto); font-size: .95rem; }
.casilla input { width: auto; margin-top: .25rem; }
.alta { display: grid; grid-template-columns: 2fr 2fr 1fr auto; gap: .7rem; align-items: end; }
@media (max-width: 760px) { .alta { grid-template-columns: 1fr; } }

/* Ingreso */
.ingreso { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.ingreso .caja { background: var(--superficie); border: 1px solid var(--borde); border-top: 5px solid var(--marca); border-radius: 8px; padding: 2rem; width: min(400px, 100%); text-align: center; }
.ingreso img { max-width: 220px; width: 100%; height: auto; margin-bottom: 1rem; }
.ingreso .boton { width: 100%; margin-top: 1rem; padding: .7rem; }
.ingreso form { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--borde); text-align: left; }
.ingreso form div { margin-bottom: .7rem; }
.ingreso .nota { font-size: .85rem; color: var(--texto-suave); margin-top: 1rem; }

/* En las grillas las celdas no se parten (la tabla se desplaza de costado); los textos largos sí. */
tbody td { white-space: nowrap; }
tbody td.fuerte, dialog tbody td { white-space: normal; }

/* Pantallas angostas: el menú baja a su propia fila en vez de apilarse palabra por palabra */
.barra nav button { white-space: nowrap; }
@media (max-width: 760px) { .barra nav { order: 3; flex-basis: 100%; } .barra .quien { margin-left: auto; } }
