:root, [data-theme="claro"] {
  --fondo: #ffffff;
  --texto: #0b4a0b;           /* verde oscuro de las sucursales */
  --brillo: #8fe03a;          /* halo verde claro */
  --total: #7a1c1c;           /* bordó */
  --total-brillo: #8fe03a;
  --acento: #63d11c;          /* verde lima del pie */
  --acento-borde: #1f5c0c;
  --pill-borde: #000000;
  --pill-texto: #0b4a0b;
  --panel: #ffffff;
  --panel-borde: #cfe8c0;
  --sutil: #4b6b4b;
  --error: #b3261e;
  --lista-hover: #eef9e6;
  --logo-filtro: none;
}
[data-theme="oscuro"] {
  --fondo: #000000;
  --texto: #f9c1f7;           /* lila claro */
  --brillo: #b04dff;          /* halo violeta */
  --total: #7fe7df;           /* turquesa */
  --total-brillo: #1d6b66;
  --acento: #9b3ff0;          /* violeta del pie */
  --acento-borde: #f2a3f5;
  --pill-borde: #ffffff;
  --pill-texto: #f9c1f7;
  --panel: #141017;
  --panel-borde: #3b2752;
  --sutil: #b9a3c9;
  --error: #ff8a80;
  --lista-hover: #241a30;
  /* Logo verde -> violeta (si existe public/logo-oscuro.png se usa ese) */
  --logo-filtro: hue-rotate(185deg) saturate(1.25) brightness(1.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--fondo);
  color: var(--texto);
  font-family: "Fira Sans Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
  transition: background .25s, color .25s;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

.pantalla {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(18px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom));
}

/* Logo */
.logo { display: flex; justify-content: center; padding: 3vh 0 4.5vh; }
.logo-img { width: min(78%, 380px); height: auto; filter: var(--logo-filtro); }
.logo-img.propio { filter: none; }

/* Buscador */
.buscador { position: relative; margin: 0 2%; }
.pill {
  display: flex; align-items: center; gap: 8px;
  border: 3px solid var(--pill-borde);
  border-radius: 999px;
  padding: 0 14px;
  height: 52px;
  background: var(--fondo);
}
.pill .ic { width: 24px; height: 24px; flex: none; color: var(--pill-borde); }
.pill input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 19px; letter-spacing: .2px;
  color: var(--pill-texto);
  text-transform: uppercase;
  text-overflow: ellipsis;
}
.pill input::placeholder { color: var(--sutil); opacity: .75; }
.pill input::-webkit-search-cancel-button { display: none; }
.pill:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brillo) 55%, transparent); }
.icono-btn { background: none; border: 0; padding: 6px; cursor: pointer; display: grid; place-items: center; border-radius: 50%; }
.icono-btn:focus-visible { outline: 2px solid var(--acento); }
#borrar { margin-right: -6px; color: var(--pill-borde); }
#borrar .ic { width: 20px; height: 20px; }

.resultados {
  position: absolute; z-index: 5; left: 0; right: 0; top: 58px;
  margin: 0; padding: 4px 0; list-style: none;
  max-height: 55dvh; overflow-y: auto;
  background: var(--panel);
  border: 2px solid var(--panel-borde);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.resultados li {
  padding: 11px 14px;
  font-size: 16px; font-weight: 600; line-height: 1.2;
  cursor: pointer;
  border-bottom: 1px solid var(--panel-borde);
}
.resultados li:last-child { border-bottom: 0; }
.resultados li small { display: block; color: var(--sutil); font-weight: 600; font-size: 12.5px; margin-top: 2px; }
.resultados li[aria-selected="true"], .resultados li:hover { background: var(--lista-hover); }
.resultados .vacio { color: var(--sutil); cursor: default; }

/* Stock */
.stock { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 3vh 0; }
/* Una sola grilla para todas las filas: la columna de nombres termina en la misma línea
   (alineados a la derecha) y los números arrancan en la misma línea (alineados a la izquierda) */
.tabla {
  display: grid;
  grid-template-columns: max-content max-content;
  justify-content: center;
  column-gap: 0.45em;
  font-size: clamp(26px, 8.6vw, 46px);
  line-height: 1.22;
  font-weight: 800;
  text-shadow: 0 0 2px var(--brillo), 0 0 3px var(--brillo), 0 0 6px var(--brillo);
}
/* "SUMA DE N ARTÍCULOS" cuando se muestra la suma de todo lo que coincide con el buscador */
.leyenda { text-align: center; margin: 0 0 .6em; font-size: clamp(15px, 4.4vw, 20px); font-weight: 700; letter-spacing: .04em; color: var(--sutil); }
.tabla.chico { font-size: clamp(20px, 7vw, 40px); }
.filas, .fila { display: contents; }
.fila .lbl { text-align: right; white-space: nowrap; }
.fila .val { text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 2.6em; }
.fila.total { color: var(--total); text-shadow: 0 0 2px var(--total-brillo), 0 0 4px var(--total-brillo); }
.fila.total > span { margin-top: .35em; }
[data-theme="claro"] .fila.total { text-shadow: 0 0 2px var(--total-brillo), 0 0 3px var(--total-brillo); }

/* Pie */
.pie { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; padding-top: 1vh; }
.pie-ic { color: var(--acento); }
.pie-ic svg { width: 46px; height: 46px; filter: drop-shadow(0 0 1px var(--acento-borde)) drop-shadow(0 0 1px var(--acento-borde)); }
.usuario {
  text-align: center;
  font-size: clamp(26px, 8.5vw, 42px);
  color: var(--acento);
  text-shadow: 0 0 1px var(--acento-borde), 0 0 2px var(--acento-borde), 0 0 2px var(--acento-borde);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Login */
.login-form { display: flex; flex-direction: column; gap: 16px; margin: 2vh 4% 0; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 18px; }
.login-form select, .login-form input, .fila-form input {
  font: inherit; font-size: 18px; font-weight: 600;
  padding: 12px 16px;
  border: 3px solid var(--pill-borde); border-radius: 999px;
  background: var(--fondo); color: var(--texto);
  appearance: none;
}
.boton {
  font-size: 20px; padding: 13px 18px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--acento); color: #fff;
  text-shadow: 0 0 2px var(--acento-borde);
}
.boton:disabled { opacity: .6; }
.boton.chico { font-size: 16px; padding: 10px 14px; }
.error { color: var(--error); font-size: 15px; font-weight: 600; min-height: 1.2em; margin: 0; }

/* Panel de configuración */
.panel-fondo { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.panel {
  width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto;
  background: var(--panel); color: var(--texto);
  border-radius: 22px 22px 0 0;
  border: 2px solid var(--panel-borde); border-bottom: 0;
  padding: 18px 18px max(18px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.panel h2 { margin: 0 0 4px; font-size: 24px; }
.opcion {
  display: flex; align-items: center; gap: 12px;
  font-size: 20px; text-align: left;
  padding: 13px 16px; border-radius: 14px;
  border: 2px solid var(--panel-borde); background: transparent; cursor: pointer;
}
.opcion .ic { width: 26px; height: 26px; color: var(--acento); }
.opcion:disabled { opacity: .6; cursor: progress; }
.opcion.girando .ic { animation: girar 1s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
.nota { margin: 0; font-size: 14px; font-weight: 600; color: var(--sutil); }
.nota.error { color: var(--error); }
#avisos p { margin: 0; font-size: 13px; font-weight: 600; color: var(--error); }
.usuarios summary { cursor: pointer; font-size: 18px; padding: 6px 0; }
.usuarios ul { list-style: none; padding: 0; margin: 6px 0 10px; }
.usuarios li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--panel-borde); font-size: 16px; font-weight: 600; }
.usuarios li span { flex: 1; }
.usuarios li em { font-style: normal; color: var(--sutil); font-size: 13px; }
.usuarios li > button { font-size: 13px; padding: 6px 10px; border-radius: 999px; border: 1.5px solid var(--panel-borde); background: none; cursor: pointer; }
.alta { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 2px solid var(--panel-borde); border-radius: 14px; }
.alta h3 { margin: 0; font-size: 18px; }
.alta label { display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
.alta input, .alta select {
  font: inherit; font-size: 16px; font-weight: 600;
  padding: 9px 14px; border: 2px solid var(--pill-borde); border-radius: 999px;
  background: var(--fondo); color: var(--texto); appearance: none; min-width: 0;
}
/* Cambio de clave (pantalla de clave provisoria y "Editar" / "Cambiar mi clave") */
.usuario-oculto { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.titulo-cambio { margin: 0; font-size: 24px; }
.form-clave .botones { display: flex; gap: 8px; }
.form-clave .botones .boton { flex: 1; }
.boton.secundario { background: none; color: var(--texto); border: 2px solid var(--panel-borde); text-shadow: none; }
.enlace { background: none; border: 0; color: var(--sutil); font: inherit; font-size: 15px; font-weight: 600; text-decoration: underline; cursor: pointer; align-self: center; }
.usuarios li { flex-wrap: wrap; }
.usuarios li > .form-clave { flex-basis: 100%; margin-top: 4px; }
.usuarios li .prov { display: block; color: var(--error); font-size: 12px; }
.clave-nueva { font-family: ui-monospace, Consolas, monospace; background: var(--lista-hover); padding: 1px 6px; border-radius: 6px; user-select: all; }
/* Volumen vacío: en lugar de la tabla, qué hacer (sin Maestro o sin stock) */
.sin-datos {
  margin: 0 2%; padding: 18px 16px; text-align: center;
  border: 2px dashed var(--panel-borde); border-radius: 18px;
}
.stock.vacio .tabla, .stock.vacio .leyenda { display: none; }
.sin-datos p { margin: 0; font-size: clamp(20px, 6vw, 26px); line-height: 1.25; }
.sin-datos small { display: block; margin-top: 8px; font-size: 15px; font-weight: 600; color: var(--sutil); }
/* Subir el Maestro de exención (engranaje del administrador) */
.maestro { display: flex; flex-direction: column; gap: 6px; }
.maestro .nota b { color: var(--texto); }
.archivo-oculto { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.maestro-msg { display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }
.maestro-msg:empty { display: none; }
.maestro-msg p { margin: 0; }
.maestro-msg .ok { font-size: 17px; color: var(--texto); }
.maestro-msg .error { font-size: 14px; min-height: 0; }
#avisos p.falta { font-size: 15px; color: var(--texto); }
