:root {
  --verde: #1f6f5c; --verde-claro: #e3f1ec; --fondo: #f5f6f8; --texto: #1f2933; --suave: #61707d;
  --borde: #dde2e7; --rojo: #b42318; --rojo-claro: #fdecea; --ambar: #8a5a00; --ambar-claro: #fff4d6;
  --radio: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fondo); color: var(--texto); font-size: 16px; }
button, input, select, textarea { font: inherit; }
.cargando { padding: 40px; text-align: center; color: var(--suave); }

/* Encabezado y navegacion */
header { position: sticky; top: 0; z-index: 5; background: var(--verde); color: #fff; padding: 10px 14px calc(0px); padding-top: calc(10px + env(safe-area-inset-top)); }
header .fila { display: flex; align-items: center; gap: 10px; }
header h1 { font-size: 1.05rem; margin: 0; flex: 1; }
header select { background: #fff; color: var(--texto); border: 0; border-radius: 8px; padding: 6px 8px; max-width: 55vw; }
header .salir { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5); border-radius: 8px; padding: 5px 9px; font-size: .85rem; }
nav { display: flex; gap: 4px; margin-top: 10px; overflow-x: auto; }
nav button { flex: 1; background: transparent; color: rgba(255,255,255,.85); border: 0; border-bottom: 3px solid transparent; padding: 8px 6px; white-space: nowrap; }
nav button.activo { color: #fff; border-bottom-color: #fff; font-weight: 600; }

main { padding: 14px; max-width: 900px; margin: 0 auto; padding-bottom: 80px; }
h2 { font-size: 1.1rem; margin: 4px 0 12px; }
.tarjeta { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px; margin-bottom: 12px; }
.suave { color: var(--suave); font-size: .9rem; }
.fila { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crece { flex: 1; min-width: 0; }
label { display: block; font-size: .85rem; color: var(--suave); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--verde); outline-offset: 0; border-color: var(--verde); }
input.grande { font-size: 1.4rem; text-align: center; }
.boton { background: var(--verde); color: #fff; border: 0; border-radius: 8px; padding: 11px 16px; font-weight: 600; cursor: pointer; }
.boton.secundario { background: #fff; color: var(--verde); border: 1px solid var(--verde); }
.boton.peligro { background: #fff; color: var(--rojo); border: 1px solid var(--rojo); }
.boton.chico { padding: 6px 10px; font-size: .85rem; font-weight: 500; }
.boton:disabled { opacity: .5; }
.ancho { width: 100%; }

/* Segmentos */
.segmentos { display: flex; background: #fff; border: 1px solid var(--borde); border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 12px; }
.segmentos button { flex: 1; border: 0; background: transparent; padding: 9px 4px; border-radius: 8px; color: var(--suave); }
.segmentos button.activo { background: var(--verde); color: #fff; font-weight: 600; }

/* Tablas y listas */
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--borde); text-align: left; vertical-align: top; }
th { font-size: .8rem; color: var(--suave); font-weight: 600; position: sticky; top: 0; background: #fff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; }
.tabla { overflow-x: auto; border: 1px solid var(--borde); border-radius: var(--radio); }
.lista > div { display: flex; gap: 10px; align-items: center; padding: 11px 12px; background: #fff; border-bottom: 1px solid var(--borde); }
.lista > div:first-child { border-radius: var(--radio) var(--radio) 0 0; }
.lista > div:last-child { border-bottom: 0; border-radius: 0 0 var(--radio) var(--radio); }
.lista { border: 1px solid var(--borde); border-radius: var(--radio); }
.cifra { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }
.cifra.neg { color: var(--rojo); }
.etiqueta { display: inline-block; font-size: .75rem; padding: 2px 7px; border-radius: 99px; background: var(--verde-claro); color: var(--verde); font-weight: 600; }
.etiqueta.ambar { background: var(--ambar-claro); color: var(--ambar); }
.etiqueta.roja { background: var(--rojo-claro); color: var(--rojo); }
.resumen { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 12px; }
.resumen div { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 10px; }
.resumen b { display: block; font-size: 1.25rem; }
.vacio { text-align: center; color: var(--suave); padding: 24px 10px; }

/* Aviso flotante */
#aviso { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #1f2933; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 92vw; z-index: 20; }
#aviso.ver { opacity: .95; }
#aviso.error { background: var(--rojo); }

/* Camara */
.camara { position: fixed; inset: 0; background: #000; z-index: 30; display: flex; flex-direction: column; }
.camara video { flex: 1; width: 100%; object-fit: cover; }
.camara .barra { padding: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; justify-content: center; }
.camara .mira { position: absolute; left: 10%; right: 10%; top: 40%; height: 20%; border: 3px solid rgba(255,255,255,.8); border-radius: 12px; pointer-events: none; }

/* Inicio de sesion */
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }
.login h1 { color: var(--verde); text-align: center; }
.pendiente { background: var(--ambar-claro); color: var(--ambar); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: .9rem; }
