:root {
  --bg:      #000000;
  --bg2:     #202020;
  --bg3:     #2a2a2a;
  --accent:  #F7941D;
  --accent2: #8DC63F;
  --text:    #F5F5F5;
  --text2:   #909090;
  --danger:  #e74c3c;
  --border:  #3a3a3a;
  --radius:  3px;
  --touch:   48px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  overflow: hidden;
}

/* ── Pantallas ── */
.screen { display: none; flex-direction: column; height: 100dvh; width: 100%; position: absolute; top: 0; left: 0; }
.screen.activa { display: flex; }

/* ── Header ── */
.header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--touch);
  flex-shrink: 0;
}
.header h1 { font-size: 1rem; font-weight: 600; }
.header .empresa { font-size: 0.72rem; color: var(--text2); }

/* ── Contenido scrollable ── */
.contenido { flex: 1; overflow-y: auto; padding: 16px; }

/* ── Formularios ── */
.form-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  max-width: 400px;
  margin: 0 auto;
}

.campo { margin-bottom: 14px; }
.campo label { display: block; font-size: 0.75rem; color: var(--text2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.campo input, .campo-select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  padding: 11px 13px;
  min-height: var(--touch);
  outline: none;
  transition: border-color 0.2s;
}
.campo input:focus, .campo-select:focus { border-color: var(--accent); }
.campo-select { appearance: none; cursor: pointer; }

/* ── Botones ── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0 20px;
  transition: opacity 0.15s, transform 0.1s;
  width: 100%;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn-primario   { background: var(--accent);  color: #fff; }
.btn-secundario { background: var(--bg3);     color: var(--text); border: 1px solid var(--border); }
.btn-exito      { background: var(--accent2); color: #fff; }
.btn-peligro    { background: var(--danger);  color: #fff; }
.btn:disabled   { opacity: 0.4; pointer-events: none; }

/* ── Botón ícono pequeño ── */
.btn-icon {
  width: 36px; height: 36px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.btn-icon:active { background: var(--border); }
.btn-icon--accent { border-color: var(--accent); color: var(--accent); }
.btn-icon--danger { border-color: var(--danger); color: var(--danger); }

/* ── Listas ── */
.lista-items { display: flex; flex-direction: column; gap: 10px; }
.item-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--touch);
  transition: border-color 0.2s;
}
.item-card:active { border-color: var(--accent); }
.item-card .nombre { font-weight: 600; }
.item-card .detalle { font-size: 0.78rem; color: var(--text2); margin-top: 2px; }
.item-card.seleccionado { border-color: var(--accent); background: #2a1500; }

/* ── Footer acciones ── */
.footer-acciones {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Toast ── */
@keyframes _toastIn { from { opacity:0; transform:translateX(-50%) translateY(10px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }
@keyframes _toastShake { 0%,100%{transform:translateX(-50%)} 25%{transform:translateX(calc(-50% - 7px))} 75%{transform:translateX(calc(-50% + 7px))} }
#toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: #333; color: #fff; padding: 10px 20px; border-radius: var(--radius);
  font-size: 0.85rem; z-index: 9999; display: none; white-space: nowrap;
  max-width: 90vw; text-align: center; animation: _toastIn 0.2s ease-out;
}
#toast.error  { background: var(--danger); animation: _toastIn 0.15s, _toastShake 0.4s 0.15s; }
#toast.exito  { background: var(--accent2); }

/* ── Loading overlay ── */
#loading {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 8888; align-items: center; justify-content: center; flex-direction: column; gap: 12px;
}
#loading.visible { display: flex; }
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Logo / Inicio ── */
.screen-centrada { justify-content: center; align-items: center; padding: 24px; }
.logo-texto { font-size: 2.5rem; font-weight: 700; color: var(--accent); letter-spacing: 4px; }
.logo-sub { font-size: 0.8rem; color: var(--text2); margin-top: 4px; }

/* ── Input código de barras ── */
.inp-codigo {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  padding: 11px 13px;
  min-height: var(--touch);
  outline: none;
  width: 100%;
}
.inp-codigo:focus { border-color: var(--accent); }

/* ── Input cantidad grande ── */
.inp-cantidad {
  background: var(--bg2);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 2.2rem;
  font-weight: 700;
  padding: 12px 16px;
  outline: none;
  width: 100%;
  text-align: center;
}
.inp-cantidad:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(247,148,29,0.2); }

/* ── Radio IVA ── */
.radio-grupo { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-lbl {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; cursor: pointer; font-size: 0.9rem; font-weight: 600;
  flex: 1; justify-content: center;
}
.radio-lbl input { display: none; }
.radio-lbl.activo { border-color: var(--accent); background: #2a1500; color: var(--accent); }

/* ── Filtros reportes ── */
.inp-filtro {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  padding: 8px 10px;
  outline: none;
}
.inp-filtro:focus { border-color: var(--accent); }

/* ── Selector de período ── */
.periodo-grupo { display: flex; gap: 6px; }
.btn-periodo {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 0;
  cursor: pointer;
}
.btn-periodo.activo { background: #2a1500; border-color: var(--accent); color: var(--accent); }

/* ── Tabla reporte ── */
.tabla-reporte { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.tabla-reporte th {
  background: var(--bg2); border-bottom: 2px solid var(--border);
  padding: 8px 10px; text-align: left; font-size: 0.72rem;
  color: var(--text2); text-transform: uppercase; letter-spacing: 0.4px;
  position: sticky; top: 0;
}
.tabla-reporte td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabla-reporte tr:active td { background: var(--bg2); }

/* ── Info producto: filas dato ── */
.info-fila {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.info-label { font-size: 0.78rem; color: var(--text2); }
.info-valor { font-size: 0.92rem; font-weight: 600; text-align: right; }
.info-valor--grande { font-size: 1.5rem; font-weight: 700; color: var(--accent); }

/* ── Buscar overlay ── */
.buscar-overlay-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px;
  background: var(--bg2); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.buscar-overlay-bar input {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 1rem;
  padding: 10px 14px; outline: none;
}
.buscar-overlay-bar input:focus { border-color: var(--accent); }

/* ── Scanner ── */
#scanner-reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
#scanner-reader { flex: 1; }

/* ── Responsive ── */
@media (min-width: 600px) { html { font-size: 17px; } }
